diff --git a/api/v1/get/application.php b/api/v1/get/application.php index 2c289f7..bec050f 100644 --- a/api/v1/get/application.php +++ b/api/v1/get/application.php @@ -151,9 +151,34 @@ switch ($action) { break; - default: - # code... - break; + case 'report_usage_servicereports': + $sql = 'SELECT YEAR(h.created) AS year, QUARTER(h.created) AS quarter, MONTH(h.created) as month, count(h.rowID) AS count FROM history h LEFT JOIN equipment e ON h.equipmentid = e.rowID where h.type = "ServiceReport" AND NOT e.productrowid = "31" GROUP BY YEAR(h.created), QUARTER(h.created), MONTH(h.created)'; + break; + + case 'report_usage_firmware': + $sql = 'SELECT YEAR(h.created) AS year,QUARTER(h.created) AS quarter, MONTH(h.created) as month, count(h.rowID) AS count FROM history h LEFT JOIN equipment e ON h.equipmentid=e.rowID where h.type="Firmware" AND NOT e.productrowid="31" GROUP BY YEAR(h.created),QUARTER(h.created), MONTH(h.created)'; + break; + + case 'report_usage_warranty': + $sql = 'SELECT YEAR(h.created) AS year, QUARTER(h.created) AS quarter, MONTH(h.created) as month, count(h.rowID) AS count FROM history h LEFT JOIN equipment e ON h.equipmentid = e.rowID where h.type = "Warranty" AND NOT e.productrowid = "31" GROUP BY YEAR(h.created), QUARTER(h.created), MONTH(h.created)'; + break; + + case 'report_usage_other': + $sql = 'SELECT YEAR(h.created) AS year, QUARTER(h.created) AS quarter, MONTH(h.created) as month, count(h.rowID) AS count FROM history h LEFT JOIN equipment e ON h.equipmentid = e.rowID where NOT h.type = "Warranty" OR NOT h.type = "Firmware" OR NOT h.type = "ServiceReport" GROUP BY YEAR(h.created), QUARTER(h.created), MONTH(h.created)'; + break; + + case 'report_usage_equipment': + $sql = 'SELECT YEAR(created) AS year, QUARTER(created) AS quarter, MONTH(created) as month, count(rowID) AS count FROM equipment GROUP BY YEAR(created), QUARTER(created), MONTH(created)'; + break; + + case 'report_usage_changes': + $sql = 'SELECT YEAR(created) AS year, QUARTER(created) AS quarter, MONTH(created) as month, count(rowID) AS count FROM changelog GROUP BY YEAR(created), QUARTER(created), MONTH(created)'; + break; + + case 'report_usage_users': + $sql = 'SELECT YEAR(created) AS year, QUARTER(created) AS quarter, MONTH(created) as month, count(id) AS count FROM users WHERE NOT view = "3" GROUP BY YEAR(created), QUARTER(created), MONTH(created)'; + break; + } $stmt = $pdo->prepare($sql); @@ -192,20 +217,11 @@ switch ($action) { } break; - case 'serviceforecast': - $messages = $stmt->fetchAll(PDO::FETCH_ASSOC); - break; - - case 'warrantyforecast': - $messages = $stmt->fetchAll(PDO::FETCH_ASSOC); - break; - - case 'geolocation': + default: $messages = $stmt->fetchAll(PDO::FETCH_ASSOC); break; } - //------------------------------------------ //Encrypt results //------------------------------------------ diff --git a/assets/functions.php b/assets/functions.php index ac8ea0e..46b68c1 100644 --- a/assets/functions.php +++ b/assets/functions.php @@ -234,7 +234,7 @@ echo <<$title - + diff --git a/usage_reporting.php b/usage_reporting.php new file mode 100644 index 0000000..ff752dd --- /dev/null +++ b/usage_reporting.php @@ -0,0 +1,165 @@ + + '; + + return $view; + } + +template_header('Usage', 'usage'); +$view = ' +
+
+ +
+

Usage overview

+

+
+
+
'; + + +$usage_firmware = usageReportingView(json_decode(json_encode($report_usage_firmware), true)) ?? ''; +$usage_servicereports = usageReportingView(json_decode(json_encode($report_usage_servicereports), true)) ?? ''; +$usage_warranty = usageReportingView(json_decode(json_encode($report_usage_warranty), true)) ?? ''; +$usage_other = usageReportingView(json_decode(json_encode($report_usage_other), true)) ?? ''; +$usage_equipment = usageReportingView(json_decode(json_encode($report_usage_equipment), true)) ?? ''; +$usage_changes = usageReportingView(json_decode(json_encode($report_usage_changes), true)) ?? ''; +$usage_users = usageReportingView(json_decode(json_encode($report_usage_users), true)) ?? ''; + +$view .= ' +
+
+
+ Firmware +
'.$usage_firmware.' +
+
+
+ ServiceReports +
'.$usage_servicereports.' +
+
+ +
+
+
+ Warranty +
'.$usage_warranty.' +
+
+
+ Other +
'.$usage_other.' +
+
+ +
+
+
+ Equipment +
'.$usage_equipment.' +
+
+
+ Changes +
'.$usage_changes.' +
+
+ +
+
+
+ Users +
'.$usage_users.' +
+
+'; + +//OUTPUT +echo $view; + +template_footer();