first commit
This commit is contained in:
@@ -0,0 +1,190 @@
|
||||
$(document).ready(function(){
|
||||
var categories = [];
|
||||
|
||||
getCompanies();
|
||||
getCategories();
|
||||
|
||||
$(document).on('click', '.dragDropContainer', function (e) {
|
||||
$('#uploadDocumentFrm #updloadedFiles').click();
|
||||
});
|
||||
|
||||
$(document).on('change', '#uploadDocumentFrm #updloadedFiles', function (e) {
|
||||
var html = $('#uploadedFileList').html();
|
||||
var files = e.target.files;
|
||||
var html = '';
|
||||
var categoriesHtml = '';
|
||||
|
||||
categories.forEach(function(category) {
|
||||
categoriesHtml += `
|
||||
<option value="` + category.id + `">` + category.name + `</option>
|
||||
`;
|
||||
});
|
||||
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var filename = files[i].name;
|
||||
var extension = files[i].type
|
||||
var icon = extension == 'application/pdf' ? "/themes/tailwind/images/pdf-icon.png" : "/themes/tailwind/images/doc-icon.png";
|
||||
|
||||
html += `
|
||||
<div class="file-row" data-index="` + i + `">
|
||||
<div class="file-details mb-3">
|
||||
<div class="d-flex align-items-center" style="width: 25%; word-break: break-word;">
|
||||
<img class="img-fluid mr-2" width="30" src="` + icon + `">
|
||||
<span class="file-title">` + filename + `</span>
|
||||
</div>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="file-progress-wrapper mr-2">
|
||||
<div class="file-progress" style="width: 0%;"></div>
|
||||
</div>
|
||||
<span class="file-progress-percent mr-2">0%</span>
|
||||
<img class="img-fluid file-progress-remove" width="24" src="/themes/tailwind/images/close-circle-red.png">
|
||||
</div>
|
||||
<div class="d-flex align-items-center">
|
||||
<label class="col-form-label mr-2">Document category</label>
|
||||
<select class="w-fit-content" name="bookkeeping_document_category_id">
|
||||
` + categoriesHtml + `
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3 align-items-center">
|
||||
<div class="col-auto" required>
|
||||
<label class="col-form-label">Batch Name</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="text" class="form-control" value="" name="batch_name" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3 align-items-center">
|
||||
<div class="col-auto" required>
|
||||
<label class="col-form-label">Remark</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="text" class="form-control" value="" name="remark" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<hr class="file-row-separator">
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
$('#uploadedFileList').html(html);
|
||||
$('#uploadedFileCount #totalFile').html(files.length);
|
||||
});
|
||||
|
||||
$(document).on('click', '#uploadDocumentFrm .file-progress-remove', function (e) {
|
||||
$(this).parents('.file-row').first().remove();
|
||||
});
|
||||
|
||||
$('#uploadDocumentFrm').submit(function(e) {
|
||||
e.preventDefault();
|
||||
var action = $(this).attr('action');
|
||||
var button = $(this).find('button[type="submit"]');
|
||||
var buttonHtml = button.html();
|
||||
var totalDone = 0;
|
||||
var form = $(this);
|
||||
|
||||
if (!button.is(':disabled') && action) {
|
||||
button.attr('disabled', 'disabled');
|
||||
button.html('<i class="fa fa-spinner fa-spin" style="font-size:24px"></i>');
|
||||
|
||||
var files = $('#uploadDocumentFrm #updloadedFiles')[0].files;
|
||||
$('#uploadDocumentFrm .file-row').each(function() {
|
||||
var formData = new FormData();
|
||||
var fileRowElem = $(this);
|
||||
var index = fileRowElem.attr('data-index');
|
||||
var isLast = $('#uploadDocumentFrm .file-row').length - 1 == index ? true : false;
|
||||
|
||||
formData.append('company_id', form.find('select[name="company_id"]').val());
|
||||
formData.append('uploaded_file', files[index]);
|
||||
formData.append('bookkeeping_document_category_id', $(this).find('select[name="bookkeeping_document_category_id"]').val());
|
||||
formData.append('batch_name', $(this).find('input[name="batch_name"]').val());
|
||||
formData.append('remark', $(this).find('input[name="remark"]').val());
|
||||
|
||||
fileRowElem.find('.file-progress-wrapper .file-progress').css('width', '50%');
|
||||
fileRowElem.find('.file-progress-percent').html('50%');
|
||||
|
||||
$.ajax({
|
||||
url: action,
|
||||
type: "post",
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success:function(data) {
|
||||
totalDone++;
|
||||
console.log(isLast);
|
||||
|
||||
if (isLast) {
|
||||
button.removeAttr('disabled');
|
||||
button.html(buttonHtml);
|
||||
|
||||
if (data.success) {
|
||||
popToast('success', data.message);
|
||||
$('.reload-main-table').click();
|
||||
$('#uploadDocumentModal').modal('hide');
|
||||
$('#uploadedFileList').html('');
|
||||
$('#uploadedFileCount #totalFile').html('0');
|
||||
}
|
||||
else {
|
||||
popToast('danger', data.message);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.success) {
|
||||
fileRowElem.find('.file-progress-wrapper .file-progress').css('width', '100%');
|
||||
fileRowElem.find('.file-progress-wrapper .file-progress').addClass('green');
|
||||
fileRowElem.find('.file-progress-percent').html('100%');
|
||||
fileRowElem.find('#uploadedFileCount #totalDone').html(totalDone);
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
var errors = data.responseJSON.errors;
|
||||
$.each(errors, function(index, error) {
|
||||
popToast('danger', errors[0]);
|
||||
return false;
|
||||
});
|
||||
|
||||
button.removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
|
||||
index++;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function getCompanies() {
|
||||
$.ajax({
|
||||
url: "/cms/bookkeepings/get-companies",
|
||||
type: "get",
|
||||
data: {},
|
||||
dataType: 'json',
|
||||
success:function(data) {
|
||||
var companies = data.companies;
|
||||
var html = '';
|
||||
|
||||
companies.forEach(function(company) {
|
||||
html += `
|
||||
<option value="` + company.id + `" selected>` + company.name + `</option>
|
||||
`;
|
||||
});
|
||||
|
||||
$('#uploadDocumentFrm select[name="company_id"]').html(html);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getCategories() {
|
||||
$.ajax({
|
||||
url: "/cms/bookkeepings/get-categories",
|
||||
type: "get",
|
||||
data: {},
|
||||
dataType: 'json',
|
||||
success:function(data) {
|
||||
categories = data.categories;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
60
public/themes/tailwind/js/cms/companies/index.js
Normal file
60
public/themes/tailwind/js/cms/companies/index.js
Normal file
@@ -0,0 +1,60 @@
|
||||
$(document).ready( function () {
|
||||
var currentLanguage = $('#currentLanguage').val();
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
|
||||
var companyListTableColumns = [
|
||||
(currentLanguage == 'zh_hk' ? {data: 'name_chinese', name: 'companies.name_chinese'} : {data: 'name_english', name: 'companies.name_english'}),
|
||||
{data: 'bookkeeping_subscription', name: 'bookkeeping_subscription', searchable: false, sortable: false},
|
||||
{data: 'bookkeeping_requests_count', name: 'bookkeeping_requests_count', searchable: false, sortable: false},
|
||||
{data: 'com_sec_subscription', name: 'com_sec_subscription', searchable: false, sortable: false},
|
||||
{data: 'com_sec_requests_count', name: 'com_sec_requests_count', searchable: false, sortable: false},
|
||||
{data: 'actions', name: 'actions', searchable: false, sortable: false}
|
||||
];
|
||||
var companyListTableUrl = $("#companyListTable").attr('data-ajax-url');
|
||||
var companyListTableEmptyText = $("#companyListTable").attr('data-empty-text');
|
||||
var companyListTable = $("#companyListTable").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: companyListTableUrl,
|
||||
type: 'post',
|
||||
"data": function ( d ) {
|
||||
return $.extend( {}, d, {
|
||||
"company_name": $('#searchFrm #search_company_name').val(),
|
||||
"bookkeeping_subscription_status": $('#searchFrm #search_bookkeeping_subscription_status').val(),
|
||||
"com_sec_subscription_status": $('#searchFrm #search_com_sec_subscription_status').val(),
|
||||
} );
|
||||
},
|
||||
"dataSrc": function ( json ) {
|
||||
for (var i = 0; i < json.data.length; i++) {
|
||||
$.each( json.data[i], function( key, value ) {
|
||||
json.data[i][key] = value ? value : '-';
|
||||
});
|
||||
}
|
||||
|
||||
return json.data;
|
||||
}
|
||||
},
|
||||
columns: companyListTableColumns,
|
||||
order: [[0, "asc"]],
|
||||
searchDelay: 500,
|
||||
"language": {
|
||||
"paginate": {
|
||||
"next": ">", // Text for the "Next" page button
|
||||
"previous": "<" // Text for the "Previous" page button
|
||||
},
|
||||
"emptyTable": companyListTableEmptyText
|
||||
// Add more text customizations if needed
|
||||
}
|
||||
});
|
||||
|
||||
$('#searchFrm').submit(function(e) {
|
||||
e.preventDefault();
|
||||
companyListTable.ajax.reload();
|
||||
});
|
||||
} );
|
||||
45
public/themes/tailwind/js/cms/companies/show-log.js
Normal file
45
public/themes/tailwind/js/cms/companies/show-log.js
Normal file
@@ -0,0 +1,45 @@
|
||||
$(document).ready( function () {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
|
||||
var allUserAccessLogsListTableUrl = $("#allUserAccessLogsListTable").attr('data-ajax-url');
|
||||
var allUserAccessLogsListTableEmptyText = $("#allUserAccessLogsListTable").attr('data-empty-text');
|
||||
$("#allUserAccessLogsListTable").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: allUserAccessLogsListTableUrl,
|
||||
type: 'post',
|
||||
"dataSrc": function ( json ) {
|
||||
for (var i = 0; i < json.data.length; i++) {
|
||||
$.each( json.data[i], function( key, value ) {
|
||||
json.data[i][key] = value ? value : '-';
|
||||
});
|
||||
}
|
||||
|
||||
return json.data;
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{data: 'email', name: 'users.email'},
|
||||
{data: 'date', name: 'user_access_logs.created_at'},
|
||||
{data: 'time', name: 'user_access_logs.created_at'},
|
||||
{data: 'event', name: 'user_access_logs.event'},
|
||||
{data: 'description', name: 'user_access_logs.description'},
|
||||
{data: 'status', name: 'user_access_logs.status'},
|
||||
],
|
||||
order: [[1, "desc"]],
|
||||
searchDelay: 500,
|
||||
"language": {
|
||||
"paginate": {
|
||||
"next": ">", // Text for the "Next" page button
|
||||
"previous": "<" // Text for the "Previous" page button
|
||||
},
|
||||
"emptyTable": allUserAccessLogsListTableEmptyText
|
||||
// Add more text customizations if needed
|
||||
}
|
||||
});
|
||||
} );
|
||||
55
public/themes/tailwind/js/cms/companies/show-user-invite.js
Normal file
55
public/themes/tailwind/js/cms/companies/show-user-invite.js
Normal file
@@ -0,0 +1,55 @@
|
||||
$(document).ready( function () {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
|
||||
$('#sendInviteUserFrm').submit(function(e) {
|
||||
e.preventDefault();
|
||||
var action = $(this).attr('action');
|
||||
var button = $(this).find('button[type="submit"]');
|
||||
var buttonHtml = button.html();
|
||||
|
||||
if (!button.is(':disabled') && action) {
|
||||
button.attr('disabled', 'disabled');
|
||||
button.html('<i class="fa fa-spinner fa-spin" style="font-size:24px"></i>');
|
||||
|
||||
$.ajax({
|
||||
url: action,
|
||||
type: "post",
|
||||
data: $(this).serialize(),
|
||||
dataType: 'json',
|
||||
success:function(data) {
|
||||
button.removeAttr('disabled');
|
||||
button.html(buttonHtml);
|
||||
|
||||
if (data.success) {
|
||||
$('#validationModal').modal('show');
|
||||
$('#validationModal .error-message').html(data.message);
|
||||
|
||||
$('#sendInviteUserFrm').trigger("reset");
|
||||
}
|
||||
else {
|
||||
$('#validationModal .error-message').html(data.message);
|
||||
$('#validationModal').modal('show');
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
var errors = data.responseJSON.errors;
|
||||
var errorMessage = '<ul>';
|
||||
$.each(errors, function(index, error) {
|
||||
console.log(error);
|
||||
errorMessage += '<li>' + error[0] + '</li>';
|
||||
});
|
||||
errorMessage += '</ul>';
|
||||
|
||||
$('#validationModal .error-message').html(errorMessage);
|
||||
$('#validationModal').modal('show');
|
||||
button.removeAttr('disabled');
|
||||
button.html(buttonHtml);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} );
|
||||
386
public/themes/tailwind/js/cms/companies/show-user.js
Normal file
386
public/themes/tailwind/js/cms/companies/show-user.js
Normal file
@@ -0,0 +1,386 @@
|
||||
$(document).ready( function () {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
|
||||
var userAccessLogsListTable = null;
|
||||
var userListTableUrl = $("#userListTable").attr('data-ajax-url');
|
||||
var userListTableEmptyText = $("#userListTable").attr('data-empty-text');
|
||||
var userListTable = $("#userListTable").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: userListTableUrl,
|
||||
type: 'post',
|
||||
"dataSrc": function ( json ) {
|
||||
for (var i = 0; i < json.data.length; i++) {
|
||||
$.each( json.data[i], function( key, value ) {
|
||||
json.data[i][key] = value ? value : '-';
|
||||
});
|
||||
}
|
||||
|
||||
return json.data;
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{data: 'first_name', name: 'users.first_name'},
|
||||
{data: 'last_name', name: 'users.last_name'},
|
||||
{data: 'phone', name: 'users.phone'},
|
||||
{data: 'email', name: 'users.email'},
|
||||
{data: 'display_name', name: 'roles.display_name'},
|
||||
{data: 'status', name: 'users.status'},
|
||||
{data: 'actions', name: 'actions', searchable: false, sortable: false}
|
||||
],
|
||||
order: [[0, "asc"]],
|
||||
searchDelay: 500,
|
||||
"language": {
|
||||
"paginate": {
|
||||
"next": ">", // Text for the "Next" page button
|
||||
"previous": "<" // Text for the "Previous" page button
|
||||
},
|
||||
"emptyTable": userListTableEmptyText
|
||||
// Add more text customizations if needed
|
||||
}
|
||||
});
|
||||
|
||||
$('.password-hide-show').click(function() {
|
||||
var type = $(this).parent().find('input').attr('type');
|
||||
|
||||
if (type == 'password') {
|
||||
$(this).parent().find('input').attr('type', 'text');
|
||||
}
|
||||
else {
|
||||
$(this).parent().find('input').attr('type', 'password');
|
||||
}
|
||||
});
|
||||
|
||||
$('#addUserFrm').submit(function(e) {
|
||||
e.preventDefault();
|
||||
var action = $(this).attr('action');
|
||||
var button = $(this).find('button[type="submit"]');
|
||||
var buttonHtml = button.html();
|
||||
|
||||
if (!button.is(':disabled') && action) {
|
||||
button.attr('disabled', 'disabled');
|
||||
button.html('<i class="fa fa-spinner fa-spin" style="font-size:24px"></i>');
|
||||
|
||||
$.ajax({
|
||||
url: action,
|
||||
type: "post",
|
||||
data: $(this).serialize(),
|
||||
dataType: 'json',
|
||||
success:function(data) {
|
||||
button.removeAttr('disabled');
|
||||
button.html(buttonHtml);
|
||||
|
||||
if (data.success) {
|
||||
$('#newUserModal').modal('hide');
|
||||
$('#validationModal').modal('show');
|
||||
$('#validationModal .error-message').html(data.message);
|
||||
|
||||
$('#addUserFrm').trigger("reset");
|
||||
userListTable.ajax.reload();
|
||||
}
|
||||
else {
|
||||
$('#validationModal .error-message').html(data.message);
|
||||
$('#validationModal').modal('show');
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
var errors = data.responseJSON.errors;
|
||||
var errorMessage = '<ul>';
|
||||
$.each(errors, function(index, error) {
|
||||
console.log(error);
|
||||
errorMessage += '<li>' + error[0] + '</li>';
|
||||
});
|
||||
errorMessage += '</ul>';
|
||||
|
||||
$('#validationModal .error-message').html(errorMessage);
|
||||
$('#validationModal').modal('show');
|
||||
button.removeAttr('disabled');
|
||||
button.html(buttonHtml);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.suspend-user', function(e) {
|
||||
var action = $(this).attr('data-action');
|
||||
|
||||
if (action) {
|
||||
Swal.fire({
|
||||
title: languageTexts["Are you sure?"],
|
||||
text: languageTexts["You would not be able to revert this!"],
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: languageTexts["Yes"],
|
||||
cancelButtonText: languageTexts["Cancel"]
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: action,
|
||||
type: "post",
|
||||
data: {},
|
||||
dataType: 'json',
|
||||
success:function(data) {
|
||||
if (data.success) {
|
||||
$('#validationModal').modal('show');
|
||||
$('#validationModal .error-message').html(data.message);
|
||||
|
||||
userListTable.ajax.reload();
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
var errors = data.responseJSON.errors;
|
||||
var errorMessage = '<ul>';
|
||||
$.each(errors, function(index, error) {
|
||||
console.log(error);
|
||||
errorMessage += '<li>' + error[0] + '</li>';
|
||||
});
|
||||
errorMessage += '</ul>';
|
||||
|
||||
$('#validationModal .error-message').html(errorMessage);
|
||||
$('#validationModal').modal('show');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.activate-user', function(e) {
|
||||
var action = $(this).attr('data-action');
|
||||
|
||||
if (action) {
|
||||
Swal.fire({
|
||||
title: languageTexts["Are you sure?"],
|
||||
text: languageTexts["You would not be able to revert this!"],
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: languageTexts["Yes"],
|
||||
cancelButtonText: languageTexts["Cancel"]
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: action,
|
||||
type: "post",
|
||||
data: {},
|
||||
dataType: 'json',
|
||||
success:function(data) {
|
||||
if (data.success) {
|
||||
$('#validationModal').modal('show');
|
||||
$('#validationModal .error-message').html(data.message);
|
||||
|
||||
userListTable.ajax.reload();
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
var errors = data.responseJSON.errors;
|
||||
var errorMessage = '<ul>';
|
||||
$.each(errors, function(index, error) {
|
||||
console.log(error);
|
||||
errorMessage += '<li>' + error[0] + '</li>';
|
||||
});
|
||||
errorMessage += '</ul>';
|
||||
|
||||
$('#validationModal .error-message').html(errorMessage);
|
||||
$('#validationModal').modal('show');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.remove-user', function(e) {
|
||||
var action = $(this).attr('data-action');
|
||||
|
||||
if (action) {
|
||||
Swal.fire({
|
||||
title: languageTexts["Are you sure?"],
|
||||
text: languageTexts["You would not be able to revert this!"],
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: languageTexts["Yes"],
|
||||
cancelButtonText: languageTexts["Cancel"]
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: action,
|
||||
type: "post",
|
||||
data: {},
|
||||
dataType: 'json',
|
||||
success:function(data) {
|
||||
if (data.success) {
|
||||
$('#validationModal').modal('show');
|
||||
$('#validationModal .error-message').html(data.message);
|
||||
|
||||
userListTable.ajax.reload();
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
var errors = data.responseJSON.errors;
|
||||
var errorMessage = '<ul>';
|
||||
$.each(errors, function(index, error) {
|
||||
console.log(error);
|
||||
errorMessage += '<li>' + error[0] + '</li>';
|
||||
});
|
||||
errorMessage += '</ul>';
|
||||
|
||||
$('#validationModal .error-message').html(errorMessage);
|
||||
$('#validationModal').modal('show');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.edit-user', function(e) {
|
||||
var actionShow = $(this).attr('data-action-show');
|
||||
var actionUpdate = $(this).attr('data-action-update');
|
||||
|
||||
if (actionShow && actionUpdate) {
|
||||
$.ajax({
|
||||
url: actionShow,
|
||||
type: "post",
|
||||
data: {},
|
||||
dataType: 'json',
|
||||
success:function(data) {
|
||||
if (data.success) {
|
||||
$('#editUserFrm').attr('action', actionUpdate);
|
||||
$('#editUserFrm input[name="first_name"]').val(data.user.first_name);
|
||||
$('#editUserFrm input[name="last_name"]').val(data.user.last_name);
|
||||
$('#editUserFrm input[name="phone"]').val(data.user.phone);
|
||||
$('#editUserFrm input[name="email"]').val(data.user.email);
|
||||
$('#editUserFrm select[name="role_id"]').val(data.user.role_id);
|
||||
$('#editUserFrm input[name="status"]').val(data.user.status);
|
||||
$('#editUserModal').modal('show');
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
var errors = data.responseJSON.errors;
|
||||
var errorMessage = '<ul>';
|
||||
$.each(errors, function(index, error) {
|
||||
console.log(error);
|
||||
errorMessage += '<li>' + error[0] + '</li>';
|
||||
});
|
||||
errorMessage += '</ul>';
|
||||
|
||||
$('#validationModal .error-message').html(errorMessage);
|
||||
$('#validationModal').modal('show');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#editUserFrm').submit(function(e) {
|
||||
e.preventDefault();
|
||||
var action = $(this).attr('action');
|
||||
var button = $(this).find('button[type="submit"]');
|
||||
var buttonHtml = button.html();
|
||||
|
||||
if (!button.is(':disabled') && action) {
|
||||
button.attr('disabled', 'disabled');
|
||||
button.html('<i class="fa fa-spinner fa-spin" style="font-size:24px"></i>');
|
||||
|
||||
$.ajax({
|
||||
url: action,
|
||||
type: "post",
|
||||
data: $(this).serialize(),
|
||||
dataType: 'json',
|
||||
success:function(data) {
|
||||
button.removeAttr('disabled');
|
||||
button.html(buttonHtml);
|
||||
|
||||
if (data.success) {
|
||||
$('#editUserModal').modal('hide');
|
||||
$('#validationModal').modal('show');
|
||||
$('#validationModal .error-message').html(data.message);
|
||||
|
||||
$('#editUserFrm').trigger("reset");
|
||||
userListTable.ajax.reload();
|
||||
}
|
||||
else {
|
||||
$('#validationModal .error-message').html(data.message);
|
||||
$('#validationModal').modal('show');
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
var errors = data.responseJSON.errors;
|
||||
var errorMessage = '<ul>';
|
||||
$.each(errors, function(index, error) {
|
||||
console.log(error);
|
||||
errorMessage += '<li>' + error[0] + '</li>';
|
||||
});
|
||||
errorMessage += '</ul>';
|
||||
|
||||
$('#validationModal .error-message').html(errorMessage);
|
||||
$('#validationModal').modal('show');
|
||||
button.removeAttr('disabled');
|
||||
button.html(buttonHtml);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var userAccessLogsListTableUrl = $("#userAccessLogsListTable").attr('data-ajax-url');
|
||||
var userAccessLogsListTableEmptyText = $("#userAccessLogsListTable").attr('data-empty-text');
|
||||
$(document).on('click', '.view-user-log', function(e) {
|
||||
var action = $(this).attr('data-action');
|
||||
|
||||
if (action) {
|
||||
initializeUserAccessLogsListTable(action);
|
||||
$('#userActionLogsModal').modal('show');
|
||||
}
|
||||
});
|
||||
|
||||
function initializeUserAccessLogsListTable(url = userAccessLogsListTableUrl) {
|
||||
if (userAccessLogsListTable) {
|
||||
userAccessLogsListTable.destroy();
|
||||
}
|
||||
|
||||
userAccessLogsListTable = $("#userAccessLogsListTable").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: url,
|
||||
type: 'post',
|
||||
"dataSrc": function ( json ) {
|
||||
for (var i = 0; i < json.data.length; i++) {
|
||||
$.each( json.data[i], function( key, value ) {
|
||||
json.data[i][key] = value ? value : '-';
|
||||
});
|
||||
}
|
||||
|
||||
return json.data;
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{data: 'date', name: 'user_access_logs.created_at'},
|
||||
{data: 'time', name: 'user_access_logs.created_at'},
|
||||
{data: 'event', name: 'user_access_logs.event'},
|
||||
{data: 'description', name: 'user_access_logs.description'},
|
||||
{data: 'status', name: 'user_access_logs.status'},
|
||||
],
|
||||
order: [[1, "desc"]],
|
||||
searchDelay: 500,
|
||||
"language": {
|
||||
"paginate": {
|
||||
"next": ">", // Text for the "Next" page button
|
||||
"previous": "<" // Text for the "Previous" page button
|
||||
},
|
||||
"emptyTable": userAccessLogsListTableEmptyText
|
||||
// Add more text customizations if needed
|
||||
}
|
||||
});
|
||||
}
|
||||
} );
|
||||
53
public/themes/tailwind/js/cms/companies/show-xero-api.js
Normal file
53
public/themes/tailwind/js/cms/companies/show-xero-api.js
Normal file
@@ -0,0 +1,53 @@
|
||||
$(document).ready( function () {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
|
||||
$('#updateXeroApiFrm').submit(function(e) {
|
||||
e.preventDefault();
|
||||
var action = $(this).attr('action');
|
||||
var button = $(this).find('button[type="submit"]');
|
||||
var buttonHtml = button.html();
|
||||
|
||||
if (!button.is(':disabled') && action) {
|
||||
button.attr('disabled', 'disabled');
|
||||
button.html('<i class="fa fa-spinner fa-spin" style="font-size:24px"></i>');
|
||||
|
||||
$.ajax({
|
||||
url: action,
|
||||
type: "post",
|
||||
data: $(this).serialize(),
|
||||
dataType: 'json',
|
||||
success:function(data) {
|
||||
button.removeAttr('disabled');
|
||||
button.html(buttonHtml);
|
||||
|
||||
if (data.success) {
|
||||
$('#validationModal').modal('show');
|
||||
$('#validationModal .error-message').html(data.message);
|
||||
}
|
||||
else {
|
||||
$('#validationModal .error-message').html(data.message);
|
||||
$('#validationModal').modal('show');
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
var errors = data.responseJSON.errors;
|
||||
var errorMessage = '<ul>';
|
||||
$.each(errors, function(index, error) {
|
||||
console.log(error);
|
||||
errorMessage += '<li>' + error[0] + '</li>';
|
||||
});
|
||||
errorMessage += '</ul>';
|
||||
|
||||
$('#validationModal .error-message').html(errorMessage);
|
||||
$('#validationModal').modal('show');
|
||||
button.removeAttr('disabled');
|
||||
button.html(buttonHtml);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} );
|
||||
59
public/themes/tailwind/js/cms/companies/show.js
Normal file
59
public/themes/tailwind/js/cms/companies/show.js
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
$(document).ready( function () {
|
||||
$('#document-table__enqueue, #document-table__completed, #document-table, #comsec-table__enqueue, #comsec-table__completed').DataTable({
|
||||
"language": {
|
||||
"paginate": {
|
||||
"next": ">", // Text for the "Next" page button
|
||||
"previous": "<" // Text for the "Previous" page button
|
||||
},
|
||||
// Add more text customizations if needed
|
||||
},
|
||||
columnDefs: [
|
||||
{ targets: [0,1,2,3,4,5,6], orderable: false } // Change the index [1] if needed
|
||||
]
|
||||
});
|
||||
|
||||
$("#subscription-table").DataTable({
|
||||
"language": {
|
||||
"paginate": {
|
||||
"next": ">", // Text for the "Next" page button
|
||||
"previous": "<" // Text for the "Previous" page button
|
||||
},
|
||||
// Add more text customizations if needed
|
||||
},
|
||||
columnDefs: [
|
||||
{ targets: [0,1,2,3,4,5], orderable: false } // Change the index [1] if needed
|
||||
]
|
||||
});
|
||||
|
||||
$("#access-level-table, #log-table").DataTable({
|
||||
"language": {
|
||||
"paginate": {
|
||||
"next": ">", // Text for the "Next" page button
|
||||
"previous": "<" // Text for the "Previous" page button
|
||||
},
|
||||
// Add more text customizations if needed
|
||||
},
|
||||
columnDefs: [
|
||||
{ targets: [0,1,2,3,4], orderable: false } // Change the index [1] if needed
|
||||
]
|
||||
});
|
||||
|
||||
$(".js-side-nav").click(function(e){
|
||||
e.preventDefault();
|
||||
var id = jQuery(this).data('id');
|
||||
jQuery(this).closest('.side-nav-tabs').next().find('.js-content-tab').hide();
|
||||
jQuery(id).show();
|
||||
jQuery(this).closest('.side-nav-tabs').find('li').removeClass('active');
|
||||
jQuery(this).parent().addClass('active');
|
||||
});
|
||||
|
||||
$(".js-tab-navigate").click(function(e){
|
||||
e.preventDefault();
|
||||
var id = jQuery(this).data('id');
|
||||
jQuery(this).closest('.tabs-navigation').next().find('.tabs-content-item').hide();
|
||||
jQuery(id).show();
|
||||
jQuery(this).closest('.tabs-navigation').find('li').removeClass('active');
|
||||
jQuery(this).parent().addClass('active');
|
||||
});
|
||||
} );
|
||||
172
public/themes/tailwind/js/cms/subscriptions/index.js
Normal file
172
public/themes/tailwind/js/cms/subscriptions/index.js
Normal file
@@ -0,0 +1,172 @@
|
||||
$(document).ready( function () {
|
||||
var currentLanguage = $('#currentLanguage').val();
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
|
||||
var activeSubscriptionTableColumns = [
|
||||
(currentLanguage == 'zh_hk' ? {data: 'company_name_chinese', name: 'companies.name_chinese'} : {data: 'company_name_english', name: 'companies.name_english'}),
|
||||
{data: 'created_at', name: 'company_subscriptions.created_at'},
|
||||
{data: 'service_type', name: 'subscriptions.service_type'},
|
||||
{data: 'subscription_period', name: 'company_subscriptions.created_at'},
|
||||
(currentLanguage == 'zh_hk' ? {data: 'name_chinese', name: 'subscriptions.name_chinese'} : {data: 'name_english', name: 'subscriptions.name_english'}),
|
||||
{data: 'status', name: 'company_subscriptions.status'},
|
||||
{data: 'invoice', name: 'invoice', searchable: false, sortable: false}
|
||||
];
|
||||
var activeSubscriptionTableUrl = $("#activeSubscriptionTable").attr('data-ajax-url');
|
||||
var activeSubscriptionTableEmptyText = $("#activeSubscriptionTable").attr('data-empty-text');
|
||||
var activeSubscriptionTable = $("#activeSubscriptionTable").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: activeSubscriptionTableUrl,
|
||||
type: 'post',
|
||||
"data": function ( d ) {
|
||||
return $.extend( {}, d, {
|
||||
"company_name": $('#searchFrm #search_company_name').val(),
|
||||
"service_type": $('#searchFrm #search_service_type').val(),
|
||||
"subscription_id": $('#searchFrm #search_subscription_id').val(),
|
||||
} );
|
||||
},
|
||||
"dataSrc": function ( json ) {
|
||||
for (var i = 0; i < json.data.length; i++) {
|
||||
$.each( json.data[i], function( key, value ) {
|
||||
json.data[i][key] = value ? value : '-';
|
||||
});
|
||||
}
|
||||
|
||||
return json.data;
|
||||
},
|
||||
complete: function (data) {
|
||||
if (data['responseJSON'].recordsTotal > 0) {
|
||||
$('#totalActive').show();
|
||||
$('#totalActive').html(data['responseJSON'].recordsTotal);
|
||||
}
|
||||
else {
|
||||
$('#totalActive').hide();
|
||||
}
|
||||
},
|
||||
},
|
||||
columns: activeSubscriptionTableColumns,
|
||||
order: [[1, "desc"]],
|
||||
searchDelay: 500,
|
||||
"language": {
|
||||
"paginate": {
|
||||
"next": ">", // Text for the "Next" page button
|
||||
"previous": "<" // Text for the "Previous" page button
|
||||
},
|
||||
"emptyTable": activeSubscriptionTableEmptyText
|
||||
// Add more text customizations if needed
|
||||
}
|
||||
});
|
||||
|
||||
var expiredSubscriptionTableColumns = [
|
||||
(currentLanguage == 'zh_hk' ? {data: 'company_name_chinese', name: 'companies.name_chinese'} : {data: 'company_name_english', name: 'companies.name_english'}),
|
||||
{data: 'created_at', name: 'company_subscriptions.created_at'},
|
||||
{data: 'service_type', name: 'subscriptions.service_type'},
|
||||
{data: 'subscription_period', name: 'company_subscriptions.created_at'},
|
||||
(currentLanguage == 'zh_hk' ? {data: 'name_chinese', name: 'subscriptions.name_chinese'} : {data: 'name_english', name: 'subscriptions.name_english'}),
|
||||
{data: 'status', name: 'company_subscriptions.status'},
|
||||
{data: 'invoice', name: 'invoice', searchable: false, sortable: false}
|
||||
];
|
||||
var expiredSubscriptionTableUrl = $("#expiredSubscriptionTable").attr('data-ajax-url');
|
||||
var expiredSubscriptionTableEmptyText = $("#expiredSubscriptionTable").attr('data-empty-text');
|
||||
var expiredSubscriptionTable = $("#expiredSubscriptionTable").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: expiredSubscriptionTableUrl,
|
||||
type: 'post',
|
||||
"data": function ( d ) {
|
||||
return $.extend( {}, d, {
|
||||
"company_name": $('#searchFrm #search_company_name').val(),
|
||||
"service_type": $('#searchFrm #search_service_type').val(),
|
||||
"subscription_id": $('#searchFrm #search_subscription_id').val(),
|
||||
} );
|
||||
},
|
||||
"dataSrc": function ( json ) {
|
||||
for (var i = 0; i < json.data.length; i++) {
|
||||
$.each( json.data[i], function( key, value ) {
|
||||
json.data[i][key] = value ? value : '-';
|
||||
});
|
||||
}
|
||||
|
||||
return json.data;
|
||||
},
|
||||
complete: function (data) {
|
||||
if (data['responseJSON'].recordsTotal > 0) {
|
||||
$('#totalExpired').show();
|
||||
$('#totalExpired').html(data['responseJSON'].recordsTotal);
|
||||
}
|
||||
else {
|
||||
$('#totalExpired').hide();
|
||||
}
|
||||
},
|
||||
},
|
||||
columns: expiredSubscriptionTableColumns,
|
||||
order: [[1, "desc"]],
|
||||
searchDelay: 500,
|
||||
"language": {
|
||||
"paginate": {
|
||||
"next": ">", // Text for the "Next" page button
|
||||
"previous": "<" // Text for the "Previous" page button
|
||||
},
|
||||
"emptyTable": expiredSubscriptionTableEmptyText
|
||||
// Add more text customizations if needed
|
||||
}
|
||||
});
|
||||
|
||||
$('#searchFrm #search_service_type').change(function(e) {
|
||||
var html = '<option value="" selected>All</option>';
|
||||
|
||||
if ($(this).val()) {
|
||||
$.ajax({
|
||||
url: "/cms/subscriptions/get-subscriptions/" + $(this).val(),
|
||||
type: "get",
|
||||
data: {},
|
||||
dataType: 'json',
|
||||
success:function(data) {
|
||||
var subscriptions = data.subscriptions;
|
||||
|
||||
subscriptions.forEach(function(subscription) {
|
||||
html += `
|
||||
<option value="` + subscription.id + `">` + (currentLanguage == 'zh_hk' ? subscription.name_chinese : subscription.name_english) + `</option>
|
||||
`;
|
||||
});
|
||||
|
||||
$('#searchFrm select#search_subscription_id').html(html);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
$('#searchFrm select#search_subscription_id').html(html);
|
||||
}
|
||||
});
|
||||
|
||||
$('#searchFrm').submit(function(e) {
|
||||
e.preventDefault();
|
||||
activeSubscriptionTable.ajax.reload();
|
||||
expiredSubscriptionTable.ajax.reload();
|
||||
});
|
||||
|
||||
$(".js-side-nav").click(function(e){
|
||||
e.preventDefault();
|
||||
var id = jQuery(this).data('id');
|
||||
jQuery(this).closest('.side-nav-tabs').next().find('.js-content-tab').hide();
|
||||
jQuery(id).show();
|
||||
jQuery(this).closest('.side-nav-tabs').find('li').removeClass('active');
|
||||
jQuery(this).parent().addClass('active');
|
||||
});
|
||||
|
||||
$(".js-tab-navigate").click(function(e){
|
||||
e.preventDefault();
|
||||
var id = jQuery(this).data('id');
|
||||
jQuery(this).closest('.tabs-navigation').next().find('.tabs-content-item').hide();
|
||||
jQuery(id).show();
|
||||
jQuery(this).closest('.tabs-navigation').find('li').removeClass('active');
|
||||
jQuery(this).parent().addClass('active');
|
||||
});
|
||||
} );
|
||||
Reference in New Issue
Block a user