Add /get and #requirements to message.

This commit is contained in:
Ceda EI 2018-07-02 22:42:19 +05:30
parent ad8786da00
commit f606bf329f
1 changed files with 13 additions and 5 deletions

View File

@ -93,7 +93,7 @@ function add_requirement() {
$stmt->execute();
$conn->close();
send_html("Added to requirements");
get_updated_req();
edit_html(get_updated_req());
}
function deposit(){
@ -114,7 +114,7 @@ function deposit(){
$stmt->execute();
$conn->close();
send_html("Deposited!");
get_updated_req();
edit_html(get_updated_req());
}
function get_updated_req() {
@ -126,15 +126,15 @@ function get_updated_req() {
$sql = "SELECT name, quantity FROM req WHERE quantity > 0;";
$result = $conn->query($sql);
$text = "";
$text = "#requirements\n";
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$text .= $row["name"] . " " . $row["quantity"] . "\n";
}
} else {
$text = "Everything is complete";
$text .= "Everything is complete";
}
edit_html($text);
return $text;
}
function everyone() {
@ -147,6 +147,10 @@ function everyone() {
send_html($text);
}
function get_req() {
send_html(get_updated_req());
}
// Get JSON from post, store it and decode it.
$var = file_get_contents('php://input');
$decoded = json_decode($var);
@ -174,6 +178,10 @@ $modules = array(
array(
"command" => "/everyone",
"function" => "everyone();"
),
array(
"command" => "/get",
"function" => "get_req();"
)
);