Initial commit: legacy WOPS PHP application
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
#Datenbank Verbindung einbinden
|
||||
require 'Connections/Connections.php';
|
||||
#Include datei für Loginüberprüfung
|
||||
include "Includes/Session.php";
|
||||
|
||||
$Eingeladen = $con->query("SELECT invite from invite where userid_fk = $Userid;")->fetch_object()->invite;
|
||||
|
||||
#Bestellung aller user Anzeigen
|
||||
function print_order_all()
|
||||
{
|
||||
global $con; # setzt die Variable CON für die Datenbank verbindung
|
||||
$Produkte = $con->query("SELECT Distinct Produktid_fk from Bestellungen;");
|
||||
#Ausgabe für jedes Bestellte Product
|
||||
echo '<div class="table-container"><table class="Print_table"><thead><tr><th>Name</th>';
|
||||
while($row = mysqli_fetch_array($Produkte))
|
||||
{
|
||||
$Produktid = $row['Produktid_fk'];
|
||||
$Produktname = $con->query("SELECT Name FROM produkte where ArtNr='{$Produktid}'")->fetch_object()->Name;
|
||||
echo "<th>$Produktname</th>";
|
||||
}
|
||||
echo '<th>Gesamt Preis</th></tr></thead><tbody>';
|
||||
#Auslesen für jeden user
|
||||
$users = $con->query("Select DISTINCT Userid_fk from Bestellungen;");
|
||||
while($row = mysqli_fetch_array($users))
|
||||
{
|
||||
#schreibt row variable in normale
|
||||
$D_userid = $row['Userid_fk'];
|
||||
#Deklaration arrays
|
||||
$OrderNum = array();
|
||||
#Userid durch name ersetzen
|
||||
$name = $con->query("SELECT CONCAT(Lname, ' ',Fname) as 'Name' FROM user where UserID='{$D_userid}'")->fetch_object()->Name;
|
||||
#Preis Pro user errechnen
|
||||
$g_Preis = $con->query("SELECT sum(Preis) as G_Preis FROM Bestellungen where Userid_fk='{$D_userid}';")->fetch_object()->G_Preis;
|
||||
$i = 0 ;
|
||||
$sql = $con->query("SELECT Anzahl FROM Bestellungen where Userid_fk='{$D_userid}';");
|
||||
while($ans = mysqli_fetch_array($sql))
|
||||
{
|
||||
$OrderNum[$i] = $ans['Anzahl'];
|
||||
$i++;
|
||||
}
|
||||
echo "<tr><td>$name</td>";
|
||||
for($x=0;$x<$i;$x++) {echo "<td>$OrderNum[$x]</td>";}
|
||||
echo "<td>$g_Preis</td>";
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tbody></table></div>';
|
||||
}
|
||||
|
||||
#Bestellung aller user Anzeigen
|
||||
function print_sum_of_order_all()
|
||||
{
|
||||
global $con; # setzt die Variable CON für die Datenbank verbindung
|
||||
$GesOrderNum = array();
|
||||
$i = 0;
|
||||
$Produkte = $con->query("SELECT Distinct Produktid_fk from Bestellungen;");
|
||||
$g_Preis = $con->query("SELECT sum(Preis) as G_Preis FROM Bestellungen;")->fetch_object()->G_Preis;
|
||||
#Ausgabe für jedes Bestellte Product
|
||||
echo '<div class="table-container"><table class="Print_table"><thead><tr>';
|
||||
while($row = mysqli_fetch_array($Produkte))
|
||||
{
|
||||
$Produktid = $row['Produktid_fk'];
|
||||
$Produktname = $con->query("SELECT Name FROM produkte where ArtNr='{$Produktid}'")->fetch_object()->Name;
|
||||
$GesOrderNum[$i] = $con->query("SELECT SUM(Anzahl) as 'Anzahl' from Bestellungen where Produktid_fk='{$Produktid}'")->fetch_object()->Anzahl;
|
||||
echo "<th>$Produktname</th>";
|
||||
$i++;
|
||||
}
|
||||
echo '<th>Preis</th></tr></thead><tbody><tr>';
|
||||
for($x=0;$x<$i;$x++) {echo "<td>$GesOrderNum[$x]</td>";}
|
||||
echo "<td>$g_Preis</td></tr></tbody></table></div>";
|
||||
}
|
||||
|
||||
if($Eingeladen == 1 )
|
||||
{
|
||||
echo '<div class="center"><h1>Gesamt Bestellung</h1>
|
||||
<div class="mediacenter">';
|
||||
print_order_all();
|
||||
echo '</div><h4>Summen</h4>
|
||||
<div class="mediacenter">';
|
||||
print_sum_of_order_all();
|
||||
echo '</div>
|
||||
<a href="#" onclick="javascript:showPopup()">Print</a>
|
||||
</div>';
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user