| 
									
										
										
										
											2017-06-19 00:37:53 -06:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | dieifnotloggedin(); | 
					
						
							| 
									
										
										
										
											2017-07-03 03:27:08 -06:00
										 |  |  | require_once __DIR__ . "/../lib/login.php"; | 
					
						
							| 
									
										
										
										
											2017-06-19 00:37:53 -06:00
										 |  |  | addMultiLangStrings(["en_us" => [ | 
					
						
							|  |  |  |         "qwikclock" => "QwikClock", | 
					
						
							|  |  |  |         "punch in" => "Punch in", | 
					
						
							| 
									
										
										
										
											2017-07-03 03:27:08 -06:00
										 |  |  |         "punch out" => "Punch out", | 
					
						
							|  |  |  |         "permission denied" => "You do not have permission to do that." | 
					
						
							| 
									
										
										
										
											2017-06-19 00:37:53 -06:00
										 |  |  |     ] | 
					
						
							|  |  |  | ]); | 
					
						
							|  |  |  | $APPS["qwikclock_inout"]["i18n"] = TRUE; | 
					
						
							|  |  |  | $APPS["qwikclock_inout"]["title"] = "qwikclock"; | 
					
						
							|  |  |  | $APPS["qwikclock_inout"]["icon"] = "clock-o"; | 
					
						
							| 
									
										
										
										
											2017-06-19 00:54:49 -06:00
										 |  |  | $APPS["qwikclock_inout"]["type"] = "blue"; | 
					
						
							| 
									
										
										
										
											2017-06-19 00:37:53 -06:00
										 |  |  | $content = ""; | 
					
						
							| 
									
										
										
										
											2017-07-03 03:27:08 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | use GuzzleHttp\Exception\ClientException; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-19 00:37:53 -06:00
										 |  |  | 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") { | 
					
						
							| 
									
										
										
										
											2017-06-19 00:54:49 -06:00
										 |  |  |             $content = "<div class=\"alert alert-success alert-dismissable\"><button type=\"button\" class=\"close\">×</button>" . $resp['msg'] . "</div>"; | 
					
						
							| 
									
										
										
										
											2017-06-19 00:37:53 -06:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2017-06-19 00:54:49 -06:00
										 |  |  |             $content = "<div class=\"alert alert-danger alert-dismissable\"><button type=\"button\" class=\"close\">×</button>" . $resp['msg'] . "</div>"; | 
					
						
							| 
									
										
										
										
											2017-06-19 00:37:53 -06:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-07-03 03:27:08 -06:00
										 |  |  |     } catch (ClientException $e) { | 
					
						
							|  |  |  |         if ($e->getResponse()->getStatusCode() == 403) { | 
					
						
							|  |  |  |             $content = "<div class=\"alert alert-danger alert-dismissable\"><button type=\"button\" class=\"close\">×</button>" . lang("permission denied", false) . "</div>"; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-06-19 00:37:53 -06:00
										 |  |  |     } catch (Exception $e) { | 
					
						
							| 
									
										
										
										
											2017-06-19 00:54:49 -06:00
										 |  |  |         $content = "<div class=\"alert alert-danger alert-dismissable\"><button type=\"button\" class=\"close\">×</button>" . lang("error loading widget", false) . "  " . $e->getMessage() . "</div>"; | 
					
						
							| 
									
										
										
										
											2017-06-19 00:37:53 -06:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | $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> | 
					
						
							|  |  |  |                 <a href="home.php?qwikclock=punchout" class="btn btn-block btn-danger btn-lg"><i class="fa fa-stop"></i> $lang_punchout</a>         | 
					
						
							|  |  |  | END; | 
					
						
							| 
									
										
										
										
											2017-07-03 03:00:23 -06:00
										 |  |  | $content .= '<br /><a href="' . QWIKCLOCK_HOME . '" class="btn btn-primary btn-block mobile-app-hide">' . lang("open app", false) . '  <i class="fa fa-external-link-square"></i></a>'; | 
					
						
							| 
									
										
										
										
											2017-06-19 00:37:53 -06:00
										 |  |  | $APPS["qwikclock_inout"]["content"] = $content; | 
					
						
							| 
									
										
										
										
											2017-07-03 03:27:08 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (account_has_permission($_SESSION['username'], "QWIKCLOCK") !== true) { | 
					
						
							|  |  |  |     unset($APPS['qwikclock_inout']); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-06-19 00:37:53 -06:00
										 |  |  | ?>
 |