daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Aug 13th, 2016 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <style>
  3. table {
  4.     border-collapse: collapse;
  5.     text-align: center;
  6.     margin-top: 30px;
  7.     width: 600px;
  8.     margin: 30px auto;
  9. }
  10.  
  11. table tr {
  12.     border-bottom: 1px dotted grey;
  13. }
  14.  
  15.  
  16. table tr td {
  17.     margin-left: 20px;
  18. }
  19.  
  20. #leWindow {
  21.     width: 800px;
  22.     margin: 30px auto;
  23.     text-align: center;
  24. }
  25. </style>
  26. <link type="text/css" rel="stylesheet" href="alka.css">
  27. <script type="text/javascript" src="alka.js"></script>
  28. <body onload="load()">
  29.  
  30. <div id="leWindow">
  31. <?php
  32. $connect = connect();
  33.  
  34. $Artikel = $_POST["Artikel"];
  35. $Eingang = $_POST["Eingang"];
  36. $Unterschrift = $_POST["Unterschrift"];
  37. $Lagerplatz = $_POST["Lagerplatz"];
  38. $Bestand = getBestand($connect);
  39.  
  40. $NeuerBestand = $Bestand + $Eingang;
  41.  
  42. $artBool = artCheck($connect);
  43. $platzBool = lagerplatzCheck($connect);
  44.  
  45. if ($Eingang == "" || $Eingang <= 0 || $Unterschrift == "" || $Lagerplatz == "" || !$artBool || !$platzBool) {
  46.     echo "Irgendeine Angabe ist falsch :(";
  47.     select($connect);
  48.     die();
  49. }
  50.  
  51. else {
  52.     insert($connect);
  53.     select($connect);
  54.     die();
  55. }
  56.  
  57. function insert($conn) {
  58. global $Artikel, $Eingang, $Unterschrift, $Lagerplatz, $NeuerBestand;
  59.     $sql = "INSERT INTO Material (Artikel, Eingang, Ausgang,Datum, Unterschrift, Bestand, Lagerplatz)
  60.     VALUES ('$Artikel', $Eingang, 0, NOW(), '$Unterschrift', $NeuerBestand, '$Lagerplatz')";
  61.  
  62.     if ($conn->query($sql) === TRUE) {
  63.         echo "Neuen Eintrag erfolgreich gesetzt.<br><br>";
  64.     }
  65.     else {
  66.         die("Eintrag nicht korrekt. ");
  67.     }
  68. }
  69.  
  70. function connect() {
  71.     $servername = "*";
  72.     $username = "*";
  73.     $password = "*";
  74.     $dbname = "alkanetc_Demo";
  75.  
  76.     $conn = new mysqli($servername, $username, $password, $dbname);
  77.  
  78.     if ($conn->connect_error) {
  79.         die("Verbindung zur Datenbank fehlgeschlagen " . $conn->connect_error);
  80.     }
  81.    
  82.     $conn->query("SET NAMES'utf8'");
  83.    
  84.     return $conn;
  85. }
  86.  
  87.  
  88. function select($conn) {
  89.     $sql = "SELECT Artikel, Bestand, Lagerplatz, Datum FROM ( SELECT * FROM Material ORDER BY Datum DESC ) Material
  90.     GROUP BY Artikel ORDER BY Datum DESC";
  91.     $result = $conn->query($sql);
  92.  
  93.     if ($result->num_rows > 0) {
  94.         echo "<table><tr><th>Artikel</th>";
  95.         echo "<th>Bestand</th><th>Lagerplatz</th><th>Letzte Ă„nderung: </th></tr>";
  96.         while($row = $result->fetch_assoc()) {
  97.             echo "<tr><td>" . $row["Artikel"] . "</td>";
  98.             echo "<td>" . $row["Bestand"] . "</td>";
  99.             echo "<td>" . $row["Lagerplatz"] . "</td>";
  100.             echo "<td>" . $row["Datum"] . "</td></tr>";
  101.         }
  102.         echo "</table>";
  103.     }
  104.     else
  105.         echo "0 Ergebnisse";
  106. }
  107.  
  108. function artCheck($conn) {
  109.     global $Artikel;
  110.    
  111.     $sql = "SELECT Artikel FROM Material";
  112.     $result = $conn->query($sql);
  113.    
  114.     if ($result->num_rows > 0)
  115.         return 1;
  116.     else
  117.         return 0;
  118.    
  119.    
  120. }
  121.  
  122. function getBestand($conn) {
  123.     global $Artikel;
  124.    
  125.     $sql ="SELECT Bestand FROM ( SELECT * FROM Material WHERE Artikel = '$Artikel' ORDER BY Datum DESC ) Material GROUP BY Artikel";
  126.     $result = $conn->query($sql);
  127.    
  128.     if ($result->num_rows > 0) {
  129.         $row = $result->fetch_assoc();
  130.         return $row["Bestand"];
  131.         }
  132.    
  133.     else {
  134.         return 0;
  135.     }
  136. }
  137.  
  138. function lagerplatzCheck($conn) {
  139.     global $Artikel, $Lagerplatz;
  140.    
  141.     $sql ="SELECT * FROM ( SELECT * FROM Material ORDER BY Datum DESC ) Material  
  142.             WHERE Artikel = '$Artikel'";
  143.     $result = $conn->query($sql);
  144.    
  145.     if ($result->num_rows > 0) {
  146.         $row = $result->fetch_assoc();
  147.        
  148.         if ($row["Lagerplatz"] == $Lagerplatz) {
  149.             return 1;
  150.         }
  151.         return 0;  
  152.     }
  153.     else {
  154.         return 0;
  155.     }
  156. }
  157.  
  158. ?>
  159. </div>
  160.  
  161.  
  162.  
  163.  
  164.  
  165. </body>
  166. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top