<?php
require 'dbconfig.php';
require 'steamauth/steamauth.php';
/*Temporary for local testing. Remove line 5 to deploy for live testing*/
$_SESSION['steamid'] = "steam:11000010533fe0f";
if(isset($_SESSION['steamid']) && $_SESSION['lvl'] >= 1) {
//include 'steamauth/userInfo.php';
/*$steamid = "steam:" . dechex($_SESSION['steamid']);*/
$query = $conn->prepare("SELECT u.steamid, firstgiven, lastgiven, department, jobtitle FROM characters JOIN users u using(userid) WHERE steamid = :steamid AND department = 'DOJ'");
$query->bindValue(':steamid', $_SESSION['steamid']);
$query->execute();
$authorized = $query->fetch(PDO::FETCH_ASSOC);
if(isset($authorized)) {
$name = $authorized['jobtitle'] . " " . $authorized['lastgiven'];
$_SESSION['name'] = $name;
}
} else {
header('Location: index.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Adjust Debt</title>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CDN's and links -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/index.css?v=1.1">
<link href="https://fonts.googleapis.com/css?family=Cinzel" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/ui.jqgrid.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.13.0/umd/popper.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/js/jquery.jqgrid.min.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="sidenav" id="mysidenav">
<div class="text-center">
<?php
if(!isset($_SESSION['steamid'])) { ?>
<div><?php loginbutton();?></div>
<?php } else { ?>
<div class="text-warning" id="name"><?=$name;?></div>
<hr>
<div class="navbtns">
<button class="btn btn-sm btn-warning col-md-6" id="home">Home</button>
<button class="btn btn-sm btn-warning col-md-6" id="ncic">Search Criminals</button>
<button class="btn btn-sm btn-warning col-md-6" id="asset">SEIZE ASSETS</button>
<button class="btn btn-sm btn-warning col-md-6" id="warrant">ISSUE WARRANT</button>
<button class="btn btn-sm btn-warning col-md-6" id="courtorder">ISSUE COURT ORDER</button>
<button class="btn btn-sm btn-warning col-md-6" id="prison">ADJUST PRISON TIME</button>
</div>
<hr>
<div><?php logoutbutton(); ?></div>
<input id="session" value="<?=$_SESSION['lvl'];?>" hidden>
<?php } ?>
<span class="closebtn">×</span>
</div>
</div>
<div class="text-right"><span id="menu" onclick="opennav()">☰</span></div>
</div>
<?php if(isset($_SESSION['steamid'])) { ?>
<div class="container-fluid text-center main">
<h1 class="text-warning">San Andreas Department of Justice</h1>
<hr>
<h3 class="text-warning">Adjust Debt</h3>
<form class="container" id="adjustform">
<div class="form-group">
<label>-Enter first/last name with "/" separating the names-</label>
<input type="text" class="form-control text-center" id="charname" placeholder="ben/travis">
</div>
<div class="form-group">
<label>-Or Character ID-</label>
<input type="text" class="form-control text-center" id="charid" placeholder="12345">
<button type="submit" class="btn btn-lg btn-primary" id="submitbtn">Search</button>
</div>
</form>
<div class="container table-responsive">
<table class="table table-dark table-striped table-bordered table-hover" id="adjusttbl" width="100%">
<thead>
<tr>
<th>Username</th>
<th>Char ID</th>
<th>Name</th>
<th>Owes State</th>
</tr>
</thead>
</table>
</div>
</div>
<?php } ?>
<script>
function opennav() {
$("#mysidenav").css("width", "20em");
$(".main").fadeTo("slow", 0.5);
if($("#session").val() == 0) {
$("#adjustdebt, #asset, #warrant, #courtorder, #prison").remove();
} else if($("#session").val() == 1) {
$("#warrant, #courtorder, #prison").remove();
} else {
$(".navbtns").show();
}
}
$(".main, .closebtn, #crimdues").click(function closenav() {
$("#mysidenav").css("width", "0em");
$(".main").fadeTo("slow", 1.0);
});
$(document).ready(()=> {
$("#adjustform").submit((event)=> {
if($("#charname").val() != "") {
$.get("data.php?name=" + encodeURIComponent($("#charname").val()), (data)=> {
console.log(data['generalInfo']);
$("#adjusttbl").DataTable({
destroy: true,
paging: false,
searching: false,
info: false,
ordering: false,
data: data['generalInfo'],
columns: [
{'data': 'username'},
{'data': 'charid'},
{
'data': null,
render: (data)=> {
let name = data.firstgiven + " " + data.lastgiven;
return name;
}
},
{
'data': null,
render: (data)=> {
let owesstate = '<div id="owes">$'+data.owesstate+'</div>';
$("#owes").click(()=> {
let newDebt = prompt("Please enter new State Debt:");
if(newDebt != null) {
$.post("data.php", {newDebt: newDebt, charid: data.charid}, (newdata)=> {
let owesstate = '$' + newdata.owesstate;
console.log(owesstate);
$("#owes").replaceWith('<div id="owes">'+owesstate+'</div>');
});
}
});
return owesstate;
}
}
]
});
});
$("#adjusttbl").delay(2800).css("left", "0").delay(30).css("position", "relative").css("width", "100%").css("opacity", "100");
}
if($("#charid").val() != "") {
$.get("data.php?charid=" + encodeURIComponent($("#charid").val()), (data)=> {
console.log(data['generalInfo']);
$("#adjusttbl").DataTable({
destroy: true,
paging: false,
searching: false,
info: false,
ordering: false,
data: data['generalInfo'],
columns: [
{'data': 'username'},
{'data': 'charid'},
{
'data': null,
render: (data)=> {
let name = data.firstgiven + " " + data.lastgiven;
return name;
}
},
{
'data': null,
render: (data)=> {
let owesstate = '<div id="owes">$'+data.owesstate+'</div>';
$("#owes").click(()=> {
let newDebt = prompt("Please enter new State Debt:");
if(newDebt != null) {
$.post("data.php", {newDebt: newDebt, charid: data.charid}, (newdata)=> {
let owesstate = '$' + newdata.owesstate;
console.log(owesstate);
$("#owes").replaceWith('<div id="owes">'+owesstate+'</div>');
});
}
});
return owesstate;
}
}
]
});
});
$("#adjusttbl").delay(2800).css("left", "0").delay(30).css("position", "relative").css("width", "100%").css("opacity", "100");
}
event.preventDefault();
});
});
//navigation buttons
$("#home").click(()=> {
window.location.href='index.php';
});
$("#ncic").click(()=> {
window.location.href='ncic.php';
});
$("#appeal").click(()=> {
window.location.href='appeal.php';
});
$("#warrant").click(()=> {
window.location.href='warrant.php';
});
$("#courtorder").click(()=> {
window.location.href='courtorder.php';
});
$("#prison").click(()=> {
window.location.href = 'prison.php';
});
$("#asset").click(()=> {
window.location.href = 'asset.php';
});
</script>
</body>
</html>
Comments
0 B
|0 👍
/0 👎
0 B
|👍
/👎