profile.js 0000644 00000015633 15024756424 0006563 0 ustar 00 (function(e){
"use strict";
var search_type_filter = [];
var companiesList = null;
function delay(callback, ms) {
var timer = 0;
return function () {
var context = this,
args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
callback.apply(context, args);
}, ms || 0);
};
}
function getDataTableData(){
var data = {};
return data;
}
function initList(){
$('.txt_search').on("keyup",delay(function(e){
companiesList.search($('.txt_search').val()).draw()
},500));
const search_type_default = "Company";
const search_types = ["Company", "Code"];
$.each(search_types, function (i, n) {
$(".system-search-type").append(
`
` +
n +
``
);
});
$(".system-search-type li").each(function () {
if ($(this).text() == search_type_default) {
$(this).removeClass("active").addClass("active");
var active_items_arr = [];
active_items_arr.push(search_type_default);
search_type_filter = JSON.stringify(active_items_arr);
}
$(this).on("click", function () {
//remove all selected menu
$(".system-search-type")
.find("li.active")
.map(function () {
$(this).removeClass("active");
});
$(this).toggleClass("active");
var active_items = $(".system-search-type")
.find("li.active")
.map(function () {
var item = {};
// item.id = this.value;
item.status = $(this).text();
return item;
});
var active_items_arr = [];
$.each(active_items, function (i, n) {
active_items_arr.push(n.status);
});
search_type_filter = JSON.stringify(active_items_arr);
// refreshOrcrPlateTable();
// if ($('#txt_search').val() != '') {
companiesList.draw(false);
// }
});
});
var cols = [
{
title: "ID",
data: 'id',
className: 'align-middle p-1 dt-left',
orderable: true,
width: "5%",
},
{
title: "Code",
data: 'code',
className: 'align-middle p-1 dt-left',
orderable: true,
width: "40%",
},
{
title: "Company",
data: 'name',
className: 'align-middle p-1 dt-left',
orderable: true,
width: "40%",
},
// {
// title: "Action",
// data: null,
// orderable: false,
// width: "20%",
// className: "align-middle p-1 dt-center",
// render: function (data, type, row, meta) {
// return `
//
// `;
// },
// },
];
companiesList = $('#companiesTable').DataTable({
fnDrawCallback: function () {
// initActionRemove();
// initActionUpdate();
},
order: [[0, "desc"]],
retrieve: true,
columns: cols,
paging: true,
lengthChange: false,
searching: true,
pageLength: 5,
info: true,
autoWidth: true,
responsive: true,
processing: true,
serverSide: true,
autoWidth: true,
columnDefs: [
{ width: '20%', targets: 0 }
],
fixedColumns: true,
ajax: {
url:'/companies/fetchall',
data: function (d){
return $.extend({},d,{
search_type: search_type_filter,
data: getDataTableData(),
})
}
},
sDom: "lrtip",
});
}
$(function(){
$('.edit-profile').on('submit', function(e){
e.preventDefault();
var formData = new FormData(this);
$.ajax({
type:"POST",
url:"/update-profile",
dataType: 'json',
data: formData,
processData: false,
contentType: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(e){
console.log(e);
toastRWithTime(e.message,'success');
window.location.reload();
// setTimeout(function() {
// window.location.href = "/";
// }, 5000);
},
error: function(error){
console.log(error);
toastRWithTime(error.responseJSON.message,"error");
}
});
});
$('#import_company').on('click', function(e){
$.ajax({
type:"POST",
url:"/import_comp",
dataType: 'json',
data: null,
processData: false,
contentType: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(e){
console.log(e);
toastRWithTime(e.message,'Success');
// window.location.reload();
},
error: function(error){
console.log(error);
toastRWithTime(error.responseJSON.message,"error");
}
});
});
initList();
$('#reload_list').on('click', function(e){
companiesList.draw(false);
});
});
})(); reset_password.js 0000644 00000002031 15024756424 0010153 0 ustar 00 (function(e){
"use strict";
$(function(){
$('.reset-form').on('submit', function(e){
e.preventDefault();
var formData = new FormData(this);
formData.append('id', id);
formData.append('url',window.location.href);
$.ajax({
type:"POST",
url:"/reset-password",
dataType: 'json',
data: formData,
processData: false,
contentType: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(e){
toastRWithTime("Success",'success');
setTimeout(function() {
window.location.href = "/";
}, 5000);
},
error: function(error){
toastRWithTime("Wrong username or password","error");
}
});
});
});
})(); dashboard.js 0000644 00000023335 15024756424 0007050 0 ustar 00 (function(e){
"use strict";
var templates = [];
var average = [];
var systems = [];
var myChart, myChart2, myChart3;
var id = null;
var start = null;
var end = null;
function generateRandomColor() {
// const colorPalette = ["#191825", "#865DFF", "#E384FF", "#FFA3FD"];
// const colorPalette = ["#658864", "#B7B78A", "#DDDDDD", "#EEEEEE"];
// const colorPalette = ["#557153", "#7D8F69", "#A9AF7E", "#E6E5A3"];
// const colorPalette = ["#395144", "#4E6C50", "#AA8B56", "#F0EBCE"];
// const colorPalette = ["#425F57", "#749F82", "#A8E890", "#CFFF8D"];
const colorPalette = ["#3C6255", "#61876E", "#A6BB8D", "#EAE7B1","#425F57", "#749F82", "#A8E890", "#CFFF8D"];
// Generate a random index to select a color from the palette
const randomIndex = Math.floor(Math.random() * colorPalette.length);
// Get the random color from the palette
const randomColor = colorPalette[randomIndex];
// var hex = Math.floor(Math.random() * 0xFFFFFF);
return randomColor;
}
function createChart(responseData){
const ctx = document.getElementById('myChart').getContext('2d');
var labels = [];
var values = [];
for (var i = 0; i < responseData['result'].length; i++) {
labels.push(responseData['result'][i].system);
values.push(responseData['result'][i].average);
}
if(myChart){
myChart.destroy();
}
var bGs = values.map(function(){
return generateRandomColor();
});
myChart = new Chart(ctx, {
type: "bar",
data: {
labels: labels,
datasets: [
{
label: responseData['result'][0].template,
data: values,
backgroundColor: bGs,
borderColor: "white",
borderWidth: 1
}
]
},
options: {
responsive:true,
maintainAspectRatio:false,
scales: {
y:{
beginAtZero: true
}
}
}
});
}
function createPie(responseData){
const ctx = document.getElementById('myChart2').getContext('2d');
var labels = [];
var values = [];
console.log(responseData);
for(var i = 0; i < responseData.length; i++){
labels.push(responseData[i].system);
values.push(responseData[i].respondents);
}
if(myChart2){
myChart2.destroy();
}
var bGs = values.map(function(){
return generateRandomColor();
});
myChart2 = new Chart(ctx, {
type: 'doughnut',
data: {
labels: labels,
datasets: [{
label:"respondents",
data: values,
backgroundColor: bGs
}]
},
options:{
responsive:true,
maintainAspectRatio:false,
// scales:{
// y:{
// beginAtZero:true,
// }
// }
}
});
}
// function createCompanyBar(responseData){
// const ctx = document.getElementById('myChart3').getContext('2d');
// var labels = [];
// var values = [];
// console.log(responseData);
// for(var i = 0; i < responseData.length; i++){
// labels.push(responseData[i].company);
// values.push(responseData[i].respondents);
// }
// if(myChart3){
// myChart3.destroy();
// }
// var bGs = values.map(function(){
// return generateRandomColor();
// });
// myChart3 = new Chart(ctx, {
// type: 'bar',
// data: {
// labels: labels,
// datasets: [{
// label:responseData.map('company'),
// data: values,
// backgroundColor: bGs
// }]
// },
// options: {
// responsive:true,
// // maintainAspectRatio:false,
// indexAxis: 'y',
// },
// });
// }
function createCompanyBar(responseData) {
const ctx = document.getElementById('myChart3').getContext('2d');
var datasets = [];
var comp = [];
for (var i = 0; i < responseData.length; i++) {
var company = responseData[i].company;
var respondents = responseData[i].respondents;
datasets.push({
label: company, // Use company name as label for this dataset
data: [respondents], // Use an array since each dataset needs its own array of data
backgroundColor: generateRandomColor()
});
}
if (myChart3) {
myChart3.destroy();
}
myChart3 = new Chart(ctx, {
type: 'bar',
data: {
labels: [''], // You can leave this empty since we're using individual labels per dataset
datasets: datasets
},
options: {
responsive: true,
indexAxis: 'x'
}
});
}
function ajax(id,start,end){
$.ajax({
type:"GET",
url:"/getTopFive",
data:{
id:id,
start_date:start,
end_date:end
},
dataType: 'json',
success: function(success){
createChart(success.topFivePerTemplate);
createPie(success.respondents);
createCompanyBar(success.perCompany);
},
error: function(error){
toastRWithTime("No Records Exists","error");
}
});
}
$(function(e){
$('.date-filter').on('click', function(e) {
e.preventDefault();
var selectedValue = $(this).data('value');
switch (selectedValue) {
case "weekly":
start = "weekly";
end = "weekly";
ajax(id,start,end);
break;
case "monthly":
start = "monthly";
end = "monthly";
ajax(id,start,end);
break;
case "yearly":
start = "yearly";
end = "yearly";
ajax(id,start,end);
break;
case "custom":
$('#dateModal').modal('show');
// start = "custom";
// end = "custom";
// ajax(id,start,end);
break;
default:
break;
}
});
ajax(id,start,end);
$('#templates_select').select2({
// theme: 'classic',
allowClear: true,
language: {
noResults: function () {
return "Select";
},
},
escapeMarkup: function (markup) {
return markup;
},
placeholder: "Select template",
ajax: {
url:"/fetchTmp",
dataType: 'json',
delay: 250,
data: function (data) {
return {
search: data.term,
limit: 15,
};
},
processResults: function (response) {
return {
results: response.results,
};
},
cache: true,
}
});
$('#templates_select').on('change',function(){
id = $(this).val();
ajax(id,start,end);
});
$('#from_date').on('change', function(){
start = $(this).val();
// if(!start){
// toastRWithTime("Please Select Start Date",'error');
// } else if(!end){
// toastRWithTime("Please Select End Date",'error');
// } else {
// // toastRWithTime("Nice",'info');
// $('#dateModal').modal('hide');
// ajax(id,start,end);
// }
});
$('#to_date').on('change', function(){
end = $(this).val();
// if(!start){
// toastRWithTime("Please Select Start Date",'error');
// } else if(!end){
// toastRWithTime("Please Select End Date",'error');
// } else {
// // toastRWithTime("Nice",'info');
// $('#dateModal').modal('hide');
// ajax(id,start,end);
// }
});
$('#submitBtnCustom').on('click', function(e){
if(!start){
toastRWithTime("Please Select Start Date",'error');
} else if(!end){
toastRWithTime("Please Select End Date",'error');
} else {
// toastRWithTime("Nice",'info');
$('#dateModal').modal('hide');
ajax(id,start,end);
}
});
window.addEventListener('resize', function() {
myChart.resize();
myChart2.resize();
});
});
})(); roles.js 0000644 00000007375 15024756424 0006253 0 ustar 00 (function(e){
"use strict";
var search_type_filter = [];
var rolesList = null;
var url = window.location.href;
var id = url.match(/\/(\d+)$/)[1];
function fetchAbilities(){
$.ajax({
type: "GET",
url: "/getAbilities/" + id,
dataType: 'json',
data: null,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(result){
$('#abilities-panel').jstree({
core:{
data: result.availableAbilities
},
checkbox: {
three_state: true
},
plugins:['checkbox']
// });
}).on('ready.jstree', function(){
var tree = $('#abilities-panel').jstree(true);
result.abilities.forEach(function(ability){
// console.log(ability);
var node = tree.get_json('#', { flat: true }).find(function(n) {
return n.text === ability;
});
if (node) {
tree.check_node(node.id);
}
})
});
},
error: function(error){
// toastRWithTime("Not sent",'error');
}
});
}
function submitRoleAbilities(){
$('#user_abilities').on('submit', function(e){
e.preventDefault();
var selectedNodes = $('#abilities-panel').jstree('get_checked', true);
var selectedData = [];
$.each(selectedNodes, function(index, node) {
var nodeId = node.id;
var nodeText = node.text;
var parentNode = $('#abilities-panel').jstree('get_parent', node);
var parentText = '';
if (parentNode !== '#') {
parentText = $('#abilities-panel').jstree('get_node', parentNode).text;
}
selectedData.push({
nodeId: nodeId,
nodeText: nodeText,
parentNodeText: parentText
});
});
// alert(selectedData)
// return;
$.ajax({
type: "POST",
url: "/updateRoleAbilities",
dataType: 'json',
data: {
id:id,
abilities:selectedData
},
// processData: false,
// contentType: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(result){
toastRWithTime("Success","success");
// window.location.href = '/userIndex';
},
error: function(error){
console.log(error);
toastRWithTime(error.responseJSON.message,"error")
}
});
});
}
$(function(){
fetchAbilities();
submitRoleAbilities();
$('.check-all').on('click', function(e){
e.preventDefault();
var tree = $('#abilities-panel').jstree(true);
tree.check_all();
toastRWithTime("all abilities checked","Success");
});
$('.uncheck-all').on('click', function(e){
e.preventDefault();
var tree = $('#abilities-panel').jstree(true);
tree.uncheck_all();
toastRWithTime("all abilities unchecked","error");
});
});
})(); registration.js 0000644 00000004334 15024756424 0007631 0 ustar 00 (function(e){
"use strict";
$(function(){
$('#cancel-btn').on('click', function(e){
window.location.href = "/";
});
$('.register_user').submit(function(e){
e.preventDefault();
e.preventDefault();
var formData = new FormData(this);
// formData.append('name',$('#register_name').val());
// formData.append('email',$('#register_email').val());
// formData.append('password',$('#register_password').val());
// formData.append('confirm_password',$('#register_confirm_password').val());
$.ajax({
type:"POST",
url:"/register",
dataType: 'json',
data: formData,
processData: false,
contentType: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(e){
window.location.href = '/dashboard';
// alert(e);
},
error: function(error){
console.log(error);
$.each(error.responseJSON.message, function(key,value){
toastRWithTime(value,"error");
});
}
});
});
$('#comp_id').select2({
allowClear: true,
language: {
noResults: function () {
return "Select";
},
},
escapeMarkup: function (markup) {
return markup;
},
placeholder: "Select Company",
ajax: {
url:"/getCompany",
dataType: 'json',
delay: 250,
data: function (data) {
return {
search: data.term,
limit: 1,
};
},
processResults: function (response) {
return {
results: response.results,
};
},
cache: true,
}
});
});
})(); user.js 0000644 00000010736 15024756424 0006100 0 ustar 00 (function(e){
"use strict";
var search_type_filter = [];
var usersList = null;
var id = null;
function delay(callback, ms) {
var timer = 0;
return function () {
var context = this,
args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
callback.apply(context, args);
}, ms || 0);
};
}
function initActionEdit(){
$('[data-action-edit]').each(function(e){
$(this).on('click', function(e){
var row = $(this).closest("tr");
id = usersList.row(row).data().id;
window.location.href="/userEdit/" + id;
});
});
}
function getDataTableData(){
}
function initList(){
$('.txt_search_email').on("keyup",delay(function(e){
usersList.search($('.txt_search_email').val()).draw()
},500));
const search_type_default = "Company";
const search_types = ["ID", "Company", "Code"];
$.each(search_types, function (i, n) {
$(".email-search-type").append(
`` +
n +
``
);
});
$(".email-search-type li").each(function () {
if ($(this).text() == search_type_default) {
$(this).removeClass("active").addClass("active");
var active_items_arr = [];
active_items_arr.push(search_type_default);
search_type_filter = JSON.stringify(active_items_arr);
}
$(this).on("click", function () {
//remove all selected menu
$(".email-search-type")
.find("li.active")
.map(function () {
$(this).removeClass("active");
});
$(this).toggleClass("active");
var active_items = $(".email-search-type")
.find("li.active")
.map(function () {
var item = {};
// item.id = this.value;
item.status = $(this).text();
return item;
});
var active_items_arr = [];
$.each(active_items, function (i, n) {
active_items_arr.push(n.status);
});
search_type_filter = JSON.stringify(active_items_arr);
// refreshOrcrPlateTable();
// if ($('#txt_search').val() != '') {
usersList.draw(false);
// }
});
});
}
var cols = [
{
title: "ID",
data: 'id',
className: 'align-middle p-1 dt-left',
orderable: true,
width: "5%",
},
{
title: "Name",
data: 'name',
className: 'align-middle p-1 dt-left',
orderable: true,
width: "25%",
},
{
title: "Action",
data: null,
orderable: false,
width: "20%",
className: "align-middle p-1 dt-center",
render: function (data, type, row, meta) {
return `
`;
},
},
];
usersList = $('#userTable').DataTable({
fnDrawCallback: function () {
initActionEdit();
},
order: [[0, "desc"]],
retrieve: true,
columns: cols,
paging: true,
lengthChange: false,
searching: true,
pageLength: 5,
info: true,
autoWidth: true,
responsive: true,
processing: true,
serverSide: true,
autoWidth: true,
columnDefs: [
{ width: '20%', targets: 0 }
],
fixedColumns: true,
ajax: {
url:'/fetchUsers',
data: function (d){
return $.extend({},d,{
search_type: search_type_filter,
data: getDataTableData(),
})
}
},
sDom: "lrtip",
});
$(function(){
$('#reload_list').on('click', function(e){
usersList.draw(false);
});
initList();
});
})(); emailResponse.js 0000644 00000016526 15024756424 0007733 0 ustar 00 (function(e){
"use strict";
var search_type_filter = [];
var emailsList = null;
var id = null;
function delay(callback, ms) {
var timer = 0;
return function () {
var context = this,
args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
callback.apply(context, args);
}, ms || 0);
};
}
function initActionResend(){
$("[data-action-resend]").each(function(e){
$(this).on('click', function(e){
var row = $(this).closest("tr");
id = emailsList.row(row).data().id;
var formData = new FormData();
formData.append("id",id);
formData.append("email",emailsList.row(row).data().email);
$.ajax({
type: "POST",
url: "/resend",
dataType: 'json',
data: formData,
processData: false,
contentType: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(result){
if(result == 0){
toastRWithTime("Not sent",'error');
emailsList.draw(false);
} else {
toastRWithTime("Sent",'success');
emailsList.draw(false);
}
},
error: function(error){
toastRWithTime("Not sent",'error');
}
});
});
});
}
function getDataTableData(){
var data = {};
data.status = $('select[name="status"]').val();
return data;
}
function initList(){
$('.txt_search_email').on("keyup",delay(function(e){
emailsList.search($('.txt_search_email').val()).draw()
},500));
const search_type_default = "Company";
const search_types = ["Company", "Code"];
$.each(search_types, function (i, n) {
$(".email-search-type").append(
`` +
n +
``
);
});
$(".email-search-type li").each(function () {
if ($(this).text() == search_type_default) {
$(this).removeClass("active").addClass("active");
var active_items_arr = [];
active_items_arr.push(search_type_default);
search_type_filter = JSON.stringify(active_items_arr);
}
$(this).on("click", function () {
//remove all selected menu
$(".email-search-type")
.find("li.active")
.map(function () {
$(this).removeClass("active");
});
$(this).toggleClass("active");
var active_items = $(".email-search-type")
.find("li.active")
.map(function () {
var item = {};
// item.id = this.value;
item.status = $(this).text();
return item;
});
var active_items_arr = [];
$.each(active_items, function (i, n) {
active_items_arr.push(n.status);
});
search_type_filter = JSON.stringify(active_items_arr);
// refreshOrcrPlateTable();
// if ($('#txt_search').val() != '') {
emailsList.draw(false);
// }
});
});
var cols = [
{
title: "ID",
data: 'id',
className: 'align-middle p-1 dt-left',
orderable: true,
width: "5%",
},
{
title: "Ratee",
data: 'user_name',
className: 'align-middle p-1 dt-left',
orderable: true,
width: "25%",
},
{
title: "Email",
data: 'email',
className: 'align-middle p-1 dt-left',
orderable: true,
width: "30%",
},
{
title: "Date",
data: 'created_at',
className: 'align-middle p-1 dt-left',
orderable: true,
width: "15%",
render: function(data, type, row){
return moment(data).format('MMMM D, YYYY')
}
},
{
title: "Status",
data: 'status',
className: 'align-middle p-1 dt-left',
orderable: true,
width: "5%",
render: function (data, type, row, meta){
if(row.status == 0){
return `Failed
`
} else {
return `Sent
`
}
}
},
{
title: "Action",
data: null,
orderable: false,
width: "20%",
className: "align-middle p-1 dt-center",
render: function (data, type, row, meta) {
// if (row.status == 0){
return `
`;
// } else {
// return ``;
// }
},
},
];
emailsList = $('#emailsTable').DataTable({
fnDrawCallback: function () {
initActionResend();
// initActionUpdate();
},
order: [[0, "desc"]],
retrieve: true,
columns: cols,
paging: true,
lengthChange: false,
searching: true,
pageLength: 5,
info: true,
autoWidth: true,
responsive: true,
processing: true,
serverSide: true,
autoWidth: true,
columnDefs: [
{ width: '20%', targets: 0 }
],
fixedColumns: true,
ajax: {
url:'/emails/fetchall',
data: function (d){
return $.extend({},d,{
search_type: search_type_filter,
data: getDataTableData(),
})
}
},
sDom: "lrtip",
});
}
$(function(){
initList();
$('select[name="status"]').on('change', delay(function(e){
emailsList.draw(false);
},500));
$('#reload_emailList').on('click', function(e){
emailsList.draw(false);
});
});
})(); reports.js 0000644 00000001213 15024756424 0006606 0 ustar 00 (function(e){
"use strict";
$(function(){
$('#qst_masterfile').load('css/datatables.bootstrap5.min.css')
$('#reports_display').attr('src','/blank');
$('#js_tree').jstree();
$(".expand-all").on("click", function (t) {
$("#js_tree").jstree("open_all");
});
$(".collapse-all").on("click", function (t) {
$("#js_tree").jstree("close_all");
});
$('#js_tree').on("changed.jstree", function (e, data) {
// console.log(data.node.li_attr.value);
$('#reports_display').attr('src',data.node.li_attr.value);
});
});
})(); add_roles.js 0000644 00000007374 15024756424 0007062 0 ustar 00 (function(e){
"use strict";
var search_type_filter = [];
var rolesList = null;
var url = window.location.href;
// var id = url.match(/\/(\d+)$/)[1];
function fetchAbilities(){
$.ajax({
type: "GET",
url: "/getAllAbilities",
dataType: 'json',
data: null,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(result){
$('#abilities-panel').jstree({
core:{
data: result.abilities
},
checkbox: {
three_state: true
},
plugins:['checkbox']
// });
})
// .on('ready.jstree', function(){
// var tree = $('#abilities-panel').jstree(true);
// result.abilities.forEach(function(ability){
// // console.log(ability);
// var node = tree.get_json('#', { flat: true }).find(function(n) {
// return n.text === ability;
// });
// if (node) {
// tree.check_node(node.id);
// }
// })
// });
},
error: function(error){
// toastRWithTime("Not sent",'error');
}
});
}
function submitRoleAbilities(){
$('#user_abilities').on('submit', function(e){
e.preventDefault();
var selectedNodes = $('#abilities-panel').jstree('get_checked', true);
var selectedData = [];
$.each(selectedNodes, function(index, node) {
var nodeId = node.id;
var nodeText = node.text;
var parentNode = $('#abilities-panel').jstree('get_parent', node);
var parentText = '';
if (parentNode !== '#') {
parentText = $('#abilities-panel').jstree('get_node', parentNode).text;
}
selectedData.push({
nodeId: nodeId,
nodeText: nodeText,
parentNodeText: parentText
});
});
$.ajax({
type: "POST",
url: "/addNewRole",
dataType: 'json',
data: {
name: $('#role_name').val(),
abilities:selectedData
},
// processData: false,
// contentType: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(result){
toastRWithTime("Success","success");
// window.location.href = '/userIndex';
},
error: function(error){
console.log(error);
toastRWithTime(error.responseJSON.message,"error")
}
});
});
}
$(function(){
fetchAbilities();
submitRoleAbilities();
$('.check-all').on('click', function(e){
e.preventDefault();
var tree = $('#abilities-panel').jstree(true);
tree.check_all();
toastRWithTime("all abilities checked","Success");
});
$('.uncheck-all').on('click', function(e){
e.preventDefault();
var tree = $('#abilities-panel').jstree(true);
tree.uncheck_all();
toastRWithTime("all abilities unchecked","error");
});
});
})(); assign_role.js 0000644 00000006022 15024756424 0007420 0 ustar 00 (function(){
"use strict";
function initializeTree(){
$('#users-panel').jstree({
core: {
data: user
},
checkbox: {
three_state: true
},
plugins: ['checkbox']
}).on('ready.jstree', function() {
var tree = $('#users-panel').jstree(true);
// Check the nodes corresponding to the selected abilities
userWithRoles.forEach(function(user_name) {
console.log(user_name);
var node = tree.get_json('#', { flat: true }).find(function(n) {
return n.text === user_name.text;
});
if (node) {
tree.check_node(node.id);
}
});
});
}
function submit(){
$('#user_roles').on('submit', function(e){
e.preventDefault();
var url = window.location.href;
var Roleid = url.match(/\/(\d+)$/)[1];
var selectedNodes = $('#users-panel').jstree('get_checked', true);
var selectedData = [];
$.each(selectedNodes, function(index, node) {
console.log(node);
var nodeId = node.id;
var nodeText = node.text;
var parentNode = $('#users-panel').jstree('get_parent', node);
var parentText = '';
if (parentNode !== '#') {
parentText = $('#users-panel').jstree('get_node', parentNode).text;
}
selectedData.push({
nodeId: nodeId,
nodeText: nodeText,
parentNodeText: parentText
});
});
$.ajax({
type: "POST",
url: "/updateUserRole/" + Roleid,
dataType: 'json',
data:{selectedUsers: selectedData},
// processData: false,
// contentType: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(result){
toastRWithTime(result.message,"success");
},
error: function(error){
toastRWithTime(error.responseText,"error")
}
});
});
}
$(function(){
initializeTree();
submit();
$('.check-all').on('click', function(e){
e.preventDefault();
var tree = $('#users-panel').jstree(true);
tree.check_all();
toastRWithTime("all user checked","success");
});
$('.uncheck-all').on('click', function(e){
e.preventDefault();
var tree = $('#users-panel').jstree(true);
tree.uncheck_all();
toastRWithTime("all user unchecked","error");
});
// console.log(userWithRoles);
// console.log(user);
});
})(); disclaimer.js 0000644 00000001704 15024756424 0007231 0 ustar 00 (function(e){
"use strict";
function submitDisclaimer(){
$('#policyForm').on('submit', function(e){
e.preventDefault();
$.ajax({
type:"POST",
url:"/update-disclaimer",
dataType: 'json',
data: {
disclaimer:$('#disclaimer').val()
},
// processData: false,
// contentType: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(e){
toastRWithTime(e.message,'success');
// window.location.reload();
},
error: function(error){
toastRWithTime(error.responseJSON.message,"error");
}
});
});
}
$(function(){
submitDisclaimer();
});
})(); login.js 0000644 00000004416 15024756424 0006230 0 ustar 00 (function(e){
"use strict";
$(function(){
$('#forget-password').on('click', function(e){
e.preventDefault();
var formData = new FormData;
formData.append("email", $('#forgot_email').val());
$.ajax({
type:"POST",
url:"/forgot_password",
dataType: 'json',
data: formData,
processData: false,
contentType: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(e){
swal.fire({
icon: 'success',
title: "success",
text: e.message,
showConfirmButton: true,
allowOutsideClick: false
}).then((result) => {
if(result.isConfirmed){
window.location.href = '/';
}
});
// toastRWithTime(e.message,'success');
// setTimeout(function(){
// }, 10000);
},
error: function(error){
console.log(error);
toastRWithTime(error.responseJSON['message'],"error");
}
});
});
$('#login-btn').on('click', function(){
var formData = new FormData();
formData.append('email',$('#user_name_login').val());
formData.append('password',$('#user_name_password').val());
$.ajax({
type:"POST",
url:"/login",
dataType: 'json',
data: formData,
processData: false,
contentType: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(e){
window.location.href = '/dashboard';
},
error: function(error){
toastRWithTime("Wrong username or password","error");
}
});
});
});
})(); user_roles.js 0000644 00000013351 15024756424 0007300 0 ustar 00 (function(e){
"use strict";
var search_type_filter = [];
var rolesList = null;
var id = null;
var url = null;
function delay(callback, ms) {
var timer = 0;
return function () {
var context = this,
args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
callback.apply(context, args);
}, ms || 0);
};
}
function initActionAssign(){
$('[data-action-assign]').each(function(e){
$(this).on('click', function(e){
var row = $(this).closest("tr");
id = rolesList.row(row).data().id;
window.location.href="/assignRoleToUser/" + id;
});
});
}
function initActionEdit(){
$('[data-action-edit]').each(function(e){
$(this).on('click', function(e){
var row = $(this).closest("tr");
id = rolesList.row(row).data().id;
window.location.href="/editRole/" + id;
});
});
}
function getDataTableData(){
var data = {};
return data;
}
function initRolesTable(){
$('.txt_search').on("keyup",delay(function(e){
rolesList.search($('.txt_search').val()).draw()
},500));
const search_type_default = "Title";
const search_types = ["ID", "Title"];
$.each(search_types, function (i, n) {
$(".system-search-type").append(
`` +
n +
``
);
});
$(".system-search-type li").each(function () {
if ($(this).text() == search_type_default) {
$(this).removeClass("active").addClass("active");
var active_items_arr = [];
active_items_arr.push(search_type_default);
search_type_filter = JSON.stringify(active_items_arr);
}
$(this).on("click", function () {
//remove all selected menu
$(".system-search-type")
.find("li.active")
.map(function () {
$(this).removeClass("active");
});
$(this).toggleClass("active");
var active_items = $(".system-search-type")
.find("li.active")
.map(function () {
var item = {};
// item.id = this.value;
item.status = $(this).text();
return item;
});
var active_items_arr = [];
$.each(active_items, function (i, n) {
active_items_arr.push(n.status);
});
search_type_filter = JSON.stringify(active_items_arr);
// refreshOrcrPlateTable();
// if ($('#txt_search').val() != '') {
rolesList.draw(false);
// }
});
});
var cols = [
{
title: "ID",
data: 'id',
className: 'align-middle p-1 dt-left',
orderable: true,
width: "5%",
},
{
title: "Title",
data: 'title',
className: 'align-middle p-1 dt-left',
orderable: true,
width: "40%",
},
{
title: "Action",
data: null,
orderable: false,
width: "20%",
className: "align-middle p-1 dt-center",
render: function (data, type, row, meta) {
return `
`;
},
},
];
rolesList = $('#rolesTable').DataTable({
fnDrawCallback: function () {
// initActionRemove();
initActionAssign();
initActionEdit();
},
order: [[0, "desc"]],
retrieve: true,
columns: cols,
paging: true,
lengthChange: false,
searching: true,
pageLength: 5,
info: true,
autoWidth: true,
responsive: true,
processing: true,
serverSide: true,
autoWidth: true,
columnDefs: [
{ width: '20%', targets: 0 }
],
fixedColumns: true,
ajax: {
url:'/fetchRoles',
data: function (d){
return $.extend({},d,{
search_type: search_type_filter,
data: getDataTableData(),
})
}
},
sDom: "lrtip",
});
}
$(function(){
initRolesTable();
$('#r_create').on('click', function(e){
window.location.href = "/addRole";
});
})
})();
employeeLogin.js 0000644 00000005150 15024756424 0007724 0 ustar 00
(function(e){
"use strict";
$(function(){
$('#employeeLoginCard').hide();
$('#proceed_rating').on('click', (e) => {
e.preventDefault();
$(".inner-disclaimer").hide();
if($('#data-privacy').prop("checked")){
$('.data-privacy').hide();
$('#employeeLoginCard').show();
}else{
toastRWithTime('Please agree to the terms and agreements first','error');
}
});
$('#company').select2({
allowClear: true,
language: {
noResults: function () {
return "Select";
},
},
escapeMarkup: function (markup) {
return markup;
},
placeholder: "Select Company",
ajax: {
url:"/getCompany",
dataType: 'json',
delay: 250,
data: function (data) {
return {
search: data.term,
limit: 1,
};
},
processResults: function (response) {
return {
results: response.results,
};
},
cache: true,
}
});
$('#login-btn').on('click', function(e){
e.preventDefault();
var formData = new FormData();
formData.append('f_name',$('#f_name').val());
formData.append('l_name',$('#l_name').val());
formData.append('email',$('#email').val());
formData.append('comp_id',$('#company').val());
// console.log($('#company').val());
// return;
$.ajax({
type: "POST",
url: "/employeeLogin",
dataType: 'json',
data: formData,
processData: false,
contentType: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(success){
window.location.href = success;
},
error: function(error){
Swal.fire({
title: "Error",
text: error.responseJSON.message
});
if(error.responseJSON.message == "CSRF token mismatch"){
window.location.reload();
}
}
});
});
});
})(); email_responses.blade.php 0000644 00000001636 15025017115 0011516 0 ustar 00