summaryrefslogtreecommitdiffstats
path: root/Bachelor/Entwicklung webbasierter Anwendungen/Praktikum5_6/f-fahrer.php
diff options
context:
space:
mode:
Diffstat (limited to 'Bachelor/Entwicklung webbasierter Anwendungen/Praktikum5_6/f-fahrer.php')
-rw-r--r--Bachelor/Entwicklung webbasierter Anwendungen/Praktikum5_6/f-fahrer.php161
1 files changed, 161 insertions, 0 deletions
diff --git a/Bachelor/Entwicklung webbasierter Anwendungen/Praktikum5_6/f-fahrer.php b/Bachelor/Entwicklung webbasierter Anwendungen/Praktikum5_6/f-fahrer.php
new file mode 100644
index 0000000..696a9fd
--- /dev/null
+++ b/Bachelor/Entwicklung webbasierter Anwendungen/Praktikum5_6/f-fahrer.php
@@ -0,0 +1,161 @@
+<?php
+ include ("classes.inc");
+ $Con=mysql_connect('localhost','ewa','ewa',3306)
+ or die('Could not connect: ' . mysql_error());
+ mysql_select_db('ewa') or die('Could not select database');
+ $query = "SELECT b.AuftragNr, b.SessionId, p.Bezeichnung, b.Lieferadresse, b.Zustand
+ FROM t_bestellung b
+ NATURAL JOIN t_pizza p
+ WHERE Zustand='unterwegs' or Zustand='geliefert' or Zustand='fertig'
+ ORDER BY Zeitpunkt
+ ";
+ $result = mysql_query($query) or die('Query failed: ' . mysql_error());
+
+ $Best = array();
+ $Adressen = array();
+
+ $n=0;
+ while($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
+ $Best[$n] = new Bestellung($line[AuftragNr],
+ $line[SessionId],
+ $line[Lieferadresse],
+ $line[Bezeichnung],
+ $line[Zustand]
+ );
+ $n++;
+ }
+ $adr_query =
+ "SELECT DISTINCT Lieferadresse
+ FROM t_bestellung
+ WHERE Zustand='unterwegs' or Zustand='geliefert' or Zustand='fertig'
+ ";
+ $adr_result = mysql_query($adr_query) or die('Query failed: ' . mysql_error());
+ $a=0;
+ while($adr_line = mysql_fetch_array($adr_result, MYSQL_ASSOC)) {
+ $Adressen[$a] = $adr_line[Lieferadresse];
+ $a++;
+ }
+
+ //if (isset($_POST))
+ if (isset($_GET))
+ {
+ foreach ($_GET as $key => $val)
+ {
+ //echo "$key $val \n";
+ $auftrg_nr = substr($key,2);
+ }
+ //if (is_array($Best))
+ {
+ foreach ($Best as $aktBest) {
+ if ($aktBest->AuftNr == $auftrg_nr)
+ {
+ $pzAktZust = $aktBest->getzustand();
+ $newZustand=$pzAktZust;
+ if ($pzAktZust == 'fertig')
+ $newZustand = 'unterwegs';
+ else if ($pzAktZust == 'unterwegs')
+ $newZustand = 'geliefert';
+ }
+ }
+ }
+ /*else
+ {
+ echo "HERE" ;
+ }*/
+
+ $update_str = "UPDATE t_bestellung b SET Zustand='$newZustand' WHERE b.AuftragNr = '$auftrg_nr'";
+ $res = mysql_query($update_str) or die('Query failed: ' . mysql_error());
+ $del_str = "DELETE FROM t_bestellung WHERE Zustand = 'geliefert' or Zustand=''";
+ $res = mysql_query($del_str) or die('Query failed: ' . mysql_error());
+ }
+?>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+ <title>Fahrer</title>
+ <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
+ <link rel="stylesheet" type="text/css" href="formats.css">
+ <script type="text/javascript">
+ <!--
+ function submit_form() {
+ document.fahrer.submit();
+ //parent.location.reload();
+ }
+ -->
+ </script>
+</head>
+
+<body>
+ <h1>Fahrer</h1>
+ <?php
+ //echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\" name=\"fahrer\">";
+ echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"GET\" name=\"fahrer\">";
+ //echo "<form action=\"http://www.fbi.h-da.de/cgi-bin/Echo.pl\" method=\"POST\" name=\"baecker\">";
+ ?>
+ <table>
+ <tr>
+ <td class="dummy">
+ </td>
+ </tr>
+ <tr>
+ <td class="dummy">
+ </td>
+ <td>unterwegs
+ </td>
+ <td>geliefert
+ </td>
+ </tr>
+ <?php
+
+ //if(is_array($Adressen))
+ foreach($Adressen as $akt_adr)
+ {
+ //if(is_array($Best))
+ {
+ foreach ($Best as $aktBest)
+ {
+ if ($akt_adr == $aktBest->adresse)
+ {
+ echo "<tr>\n";
+ echo "<td>";
+ $aktName = $aktBest->getpiz_name();
+ $nr = $aktBest->getauftnr();
+ $aktZustand = $aktBest->getzustand();
+ echo $aktName;
+ echo "</td>\n";
+ if ($aktZustand == 'fertig') {
+ echo "<td><input type=\"radio\" onclick=\"submit_form()\" name=\"nr$nr\" ></td>\n";
+ echo "<td><input type=\"radio\" name=\"nr$nr\" DISABLED></td>\n";
+ } else if ($aktZustand == 'unterwegs') {
+ echo "<td><input type=\"radio\" name=\"nr$nr\" DISABLED CHECKED> </td>\n";
+ echo "<td><input type=\"radio\" onclick=\"submit_form()\" name=\"nr$nr\"></td>\n";
+ } else if ($aktZustand == 'geliefert') {
+ echo "<td><input type=\"radio\" name=\"nr$nr\" DISABLED CHECKED> </td>\n";
+ echo "<td><input type=\"radio\" name=\"nr$nr\" DISABLED CHECKED> </td>\n";
+ }
+ echo "</tr>\n";
+ }
+ }
+ }
+
+ ?>
+ <!-- Adresse -->
+ <tr>
+ <td class="kunde" colspan="2">
+ <?php
+ echo $akt_adr."\n</td>\n";
+ $preis_query = "SELECT sum(Preis) FROM t_pizza p NATURAL JOIN t_bestellung WHERE Lieferadresse = '$akt_adr'";
+ $preis_result = mysql_query($preis_query) or die('Query failed: ' . mysql_error());
+ $preis = number_format(mysql_result($preis_result,0),2,".",",");
+ ?>
+ <td class="kunde" id="preis">
+ <?php echo $preis ?>
+ &euro;</td>
+ </tr>
+ <?php } ?>
+ </table>
+ </form>
+</body>
+</html> \ No newline at end of file