function createDropdown($dropdownarray, $arrayId, $arrayName, $selectGet, $selectName) { $listHtml = "<select name=\"{$selectGet}\">"; $listHtml .= "<option value=\"\">Select {$selectName}</option>"; foreach ($dropdownarray as $option) { $optionValue = $option->{$arrayId}; $optionText = $option->{$arrayName}; $listHtml .= "<option value=\"{$optionValue}\">{$optionText}</option>"; } $listHtml .= "</select>"; return $listHtml; } /* * Visits table gateway */ $visitsGateway = new VisitsTableGateway($dbAdapter); /* * Retrieves all visit information to be used for browser visits table */ $browserVisits = array(); $browsersGateway = new BrowserTableGateway($dbAdapter); $results = $browsersGateway->findAll(); $totalVisits = 0; foreach ($results as $result) { $browserVisits[$result->name] = $visitsGateway->countByBrowser($result->id); $totalVisits += $browserVisits[$result->name]; } foreach ($browserVisits as $key => $value) { $browserVisits[$key] = round($value / $totalVisits * 100, 2) . "%"; } $browserHeaders = array("Browser", "Visits");
<?php include 'dashboard1.php'; require_once 'lib/helpers/visits-setup.inc.php'; $gate = new VisitsTableGateway($dbAdapter); $result = $gate->findByBrowserPercent(); $result4 = $gate->findAllTables(); $gate2 = new DeviceBrandTableGateway($dbAdapter); $result2 = $gate2->findByName(); $gate3 = new ContinentTableGateway($dbAdapter); $result3 = $gate3->findByName(); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="description" content="A front-end template that helps you build fast, modern mobile web apps."> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Dashboard</title> <!-- Add to homescreen for Chrome on Android --> <meta name="mobile-web-app-capable" content="yes"> <link rel="icon" sizes="192x192" href="images/android-desktop.png"> <!-- Add to homescreen for Safari on iOS --> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-title" content="Material Design Lite"> <link rel="apple-touch-icon-precomposed" href="images/ios-desktop.png">
<html> <body> <h1> Table Gateways Tester </h1> <?php echo '<hr/>'; echo '<h2>Test BrowserTableGateway</h2>'; echo '<h3>Test findAll()</h3>'; $gate = new BrowserTableGateway($dbAdapter); $result = $gate->findAll(); foreach ($result as $row) { echo $row->id . " - " . $row->name . "<br/>"; } echo '<h3>Test findById(3)</h3>'; $gate = new VisitsTableGateway($dbAdapter); $result = $gate->findByBrowserPercent(); foreach ($result as $row) { echo "['" . $row->name . "', " . $row->num . "],"; } echo '<hr/>'; echo '<h2>Test DeviceBrandTableGateway</h2>'; echo '<h3>Test findAllSorted()</h3>'; $gate = new DeviceBrandTableGateway($dbAdapter); $result = $gate->findAllSorted(true); foreach ($result as $row) { echo $row->id . " - " . $row->name . "<br/>"; } echo '<h3>Test findById(11)</h3>'; $result = $gate->findById(11); echo $result->id . " - " . $result->name;
function actionData($userData, $actionType, $param, $param2) { require_once 'lib/helpers/visits-setup.inc.php'; $BrowsersToPull = new BrowserTableGateway($dbAdapter); $CountriesToPull = new CountriesTableGateway($dbAdapter); $VisitsToPull = new VisitsTableGateway($dbAdapter); $dataSets = array("Browsers", "Continents", "Countries", "DeviceBrand", "DeviceType", "OperatingSystems", "Referrers", "Visits"); if (in_array($userData, $dataSets)) { switch ($userData) { case "Visits": if ($actionType == "countmonth") { $dataOutput = $VisitsToPull->countByMonth($param); } elseif ($actionType == "countmonthbyday") { $dataOutput = $VisitsToPull->visitsByDayForMonth($param); } elseif ($actionType == "countbycountrycode") { $dataOutput = $VisitsToPull->countByCountryCode($param); } elseif ($actionType == "countbydevicetype") { $dataOutput = $VisitsToPull->countByDeviceType($param); } elseif ($actionType == "countbydevicebrand") { $dataOutput = $VisitsToPull->countByDeviceBrand($param); } elseif ($actionType == "countbybrowser") { $dataOutput = $VisitsToPull->countByBrowser($param); } elseif ($actionType == "countbyreferrer") { $dataOutput = $VisitsToPull->countByReferrer($param); } elseif ($actionType == "countbyos") { $dataOutput = $VisitsToPull->countByOS($param); } elseif ($actionType == "filtervisitsdata") { $dataOutput = $VisitsToPull->filterVisitsData($param, $param2); } elseif ($actionType == "visitsforbarchart") { $dataOutput = $VisitsToPull->visitsForBarChart($param); } else { $dataOutput = null; } echo json_encode($dataOutput); break; case "Countries": if ($actionType == "filterbycontinentcode") { $dataOutput = $CountriesToPull->filterByContinentCode($param); } elseif ($actionType == "countrieslike") { $dataOutput = $CountriesToPull->countryLike($param); } elseif ($actionType == "visitsbycountry") { $dataOutput = $CountriesToPull->visitsByCountry($param); } elseif ($actionType == "fetchcountrynames") { $dataOutput = $CountriesToPull->fetchCountryNames(); } elseif ($actionType == "fetchcountrynamestop10visits") { $dataOutput = $CountriesToPull->fetchCountryNamesTop10Visits(); } elseif ($actionType == "visitsbycountryfromcontinent") { $dataOutput = $CountriesToPull->visitsByCountryFromContinent($param); } else { $dataOutput = "Invalid Input"; } echo json_encode($dataOutput); break; case "Browsers": if ($actionType == "visitsbybrowser") { $dataOutput = $BrowsersToPull->visitsByBrowser(); } else { $dataOutput = "Invalid Input"; } echo json_encode($dataOutput); break; } } }