<?php

/** *****************************
 * Ideenmelder
 * Autor: Walter Hupfeld, Hamm
 * E-Mail: info@hupfeld-software.de
 * Version: 3.0
 * Datum: 18.02.2024
 * zuletzt bearbeitet: 11.03.2024
 ******************************** */

require_once("config.db.php");

$boolTopics=false;

$strSQL = "select * from config";
$result = $db->query($strSQL);

// Allegemeine Konfiguration
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
    switch ($row['key']) {
        case "uploaddir" : 
            $uploaddir=$row['value'];
        break;
        case "title" :
            $strTitle=$row['value'];
        break;
        case "logo":
            $strLogo=$row['value'];
        break;
        case "contactEmail":
            $contactEmail =$row['value'];
        break;
        case "introText":
            $strIntroText =$row['value'];
        break;
        case "impressum":
            $strImpressum =$row['value'];
        break;
        case "url":
            $strUrl   =$row['value'];
        break;
        case "UrlBez":
            $strUrlBez   =$row['value'];
        break;
        case "boolRating":
            $boolRating = ($row['value']=="1");
        break;            
        case "boolComment":
            $boolComment = ($row['value']=="1");
        break;            
        case "boolUpload":
            $boolUpload = ($row['value']=="1");
        break;            
        case "boolDefect":
            $boolDefect = ($row['value']=="1");
        break; 
        case "boolUserinfo":
            $boolUserinfo = ($row['value']=="1");
        break; 
        case "boolDistrictSelection":
            $boolDistrictSelection  = ($row['value']=="1");
        break;
        case "boolApprove":
            $boolApprove  = ($row['value']=="1");
        break;

        default: ;
                //echo "Fehler bei ".$row['key'];
        // Ende Lokalisierung
        break;
    }
    
}

// Falls der Parameter district fehlt => Hamm
$result= $db->prepare("SELECT count(*) FROM district WHERE district=:district");
$result->bindParam(":district",$strDistrict);
$result->execute(); 
if ($row=$result->fetch(PDO::FETCH_NUM)) {
    if ($row[0]==0) {
        $strDistrict="unkown";  //default setzten
        $strDistrictTitle="Unbekannt";
    }
}
   
// Spezifische Konfiguration für Districtt
$result= $db->prepare("SELECT * FROM district WHERE district=:district");
$result->bindParam(":district",$strDistrict);
$result->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {

    $boolActive = $row['active']==1;
    $strDistrict = $row['district'];
    $strDistrictTitle = $row['title'];
    $strGeojson = $row['geojson'];

    $numULAND=$row['ULAND'];
    $numUREGBEZ=$row['UREGBEZ'];
    $numUKREIS=$row['UKREIS'];
    $numUGEMEINDE=$row['UGEMEINDE'];

    $numInfoLat=$row['lat'];
    $numInfoLng=$row['lng'];
    $numZoom=$row['zoom'];

    $strIntroText = ($boolActive) ? $strIntroText : "Dateneingabe nicht möglich";
    $fileGeojson ="geojson/$strGeojson";
    $strLocation = " AND ULAND=$numULAND AND UREGBEZ=$numUREGBEZ  AND UKREIS=$numUKREIS  ";
    if ($numUGEMEINDE>0) {
        $strLocation .= "AND UGEMEINDE=$numUGEMEINDE";
    }
}

// Arrax mit allen Distrikten für Auswahl
$arrDisctrict = array ();
$strSQL = "SELECT district,title FROM district WHERE active=1 ORDER BY title ASC";
$result=$db->query($strSQL);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
    $arrDistrict[$row['district']]=$row['title'];
}

$arrTopic = array (
    2 => "Radverkehr",
//    1 => "Fußverkehr",
//    3 => "Bus und Bahn",
//    4 => "Pkw-Verkehr",
//    5 => "Lkw-Verkehr"
); 

$arrMarkerType = array (
    1=>"pedestrianMarker",
    2=>"bicycleMarker",
    3=>"trainMarker",
    4=>"carMarker",
    5=>"truckMarker",
   );

$arrIcon = array (
    1 => "<i class='wa bg-info fa fa-male'></i>",
    2 => "<i class='wa bg-success fa fa-bicycle'></i>",
    3 => "<i class='wa bg-primary fa fa-bus'></i>",
    4 => "<i class='wa bg-danger fa fa-car'></i>",
    5 => "<i class='wa bg-warning fa fa-truck'></i>"
);

$arrAge = array (
    1 => "keine Angabe",
    2 => "bis 14 Jahre",
    3 => "15-17 Jahre",
    4 => "18-25 Jahre",
    5 => "25-39 Jahre",
    6 => "40-64 Jahre",
    7 => "65 Jahre und älter",
);

$arrDefect = array (
   0 => "--Bitte wählen--",
   1 => "Pfosten/Poller", 
   2 => "Schranke",
   3 => "Umlaufsperre/Drängelgitter",
   4 => "Laternenmast",
   5 => "Litfaßsäule",
   6 => "Stromverteilerkasten",
   7 => "Sonstiges"

);

$arrTransport = array (
    0 => "keine Angabe",
    1 => "kein Auto",
    2 => "Auto",
    3 => "Motorroller/Motorrad",
    4 => "Bus/Bahn",
    5 => "Fahrrad",
    6 => "Zu Fuß"
);   

