initial commit
This commit is contained in:
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
include("verbind.php");
|
||||
// Tabellenname
|
||||
define("select_table", "newsletter");
|
||||
// Trennzeichen
|
||||
define("csv_delimeter", ",");
|
||||
error_reporting(0);
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
|
||||
//------------------------------------- Definitionen ----------------------------------------
|
||||
|
||||
|
||||
$ausw = $_GET['ausw'];
|
||||
// $wl= $_GET['wl'];
|
||||
$is= $_GET['is'];
|
||||
$abweichung= $_GET['ab'];
|
||||
$starttage= $_POST['starttage'];
|
||||
// if (empty($starttage)) {$starttage = $_GET['st'];}
|
||||
$startdatum= $_POST['startdatum'];
|
||||
// if (empty($startdatum)) {$startdatum = $_GET['sd'];}
|
||||
$endedatum= $_POST['endedatum'];
|
||||
$farbe= $_POST['farbe'];
|
||||
$legende= $_POST['legende'];
|
||||
$range= $_POST['range'];
|
||||
|
||||
|
||||
// if (empty($endedatum)) {$endedatum = $_GET['ed'];}
|
||||
$az=$_GET['az'];
|
||||
$anz=$_GET['anz'];
|
||||
|
||||
if (empty($abweichung)) {$abweichung = 0;}
|
||||
|
||||
if (empty($starttage)) {$starttage = $_GET['st'];}
|
||||
if (empty($startdatum)) {$startdatum = $_GET['sd'];}
|
||||
if (empty($endedatum)) {$endedatum = $_GET['ed'];}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// $anfang=$_POST['startdatum'];
|
||||
// $ende=$_POST['endedatum'];
|
||||
|
||||
echo "Daten des Graphen werden geladen<br>";
|
||||
|
||||
echo "Startdatum: $startdatum <br>";
|
||||
echo "Endedatum: $endedatum <br>";
|
||||
echo "Die vergangenen: $starttage Tage<br>";
|
||||
|
||||
//------------------------------------- Zeit aufbereiten ----------------------------------------
|
||||
|
||||
if (empty($starttage)) {
|
||||
|
||||
if (empty($startdatum)) {
|
||||
|
||||
$abwei= $abweichung.' month';
|
||||
$date = date('Y-m-j');
|
||||
$newdate = strtotime ( $abwei , strtotime ( $date ) ) ;
|
||||
$newdate = date ( 'Y-m-j' , $newdate );
|
||||
$sn = explode('-', $newdate);
|
||||
$startnewdate = $sn[0].'-'.$sn[1].'-01';
|
||||
$monatb= $sn[1];
|
||||
$jahr= $sn[0];
|
||||
$anzeigezeit1= $startnewdate;
|
||||
if ($abweichung !=0){$sn = explode('-', $newdate);$newdate = $sn[0].'-'.$sn[1].'-31';}
|
||||
$anzeigezeit2= $newdate;
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
$startdat = explode("-", $startdatum);
|
||||
$startdat = array_reverse($startdat);
|
||||
$startdat = implode("-", $startdat);
|
||||
$enddat = explode("-", $endedatum);
|
||||
$enddat = array_reverse($enddat);
|
||||
$enddat = implode("-", $enddat);
|
||||
|
||||
|
||||
|
||||
$anzeigezeit1= $startdat;
|
||||
$anzeigezeit2= $enddat;
|
||||
$anz= $startdatum.' bis '.$endedatum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
$tage= '-'.$starttage.' days';
|
||||
$erstdate = date('Y-m-j');
|
||||
$newstart = strtotime ( $tage , strtotime ( $erstdate ) ) ;
|
||||
$anzeigezeit1 = date ( 'Y-m-j' , $newstart );
|
||||
$anzeigezeit2 = date('Y-m-j');
|
||||
$anz= $startdat.' Die vergangenen '.$starttage.' Tage';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
echo "<br>";
|
||||
echo $anzeigezeit1;
|
||||
echo "<br>";
|
||||
echo $anzeigezeit2;
|
||||
*/
|
||||
$zeit= "WHERE DATE(datum) BETWEEN '$anzeigezeit1' AND '$anzeigezeit2' ";
|
||||
|
||||
switch ($monatb) {
|
||||
case 1: $monat= "Januar"; break;
|
||||
case 2: $monat= "Februar"; break;
|
||||
case 3: $monat= "März"; break;
|
||||
case 4: $monat= "April"; break;
|
||||
case 5: $monat= "Mai"; break;
|
||||
case 6: $monat= "Juni"; break;
|
||||
case 7: $monat= "Juli"; break;
|
||||
case 8: $monat= "August"; break;
|
||||
case 9: $monat= "September"; break;
|
||||
case 10: $monat= "Oktober"; break;
|
||||
case 11: $monat= "November"; break;
|
||||
case 12: $monat= "Dezember"; break;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------- Array anlegen und füllen ------------------------------------------
|
||||
|
||||
|
||||
$row_data = array();
|
||||
$row_werte = array();
|
||||
|
||||
//------------------------------------- Titelzeile -------------------------------------
|
||||
// zudem wird da auch die Abfrage für die Tabellendaten erzeugt
|
||||
// dabei wird die Positionierung sowie Teiler und Einheit berücksichtigt
|
||||
$row_data[] .="Datum ";
|
||||
|
||||
$sqlk = "SELECT isp_wert, isp_klar, einheit, teiler, tabelle2, tabelle FROM jumpgraph WHERE wahl=$ausw ORDER BY ID ";
|
||||
foreach ($pdo->query($sqlk) as $keyn) {
|
||||
$key_name= $keyn[isp_klar]."(".$keyn[einheit].")";
|
||||
//$key_name = str_replace(' ','',$key_name);
|
||||
$key_name = rawurlencode($key_name);
|
||||
$weg = array('%0D', '%0A');
|
||||
$key_name = str_replace($weg, '',$key_name);
|
||||
//$key_name = str_replace(array('\r', '\n', '\t', ' '), ' ', $key_name);
|
||||
$key_name = rawurldecode($key_name);
|
||||
$row_data[] .= $key_name ;
|
||||
//$row_werte[] .= round ($keyn[isp_wert]/$keyn[teiler],1);
|
||||
$nteiler = $keyn[teiler];
|
||||
$nwert = $keyn[isp_wert];
|
||||
$row_werte[] .= " round($nwert/$nteiler,1)";
|
||||
|
||||
//$row_werte[] .= $keyn[isp_wert];
|
||||
|
||||
$abfrageisp = $keyn[tabelle2];
|
||||
$ispname = $keyn[tabelle];
|
||||
}
|
||||
$result_row[$index] = implode(csv_delimeter, $row_data);
|
||||
$abfrage = implode(",", $row_werte);
|
||||
unset($row_data);
|
||||
unset($row_werte);
|
||||
|
||||
//------------------------------------- Tabellendaten -------------------------------------
|
||||
|
||||
$sql = "SELECT datum, $abfrage FROM $abfrageisp $zeit";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
while ($array_result = $stmt->fetch(PDO::FETCH_ASSOC)){
|
||||
|
||||
$row_data = array();
|
||||
$index = count($result_row)-1;
|
||||
foreach ( $array_result as $key => $value )
|
||||
{
|
||||
$row_data[] .= $value ;
|
||||
}
|
||||
$result_row[$index] = implode(csv_delimeter, $row_data);
|
||||
$max2= max($row_data);
|
||||
if ($max2>$max1){$max1=$max2;}
|
||||
$max= ceil($max1);
|
||||
unset($row_data);
|
||||
$up2++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------- CSV schreiben und anzeigen -------------------------------------
|
||||
|
||||
$inhalt= implode(PHP_EOL, $result_row);
|
||||
|
||||
|
||||
|
||||
$fp = fopen('graph.csv', 'w');
|
||||
fwrite($fp, $inhalt);
|
||||
fclose($fp);
|
||||
echo "Max: $max";
|
||||
echo "<meta http-equiv='refresh' content='2;
|
||||
URL=anzeige.php?inf=$ispname&max=$max&az=$az&is=$is&mo=$monat&ja=$jahr&ab=$abweichung&ausw=$ausw&anz=$anz&sd=$startdatum&ed=$endedatum&st=$starttage&hd=$farbe&az=$legende&ra=$range'>";
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user