  
  <%- contentFor('HeaderCss') %>     
    
  <%- contentFor('body') %>
  <link href="/public/plugins/sweet-alert2/sweetalert2.min.css" rel="stylesheet" type="text/css">
  <!-- Start content -->
                <div class="content">
                    <div class="container-fluid">

                        <div class="row">
                            <div class="col-sm-12">
                                <div class="page-title-box">
                                    <h4 class="page-title"><%= title %></h4>
                                    <ol class="breadcrumb">
                                        <li class="breadcrumb-item"><a href="javascript:void(0);">The Land Cart</a></li>
                                        <li class="breadcrumb-item active"><%= title %></li>
                                    </ol>
            
                                    <%- include(viewsDir+'/Partials/TinyCharts') %>
                                </div>
                            </div>
                        </div>
                        <!-- end row -->
                        
                        <div class="row">
                            <div class="col-12">
                                <div class="card m-b-20">
                                    <div class="card-body">
                                        <p class="text-muted m-b-30">
                                            <a title="Add Property" class="btn btn-outline-secondary" href="/property"><i class="fas fa-plus"></i> Add Property</a>
                                            <div class="custom-filter">
                                                <label class="w-100">
                                                    Filter By:
                                                    <select name="filter_by" id="filter_by" class="form-control form-control-sm form-select form-select-sm" onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">
                                                        <option value="/properties" <%= search == '' ? 'selected="selected"' : '' %>>All</option>
                                                        <option value="/properties?search=fully-furnished">Fully Furnished</option>
                                                        <option value="/properties?search=semi-furnished">Semi Furnished</option>
                                                        <option value="/properties?search=unfurnished">Unfurnished</option>
                                                        <option value="/properties?search=ready-to-move">Ready To Move</option>
                                                        <option value="/properties?search=under-construction">Under Contruction</option>
                                                    </select>
                                                    <div class="d-flex list-inline float-right mb-0">
                                                        <div class="app-search mt-0">
                                                            <div class="form-group mb-0"> 
                                                                <input type="text" class="form-control" placeholder="Search.." id="tb_search" value="<%= ['fully-furnished','semi-furnished','unfurnished','ready-to-move','under-construction'].includes(search) ? '' : search %>">
                                                                <button type="button" id="searchterm"><i class="fa fa-search"></i></button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </label>
                                            </div>
                                        </p>

                                        <table id="manage_listing" class="table table-bordered dt-responsive nowrap" style="border-collapse: collapse; border-spacing: 0; width: 100%;" data-type="property">
                                            <thead>
                                                <tr>
                                                    <th>Name</th>
                                                    <th>Price</th>
                                                    <th>Type</th>
                                                    <th>Property Age</th>
                                                    <th>Status</th>
                                                    <th></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <% if(propertiesList.length > 0) {%>
                                                    <% propertiesList.forEach(function(property){ %>
                                                        <tr>
                                                            <td>
                                                                <div class="inbox-item">
                                                                    <h6 class="inbox-item-author mt-0 mb-1 font-size-16"><%= property.title.replace(/\w/, c => c.toUpperCase()) %></h6>
                                                                    <p class="inbox-item-text text-muted mb-0"><%= property.address+', '+property.city_name  %> </p>
                                                                </div>
                                                            </td>
                                                            <td><%= property.price != "" ? "â‚¹ "+property.price : '-' %></td>
                                                            <td><%= property.project_type %></td>
                                                            <td><%= property.property_age == 0 ? '-' : property.property_age %></td>
                                                            <td>
                                                                <i class="mdi mdi-checkbox-blank-circle <%= property.visibility == 1 ? ' text-success' : ' text-danger' %>"></i> <%= property.visibility == 1 ? ' Active' : ' Deactive' %>
                                                            </td>
                                                            <td>
                                                                <a title="Edit" class="btn btn-outline-secondary" href="/property/<%= property.property_id %>"><i class="fas fa-pencil-alt"></i></a>
                                                                
                                                                <a id="change_status" data-id="<%= property.property_id %>" data-status="<%= property.visibility == 1 ? 0 : 1 %>" title="<%= property.visibility == 1 ? ' Deactivate' : ' Activate' %>" class="btn <%= property.visibility == 1 ? 'btn-outline-primary' : 'btn-outline-success' %>" href="javascript:void(0)"><i class="far <%= property.visibility == 1 ? 'fa-thumbs-down' : 'fa-thumbs-up' %>"></i></a>

                                                                <a id="delete_project" title="Delete" class="btn btn-outline-danger" data-id="<%= property.property_id %>" href="javascript:void(0)"><i class="far fa-trash-alt"></i></a>

                                                            </td>
                                                        </tr>
                                                    <% }); %>
                                                <% } else { %>
                                                    <tr>
                                                        <td colspan="5" class="text-center">No record found.</td>
                                                    </tr>
                                                <% } %>
                                            </tbody>
                                        </table>
                                        <% if (pages > 0 && propertiesList.length > 0) { %>
                                            <nav>
                                                <ul class="pagination">
                                                    <% if (current == 1) { %>
                                                        <li class="page-item disabled"><a href="javascript:void(0);" class="page-link">First</a></li>
                                                    <% } else { %>
                                                        <li class="page-item"><a class="page-link" href="<%= pages > 1 ? paginationUrl+'1' : 'javascript:void(0)' %>">First</a></li>
                                                    <% } %>
                                                    <% var cur_index = (Number(current) > 5 ? Number(current) - 4 : 1) %>
                                                    <% if (cur_index !== 1) { %>
                                                        <li class="page-item disabled"><a class="page-link">...</a></li>
                                                    <% } %>
                                                    <% for (var i=1; i <= (Number(pages)) && i <= pages; i++) { %>
                                                        <% if (i == current) { %>
                                                            <li class="page-item active"><a class="page-link" href="<%= pages > 1 ? paginationUrl+i : 'javascript:void(0)' %>"><%= i %></a></li>
                                                        <% } else { %>
                                                            <li class="page-item"><a class="page-link" href="<%= paginationUrl+i %>"><%= i %></a></li>
                                                        <% } %>
                                                        <% if (i == Number(current) + 4 && i < pages) { %>
                                                            <li class="page-item disabled"><a class="page-link" href="javascript:void(0)">...</a></li>
                                                        <% } %>
                                                    <% } %>
                                                    <% if (current == pages) { %>
                                                        <li class="page-item disabled"><a class="page-link" href="javascript:void(0)">Last</a></li>
                                                    <% } else { %>
                                                        <li class="page-item"><a class="page-link" href="<%= paginationUrl+pages %>">Last</a></li>
                                                    <% } %>
                                                </ul>
                                            </nav>
                                        <% } %>
                                    </div>
                                </div>
                            </div> <!-- end col -->
                        </div> <!-- end row -->

                    </div> <!-- container-fluid -->

                </div> <!-- content -->
                <!-- Required datatable js -->
                <script src="/public/plugins/sweet-alert2/sweetalert2.min.js"></script>
                <script src="/public/assets/pages/projects.js"></script>

                <%- contentFor('FooterJs') %>