2023-10-09 20:46:26 +02:00
|
|
|
<?php
|
|
|
|
|
2023-10-10 11:04:06 +02:00
|
|
|
function get_unfallzahlen($numYear,$strLocation) {
|
|
|
|
global $db;
|
|
|
|
$strSQL="SELECT
|
|
|
|
UKATEGORIE, count(UKATEGORIE) as anz
|
|
|
|
FROM data
|
|
|
|
WHERE IstRad=1 AND UJAHR=$numYear $strLocation
|
|
|
|
GROUP BY UKATEGORIE";
|
|
|
|
$result = $db->query($strSQL);
|
|
|
|
$arrResult = $result->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
return $arrResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function get_beteiligte($numYear,$strLocation) {
|
2023-10-09 20:46:26 +02:00
|
|
|
global $db;
|
|
|
|
$strSQL="SELECT
|
2023-10-10 18:45:24 +02:00
|
|
|
-- sum(IstRad) as rad,
|
2023-10-09 20:46:26 +02:00
|
|
|
sum(IstPKW) as pkw,
|
|
|
|
sum(IstFuss) as fuss,
|
|
|
|
sum(IstKrad) as krad,
|
|
|
|
sum(IstGkfz) as lkw,
|
2023-10-10 11:04:06 +02:00
|
|
|
sum(IstSonstige) as sonstiges
|
2023-10-09 20:46:26 +02:00
|
|
|
FROM data
|
2023-10-10 11:04:06 +02:00
|
|
|
WHERE istRad=1 AND UJAHR =".$numYear.$strLocation;
|
2023-10-09 20:46:26 +02:00
|
|
|
$result = $db->query($strSQL);
|
2023-10-10 11:04:06 +02:00
|
|
|
if ($row = $result->fetch(PDO::FETCH_ASSOC)) { $arrResult = $row; }
|
2023-10-09 20:46:26 +02:00
|
|
|
|
|
|
|
$strSQL="SELECT count(*) as count FROM data
|
2023-10-10 11:04:06 +02:00
|
|
|
WHERE UJAHR=".$numYear." AND IstPKW=0 and IstFuss=0 and IstKrad=0 and IstGkfz=0
|
|
|
|
and IstSonstige=0 ".$strLocation;
|
|
|
|
$result = $db->query($strSQL);
|
2023-10-09 20:46:26 +02:00
|
|
|
if ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
2023-10-10 11:04:06 +02:00
|
|
|
$arrResult["gleich"]=$row['count'];
|
|
|
|
}
|
|
|
|
return $arrResult;
|
2023-10-09 20:46:26 +02:00
|
|
|
}
|
|
|
|
|
2023-10-10 11:04:06 +02:00
|
|
|
function get_unfalltyp($numYear,$strLocation){
|
2023-10-09 20:46:26 +02:00
|
|
|
global $db;
|
2023-10-10 11:04:06 +02:00
|
|
|
$strSQL="SELECT UTYP1, count(UTYP1) as anz FROM data WHERE istRad=1 AND UJAHR=".$numYear.$strLocation." GROUP BY UTYP1";
|
2023-10-09 20:46:26 +02:00
|
|
|
$result = $db->query($strSQL);
|
2023-10-10 11:04:06 +02:00
|
|
|
$arrResult = $result->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
return $arrResult;
|
2023-10-09 20:46:26 +02:00
|
|
|
}
|
|
|
|
|
2023-10-10 11:04:06 +02:00
|
|
|
function get_unfallart($numYear,$strLocation){
|
2023-10-09 20:46:26 +02:00
|
|
|
global $db;
|
2023-10-10 11:04:06 +02:00
|
|
|
$strSQL="SELECT UART, count(UART) as anz FROM data WHERE istRad=1 AND UJAHR=".$numYear.$strLocation." GROUP BY UART";
|
2023-10-09 20:46:26 +02:00
|
|
|
$result = $db->query($strSQL);
|
2023-10-10 11:04:06 +02:00
|
|
|
$arrResult = $result->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
return $arrResult;
|
2023-10-09 20:46:26 +02:00
|
|
|
}
|
|
|
|
|
2023-10-10 11:54:57 +02:00
|
|
|
function get_series($arrData,$arrBezeichnung,$strIndex1,$strIndex2="anz"){
|
2023-10-10 11:37:55 +02:00
|
|
|
$result="[";
|
|
|
|
foreach ($arrData as $row) {
|
2023-10-10 11:54:57 +02:00
|
|
|
$result.= "{ name: '".$arrBezeichnung[$row[$strIndex1]] ."', y: ".$row[$strIndex2]."},";
|
2023-10-10 11:37:55 +02:00
|
|
|
}
|
|
|
|
$result.="]";
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2023-10-10 12:22:16 +02:00
|
|
|
function get_series_beteiligte($arrData,$arrBezeichnung){
|
|
|
|
$result="[";
|
|
|
|
foreach ($arrData as $key => $numCount) {
|
|
|
|
if ($key!="rad") { // Fahrräder sind immer beteiligt.
|
|
|
|
$result .= "{name: '".$arrBezeichnung[$key]."', y: ".$numCount."},"; }
|
|
|
|
}
|
|
|
|
$result.="]";
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2023-10-10 18:45:24 +02:00
|
|
|
function get_verlauf($strLocation){
|
|
|
|
global $db;
|
|
|
|
$strSQL="SELECT
|
|
|
|
UJAHR, UKATEGORIE, count(UKATEGORIE) as anz
|
|
|
|
FROM data
|
|
|
|
WHERE IstRad=1 $strLocation
|
|
|
|
GROUP BY UJAHR,UKATEGORIE
|
|
|
|
ORDER BY UJAHR";
|
|
|
|
$result = $db->query($strSQL);
|
|
|
|
$arrResult = array();
|
|
|
|
while ($row = $result->fetch(PDO::FETCH_ASSOC)){
|
|
|
|
$arrResult[$row['UJAHR']][$row['UKATEGORIE']]=$row['anz'];
|
|
|
|
}
|
|
|
|
return $arrResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_row($arrData,$kategorie){
|
|
|
|
global $numStartYear;
|
|
|
|
global $numLatestYear;
|
|
|
|
$strResult="";
|
|
|
|
if ($kategorie==0) {
|
|
|
|
for ($i=$numLatestYear;$i>=$numStartYear;$i--){
|
|
|
|
$numAnzahl=0;
|
|
|
|
for ($kat=0;$kat<=3;$kat++) {
|
|
|
|
$numAnzahl+=(isset($arrData[$i][$kat])) ? $arrData[$i][$kat] : 0;
|
|
|
|
}
|
|
|
|
$strResult.="<td><strong>".$numAnzahl."</strong></td>";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for ($i=$numLatestYear;$i>=$numStartYear;$i--){
|
|
|
|
$strResult.="<td>";
|
|
|
|
$strResult.= (isset($arrData[$i][$kategorie])) ? $arrData[$i][$kategorie] : "0";
|
|
|
|
$strResult.="</td>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $strResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_series_verlauf($arrData,$arrBezeichnung){
|
|
|
|
global $numStartYear;
|
|
|
|
global $numLatestYear;
|
|
|
|
$strResult="[";
|
|
|
|
foreach ($arrBezeichnung as $key => $bezeichnung) {
|
|
|
|
$strResult .= "{ name: '".$bezeichnung."', data : [";
|
|
|
|
for ($i=$numLatestYear;$i>=$numStartYear;$i--){
|
|
|
|
$strResult .= (isset($arrData[$i][$key])) ? $arrData[$i][$key] : 0;
|
|
|
|
$strResult .=",";
|
|
|
|
}
|
|
|
|
$strResult=substr($strResult,0,-1)
|
|
|
|
; $strResult.="]},";
|
|
|
|
}
|
|
|
|
$strResult.="]";
|
|
|
|
return $strResult;
|
|
|
|
}
|
|
|
|
|