Merge pull request #442 from WDI-Ideas/sayli

Sayli
This commit is contained in:
Sayli Raut
2024-08-12 15:13:24 +05:30
committed by GitHub
4 changed files with 292 additions and 294 deletions

View File

@@ -19,20 +19,18 @@ class DashboardExportUser implements FromArray, WithHeadings
{
return array_map(function ($transaction) {
return [
'ID' => $transaction['id'],
'Customer Name' => $transaction['iam_principal']['first_name'] . ' ' . $transaction['iam_principal']['last_name'],
'Customer ID' => $transaction['iam_principal']['id'],
'Amount' => '$' . number_format($transaction['amount'], 2),
'Product Name' => $transaction['subscription_product']['product_name'],
'Product Details' => $transaction['subscription_product']['product_details'],
'Subscription Status' => $transaction['subscription_status'],
'Subscription Period Start' => Carbon::parse($transaction['current_period_start'])->format('m/d/Y h:i A'),
'Subscription Period End' => Carbon::parse($transaction['current_period_end'])->format('m/d/Y h:i A'),
'Next Payment Date' => Carbon::parse($transaction['next_payment_date'])->format('m/d/Y h:i A'),
// 'Subscription Period Start' => $transaction['current_period_start'],
// 'Subscription Period End' => $transaction['current_period_end'],
// 'Next Payment Date' => $transaction['next_payment_date'],
'ID' => $transaction['id'] ?? 'N/A',
'Customer Name' => ($transaction['iam_principal']['first_name'] ?? 'Deleted') . ' ' . ($transaction['iam_principal']['last_name'] ?? 'User'),
'Customer ID' => $transaction['iam_principal']['id'] ?? 'Deleted User',
'Amount' => '$' . number_format($transaction['amount'] ?? 0, 2),
'Product Name' => $transaction['subscription_product']['product_name'] ?? 'N/A',
'Product Details' => $transaction['subscription_product']['product_details'] ?? 'N/A',
'Subscription Status' => $transaction['subscription_status'] ?? 'Unknown',
'Subscription Period Start' => isset($transaction['current_period_start']) ? Carbon::parse($transaction['current_period_start'])->format('m/d/Y h:i A') : 'N/A',
'Subscription Period End' => isset($transaction['current_period_end']) ? Carbon::parse($transaction['current_period_end'])->format('m/d/Y h:i A') : 'N/A',
'Next Payment Date' => isset($transaction['next_payment_date']) ? Carbon::parse($transaction['next_payment_date'])->format('m/d/Y h:i A') : 'N/A',
];
}, $this->data);
}

View File

