From e53714ed7c9fabf731f92cb873d75c8d0830cc13 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Mon, 19 Jun 2017 00:37:53 -0600 Subject: [PATCH] Add QwikClock widget --- apps/qwikclock_inout.php | 42 ++++++++++++++++++++++++++++++++++++++++ pages.php | 1 + settings.template.php | 2 ++ 3 files changed, 45 insertions(+) create mode 100644 apps/qwikclock_inout.php diff --git a/apps/qwikclock_inout.php b/apps/qwikclock_inout.php new file mode 100644 index 0000000..1f551a3 --- /dev/null +++ b/apps/qwikclock_inout.php @@ -0,0 +1,42 @@ + [ + "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 = "
" . $resp['msg'] . "
"; + } else { + $content = "
" . $resp['msg'] . "
"; + } + } catch (Exception $e) { + $content = "
" . lang("error loading widget", false) . " " . $e->getMessage() . "
"; + } +} +$lang_punchin = lang("punch in", false); +$lang_punchout = lang("punch out", false); +$content .= << $lang_punchin +
+ $lang_punchout +END; +$APPS["qwikclock_inout"]["content"] = $content; +?> \ No newline at end of file diff --git a/pages.php b/pages.php index deebc7b..5483494 100644 --- a/pages.php +++ b/pages.php @@ -18,6 +18,7 @@ define("APPS", [ "home" => [ "taskfloor_tasks", "taskfloor_messages", + "qwikclock_inout", "inventory_link", "account_security" ], diff --git a/settings.template.php b/settings.template.php index 09a13f5..bf73439 100644 --- a/settings.template.php +++ b/settings.template.php @@ -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");