<!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.Document%> <%=lan.Setting%></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.Document%> <%=lan.Setting%></li>
                    </ol>
                </div>
              </div>
            </div>
          </div>
          <!-- Container-fluid starts-->
          <div class="container-fluid">
            <div class="row">
                <div class="col-sm-12">
                    <div class="card">
                        <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_document"><%=lan.Add%> <%=lan.Document%></button>
                        </div>
                        <div class="card-body">
                            <div class="table-responsive theme-scrollbar">
                                <table class="display" id="basic-1">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th><%=lan.Name%></th>
                                            <th><%=lan.Document%> <%=lan.image%> <%=lan.Side%></th>
                                            <th><%=lan.Input%> <%=lan.Require%></th>
                                            <th><%=lan.Status%></th>
                                            <th><%=lan.Action%></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <% var i = 1 %>
                                        <% documant_list.forEach((data) => { %>
                                            <tr>
                                                <td><%= i %></td>
                                                <td><%= data.name %></td>
                                                <td>
                                                    <% if (data.require_image_side == '1') { %>
                                                        <%=lan.Front%>
                                                    <% } else if (data.require_image_side == '2') { %>
                                                        <%=lan.Back%>
                                                    <% } else { %>
                                                        <%=lan.Both%>
                                                    <% }; %>
                                                </td>
                                                <td>
                                                    <% if (data.input_require == '1') { %>
                                                        <span class="badge badge-success"><%=lan.Active%></span>
                                                    <% } else { %>
                                                        <span class="badge badge-danger"><%=lan.Deactive%></span>
                                                    <% } %>
                                                </td>
                                                <td>
                                                    <% if (data.status == '1') { %>
                                                        <span class="badge badge-success"><%=lan.Active%></span>
                                                    <% } else { %>
                                                        <span class="badge badge-danger"><%=lan.Deactive%></span>
                                                    <% } %>
                                                </td>
                                                <td> 
                                                    <ul class="action"> 
                                                    <li class="edit"> <a data-bs-toggle="modal" data-bs-target="#edit_document" id="edit_documentdata" data-id="<%= data.id %>" 
                                                        data-name="<%= data.name %>" data-require_image_side="<%= data.require_image_side %>" data-input_require="<%= data.input_require %>" 
                                                        data-status="<%= data.status %>" data-req_field_name="<%= data.req_field_name %>"><i class="icon-pencil-alt"></i></a></li>
                                                    <li class="delete"><a href="/driver/document_delete/<%= 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_document" tabindex="-1" role="dialog" aria-labelledby="add_document" 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.Document%></h5>
                        <button class="btn-close" type="button" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <form  class="needs-validation" novalidate="" action="/driver/add_document" method="post">
                        <div class="modal-body">
                            <div class="row g-3">
                                <div class="col-12">
                                    <label class="form-label"><%=lan.Document%> <%=lan.Name%></label>
                                    <input class="form-control" type="text" name="name" placeholder="<%=lan.Enter%> <%=lan.Document%> <%=lan.Name%>" required>
                                </div>
                                <div class="col-12">
                                    <label class="col-form-label"><%=lan.Document%> <%=lan.image%> <%=lan.Side%></label>
                                    <select class="js-example-basic-single" name="documant_side" required>
                                        <option value selected disabled><%=lan.Select%> <%=lan.Document%> <%=lan.Side%></option>
                                        <option value="1"><%=lan.Front%></option>
                                        <option value="2"><%=lan.Back%></option>
                                        <option value="3"><%=lan.Both%></option>
                                    </select>
                                </div>
                                <div class="col-12 mt-4">
                                    <div class="row">
                                        <div class="col-6 d-flex justify-content-center mb-2">
                                            <div class="icon-state switch-outline">
                                                <label class="switch">
                                                    <input type="checkbox" id="add_doc_require" name="require"><span class="switch-state bg-success"></span>
                                                </label>
                                            </div>
                                            <label class="col-form-label m-l-10"><%=lan.Input%> <%=lan.Require%></label>
                                        </div>
                                        <div class="col-6 d-flex justify-content-center mb-2">
                                            <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 class="col-12 d-none" id="req_doc_name">
                                    <label class="form-label"><%=lan.Require%> <%=lan.Field%> <%=lan.Name%></label>
                                    <input class="form-control" type="text" id="requie_input" name="req_field_name" placeholder="<%=lan.Enter%> <%=lan.Field%> <%=lan.Name%>">
                                </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_document" tabindex="-1" role="dialog" aria-labelledby="edit_document" 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.Document%></h5>
                        <button class="btn-close" type="button" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <form  class="needs-validation" id="edit_doc_form" novalidate="" action="" method="post">
                        <div class="modal-body">
                            <div class="row g-3">
                                <div class="col-12">
                                    <label class="form-label"><%=lan.Document%> <%=lan.Name%></label>
                                    <input class="form-control" id="doc_name" type="text" name="name" placeholder="<%=lan.Enter%> <%=lan.Document%> <%=lan.Name%>" required>
                                </div>
                                <div class="col-12">
                                    <label class="col-form-label"><%=lan.Document%> <%=lan.image%> <%=lan.Side%></label>
                                    <select class="js-example-basic-single" id="doc_img_side" name="documant_side" required>
                                        <option value selected disabled><%=lan.Select%> <%=lan.Document%> <%=lan.Side%></option>
                                        <option value="1"><%=lan.Front%></option>
                                        <option value="2"><%=lan.Back%></option>
                                        <option value="3"><%=lan.Both%></option>
                                    </select>
                                </div>
                                <div class="col-12 mt-4">
                                    <div class="row">
                                        <div class="col-6 d-flex justify-content-center mb-2">
                                            <div class="icon-state switch-outline">
                                                <label class="switch">
                                                    <input type="checkbox" id="doc_require" name="require"><span class="switch-state bg-success"></span>
                                                </label>
                                            </div>
                                            <label class="col-form-label m-l-10"><%=lan.Input%> <%=lan.Require%></label>
                                        </div>
                                        <div class="col-6 d-flex justify-content-center mb-2">
                                            <div class="icon-state switch-outline">
                                                <label class="switch">
                                                    <input type="checkbox" id="doc_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 class="col-12 d-none" id="edit_req_doc_name">
                                    <label class="form-label"><%=lan.Require%> <%=lan.Field%> <%=lan.Name%></label>
                                    <input class="form-control" type="text" id="edit_requie_input" name="req_field_name" placeholder="<%=lan.Enter%> <%=lan.Field%> <%=lan.Name%>">
                                </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>