File manager - Edit - /home/autoph/public_html/connectv1/dist/js.bak/config_system/role_settings.js
Back
$("#role-form").on('submit', function(event) { event.preventDefault(); remove_alert_bg(); var role_name = $.trim($("#role").val()); if (role_name == '') { // $('#error-icon').addClass("fa-ban"); // $('#error-alert').addClass("alert-danger"); // $('#alert-message').text('Enter user role name'); // $('#error-alert').fadeIn(); toastr.remove(); toastr.error('Role name can\'t be left blank') // setTimeout(function() { // $('#error-alert').fadeOut() // }, 3000); return; } $.ajax({ url: "app/employee/add_role.php", data: new FormData(this), type: "POST", dataType: 'json', contentType: false, cache: false, processData: false, beforeSend: function() { // $('#error-icon').addClass("fa-info"); // $('#error-alert').addClass("alert-info"); // $('#error-alert').fadeIn(); // $('#alert-message').text(" Adding user role, please wait..."); toastr.info(" Adding role, please wait..."); }, success: function(result) { if (parseInt(result.status) == 0) { // remove_alert_bg(); // $('#error-icon').addClass("fa-ban"); // $('#error-alert').addClass("alert-danger"); // $('#alert-message').text(result.message); // setTimeout(function() { // $('#error-alert').fadeOut() // }, 3000); toastr.error(result.message) } else if (parseInt(result.status) == 1) { $("#role").val(''); // remove_alert_bg(); // $('#error-icon').addClass("fa-check"); // $('#error-alert').addClass("alert-success"); // $('#alert-message').text(result.message); toastr.success(result.message) // var url = "<?php echo $variable['site_link']; ?>role.php?value=" + role_name; // window.location.href = url; var $table = $('#role-table') $(function() { $table.bootstrapTable('refresh') }) // setTimeout(function() { // $('#error-alert').fadeOut() // }, 3000); } }, error: handleError }); }); function handleError(xhr, status, error) { //Handle failure here // remove_alert_bg(); // $('#error-icon').addClass("fa-ban"); // $('#error-alert').addClass("alert-danger"); // $('#alert-message').text("Error has been occurred."); toastr.error('Error has been occurred.') $('#submit').attr('disabled', false); // setTimeout(function() { // $('#error-alert').fadeOut() // }, 3000); } function remove_alert_bg() { $('#error-alert').removeClass("alert-success"); $('#error-alert').removeClass("alert-danger"); $('#error-alert').removeClass("alert-info"); $('#error-icon').removeClass("fa-check"); $('#error-icon').removeClass("fa-info"); $('#error-icon').removeClass("fa-ban"); } function ajaxRequest(params) { // data you may need console.log(params.data); $.ajax({ type: "GET", url: "api/role/role.php", data: { search: params.data.search, offset: params.data.offset, limit: params.data.limit, apiKey: '5093069871638054' }, // You are expected to receive the generated JSON (json_encode($data)) dataType: "json", success: function(data) { params.success({ // By default, Bootstrap table wants a "rows" property with the data "rows": data, // You must provide the total item ; here let's say it is for array length "total": data.length }) }, error: function(er) { params.error(er); } }); } function optionsFormatter(value, row, index) { return ` <a style='cursor:pointer;' class='edit m-1 btn btn-primary btn-icon btn-sm' title='Edit'><i class='fa fa-pen '></i> Edit</a> <a style='cursor:pointer;' class='company_access m-1 btn btn-primary btn-icon btn-sm' title='Company Access'> Company Access</a> <a style='cursor:pointer;' class='fields_access m-1 btn btn-primary btn-icon btn-sm' title='Fields Access'>Fields Access</a> <a style='cursor:pointer;' class='remove m-1 btn btn-sm btn-danger' title='Remove'><i class='fa fa-trash '></i></a> `; } var roleEvents = { 'click .edit': function(e, value, row, index) { generateUri("role_action.php", value); }, 'click .company_access': function(e, value, row, index) { generateUri("role_company_access.php", value); }, 'click .fields_access': function(e, value, row, index) { generateUri("role_fields.php", value); }, 'click .remove': function(e, value, row, index) { Swal.fire({ icon: 'warning', html: 'Do you want to remove this role?<br>Make sure this role not use by any users.', showDenyButton: false, showCancelButton: true, confirmButtonText: `Confirm`, denyButtonText: `Don't Confirm`, }).then((result) => { if (result.isConfirmed) { toastr.remove(); // toastr.success('Role has been deleted...') $.ajax({ url: "api/role/role.php", method: "POST", dataType: 'json', data: { apiKey: '4507690562484198', role_id: value }, beforeSend: function() { toastr.remove(); toastr.info('Removing role...') }, success: function(result) { if (parseInt(result.status) === 2) { toastr.error(result.message) } else if (parseInt(result.status) === 1) { var $table = $('#role-table') $(function() { $table.bootstrapTable('refresh') }) toastr.success(result.message) } else if (parseInt(result.status) === 0) { toastr.error(result.message) } }, error: function(xhr, status, error) { toastr.error('Error has occurred, Try again...'); } }); } else if (result.isDenied) { // Swal.fire('', 'Changes are not saved', 'info') } }) } }; var selected_id = 0; var selected_name = ""; $('#role-table').on('click-cell.bs.table', function(field, value, row, $el) { selected_name = $el.name; selected_id = row; $.extend({ confirm: function(title, message, yesText, yesCallback) { $("<div></div>").dialog({ buttons: [{ text: yesText, click: function() { yesCallback(); $(this).remove(); } }, { text: "Cancel", click: function() { $(this).remove(); } } ], close: function(event, ui) { $(this).remove(); }, resizable: false, title: title, modal: true }).text(message).parent().addClass("alert"); } }); if (value == "action") { if (row != "1" && row != "2") { if (confirm('Are you sure you want to delete this role level?')) { // Save it! $.ajax({ url: "app/employee/remove_role.php", method: "POST", data: { id: row }, success: function(data) { var $table = $('#role-table') $(function() { $table.bootstrapTable('refresh') }) } }); } else { // Do nothing! } } } }); $("#new-role").on('click', function() { generateUri("role_action.php", "new"); }); function generateUri(base, value) { window.location = generateUrl(base, { q: value }); } function generateUrl(url, params) { var i = 0, key; for (key in params) { if (i === 0) { url += "?"; } else { url += "&"; } url += key; url += '='; url += params[key]; i++; } return url; }
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.03 |
proxy
|
phpinfo
|
Settings