polygon-website-foss/directory_admin/give-currency.php

64 lines
2.7 KiB
PHP

<?php require $_SERVER['DOCUMENT_ROOT'].'/api/private/core.php';
use pizzaboxer\ProjectPolygon\Users;
use pizzaboxer\ProjectPolygon\PageBuilder;
use pizzaboxer\ProjectPolygon\Database;
Users::RequireAdmin(Users::STAFF_ADMINISTRATOR);
$pageBuilder = new PageBuilder(["title" => "Give ".SITE_CONFIG["site"]["currency"]]);
$pageBuilder->buildHeader();
?>
<h2 class="font-weight-normal">Give <?=SITE_CONFIG["site"]["currency"]?></h2>
<div class="row">
<div class="col-lg-6 py-4 divider-right">
<div class="form-group row">
<label for="username" class="col-sm-3 col-form-label">Username</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="username">
</div>
</div>
<div class="form-group row">
<label for="amount" class="col-sm-3 col-form-label">Amount</label>
<div class="col-sm-9">
<input type="number" class="form-control" id="amount">
</div>
</div>
<div class="form-group row" data-control="reason">
<label for="reason" class="col-sm-3 col-form-label">Reason</label>
<div class="col-sm-9">
<textarea class="form-control" id="reason"></textarea>
</div>
</div>
<div class="row">
<button class="btn btn-warning btn-block mx-3" data-control="giveCurrency"><span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" style="display:none"></span> Give <?=SITE_CONFIG["site"]["currency"]?></button>
</div>
</div>
<div class="col-lg-6 pt-3">
<h2 class="font-weight-normal">Some notes</h2>
<ul class="list-group">
<li class="list-group-item">dont mess up the economy with this (please)</li>
<li class="list-group-item">to take away <?=strtolower(SITE_CONFIG["site"]["currency"])?> just make it a negative number</li>
<li class="list-group-item">maximum amount of <?=strtolower(SITE_CONFIG["site"]["currency"])?> you can give/take at a time is 500 <?=strtolower(SITE_CONFIG["site"]["currency"])?></li>
<li class="list-group-item">you cant give someones <?=strtolower(SITE_CONFIG["site"]["currency"])?> amount negative (why would you)</li>
<li class="list-group-item">this is logged btw lol</li>
</ul>
</div>
</div>
<script>
//admin.js
$('button[data-control$="giveCurrency"]').on('click', this, function()
{
var button = this;
$(button).attr("disabled", "disabled").find("span").show();
$.post('/api/admin/giveCurrency', {"username":$("#username").val(), "amount":$("#amount").val(), "reason":$("#reason").val()}, function(data)
{
if(data.success){ toastr["success"](data.message); }
else{ toastr["error"](data.message); }
$(button).removeAttr("disabled").find("span").hide();
});
});
</script>
<?php $pageBuilder->buildFooter(); ?>