File manager - Edit - /home/autoph/public_html/tasks/role_fields.php.tar
Back
home/autoph/public_html/connectv1/role_fields.php 0000644 00000067445 15025012036 0016210 0 ustar 00 <?php include('cfg/db.php'); // include('app/security/security.php'); // include('api/controllers/utility.php'); if(!isset($_SESSION['user']['id'])){ header('location:signin.php'); } // if(!(isset($_SESSION['user']['action_permissions']['4']['sub_6_1']) && // $_SESSION['user']['action_permissions']['4']['sub_6_1'])){ // header('location:signin.php'); // } // $check_page = new CheckPage(); // $utility = new Utility(); // $check_page->start($db); if(!(isset($global_action_permissions['4']['6']) && in_array("1", $global_action_permissions['4']['6']))){ header('location:signin.php'); } $action = isset( $_REQUEST['q']) ? $_REQUEST['q'] : '' ; if(!$utility_class->isNotEmpty($action)){ header('location:role.php'); } $page_title = ""; $role_id = 0; if(trim($_REQUEST['q']) == 'new'){ header('location:role.php');//temporary $page_title = "Add Role"; }else{ $page_title = "Role Field Access"; $role_id = $db->escape($_REQUEST['q']); $company_name = $db -> select("SELECT name FROM `employee_role` WHERE status = 1 AND id = $role_id /*AND id <> 1*/"); if(!$utility_class->isNotEmpty($company_name)){ header('location:role.php'); } } $hasAccess = $db -> select("SELECT fields_permissions FROM `employee_role_access` WHERE status = 1 AND employee_role_id = '$role_id'"); if($utility_class->isNotEmpty($hasAccess)){ $hasAccessArray = (json_decode($hasAccess,true)); }else{ $hasAccessArray =array(); } // print_r($hasAccessArray); // echo $hasAccessArray['dashboard_permission']['dashboard_view_page']; // exit; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title><?php echo $variable['site_name']; ?> | <?php echo $page_title; ?></title> <!-- Google Font: Source Sans Pro --> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback"> <!-- Font Awesome --> <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css"> <!-- Theme style --> <link rel="stylesheet" href="dist/css/adminlte.min.css"> <!-- overlayScrollbars --> <link rel="stylesheet" href="plugins/overlayScrollbars/css/OverlayScrollbars.min.css"> <!-- Default style --> <link rel="stylesheet" href="dist/css/default.css"> <!-- Toastr --> <link rel="stylesheet" href="plugins/toastr/toastr.min.css"> <link href="dist/img/<?php echo $variable['logo']; ?>" rel="icon" /> </head> <body class="hold-transition sidebar-mini text-sm layout-fixed"> <div class="wrapper"> <!-- INCLUDE HEADER --> <?php include('include/header.php'); ?> <?php include('include/sidebar.php'); ?> <!-- /.navbar --> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <!-- Content Header (Page header) --> <section class="content-header"> <div class="container-fluid"> <div class="row mb-2"> <div class="col-sm-6"> <h1><?php echo $page_title; ?></h1> </div> <div class="col-sm-6"> <ol class="breadcrumb float-sm-right"> <li class="breadcrumb-item"><a href="home.php">Home</a></li> <li class="breadcrumb-item active"><?php echo $page_title; ?></li> </ol> </div> </div> </div><!-- /.container-fluid --> </section> <!-- Main content --> <section class="content"> <div class="container-fluid"> <div class="row"> <!-- left column --> <div class="col-md"> <!-- general form elements --> <div class="card card-primary"> <div class="card-header"> <h3 class="card-title"><button class="btn btn-tool" title="Go to Vehicle table list" type="button" onclick="back()"><i class="fas fa-arrow-alt-circle-left fa-2x"></i></button> Update <?php echo $company_name; ?> Role </h3> </div><!-- /.card-header --> <div class="card-body"> <div id="role-list" class="table-responsive"> <table id="role-table" class="table table-bordered table-sm"> <thead> <tr> <th class="">Feature</th> <th class="">Fields</th> </tr> </thead> <tbody> <!-- DASHBOARD PAGE --> <!-- DASHBOARD PAGE --> <!-- CUSTOMER PAGE --> <tr> <td>Customer</td> <td> <div class="checkbox"> <input type="checkbox" id="checkall_customer" /> <label for="checkall_customer">Check/Uncheck All</label> </div> <div class="checkbox"> <input nodetype="parent" type="text" id="customer_fields" value="customer_fields" hidden> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_email_1'])){ echo ($hasAccessArray['customer_fields']['fields_email_1'])? 'checked' : '' ; } ?> class="fields_access" id="fields_email_1" name="permissions[field][]" value="email_1"> <label style="font-weight: normal !important;" class="mb-0" for="fields_email_1"> Email 1 </label> </div> <div class="checkbox"> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_email_2'])){ echo ($hasAccessArray['customer_fields']['fields_email_2'])? 'checked' : '' ; } ?> class="fields_access" id="fields_email_2" name="permissions[field][]" value="email_2"> <label style="font-weight: normal !important;" class="mb-0" for="fields_email_2"> Email 2 </label> </div> <div class="checkbox"> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_mobile_1'])){ echo ($hasAccessArray['customer_fields']['fields_mobile_1'])? 'checked' : '' ; } ?> class="fields_access" id="fields_mobile_1" name="permissions[field][]" value="mobile_1"> <label style="font-weight: normal !important;" class="mb-0" for="fields_mobile_1"> Mobile 1 </label> </div> <div class="checkbox"> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_mobile_2'])){ echo ($hasAccessArray['customer_fields']['fields_mobile_2'])? 'checked' : '' ; } ?> class="fields_access" id="fields_mobile_2" name="permissions[field][]" value="mobile_2"> <label style="font-weight: normal !important;" class="mb-0" for="fields_mobile_2"> Mobile 2 </label> </div> <div class="checkbox"> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_landline'])){ echo ($hasAccessArray['customer_fields']['fields_landline'])? 'checked' : '' ; } ?> class="fields_access" id="fields_landline" name="permissions[field][]" value="landline"> <label style="font-weight: normal !important;" class="mb-0" for="fields_landline"> Landline </label> </div> <div class="checkbox"> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_home_phone'])){ echo ($hasAccessArray['customer_fields']['fields_home_phone'])? 'checked' : '' ; } ?> class="fields_access" id="fields_home_phone" name="permissions[field][]" value="home_phone"> <label style="font-weight: normal !important;" class="mb-0" for="fields_home_phone"> Home Phone </label> </div> <div class="checkbox"> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_business_phone'])){ echo ($hasAccessArray['customer_fields']['fields_business_phone'])? 'checked' : '' ; } ?> class="fields_access" id="fields_business_phone" name="permissions[field][]" value="business_phone"> <label style="font-weight: normal !important;" class="mb-0" for="fields_business_phone"> Business Phone</label> </div> <div class="checkbox"> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_address_1'])){ echo ($hasAccessArray['customer_fields']['fields_address_1'])? 'checked' : '' ; } ?> class="fields_access" id="fields_address_1" name="permissions[field][]" value="address_1"> <label style="font-weight: normal !important;" class="mb-0" for="fields_address_1"> Address 1 </label> </div> <div class="checkbox"> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_address_2'])){ echo ($hasAccessArray['customer_fields']['fields_address_2'])? 'checked' : '' ; } ?> class="fields_access" id="fields_address_2" name="permissions[field][]" value="address_2"> <label style="font-weight: normal !important;" class="mb-0" for="fields_address_2"> Address 2 </label> </div> <div class="checkbox"> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_viber'])){ echo ($hasAccessArray['customer_fields']['fields_viber'])? 'checked' : '' ; } ?> class="fields_access" id="fields_viber" name="permissions[field][]" value="viber"> <label style="font-weight: normal !important;" class="mb-0" for="fields_viber"> Viber </label> </div> <div class="checkbox"> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_facebook'])){ echo ($hasAccessArray['customer_fields']['fields_facebook'])? 'checked' : '' ; } ?> class="fields_access" id="fields_facebook" name="permissions[field][]" value="facebook"> <label style="font-weight: normal !important;" class="mb-0" for="fields_facebook"> Facebook </label> </div> <div class="checkbox"> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_instagram'])){ echo ($hasAccessArray['customer_fields']['fields_instagram'])? 'checked' : '' ; } ?> class="fields_access" id="fields_instagram" name="permissions[field][]" value="instagram"> <label style="font-weight: normal !important;" class="mb-0" for="fields_instagram"> Instagram </label> </div> <div class="checkbox"> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_whatsapp'])){ echo ($hasAccessArray['customer_fields']['fields_whatsapp'])? 'checked' : '' ; } ?> class="fields_access" id="fields_whatsapp" name="permissions[field][]" value="whatsapp"> <label style="font-weight: normal !important;" class="mb-0" for="fields_whatsapp"> Whatsapp </label> </div> <div class="checkbox"> <input nodetype="child" type="checkbox" <?php if(isset($hasAccessArray['customer_fields']['fields_telegram'])){ echo ($hasAccessArray['customer_fields']['fields_telegram'])? 'checked' : '' ; } ?> class="fields_access" id="fields_telegram" name="permissions[field][]" value="telegram"> <label style="font-weight: normal !important;" class="mb-0" for="fields_telegram"> Telegram </label> </div> </td> </tr> <!-- CUSTOMER PAGE --> <!-- VEHICLE PAGE --> <!-- VEHICLE PAGE --> <!-- SERVICE PAGE --> <!-- SERVICE PAGE --> <!-- SALES PAGE --> <!-- SALRES PAGE --> <!-- IMPORT PAGE --> <!-- IMPORT PAGE --> <!-- SETTINGS PAGE --> <!-- SETTINGS PAGE --> <!-- SETTINGS PAGE --> <!-- SETTINGS PAGE --> <!-- REPORTS PAGE --> <!-- REPORTS PAGE --> </tbody> </table> </div> <!--employee-list--> <div class="col-12" hidden> <!-- <span onclick="back()" href="#" class="btn btn-secondary">Back</span> --> <input type="submit" name="submit" id="submit" value="Save" class="btn btn-success float-right"> </div> </div><!-- /.card-body --> </div> </div><!-- /.col-md --> </div><!-- /.row --> </div><!-- /.container-fluid --> </section> <!-- /.content --> <!-- /.content-wrapper --> <!-- INSERT FOOTER --> </div><!-- ./cointent-wrapper --> <?php include('include/footer.php'); ?> <!-- Control Sidebar --> <aside class="control-sidebar control-sidebar-dark"> <!-- Control sidebar content goes here --> </aside> <!-- /.control-sidebar --> </div><!-- ./wrapper --> <!-- jQuery --> <script src="plugins/jquery/jquery.min.js"></script> <!-- overlayScrollbars --> <script src="plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script> <!-- Bootstrap 4 --> <script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script> <!-- bs-custom-file-input --> <script src="plugins/bs-custom-file-input/bs-custom-file-input.min.js"></script> <!-- AdminLTE App --> <script src="dist/js/adminlte.min.js"></script> <!-- Toastr --> <script src="plugins/toastr/toastr.min.js"></script> <!-- Navigation Highlight --> <script src="dist/js/main.js"></script> <script> $("#submit").click(function() { console.log(getAllData()); roleActionAccess(); }); function roleActionAccess() { $.ajax({ url: "api/role/role.php", method: "GET", dataType: 'json', data: { apiKey: '2426987890983868', role_id: <?php echo $role_id; ?>, role_access: getAllData() }, beforeSend: function() { toastr.remove(); toastr.info('Updating access role...') $('#submit').attr('disabled', true); }, success: function(result) { if (parseInt(result.status) === 1) { // sweetAlertSimple('success', 'Nice...', result.message); toastr.success(result.message) } else if (parseInt(result.status) === 0) { // sweetAlertSimple('error', 'Oops...', result.message); toastr.error(result.message) } $('#submit').attr('disabled', false); }, error: handleError }); } function handleError(xhr, status, error) { //hide loader // sweetAlertSimple('error', 'Oops...', 'Error has occurred, Try again...'); toastr.error('Error has occurred, Try again...') $('#submit').attr('disabled', false); // $('.customer-modal-overlay').hide(); } function getAllData() { var /* Create an object. */ obj = {}, /* Create a variable that references the current object (default → obj). */ ref = obj; /* Iterate over every input. */ $("#role-table :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') } } }); /* Stringify the object and return it. */ return JSON.stringify(obj); } function isEmpty(string) { var flag = false; if (string == '') { flag = true; } else if (string == null) { flag = true; } else { if (string.trim() == '') { flag = true; } } return flag; } $('#checkall_customer').change( function() { if ($(this).is(':checked')) { $('.fields_access:checkbox').prop('checked', true); } else { $('.fields_access:checkbox').prop('checked', false); } roleActionAccess(); }); $('.fields_access').change( function() { roleActionAccess(); }); var allChecked = true; $(".fields_access").each(function(index, element) { if (!element.checked) { allChecked = false; return false; } }); $(document).ready(function() { if (allChecked) { $("#checkall_customer").prop("checked", true); } }); function back() { window.history.back(); } </script> <!-- Page specific script --> </body> </html>