File manager - Edit - /home/autoph/public_html/tasks/resources/views/settings/role.php
Back
<?php if(!isset($session_access['1']) || !in_array('1_2', $session_access['1'])){ include $error_404; exit; } ?> <div class="tab-container bg-light"> <ul class="nav nav-tabs hide-sm"> <?php if(in_array('1_1', $session_access['1'])){ ?> <li class=""> <a class="" href="#settings-system">System</a> </li> <?php } ?> <?php if(in_array('1_5', $session_access['1'])){ ?> <li class=""> <a class="" href="#settings-users">Users</a> </li> <?php } ?> <?php if(in_array('1_2', $session_access['1'])){ ?> <li class="active"> <a class="" href="#settings-role">Roles</a> </li> <?php } ?> <?php if(in_array('1_3', $session_access['1'])){ ?> <li class=""> <a class="" href="#settings-sms">SMS</a> </li> <?php } ?> <?php if(in_array('1_4', $session_access['1'])){ ?> <li class=""> <a class="" href="#settings-notification">Notification</a> </li> <?php } ?> </ul> <div class="tab-content bg-white m-0 p-3"> <div class="tab-pane active cont min-height-400"> <div class="mb-0"> <nav class="navbar navbar-expand-md navbar-light justify-content-start pb-1 px-0" style=" background-color:transparent;"> <button class="navbar-toggler hide-sm" type="button" data-toggle="collapse" data-target="#navbarNav"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse show" id="navbarNav"> <ul class="nav nav-tabs navbar-nav mr-auto" style="border-bottom: 0px solid #dee2e6;"> <li class="nav-item mr-2 mb-1"> <button type="submit" class="btn btn-dark btn-sm" id="btn_new_role">New Role</button> </li> </ul> <ul class="nav nav-tabs navbar-nav ml-auto-md" style="border-bottom: 0px solid #dee2e6;"> <li class="nav-item mr-0 mb-1"> <div class="row"> <div class="input-group search-transition default-search-size" id="ticket-search-div"> <div class="input-group-prepend"> <span class="input-group-text pr-2 pl-2 pt-0 pb-0"><i class="fas fa-search"></i></span> </div> <input type="search" id="ticket-search" class="form-control form-control-sm pr-0" placeholder="Search..."> </div> <i class=" cursor-pointer tooltip-me pt-1 pl-1 fas fa-question-circle text-primary " title="Search role name."></i> </div> </li> </ul> </div> </nav> </div> <table id="table_cnf_role" data-search="false" data-show-refresh="false" data-show-header="true" class="table table-bordered table-hover table-sm small" data-show-export="false" data-page-size="15" data-page-list="[15, 30, 50, 100, all]" data-query-params="roleQueryParams" data-pagination="true"> <thead> <tr> <th data-field="no" data-width="10"> No.</th> <th data-field="name"> Name </th> <th data-width="10" data-events="" data-formatter="removeRoleFormatter" class="text-center action-formatter-th" data-field="action"> Action </th> </tr> </thead> </table> </div> </div> </div> <?php include('resources/views/modals/role_modal.php'); ?> <!-- Common scripts --> <!-- BTAble --> <script src="dist/js/tableExport/tableExport.min.js"></script> <script src="dist/js/tableExport/libs/js-xlsx/xlsx.core.min.js"></script> <script src="dist/js/tableExport/libs/jsPDF/jspdf.umd.min.js"></script> <script src="dist/js/tableExport/libs/es6-promise/es6-promise.auto.min.js"></script> <script src="dist/js/tableExport/libs/html2canvas/html2canvas.min.js"></script> <script src="plugins/bootstrap-table/js/bootstrap-table.min.js"></script> <script src="plugins/bootstrap-table/js/bootstrap-table-en-US.js"></script> <script src="plugins/bootstrap-table/js/bootstrap-table-export.min.js"></script> <!-- Select2 --> <script src="plugins/select2/js/select2.full.min.js"></script> <!-- SweetAlert2 --> <script src="plugins/sweetalert2/sweetalert2.min.js"></script> <!-- Toastr --> <script src="plugins/toastr/toastr.min.js"></script> <!-- AutoCommplete --> <script src="dist/js/bootstrap-autocomplete/bootstrap-autocomplete.min.js"></script> <!-- custom scripts for this page only --> <script> // GLOBAL </script> <?php // IMPORTANT JS FUNCTIONS include('resources/views/common/script/function.php'); ?> <script> var role_json_data = ""; var selected_role_data = 0; var is_new_role = 0; var selected_brands = []; function getAllDataAdmin() { var /* Create an object. */ obj = {}, /* Create a variable that references the current object (default → obj). */ ref = obj; /* Iterate over every input. */ $("#cnf_role_modal :input").each(function() { /* Cache the id of the input. */ var id = this.id; /* Check whether the nodetype attribute is set to 'parent'. */ if (this.getAttribute("nodetype") == "parent") { /* Set a new object to the property and set ref to refer to it. */ ref = obj[id] = []; } else { /* Set the value of the input to the referred object. */ if (this.getAttribute("nodetype") == "child") { // ref[id] = $(this).val(); // ref[id] = $(this).is(':checked'); // if ($(this).is(':checked')) { ref.push(id) // } } } }); /* Stringify the object and return it. */ return JSON.stringify(obj); } function getAllData() { var /* Create an object. */ obj = {}, /* Create a variable that references the current object (default → obj). */ ref = obj; /* Iterate over every input. */ $("#cnf_role_modal :input").each(function() { /* Cache the id of the input. */ var id = this.id; /* Check whether the nodetype attribute is set to 'parent'. */ if (this.getAttribute("nodetype") == "parent") { /* Set a new object to the property and set ref to refer to it. */ ref = obj[id] = []; } else { /* Set the value of the input to the referred object. */ if (this.getAttribute("nodetype") == "child") { // ref[id] = $(this).val(); // ref[id] = $(this).is(':checked'); if ($(this).is(':checked')) { ref.push(id) } } } }); /* Stringify the object and return it. */ return JSON.stringify(obj); } function loadUserCategories() { return $.ajax({ url: "app/models/user.php", data: { model: 'read_user_categories', }, type: "POST", dataType: 'json', beforeSend: function() { $('#dd_user_type').html(''); }, success: function(result) { $.each(result, function(i, n) { $('#dd_user_type').append(`<option value="` + n.id + `">` + n.text + `</option>`); }); }, error: function() {} }); } function createRole() { return $.ajax({ url: "app/models/user.php", data: { model: 'create_role', json_data: role_json_data, role_data: getAllData(), brand_data : JSON.stringify(selected_brands), role_id: selected_role_data, is_new_role: is_new_role }, type: "POST", dataType: 'json', beforeSend: function() { $('#btn_cnf_role_save').prop( 'disabled', true); toastr.remove(); toastr.info("Saving role..."); }, success: function(result) { if (parseInt(result.status) === 1) { // created_ticket_id = result.id; createRoleDone(result.message) } else { $('#btn_cnf_role_save').prop( 'disabled', false); toastr.remove(); toastr.error(result.message); } }, error: function() { $('#btn_cnf_role_save').prop( 'disabled', false); toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function resetRoleModal() { var $el = $('#cnf_role_modal'); // resetElementForm($el); $el .find("input,textarea") .val('') .trigger('change') .end() .find("input[type=checkbox], input[type=radio]") .prop("checked", "") .end(); $el .find("select") .prop('selectedIndex', 0) .trigger('change') .end(); // loadUserCategories(); $('#cnf-role-modal-tab li a').removeClass('active') $('#cnf-role-modal-tab-content .tab-pane').removeClass('active').removeClass('show') $('#cnf-role-modal-tab-information').addClass('active') $('#cnf-role-modal-tab-information-sec').addClass('active').addClass('show') } function createRoleDone(message) { toastr.remove(); toastr.success(message); refreshRoleTableSilent(); if(is_new_role){ resetRoleModal(); $('#cnf_role_modal').modal( 'hide'); } $('#btn_cnf_role_save').prop( 'disabled', false); } function refreshRoleTable() { initRoleList(); var $table = $('#table_cnf_role') $(function() { $table.bootstrapTable('refresh', { url: 'app/models/user.php' }); }) } function refreshRoleTableSilent() { var $table = $('#table_cnf_role') $(function() { $table.bootstrapTable('refresh', { url: 'app/models/user.php' }); }) } function initRoleList() { var $table = $('#table_cnf_role'); $table.bootstrapTable('destroy').bootstrapTable({ sidePagination: 'server', formatSearch: function() { return 'Search...' }, onLoadSuccess: function() { }, exportOptions: { fileName: function() { return 'titile' } } }); } function roleQueryParams(params) { return { search: $('#ticket-search').val(), offset: params.offset, limit: params.limit, sort: params.sort, order: params.order, model: 'read_role_list', }; } function removeRoleFormatter(value, row, index) { return '<span class="font-weight-bold"><i class="fa fa-times text-danger text-md cursor-pointer" aria-hidden="true"></i></span>'; } function initRoleSearchEvt() { $('#ticket-search').focusin(function() { $('#ticket-search-div').removeClass('default-search-size'); $('#ticket-search-div').addClass('expand-search-size'); }); $('#ticket-search').focusout(function() { if (isEmpty($(this).val())) { $('#ticket-search-div').removeClass('expand-search-size'); $('#ticket-search-div').addClass('default-search-size'); } }); $('#ticket-search').on('keyup', delay(function(e) { refreshRoleTableSilent(); }, 500)); } function initBrandSearchEvt() { $('#role-brand-search').focusin(function() { $('#role-brand-search-div').removeClass('default-search-size'); $('#role-brand-search-div').addClass('expand-search-size'); }); $('#role-brand-search').focusout(function() { if (isEmpty($(this).val())) { $('#role-brand-search-div').removeClass('expand-search-size'); $('#role-brand-search-div').addClass('default-search-size'); } }); $('#role-brand-search').on('keyup', delay(function(e) { refreshRoleTableSilent(); refreshRoleBrandfileTableSilent(); }, 500)); } ////START ROLE DEALER function refreshRoleBrandfileTable() { initRoleBrandfileList(); var $table = $('#table_role_brand_file') $(function() { $table.bootstrapTable('refresh', { url: 'app/models/user.php' }); }) } function refreshRoleBrandfileTableSilent() { var $table = $('#table_role_brand_file') $(function() { $table.bootstrapTable('refresh', { url: 'app/models/user.php' }); }) } function initRoleBrandfileList() { var $table = $('#table_role_brand_file'); $table.bootstrapTable('destroy').bootstrapTable({ sidePagination: 'server', formatSearch: function() { return 'Search...' }, onLoadSuccess: function() {}, exportOptions: { fileName: function() { return 'titile' } } }); } function roleBrandfileQueryParams(params) { return { search: $('#role-brand-search').val(), offset: params.offset, limit: params.limit, sort: params.sort, order: params.order, selected_brands: JSON.stringify(selected_brands), model: 'read_role_brand_list', }; } function roleBrandFormatter(value, row, index) { var html = '<input class="" type="checkbox">'; if (parseInt(row.status) === 1) { html = '<input class="" type="checkbox" checked>'; } return html; } window.roleBrandEvent = { 'click input': function(e, value, row, index) { //get selected id if(row.status == '0') { selected_brands.push(row.id); }else{ var index = selected_brands.indexOf(row.id); if (index !== -1) { selected_brands.splice(index, 1); } } refreshRoleBrandfileTableSilent(); } }; ////END ROLE DEALER $(function() { loadUserCategories(); refreshRoleTable(); initRoleSearchEvt(); initBrandSearchEvt(); refreshRoleBrandfileTable(); $('#btn_new_role').on('click', function(e) { $('#cnf_role_modal').modal('show'); resetRoleModal(); is_new_role = 1; }) $('#check_all').on('click', function(e) { $("[role-access]").each(function() { $(this).prop("checked", true); }); $("#cnf_role_modal .collapsed-card").each(function() { $(this).toggleClass("collapsed-card"); }); }) $("#btn_cnf_role_save").click(function() { // console.log(getAllDataAdmin());return false; if (check_if_empty_field($('#txt_role_name'), 'Role names is required.')) { return; } var $element = $("[json-role-modal]"); role_json_data = generate_json( 'json-role-modal', $element); // console.log(getAllData()); // console.log(role_json_data); createRole(); }); $('#table_cnf_role').on('click-cell.bs.table', function(field, value, row, $el) { selected_role_data = $el.id; if (value != "action") { $('#cnf_role_modal').modal('show'); resetRoleModal(); is_new_role = 0; $('#txt_role_name').val($el.name) $('#dd_user_type').val($el.user_category) var role_access = $el.json_access; const menuobj = JSON.parse(role_access); // console.log(menuobj) $.each(menuobj, function(i, n) { $.each(n, function(j, m) { $('#' + m).prop("checked", true); // console.log(m) }); // $(this).prop("checked", true); // var $current_el = $('#ra_'+n); // $current_el.val("1"); // $current_el.attr('checked',true); }); selected_brands = []; var brand_access = $el.json_brand; const brandobj = JSON.parse(brand_access); $.each(brandobj, function(i, n) { selected_brands.push(n); }); refreshRoleBrandfileTableSilent(); } else if (value == "action") { if (parseInt($el.user_count) > 0) { toastr.remove(); toastr.error('Role is currently active in some users.'); return; } Swal.fire({ icon: 'warning', html: 'Are you sure you want to remove this role?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Yes`, cancelButtonText: `No`, denyButtonText: `Don't Confirm`, showClass: { backdrop: 'swal2-noanimation', // disable backdrop animation popup: '', // disable popup animation icon: '' // disable icon animation }, hideClass: { popup: '', // disable popup fade-out animation }, customClass: 'swal-height' }).then((result) => { if (result.isConfirmed) { $.ajax({ url: "app/models/user.php", method: "POST", dataType: 'json', data: { model: 'remove_role', id: $el.id }, beforeSend: function() { toastr.remove(); toastr.info('Removing...') }, success: function(result) { if (parseInt(result.status) === 1) { toastr.remove(); toastr.success(result.message); refreshRoleTableSilent(); } else { toastr.remove(); toastr.error(result.message); } }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } else if (result.isDenied) {} else {} }) } }); }); </script>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings