diff --git a/add_demand.php b/add_demand.php index b3f4651..11e203b 100644 --- a/add_demand.php +++ b/add_demand.php @@ -49,6 +49,8 @@ date_default_timezone_set('Europe/Amsterdam'); Minimum required pieces


+ Delivery Date in YYYY-MM-DD format
+
Description

diff --git a/edit_demand.php b/edit_demand.php index 4968be7..fd3972f 100644 --- a/edit_demand.php +++ b/edit_demand.php @@ -38,6 +38,7 @@ date_default_timezone_set('Europe/Amsterdam'); $demandId = $_POST['demandId']; $piecesMax = $_POST['piecesMax']; $piecesMin = $_POST['piecesMin']; + $deliveryDate = $_POST['deliveryDate']; $title= $_POST['title']; $text = $_POST['text']; @@ -48,11 +49,13 @@ date_default_timezone_set('Europe/Amsterdam'); Maximum required pieces

Minimum required pieces
- +
+ Delivery Date in YYYY-MM-DD format
+

Description

- "; + "; ?> diff --git a/functions.php b/functions.php index 05ed8f8..aaf7507 100644 --- a/functions.php +++ b/functions.php @@ -77,6 +77,7 @@ function post_demand () $piecesMax = $_POST['piecesMax']; $piecesMin = $_POST['piecesMin']; $qualityId = $_POST['quality']; + $deliveryDate = $_POST['deliveryDate']; $title = $_POST['title']; $text = $_POST['text']; // Inserts Data into Database @@ -86,9 +87,10 @@ function post_demand () "; } else { $sql = "INSERT INTO demands (piecesMax, piecesMin, demandText, - demandTitle, userId, qualityId) + demandTitle, userId, deliveryDate, + qualityId) VALUES ('$piecesMax', '$piecesMin', '$text', '$title', - '$userId', '$qualityId')"; + '$userId', '$deliveryDate', '$qualityId')"; $result = mysqli_query($con, $sql) or die(mysqli_error($con)); } } @@ -121,6 +123,7 @@ function get_demand_titles () + @@ -138,6 +141,7 @@ function edit_demand () $demandId = $_POST['demandId']; $piecesMax = $_POST['piecesMax']; $piecesMin = $_POST['piecesMin']; + $deliveryDate = $_POST['deliveryDate']; $title = $_POST['title']; $text = $_POST['text']; @@ -151,7 +155,8 @@ function edit_demand () SET piecesMax='$piecesMax', piecesMin='$piecesMin', demandTitle='$title', - demandText='$text' + demandText='$text', + deliveryDate='$deliveryDate' WHERE demandId='$demandId'"; $result = mysqli_query($con, $sql) or die(mysqli_error($con)); header("Location: board.php"); @@ -194,13 +199,33 @@ function show_demand () echo "Maximum required pieces: " . $demand_rows->piecesMax; echo "

"; - echo "Minimumrequired pieces: " . $demand_rows->piecesMin; + echo "Minimum required pieces: " . $demand_rows->piecesMin; echo "

"; - echo "Quality: " . $quality_rows->qualityName; + echo "Desired Date of Delivery: " . $demand_rows->deliveryDate; + echo "
+
"; + echo "Desired Quality: " . $quality_rows->qualityName; echo "

Description:
"; echo $demand_rows->demandText; } + +function post_offer() +{ + if (isset($_POST['submit'])) { + global $con; + $userId = get_userid(); + $pieces = $_POST['pieces']; + $price = $_POST['price']; + $qualityId = $_POST['quality']; + $text = $_POST['text']; + // Inserts Data into Database + $sql = "INSERT INTO offers (pieces, text, price, userId, qualityId) + VALUES ('$pieces', '$text', '$price', '$userId', '$qualityId')"; + $result = mysqli_query($con, $sql) or die(mysqli_error($con)); + } +} + ?> diff --git a/show_demand.php b/show_demand.php index fc4c804..97dc1d6 100644 --- a/show_demand.php +++ b/show_demand.php @@ -31,5 +31,9 @@ include 'functions.php'; show_demand(); ?> +
+
+ +
diff --git a/sql/create_db.sql b/sql/create_db.sql index 019c145..b704731 100644 --- a/sql/create_db.sql +++ b/sql/create_db.sql @@ -43,6 +43,7 @@ CREATE TABLE if not exists `demands` ( `piecesMin` int(11) NOT NULL, `piecesMax` int(11) DEFAULT NULL, `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `deliveryDate` varchar(10) NOT NULL, `qualityId` int(11) NOT NULL, `userId` int(11) NOT NULL, `tagId` int(11) NULL, @@ -62,8 +63,11 @@ CREATE TABLE if not exists `offers` ( `delivery` bool NOT NULL, `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `userId` int(11) NOT NULL, + `qualityId` int(11) NOT NULL, CONSTRAINT `fk_offers_userId` - FOREIGN KEY (userId) REFERENCES users (userId) + FOREIGN KEY (userId) REFERENCES users (userId), + CONSTRAINT `fk_offers_qualityId` + FOREIGN KEY (qualityId) REFERENCES quality (qualityId) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;