<!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.driver %> <%=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.driver %> <%=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_label"></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_label"></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>
