done. xml created and is dispayed. can’t download it. don’t know how.

This commit is contained in:
Ivan Hörler 2017-03-03 12:43:19 +01:00
parent 05eef451e0
commit d0359a3159
4 changed files with 65 additions and 25 deletions

View File

@ -48,6 +48,7 @@ CREATE TABLE IF NOT EXISTS `bsldb`.`anbieter` (
`erfassungs_id` int(11) NOT NULL,
`angebot_preis` DECIMAL(7,2) NOT NULL,
`angebot_datum` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`angebot_file` varchar(63) NOT NULL,
PRIMARY KEY (`angebot_id`),
FOREIGN KEY (`benutzer_id`) REFERENCES `benutzer` (benutzer_id),
FOREIGN KEY (`erfassungs_id`) REFERENCES `nachfrager` (erfassungs_id)

View File

@ -1,5 +1,4 @@
<?php
require_once("session.php");
require_once("config.php");
require_once("class.user.php");
@ -11,7 +10,6 @@
$stmt->execute(array(":user_id"=>$user_id));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html>
@ -33,13 +31,13 @@
<th>Lieferung</th>
<th>Angebot</th>
<th colspan="2">Alle Angebote vom Günstigsten zum Teuersten</th>
<?php
<?php try {
foreach ($db->query("
SELECT * FROM nachfrager
LEFT JOIN anbieter
ON nachfrager.erfassungs_id = anbieter.erfassungs_id
WHERE nachfrager.benutzer_id = $user_id
ORDER BY anbieter.angebot_preis ASC
ORDER BY nachfrager.nachfr_typ ASC, anbieter.angebot_preis ASC
") as $row) {
echo
"<tr>" .
@ -55,20 +53,30 @@
}else{echo
"k.A." . "&nbsp;" . "</td>";
}
if (!empty(htmlentities($row['angebot_preis']))) {
if (!empty(htmlentities($row['angebot_file']))) {
echo
"<td>" .
"<form action='xml/" . htmlentities($row['angebot_file']) . "'>" .
"<input class='sbtn' type='submit' value='Download' />" .
"</form>" .
"</td>";
}
if (!empty(htmlentities($row['angebot_preis'])) AND empty(htmlentities($row['angebot_file']))) {
echo
"<td>" .
"<form method='GET' action='". "xml2.php" ."'>" .
"<input type='hidden' name='angebot_id' value='".htmlentities($row['angebot_id'])."'/>" .
"<input class='sbtn' type='submit' name='annehmen' value='Angebot annehmen' />" .
"</form>" .
"</td>" .
"</tr>";
} else {
"<td>" . "" .
"</td>" .
"</td>";
}
"</tr>";
}
} catch (Exception $e) {
echo $e->getMessage();
echo $e;
}
?>
</table>

View File

@ -66,7 +66,12 @@ if (isset($_GET['keywords'])) {
"<td>" . htmlentities($row['nachfr_menge']) . "&nbsp;" . "</td>" .
"<td>" . htmlentities($row['nachfr_quali']) . "&nbsp;" . "</td>" .
"<td>" . htmlentities($row['nachfr_lieferdatum']) . "&nbsp;" . "</td>" .
"<td>" . "<a href='angebot.php?id=" . $row['erfassungs_id'] . "'> Details --> </a>" . "</td>" .
"<td>" .
"<form method='GET' action='angebot.php'>" .
"<input class='sbtn' type='submit' value='Details' />" .
"<input class='sbtn' type='hidden' name='id' value='".htmlentities($row['erfassungs_id'])."' />" .
"</form>" .
"</td>" .
"</tr>";
}
}

View File

@ -15,6 +15,10 @@ if (isset($_GET['angebot_id'])) {
echo "ein problem ist aufgetreten.";
break;
}
//filename and path
$path="xml/";
$file="angebot_" . $_GET['angebot_id'] . ".xml";
//add root == artikel
$artikel = $dom->appendChild($dom->createElement('artikel'));
while ($result_array = $query->fetch(PDO::FETCH_ASSOC)) {
@ -22,7 +26,6 @@ while ($result_array = $query->fetch(PDO::FETCH_ASSOC)) {
foreach($result_array as $key => $value) {
//$key holds the table column name
//add track element to jukebox
$keys = $dom->createElement($key,$value);
$artikel->appendChild($keys);
@ -33,6 +36,29 @@ $dom->formatOutput = true; // set the formatOutput attribute of domDocument to t
// save XML as string or file
$test1 = $dom->saveXML(); // put string in test1
echo $test1;
//$dom->save('test1.xml'); // save as file
//echo $test1;
$dom->save($path.$file); // save as file
// Filepath wird in Datenbank gespeichert
if($file=="") {
$error[] = "es ist was mit dem Filepath falsch gelaufen.";
} else {
try{
$query = $db->query("
UPDATE anbieter
SET angebot_file='$file'
WHERE angebot_id='$angebot_id'
");
/*** close the database connection ***/
//$db = null;
} catch(PDOException $e) {
echo $e->getMessage();
}
$error[] = "Ihr Angebot ist nun über den Link nun bereitgestellt";
}
// Redirect to this page.
header("Location: " . "profile.php");
exit();
?>