Browse Source

Add QwikClock widget

tags/v1.0
Skylar Ittner 2 years ago
parent
commit
e53714ed7c
3 changed files with 45 additions and 0 deletions
  1. 42
    0
      apps/qwikclock_inout.php
  2. 1
    0
      pages.php
  3. 2
    0
      settings.template.php

+ 42
- 0
apps/qwikclock_inout.php View File

@@ -0,0 +1,42 @@
<?php

dieifnotloggedin();
addMultiLangStrings(["en_us" => [
"qwikclock" => "QwikClock",
"punch in" => "Punch in",
"punch out" => "Punch out"
]
]);
$APPS["qwikclock_inout"]["i18n"] = TRUE;
$APPS["qwikclock_inout"]["title"] = "qwikclock";
$APPS["qwikclock_inout"]["icon"] = "clock-o";
$content = "";
if (!is_empty($_GET['qwikclock']) && ($_GET['qwikclock'] === "punchin" || $_GET['qwikclock'] === "punchout")) {
try {
$client = new GuzzleHttp\Client();

$response = $client->request('POST', QWIKCLOCK_API, ['form_params' => [
'action' => $_GET['qwikclock'],
'username' => $_SESSION['username'],
'password' => $_SESSION['password']
]]);

$resp = json_decode($response->getBody(), TRUE);
if ($resp['status'] == "OK") {
$content = "<div class=\"alert alert-success\">" . $resp['msg'] . "</div>";
} else {
$content = "<div class=\"alert alert-danger\">" . $resp['msg'] . "</div>";
}
} catch (Exception $e) {
$content = "<div class=\"alert alert-danger\">" . lang("error loading widget", false) . " " . $e->getMessage() . "</div>";
}
}
$lang_punchin = lang("punch in", false);
$lang_punchout = lang("punch out", false);
$content .= <<<END
<a href="home.php?&qwikclock=punchin" class="btn btn-block btn-success btn-lg"><i class="fa fa-play"></i> $lang_punchin</a>
<br />
<a href="home.php?qwikclock=punchout" class="btn btn-block btn-danger btn-lg"><i class="fa fa-stop"></i> $lang_punchout</a>
END;
$APPS["qwikclock_inout"]["content"] = $content;
?>

+ 1
- 0
pages.php View File

@@ -18,6 +18,7 @@ define("APPS", [
"home" => [
"taskfloor_tasks",
"taskfloor_messages",
"qwikclock_inout",
"inventory_link",
"account_security"
],

+ 2
- 0
settings.template.php View File

@@ -62,6 +62,8 @@ define('TASKFLOOR_HOME', '/taskfloor/app.php');

define('INVENTORY_HOME', '/inventory/app.php');

define('QWIKCLOCK_API', 'http://localhost/qwikclock/api.php');

// See lang folder for language options
define('LANGUAGE', "en_us");


Loading…
Cancel
Save