@@ -13,6 +13,7 @@ use Carbon\Carbon;
use App\Exports\DashboardExportUser;
use App\Exports\DashboardSelectedExportUser;
use App\Models\ReferralUsers;
use Illuminate\Support\Facades\Log;
use Maatwebsite\Excel\Facades\Excel;
@@ -223,7 +224,7 @@ class DashboardController extends Controller
return response()->json(['status_code' => 200]);
} catch (\Exception $e) {
DB::rollBack();
\Log::error('Storing Referral Code function failed: ' . $e->getMessage());
Log::error('Storing Referral Code function failed: ' . $e->getMessage());
return response()->json(['error' => 'Something went wrong while storing Data.', 'status_code' => 500], 500);
}
}
@@ -267,17 +268,13 @@ class DashboardController extends Controller
$fileName = 'selected_customer_transaction_data.xlsx';
return Excel::download(new DashboardSelectedExportUser($ids), $fileName);
} catch (\Exception $e) {
Log::error("Export Failed " . $e->getMessage());
return response()->json(['error' => 'Export failed. Something went wrong.'], 500);
}
}
/*
Created By : Sayali parab
Created at : 07 June 2024
@@ -345,7 +342,7 @@ class DashboardController extends Controller
return jsonResponseWithSuccessMessage(__('success.update_data'));
} catch (\Exception $e) {
\Log::error("Update Status function Load Failed " . $e->getMessage());
Log::error("Update Status function Load Failed " . $e->getMessage());
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
}
}
@@ -371,7 +368,7 @@ class DashboardController extends Controller
return response()->json(['success' => true, 'status' => 200]);
} catch (\Exception $e) {
DB::rollBack();
\Log::error("delete_location function Load Failed " . $e->getMessage());
Log::error("delete_location function Load Failed " . $e->getMessage());
return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]);
}
}
@@ -406,7 +403,7 @@ class DashboardController extends Controller
return response()->json(['success' => true, 'message' => __('success.update_data'), 'status' => 200]);
} catch (\Exception $e) {
DB::rollBack();
\Log::error("Failed to update Code: " . $e->getMessage());
Log::error("Failed to update Code: " . $e->getMessage());
return response()->json(['success' => false, 'error' => __('auth.something_went_wrong'), 'status' => 500]);
}
}

View File

@@ -0,0 +1,251 @@
$('#zero-config').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_",
},
"stripeClasses": [],
"lengthMenu": [7, 10, 20, 50],
"pageLength": 10
});
$('#zero-config2').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_",
},
"stripeClasses": [],
"lengthMenu": [7, 10, 20, 50],
"pageLength": 10
});
$(document).ready(function() {
$.validator.addMethod("lettersOnly", function(value, element) {
return this.optional(element) || /^[a-zA-Z\s]+$/.test(value);
}, "Please enter only alphabets");
$.validator.addMethod("numbersOnly", function(value, element) {
return this.optional(element) || /^[0-9]+$/.test(value);
}, "Please enter only numbers");
$('#create_custom_referral_code').validate({
rules: {
referral_code: {
required: true,
},
},
messages: {
referral_code: {
required: "Please enter Referral Code.",
},
},
errorClass: 'error-message',
submitHandler: function(form) {
let b_url = url_path;
$("#create_custom_code").html("Please Wait...");
$("#create_custom_code").prop("disabled", true);
let base_url = url_path;
var formData = new FormData(form);
$.ajax({
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
"content"),
},
type: "post",
url: base_url + '/create-update-referral-code',
data: formData,
contentType: false,
processData: false,
success: function(result) {
console.log("result", result);
if (result.status_code == 200) {
toastr.success('Referral code submitted successfully');
setTimeout(function() {
window.location.href = b_url +
"/dashboard";
}, 2000);
} else if (result.status_code == 500) {
toastr.error(result.message);
setTimeout(function() {
window.location.reload();
}, 2000);
} else {
toastr.error('Something Went Wrong');
setTimeout(function() {
window.location.reload();
}, 2000);
}
$('#create_custom_code').attr('disabled', false);
$('#create_custom_code').text('Submit');
},
});
}
});
});
$(function(e) {
$("#select-all-ids").click(function() {
$(".form-check-input").prop('checked', $(this).prop('checked'));
});
$(".form-check-input").click(function() {
if (!$(this).prop('checked')) {
$("#select-all-ids").prop('checked', false);
} else {
if ($(".form-check-input:checked").length === $(".form-check-input").length) {
$("#select-all-ids").prop('checked', true);
}
}
});
$(document).on("click", "#download-selected", function(e) {
e.preventDefault();
var allIds = [];
// Iterate over each page of the DataTable
var table = $('#zero-config').DataTable();
for (var i = 0; i < table.page.info().pages; i++) {
table.page(i).draw(false); // Switch to page i
$('#zero-config tbody input:checked').each(function() {
allIds.push($(this).val());
});
}
if (allIds.length > 0) {
// If there are selected customers
$('#ids').prop('disabled', false);
$('#all_id').prop('disabled', true);
$('#ids').val(allIds);
// Now submit the form or perform download action
$('#customer-form').submit(); // Or perform your download action here
} else {
// No customers selected
toastr.error("Please select at least one customer to download.");
}
});
$(document).on("click", "#download_all", function(e) {
$('#all_id').prop('disabled', false);
$('#ids').prop('disabled', true);
})
});
$(document).on("click", ".more", function(e) {
e.preventDefault();
e.stopPropagation();
});
$(document).ready(function() {
// $('<button><ul class="navbar-item flex-row ms-lg-auto ms-0"><li class="nav-item dropdown action-dropdown order-lg-0 order-1"><a href="javascript:void(0);"class="nav-link dropdown-toggle user extra-btn" id="actionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div class="avatar-container"><div class="avatar avatar-sm avatar-mid avatar-indicators avatar-online"><h3>Export</h3></div></div></a><div class="dropdown-menu position-absolute" aria-labelledby="actionDropdown"><div class="dropdown-item"><a href="javascript:void(0)" id="download_all"><span>Download Overview</span></a></div><div class="dropdown-item"><a href="javascript:void(0)" id="download-selected"><span id="export">Download Selected</span></a></div></div></li></ul></button>')
// .insertBefore("#zero-config_filter label");
$('<button>' +
'<ul class="navbar-item flex-row ms-lg-auto ms-0">' +
'<li class="nav-item dropdown action-dropdown order-lg-0 order-1">' +
'<a href="javascript:void(0);" class="nav-link dropdown-toggle user extra-btn" id="actionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
'<div class="avatar-container">' +
'<div class="avatar avatar-sm avatar-mid avatar-indicators avatar-online">' +
'<h3>Export</h3>' +
'</div>' +
'</div>' +
'</a>' +
'<div class="dropdown-menu position-absolute" aria-labelledby="actionDropdown">' +
'<div class="dropdown-item">' +
'<a href="javascript:void(0)" id="download_all"><span>Download Overview</span></a>' +
'</div>' +
'<div class="dropdown-item">' +
'<a href="javascript:void(0)" id="download-selected"><span id="export">Download Selected</span></a>' +
'</div>' +
'</div>' +
'</li>' +
'</ul>' +
'</button>').insertBefore("#zero-config_filter label");
$("#zero-config").on("click", ".sub_admin_permission", function() {
var Name = $(this).data('name');
var Price = $(this).data('price');
var SubID = $(this).data('subscription-id');
var CustID = $(this).data('customer-id');
var SubStatus = $(this).data('subscription-status');
var startDate = $(this).data('start-date');
var endDate = $(this).data('end-date');
var nextDate = $(this).data('next-date');
var formattedPrice = '$' + Price;
$('.subadmin-option span').eq(0).text(Name);
$('.subadmin-option span').eq(1).text(formattedPrice);
$('.subadmin-option span').eq(2).text(SubID);
$('.subadmin-option span').eq(3).text(CustID);
$('.subadmin-option span').eq(4).text(SubStatus);
$('.subadmin-option span').eq(5).text(startDate);
$('.subadmin-option span').eq(6).text(endDate);
$('.subadmin-option span').eq(7).text(nextDate); // Corrected index for next-date
});
});
document.addEventListener('DOMContentLoaded', function() {
const viewButtons = document.querySelectorAll('.btn-view-details');
viewButtons.forEach(button => {
button.addEventListener('click', function() {
const row = this.closest('tr');
const user = JSON.parse(row.dataset.user);
const referredUsers = JSON.parse(row.dataset.referredUsers);
// Populate the modal fields
document.querySelector(
'#referral-user-details-modal .referral-user-inn-div:nth-child(1) span')
.innerText = `${user.first_name} ${user.last_name}`;
document.querySelector(
'#referral-user-details-modal .referral-user-inn-div:nth-child(2) span')
.innerText = user.email_address;
// document.querySelector(
// '#referral-user-details-modal .referral-user-inn-div:nth-child(3) span')
// .innerText = user.referral_code;
// Clear previous referred users
const referredUsersDiv = document.querySelector(
'#referral-user-details-modal .referral-user-inn-div.referred-users');
referredUsersDiv.innerHTML = '';
referredUsers.forEach(referredUser => {
const p = document.createElement('p');
p.innerText =
`${referredUser.first_name} ${referredUser.last_name} (${referredUser.email_address}) (${referredUser.id})`;
referredUsersDiv.appendChild(p);
});
});
});
});

View File

@@ -23,12 +23,14 @@
{{ csrf_field() }}
<h5>Create Custom Referral Code:-
<input type="text" class="form-control" name="referral_code"
id="referral_code" value="" placeholder="Enter Referral Code"
oninput="this.value = this.value.toUpperCase().replace(/\s/g, '')" maxlength="15">
<div class="">
<button id="create_custom_code" type="submit" class="download-btn-custom mt-3 custom-width-10">Submit</button>
</div>
<input type="text" class="form-control" name="referral_code"
id="referral_code" value="" placeholder="Enter Referral Code"
oninput="this.value = this.value.toUpperCase().replace(/\s/g, '')"
maxlength="15">
<div class="">
<button id="create_custom_code" type="submit"
class="download-btn-custom mt-3 custom-width-10">Submit</button>
</div>
</form>
@@ -38,15 +40,18 @@
{{ csrf_field() }}
<h5>My Custom Referral Code:-</h5>
<input type="text" class="form-control" name="referral_code"
id="referral_code" value="{{$customReferralCode->referral_code}}" placeholder="Enter Referral Code"
oninput="this.value = this.value.toUpperCase().replace(/\s/g, '')" maxlength="15">
<input type="hidden" name="id" value="{{$customReferralCode->id}}"/>
<div class="d-flex" style="justify-content: space-between;">
<button id="create_custom_code" type="submit" class="download-btn-custom mt-3 custom-width-10">Update</button>
{{-- <button id="create_custom_code" type="submit" class="download-btn-cancel mt-3 custom-width-10">Deactivate Code</button> --}}
<input type="text" class="form-control" name="referral_code" id="referral_code"
value="{{ $customReferralCode->referral_code }}"
placeholder="Enter Referral Code"
oninput="this.value = this.value.toUpperCase().replace(/\s/g, '')"
maxlength="15">
<input type="hidden" name="id" value="{{ $customReferralCode->id }}" />
<div class="d-flex" style="justify-content: space-between;">
<button id="create_custom_code" type="submit"
class="download-btn-custom mt-3 custom-width-10">Update</button>
{{-- <button id="create_custom_code" type="submit" class="download-btn-cancel mt-3 custom-width-10">Deactivate Code</button> --}}
</div>
</div>
</form>
@@ -159,8 +164,8 @@
<th class="w-10px pe-2">
<div
class="form-check form-check-sm form-check-custom form-check-solid me-3">
<input class="form-check-input" type="checkbox"
name="customer_ids" id="select-all-ids" />
<input class="form-check-input" type="checkbox" name="customer_ids"
id="select-all-ids" />
</div>
</th>
<th class="text-start">Sr no</th>
@@ -318,8 +323,8 @@
{{ count($data['refeers_users']) }}
</td>
<td class="text-start">
<a class="view-btn m-0 pointer btn-view-details"
data-toggle="modal" data-target="#referral-user-details-modal">
<a class="view-btn m-0 pointer btn-view-details" data-toggle="modal"
data-target="#referral-user-details-modal">
View
</a>
</td>
@@ -381,260 +386,7 @@
@endsection
@section('section_script')
<script>
$(document).ready(function() {
$.validator.addMethod("lettersOnly", function(value, element) {
return this.optional(element) || /^[a-zA-Z\s]+$/.test(value);
}, "Please enter only alphabets");
$.validator.addMethod("numbersOnly", function(value, element) {
return this.optional(element) || /^[0-9]+$/.test(value);
}, "Please enter only numbers");
$('#create_custom_referral_code').validate({
rules: {
referral_code: {
required: true,
},
},
messages: {
referral_code: {
required: "Please enter Referral Code.",
},
},
errorClass: 'error-message',
submitHandler: function(form) {
let b_url = url_path;
$("#create_custom_code").html("Please Wait...");
$("#create_custom_code").prop("disabled", true);
var formData = new FormData(form);
$.ajax({
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
"content"),
},
type: "post",
url: "{{ route('create-update-referral-code') }}",
data: formData,
contentType: false,
processData: false,
success: function(result) {
console.log("result", result);
if (result.status_code == 200) {
toastr.success('Referral code submitted successfully');
setTimeout(function() {
window.location.href = b_url +
"/dashboard";
}, 2000);
} else if (result.status_code == 500) {
toastr.error(result.message);
setTimeout(function() {
window.location.reload();
}, 2000);
} else {
toastr.error('Something Went Wrong');
setTimeout(function() {
window.location.reload();
}, 2000);
}
$('#create_custom_code').attr('disabled', false);
$('#create_custom_code').text('Submit');
},
});
}
});
});
</script>
<script>
$('#zero-config').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_",
},
"stripeClasses": [],
"lengthMenu": [7, 10, 20, 50],
"pageLength": 10
});
$('#zero-config2').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_",
},
"stripeClasses": [],
"lengthMenu": [7, 10, 20, 50],
"pageLength": 10
});
$(function(e) {
$("#select-all-ids").click(function() {
$(".form-check-input").prop('checked', $(this).prop('checked'));
});
$(".form-check-input").click(function() {
if (!$(this).prop('checked')) {
$("#select-all-ids").prop('checked', false);
} else {
if ($(".form-check-input:checked").length === $(".form-check-input").length) {
$("#select-all-ids").prop('checked', true);
}
}
});
$(document).on("click", "#download-selected", function(e) {
e.preventDefault();
var allIds = [];
// Iterate over each page of the DataTable
var table = $('#zero-config').DataTable();
for (var i = 0; i < table.page.info().pages; i++) {
table.page(i).draw(false); // Switch to page i
$('#zero-config tbody input:checked').each(function() {
allIds.push($(this).val());
});
}
if (allIds.length > 0) {
// If there are selected customers
$('#ids').prop('disabled', false);
$('#all_id').prop('disabled', true);
$('#ids').val(allIds);
// Now submit the form or perform download action
$('#customer-form').submit(); // Or perform your download action here
} else {
// No customers selected
toastr.error("Please select at least one customer to download.");
}
});
$(document).on("click", "#download_all", function(e) {
$('#all_id').prop('disabled', false);
$('#ids').prop('disabled', true);
})
});
$(document).on("click", ".more", function(e) {
e.preventDefault();
e.stopPropagation();
});
</script>
<script>
$(document).ready(function() {
// $('<button><ul class="navbar-item flex-row ms-lg-auto ms-0"><li class="nav-item dropdown action-dropdown order-lg-0 order-1"><a href="javascript:void(0);"class="nav-link dropdown-toggle user extra-btn" id="actionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div class="avatar-container"><div class="avatar avatar-sm avatar-mid avatar-indicators avatar-online"><h3>Export</h3></div></div></a><div class="dropdown-menu position-absolute" aria-labelledby="actionDropdown"><div class="dropdown-item"><a href="javascript:void(0)" id="download_all"><span>Download Overview</span></a></div><div class="dropdown-item"><a href="javascript:void(0)" id="download-selected"><span id="export">Download Selected</span></a></div></div></li></ul></button>')
// .insertBefore("#zero-config_filter label");
$('<button>' +
'<ul class="navbar-item flex-row ms-lg-auto ms-0">' +
'<li class="nav-item dropdown action-dropdown order-lg-0 order-1">' +
'<a href="javascript:void(0);" class="nav-link dropdown-toggle user extra-btn" id="actionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
'<div class="avatar-container">' +
'<div class="avatar avatar-sm avatar-mid avatar-indicators avatar-online">' +
'<h3>Export</h3>' +
'</div>' +
'</div>' +
'</a>' +
'<div class="dropdown-menu position-absolute" aria-labelledby="actionDropdown">' +
'<div class="dropdown-item">' +
'<a href="javascript:void(0)" id="download_all"><span>Download Overview</span></a>' +
'</div>' +
'<div class="dropdown-item">' +
'<a href="javascript:void(0)" id="download-selected"><span id="export">Download Selected</span></a>' +
'</div>' +
'</div>' +
'</li>' +
'</ul>' +
'</button>').insertBefore("#zero-config_filter label");
$("#zero-config").on("click", ".sub_admin_permission", function() {
var Name = $(this).data('name');
var Price = $(this).data('price');
var SubID = $(this).data('subscription-id');
var CustID = $(this).data('customer-id');
var SubStatus = $(this).data('subscription-status');
var startDate = $(this).data('start-date');
var endDate = $(this).data('end-date');
var nextDate = $(this).data('next-date');
var formattedPrice = '$' + Price;
$('.subadmin-option span').eq(0).text(Name);
$('.subadmin-option span').eq(1).text(formattedPrice);
$('.subadmin-option span').eq(2).text(SubID);
$('.subadmin-option span').eq(3).text(CustID);
$('.subadmin-option span').eq(4).text(SubStatus);
$('.subadmin-option span').eq(5).text(startDate);
$('.subadmin-option span').eq(6).text(endDate);
$('.subadmin-option span').eq(7).text(nextDate); // Corrected index for next-date
});
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const viewButtons = document.querySelectorAll('.btn-view-details');
viewButtons.forEach(button => {
button.addEventListener('click', function() {
const row = this.closest('tr');
const user = JSON.parse(row.dataset.user);
const referredUsers = JSON.parse(row.dataset.referredUsers);
// Populate the modal fields
document.querySelector(
'#referral-user-details-modal .referral-user-inn-div:nth-child(1) span')
.innerText = `${user.first_name} ${user.last_name}`;
document.querySelector(
'#referral-user-details-modal .referral-user-inn-div:nth-child(2) span')
.innerText = user.email_address;
{{-- document.querySelector(
'#referral-user-details-modal .referral-user-inn-div:nth-child(3) span')
.innerText = user.referral_code; --}}
// Clear previous referred users
const referredUsersDiv = document.querySelector(
'#referral-user-details-modal .referral-user-inn-div.referred-users');
referredUsersDiv.innerHTML = '';
referredUsers.forEach(referredUser => {
const p = document.createElement('p');
p.innerText =
`${referredUser.first_name} ${referredUser.last_name} (${referredUser.email_address}) (${referredUser.id})`;
referredUsersDiv.appendChild(p);
});
});
});
});
</script>
<script src="{{ asset('public/assets/js/admin/dashboard/main.js') }}"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {