File manager - Edit - /home/autoph/public_html/connectv1/role_dealer_access.php
Back
<?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($global_action_permissions['4']['6']) && in_array("1", $global_action_permissions['4']['6']))){ 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); $action = isset( $_REQUEST['q']) ? $_REQUEST['q'] : '' ; if(!$utility_class->isNotEmpty($action)){ header('location:role.php'); } $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'); } $hasAccessComponies = $db -> select("SELECT company_permissions FROM `employee_role_access` WHERE status = 1 AND employee_role_id = '$role_id'"); if($utility_class->isNotEmpty($hasAccessComponies)){ $hasAccessComponiesArray = (json_decode($hasAccessComponies)); }else{ $hasAccessComponiesArray =array(); } // var_dump( $hasAccessComponies); // $where_company_id =''; // $count_company_id = count((array)$hasAccessComponies); // echo $count_company_id; // if($count_company_id >1) // { $string = substr($hasAccessComponies, 1, -1); // Remove double quotes $company_ids = str_replace('"', '', $string); $where_company_id = ' AND scd.company_id IN ('.$company_ids.')'; // } // echo'<pre>';print_r($hasAccessComponies);echo'</pre>'; $hasAccessDealer = $db -> select("SELECT dealer_permissions FROM `employee_role_access` WHERE status = 1 AND employee_role_id = '$role_id'"); $hasAccessDealer = json_decode($hasAccessDealer); $is_all_check = 1; ?> <!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']; ?> | Dealer Access</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"> <!-- SweetAlert2 --> <!-- <link rel="stylesheet" href="plugins/sweetalert2/sweetalert2.min.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>Dealer Access</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">Dealer Access</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><?php echo $company_name; ?> Role Dealer Access </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="">Dealership</th> </tr> </thead> <tbody> <tr> <td> <div class="checkbox m-1"> <input type="checkbox" id="checkall" /> <label for="checkall">Check/Uncheck All</label> </div> <?php $companies = $db -> sql_query("SELECT scd.company_id,scd.dealer_id,d.id AS dealer_id,d.code,d.name FROM source_company_dealer scd LEFT JOIN source_dealer AS d ON scd.dealer_id = d.id WHERE scd.type=1 AND d.status =1 $where_company_id GROUP BY d.id order BY d.name"); if($companies->num_rows>0){ foreach($companies as $company){ $checked = ""; if($hasAccessDealer!=null && in_array($company['dealer_id'],$hasAccessDealer)) { $checked = "checked"; }else{ $is_all_check = 0; } ?> <div class="checkbox m-1"> <input <?php echo $checked; ?> id="<?php echo $company['dealer_id'];?>" json-modal="true" type="checkbox" class="company_access" name="permissions[company][]"> <label class="mb-0" style="font-weight: normal !important;" for="<?php echo $company['dealer_id'];?>"> <?php echo strtoupper($company['code']).' - '.strtoupper($company['name']); ?> </label> </div> <hr class="m-0 p-0"> <?php } } ?> </td> </tr> </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> <!-- Navigation Highlight --> <script src="dist/js/main.js"></script> <!-- SweetAlert2 --> <!-- <script src="plugins/sweetalert2/sweetalert2.min.js"></script> --> <!-- Toastr --> <script src="plugins/toastr/toastr.min.js"></script> <script> $("#submit").click(function() { // alert('fire') // console.log(getAllData()); companyActionAccess(); }); $(".company_access").change(function() { companyActionAccess(); if (this.checked) { //Do stuff } }); function companyActionAccess() { console.log(getAllData()); $.ajax({ url: "api/role/role.php", method: "GET", dataType: 'json', data: { apiKey: '20416187390672170', role_id: <?php echo $role_id; ?>, dealer_access: getAllData() }, beforeSend: function() { toastr.remove(); toastr.info('Updating company 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 sweetAlertSimple(icon, title, text) { // Swal.fire({ // icon: icon, // title: title, // text: text, // allowEnterKey: true // default value // }) // } 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, checkData = []; /* 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("json-modal") == "true") { // ref[id] = $(this).val(); if ($(this).is(':checked')) { // ref[id] = $(this).is(':checked') checkData.push(id); } } } }); /* Stringify the object and return it. */ return JSON.stringify(checkData); } // var d = $('#checkall').data(); // access the data object of the button $(document).ready(function() { if (<?php echo $is_all_check; ?>) { $("#checkall").prop("checked", true); } }); // $('#checkall').click(function(){ // $(':checkbox').prop('checked', !d.checked); // set all checkboxes 'checked' property using '.prop()' // d.checked = !d.checked; // set the new 'checked' opposite value to the button's data object // companyActionAccess(); // }); $('#checkall').change( function() { if ($(this).is(':checked')) { $(':checkbox').prop('checked', true); } else { $(':checkbox').prop('checked', false); } companyActionAccess(); }); function back() { window.history.back(); } </script> <!-- Page specific script --> </body> </html>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.23 |
proxy
|
phpinfo
|
Settings