270 lines
18 KiB
HTML
270 lines
18 KiB
HTML
{% extends 'layout/base_template.html' %}
|
|
{% load static %}
|
|
{% block stylesheet %}
|
|
<!-- include required css cdn link through html here -->
|
|
{% include "cdn_through_html/datatable_cdn_css.html" %}
|
|
{% include "cdn_through_html/modal_cdn_css.html" %}
|
|
{% include "cdn_through_html/sweetalert2_cdn_css.html" %}
|
|
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
|
|
<div class="row layout-top-spacing">
|
|
<div class="col-lg-12">
|
|
<div class="row">
|
|
<div class="col-sm-4">
|
|
<h3>Manage Customer</h3>
|
|
</div>
|
|
<div class="col-sm-8 text-md-end">
|
|
|
|
<a class="btn btn-dark mb-2 me-md-4" href="{% url 'accounts:download_excel_template' %}">
|
|
Download Excel Template
|
|
</a>
|
|
|
|
<a class="btn btn-dark mb-2 me-md-4" href="{% url 'accounts:import_customer_data' %}">
|
|
Import
|
|
</a>
|
|
|
|
<a class="btn btn-dark mb-2 me-md-4" href="{% url 'accounts:export_customer_data' %}">
|
|
Export
|
|
</a>
|
|
|
|
<a class="btn btn-primary mb-2 me-4" href="{% url 'accounts:customer_add' %}">Add Customer</a>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="row layout-spacing">
|
|
<div class="col-lg-12">
|
|
<div class="statbox widget box box-shadow">
|
|
<div class="widget-content widget-content-area">
|
|
<div id="style-3_wrapper" class="dataTables_wrapper container-fluid dt-bootstrap4 no-footer">
|
|
<div class="table-responsive">
|
|
<table id="style-3" class="table style-3 dt-table-hover dataTable no-footer" role="grid"
|
|
aria-describedby="style-3_info">
|
|
<thead>
|
|
<tr role="row">
|
|
<th class="checkbox-column text-center sorting_asc" tabindex="0"
|
|
aria-controls="style-3" rowspan="1" colspan="1" aria-sort="ascending"
|
|
style="width: 69.2656px;"> Record Id </th>
|
|
<th class="text-center sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" style="width: 44.2344px;">Image</th>
|
|
<th class="text-center sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" colspan="1" style="width: 79.7969px;">First Name</th>
|
|
<th class="text-center sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" colspan="1" style="width: 77.3281px;">Last Name</th>
|
|
<th class="text-center sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" colspan="1" style="width: 143.516px;">Email</th>
|
|
<th class="text-center sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" colspan="1" style="width: 98.875px;">#</th>
|
|
<th class="text-center sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" colspan="1" style="width: 98.875px;">Principal Type</th>
|
|
<!-- <th class="text-center sorting" tabindex="0" aria-controls="style-3" rowspan="1" colspan="1"
|
|
style="width: 98.875px;">Phone Verified</th> -->
|
|
<th class="text-center sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" colspan="1" style="width: 98.875px;">Email Verified</th>
|
|
<th class="text-center sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" colspan="1" style="width: 98.875px;">Referral Count</th>
|
|
<th class="text-center sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" colspan="1" style="width: 98.875px;">Onboarded by Admin</th>
|
|
<th class="text-center sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" colspan="1" style="width: 98.875px;">Transferred to Customer
|
|
</th>
|
|
<th class="text-center sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" colspan="1" style="width: 98.875px;">Created On</th>
|
|
<th class="text-center sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" colspan="1" style="width: 98.875px;">Modified On</th>
|
|
<th class="text-center sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" colspan="1" style="width: 98.875px;">Active</th>
|
|
<!-- <th class="text-center sorting" tabindex="0" aria-controls="style-3" rowspan="1" colspan="1"
|
|
style="width: 98.875px;">Delete</th> -->
|
|
<th class="text-center dt-no-sorting" tabindex="0" aria-controls="style-3"
|
|
rowspan="1" colspan="1" style="width: 51.625px;">Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for data_obj in data_objs %}
|
|
<tr role="row">
|
|
<td class="checkbox-column text-center sorting_1"> {{ data_obj.id }} </td>
|
|
<td class="text-center">
|
|
<span><img src="../src/assets/img/profile-17.jpeg" class="profile-img"
|
|
alt="avatar"></span>
|
|
</td>
|
|
<td>{{ data_obj.first_name }}</td>
|
|
<td>{{ data_obj.last_name }}</td>
|
|
<td>{{ data_obj.email }}</td>
|
|
<td>
|
|
{% if data_obj.extended_data %}
|
|
<button class="btn btn-primary btn-sm view-password-btn"
|
|
data-id="{{ data_obj.id }}" data-email="{{ data_obj.email }}">
|
|
View
|
|
</button>
|
|
{% endif %}
|
|
</td>
|
|
<td>{{ data_obj.principal_type.name }}</td>
|
|
<!-- <td>{{ data_obj.phone_verified }}</td> -->
|
|
<td>{{ data_obj.email_verified }}</td>
|
|
<td>{{ data_obj.referral_count }}</td>
|
|
<td class="text-center">
|
|
<span
|
|
class="shadow-none badge {% if data_obj.extended_data and data_obj.extended_data.is_onboarded %}badge-primary{% else %}badge-danger{% endif %}">
|
|
{% if data_obj.extended_data %}
|
|
{{ data_obj.extended_data.is_onboarded }}
|
|
{% else %}
|
|
False
|
|
{% endif %}
|
|
</span>
|
|
</td>
|
|
<td class="text-center">
|
|
<span
|
|
class="shadow-none badge {% if data_obj.extended_data and data_obj.extended_data.is_transferred %}badge-primary{% else %}badge-danger{% endif %}">
|
|
{% if data_obj.extended_data %}
|
|
{{ data_obj.extended_data.is_transferred }}
|
|
{% else %}
|
|
False
|
|
{% endif %}
|
|
</span>
|
|
</td>
|
|
<td>{{ data_obj.created_on }}</td>
|
|
<td>{{ data_obj.modified_on }}</td>
|
|
<td class="text-center">
|
|
<span
|
|
class="shadow-none badge {% if data_obj.is_active %}badge-primary{% else %}badge-danger{% endif %}">
|
|
{{ data_obj.is_active }}
|
|
</span>
|
|
</td>
|
|
<!-- <td class="text-center">
|
|
<span class="shadow-none badge {% if data_obj.deleted %}badge-primary{% else %}badge-danger{% endif %}">
|
|
{{ data_obj.deleted }}
|
|
</span>
|
|
</td> -->
|
|
<td class="text-center">
|
|
<ul class="table-controls">
|
|
<li><a href="{% url 'accounts:customer_edit' data_obj.id%}"
|
|
class="bs-tooltip" data-bs-toggle="tooltip"
|
|
data-bs-placement="top" title="" data-original-title="Edit"
|
|
data-bs-original-title="Edit" aria-label="Edit"><svg
|
|
xmlns="http://www.w3.org/2000/svg" width="24"
|
|
height="24" viewBox="0 0 24 24" fill="none"
|
|
stroke="currentColor" stroke-width="2"
|
|
stroke-linecap="round" stroke-linejoin="round"
|
|
class="feather feather-edit-2 p-1 br-8 mb-1">
|
|
<path
|
|
d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z">
|
|
</path>
|
|
</svg></a></li>
|
|
<li><a href="{% url 'accounts:customer_detail' data_obj.id%}"
|
|
class="bs-tooltip" data-bs-toggle="tooltip"
|
|
data-bs-placement="top" title="" data-original-title="View"
|
|
data-bs-original-title="View" aria-label="View">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="24"
|
|
height="24" viewBox="0 0 24 24" fill="none"
|
|
stroke="currentColor" stroke-width="2"
|
|
stroke-linecap="round" stroke-linejoin="round"
|
|
class="feather feather-eye">
|
|
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z">
|
|
</path>
|
|
<circle cx="12" cy="12" r="3"></circle>
|
|
</svg>
|
|
</a></li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="modal fade" id="passwordModal" tabindex="-1" role="dialog" aria-labelledby="passwordModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="passwordModalLabel">Customer Details</h5>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p><strong>Email:</strong> <span id="modalEmail"></span></p>
|
|
<p><strong>Password:</strong> <span id="modalPassword"></span></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
{% endblock content %}
|
|
|
|
{% block javascript %}
|
|
<!-- include required js cdn link through html here -->
|
|
{% include "cdn_through_html/datatable_cdn_js.html" %}
|
|
{% include "cdn_through_html/sweetalert2_cdn_js.html" %}
|
|
|
|
<script>
|
|
c3 = $('#style-3').DataTable({
|
|
"dom": "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
|
|
"<'table-responsive'tr>" +
|
|
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
|
"oLanguage": {
|
|
"oPaginate": { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
|
|
"sInfo": "Showing page _PAGE_ of _PAGES_",
|
|
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
|
"sSearchPlaceholder": "Search...",
|
|
"sLengthMenu": "Results : _MENU_",
|
|
},
|
|
"order": [[0, "desc"]],
|
|
"stripeClasses": [],
|
|
"lengthMenu": [5, 10, 20, 50],
|
|
"pageLength": 10
|
|
});
|
|
|
|
multiCheck(c3);
|
|
|
|
var viewUrl = "{% url 'accounts:get_decrypted_password' customer_id=0 %}"
|
|
$(".view-password-btn").on("click", function () {
|
|
const customerId = $(this).data("id");
|
|
const email = $(this).data("email");
|
|
|
|
// Make the AJAX call
|
|
$.ajax({
|
|
// url: `accounts//get-decrypted-password/${customerId}/`,
|
|
url: viewUrl.replace('0',customerId),
|
|
type: "GET",
|
|
dataType: "json",
|
|
success: function (response) {
|
|
if (response.success) {
|
|
// Populate modal with email and decrypted password
|
|
$("#modalEmail").text(email);
|
|
$("#modalPassword").text(response.decrypted_password);
|
|
|
|
// Show the modal
|
|
$("#passwordModal").modal("show");
|
|
} else {
|
|
Swal.fire({
|
|
title: 'Error!',
|
|
text: response.message || "Failed to fetch the password. Please try again.",
|
|
icon: 'error',
|
|
showConfirmButton: true
|
|
});
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error("AJAX Error:", error);
|
|
Swal.fire({
|
|
title: 'Error!',
|
|
text: "An error occurred. Please try again.",
|
|
icon: 'error',
|
|
showConfirmButton: true
|
|
});
|
|
},
|
|
});
|
|
});
|
|
|
|
</script>
|
|
{% endblock %} |