File: /var/www/content-sp/work-sp/nqb_user_access.php
<?php
include_once('nqb_user_section.php');
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$SP_EDITORS = 'csp_editors';
$SP_TEAM_WORKS = 'csp_team_work';
$SP_TEAM_ACCESS = 'csp_team_user_access';
//check edit permissions
$fileName = str_replace('.php', '', basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']));
if (in_array($fileName, $pageArray)) {
$edData = $conn->query("select e.* from $SP_EDITORS as e where editor_status='1' and team_id='3' order by e.editor_id asc");
if (isset($_POST["submit"]) || $_REQUEST["usrss"]) {
unset($_SESSION["EDTID"]);
$usrss = $_REQUEST["usrss"];
if ($usrss != 0) {
$_SESSION["EDTID"] = $usrss;
}
}
if (isset($_SESSION["EDTID"])) {
$edtId = $_SESSION["EDTID"];
$getData = $conn->query("select e.* from $SP_EDITORS as e where e.editor_id=" . $edtId);
$usr = $getData->fetch_assoc();
$getWorksNotIn = $conn->query("select w.work_id, w.work_name, w.work_code, w.parent_id from $SP_TEAM_WORKS as w where w.work_id NOT IN(select work_id from $SP_TEAM_ACCESS where editor_id='$edtId') order by w.work_id ");
$getWorksIn = $conn->query("select t.work_id, w.work_name, w.work_code, w.parent_id from $SP_TEAM_ACCESS as t LEFT JOIN $SP_TEAM_WORKS as w ON w.work_id=t.work_id where editor_id='$edtId' order by t.work_id ");
}
?>
<link href="assets/plugins/select2/css/select2.min.css" rel="stylesheet">
<script src="assets/plugins/select2/js/select2.min.js"></script>
<script type="text/javascript">
var jq = jQuery.noConflict();
jq(document).ready(function() {
jq('.editors-dropdown').select2();
});
</script>
<div class="row">
<div class="col-md-12">
<div class="panel panel-white">
<div class="panel-body">
<div class="search bg-light">
<form method="POST" data-default="150">
<div class="input-group">
<label class="slabel">Select User</label>
<select name="usrss" id="usrss" class="sselect editors-dropdown">
<option value="0">--user--</option>
<?php while ($ed = $edData->fetch_assoc()) { ?>
<option value="<?php echo $ed['editor_id']; ?>" <?php if (isset($_SESSION['EDTID'])) if ($ed['editor_id'] == $_SESSION["EDTID"]) echo "selected"; ?>><?php echo $ed['editor_id'] . "|" . $ed['editor_login'] . " | " . $ed['contact_name'] . " | " . $ed['official_email']; ?></option>
<?php } ?>
</select>
<span class="input-group-btn">
<button class="btn btn-success" type="submit" name="submit"><i class="fa fa-search"></i></button>
</span>
</div>
</form>
</div>
</div>
</div>
</div>
<?php if (isset($_SESSION["EDTID"])) { ?>
<div class="col-md-4">
<div class="panel panel-info">
<div class="panel-heading clearfix">
<h4 class="panel-title">User Details</h4>
</div>
<?php
if ($usr['editor_id'] != '') { ?>
<table class="table table-hover">
<tr>
<th colspan="2" style="text-align:center;">--------- main details ---------</th>
</tr>
<tr>
<th>Id</th>
<td><?php echo $usr['editor_id']; ?></td>
</tr>
<tr>
<th>Login Username</th>
<td><?php echo $usr['editor_login']; ?></td>
</tr>
<tr>
<th>Name</th>
<td><?php echo $usr['display_name']; ?></td>
</tr>
<tr>
<th>Email Id</th>
<td><?php echo $usr['official_email']; ?></td>
</tr>
<tr>
<th>Mobile No</th>
<td><?php echo $usr['contact_no']; ?></td>
</tr>
<tr>
<th>Status</th>
<td><?php echo $usr['status']; ?></td>
</tr>
<tr>
<th>Master Access</th>
<td><?php echo $usr['q_masters']; ?></td>
</tr>
<tr>
<th>Download Access</th>
<td><?php echo $usr['download_access']; ?></td>
</tr>
<tr>
<th>Added Date</th>
<td><?php echo $usr['added_date']; ?></td>
</tr>
<tr>
<th colspan="2" style="text-align:center;">--------- ---------</th>
</tr>
</table>
<?php } ?>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-info">
<div class="panel-heading clearfix">
<h4 class="panel-title">Access (Excluded)</h4>
</div>
<table class="table table-hover">
<tr>
<th>S.No.</th>
<th>Parent</th>
<th>Work Id</th>
<th>Work Name</th>
<th>In</th>
</tr>
<?php
$j = 1;
while ($win = $getWorksNotIn->fetch_assoc()) {
?>
<tr id="inrow_<?php echo $win['work_id']; ?>">
<td><?php echo $j; ?></td>
<td><?php echo $win['parent_id']; ?></td>
<td><?php echo $win['work_id']; ?></td>
<td><?php echo $win['work_name']; ?></td>
<td title="access work to this user"><i class="fa fa-plus-square plscls" id="inid_<?php echo $win['work_id']; ?>"></i></td>
</tr>
<?php $j++;
} ?>
</table>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-info">
<div class="panel-heading clearfix">
<h4 class="panel-title">Access (Included)</h4>
</div>
<table class="table table-hover">
<tr>
<th>S.No.</th>
<th>Parent</th>
<th>Work Id</th>
<th>Work Name</th>
<th>Ex</th>
</tr>
<?php
$i = 1;
while ($winc = $getWorksIn->fetch_assoc()) {
?>
<tr id="exrow_<?php echo $winc['work_id']; ?>">
<td><?php echo $i; ?></td>
<td><?php echo $winc['parent_id']; ?></td>
<td><?php echo $winc['work_id']; ?></td>
<td><?php echo $winc['work_name']; ?></td>
<td title="remove access from this user"><i class="fa fa-minus-square mincls" id="exid_<?php echo $winc['work_id']; ?>"></i></td>
</tr>
<?php $i++;
} ?>
</table>
</div>
</div>
<?php } ?>
</div>
<script>
jQuery.noConflict();
jQuery(function($) {
jQuery(".plscls").click(function(event) {
var clickedId = this.id;
jQuery('#' + clickedId).html('<img src="assets/images/reload.GIF" class="lodcls">');
var toAddId = clickedId.substring(5);
var site = "nqb_user_add_remove_access.php";
jQuery.ajax({
url: site,
type: 'POST',
data: {
typ: "addA",
work_id: toAddId,
editor_id: <?php echo $_SESSION["EDTID"]; ?>
},
success: function(data) {
jsonData = JSON.parse(data);
if (jsonData[0].status == 1) {
alert(jsonData[0].message);
jQuery('#' + clickedId).html('');
location.href = '/work-sp/nqb_user_access';
} else {
alert(jsonData[0].message);
jQuery('#' + clickedId).html('');
}
}
});
});
jQuery(".mincls").click(function(event) {
var clickedRemId = this.id;
jQuery('#' + clickedRemId).html('<img src="assets/images/reload.GIF" class="lodcls">');
var toRemoveId = clickedRemId.substring(5);
var site = "nqb_user_add_remove_access.php";
jQuery.ajax({
url: site,
type: 'POST',
data: {
typ: "rmA",
work_id: toRemoveId,
editor_id: <?php echo $_SESSION["EDTID"]; ?>
},
success: function(data) {
jsonData = JSON.parse(data);
if (jsonData[0].status == 1) {
alert(jsonData[0].message);
jQuery('#' + clickedRemId).html('');
location.href = '/work-sp/nqb_user_access';
} else {
alert(jsonData[0].message);
jQuery('#' + clickedRemId).html('');
}
}
});
});
});
</script>
<style>
.table-hover th,
td {
font-size: 13px;
padding: 9px !important;
}
.slabel {
margin-left: 20%;
font-size: 14px;
font-weight: bold;
}
.sselect {
margin: 5px 5px 5px 10px;
width: 40%;
height: 30px;
}
.plscls {
font-size: 16px;
color: #12afcb;
cursor: pointer;
}
.mincls {
font-size: 16px;
color: #ec1937;
cursor: pointer;
}
.lodcls {
height: 25px;
display: block;
background: #018aa0;
margin: -20px 0px 0px -5px;
}
</style>
<?php
} else {
echo "<script type='text/javascript'>alert('You dont have access');</script>";
echo "<script type='text/javascript'>location.href='/work-sp';</script>";
}
include_once('footer.php');
?>