diff --git a/AddBid.php b/AddBid.php index 9fae2c4..c6345c8 100644 --- a/AddBid.php +++ b/AddBid.php @@ -91,7 +91,6 @@ function( settings, data, dataIndex ) { oReq.send(); var oReq2 = new XMLHttpRequest(); - oReq2.onload = function() { bidders = JSON.parse(this.responseText).aaData; }; diff --git a/BuyNow.php b/BuyNow.php new file mode 100644 index 0000000..3f3ca23 --- /dev/null +++ b/BuyNow.php @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
AuctionIdDescriptionValueQuantity
+
+
+ + +
Quantity cannot be negative
+
Must Enter BidderID
+
That Bidder Number does not exist
+ +
+ +
+ \ No newline at end of file diff --git a/NewDatabase.sql b/NewDatabase.sql index 7baa761..83564fb 100644 --- a/NewDatabase.sql +++ b/NewDatabase.sql @@ -10,6 +10,7 @@ USE `fbcmtown_auctionITdb`; -- Table structure for table `accounts` -- + DROP TABLE IF EXISTS `accounts`; CREATE TABLE `accounts` ( `auto_id` int(11) NOT NULL AUTO_INCREMENT, @@ -191,12 +192,9 @@ VIEW `view_auction_items_sheet` AS (SELECT `auction_items`.`auction_id` AS `auction_id`, SUM(`auction_items`.`value`) AS `value`, - GROUP_CONCAT(DISTINCT `auction_items`.`description` - SEPARATOR ', ') AS `description`, - GROUP_CONCAT(DISTINCT `auction_items`.`description2` - SEPARATOR ', ') AS `description2`, - GROUP_CONCAT(DISTINCT `auction_items`.`donated_by` - SEPARATOR ', ') AS `donated_by`, + GROUP_CONCAT(DISTINCT `auction_items`.`description` SEPARATOR ', ') AS `description`, + GROUP_CONCAT(DISTINCT `auction_items`.`description2` SEPARATOR ', ') AS `description2`, + GROUP_CONCAT(DISTINCT `auction_items`.`donated_by` SEPARATOR ', ') AS `donated_by`, `b`.`bidder_id` AS `winning_bidder_id`, `bidders`.`name` AS `winning_bidder`, `b`.`amount` AS `winning_bid`, @@ -218,7 +216,9 @@ VIEW `view_auction_items_sheet` AS LEFT JOIN `bidders` ON ((`bidders`.`bidder_id` = `b`.`bidder_id`))) WHERE (`auction_items`.`auction_id` IS NOT NULL) - GROUP BY `auction_items`.`auction_id`) UNION (SELECT + GROUP BY `auction_items`.`auction_id`, `b`.`bidder_id`) + UNION + (SELECT `auction_items`.`auction_id` AS `auction_id`, `auction_items`.`value` AS `value`, `auction_items`.`description` AS `description`, @@ -335,6 +335,34 @@ VIEW `view_receipts` AS AND (`p`.`bidder_id` = `b`.`bidder_id`)); +drop view if exists view_six_hundreds; +CREATE + ALGORITHM = UNDEFINED + SQL SECURITY DEFINER +VIEW `view_six_hundreds` AS + SELECT * + FROM `view_auction_items_sheet` + where `auction_id` >= 600; + +drop procedure if exists buy_now; + +DELIMITER ;; +CREATE PROCEDURE buy_now (IN AuctionId INT, IN BidderId INT, IN Amount INT) +BEGIN +IF (AuctionId > 599 AND AuctionId < 700) THEN + IF EXISTS (SELECT * FROM purchases WHERE auction_id = AuctionId AND bidder_id = BidderId) THEN + UPDATE purchases + SET purchases.quantity = (purchases.quantity + Amount), purchases.price = (select `value` from auction_items where auction_id = AuctionId) + WHERE auction_id = AuctionId AND bidder_id = BidderId; + ELSE + INSERT INTO purchases (auction_id, bidder_id, price, quantity) + VALUES (AuctionId, BidderId, (select `value` from auction_items where auction_id = AuctionId), Amount); + End IF; +END IF; +END ;; + +DELIMITER ; + -- -- Dumping routines for database 'fbcmtown_auctionITdb' -- diff --git a/PhpScripts/BuyNowDatabase.php b/PhpScripts/BuyNowDatabase.php new file mode 100644 index 0000000..7eee5df --- /dev/null +++ b/PhpScripts/BuyNowDatabase.php @@ -0,0 +1,29 @@ +real_escape_string($_POST['auctionID']); +$bidderID = $conn->real_escape_string($_POST['bidderID']); +$amount = $conn->real_escape_string($_POST['amount']); + +$sql = "CALL buy_now(" . $auctionID. "," . $bidderID . "," . $amount .")"; +$result = $conn->query($sql); +session_start(); + +/* +if (!$result) { + $_SESSION['bidSuccess'] = 2; + die("Couldn't enter data: ".$conn->error); +} +else { +$_SESSION['bidSuccess'] = 1; +$_SESSION["result"] = $result; + +} */ + + +$conn->close(); +?> diff --git a/PhpScripts/DatabaseConnection.php b/PhpScripts/DatabaseConnection.php index f8a0ec8..0cc6b72 100644 --- a/PhpScripts/DatabaseConnection.php +++ b/PhpScripts/DatabaseConnection.php @@ -1,39 +1,15 @@ connect_error); return $conn; } - - - - - +?> diff --git a/PhpScripts/FPDFWrapperHelpers.php b/PhpScripts/FPDFWrapperHelpers.php index 47d20b6..7d0c1ec 100644 --- a/PhpScripts/FPDFWrapperHelpers.php +++ b/PhpScripts/FPDFWrapperHelpers.php @@ -45,31 +45,31 @@ function GetReceiptsFromPurchases($purchases, $bidderID) { foreach ($purchases as $purchase) { - // Check if a receipt for that buyer is already started + // Check if the receipt is for a specific user and that the purchase is theirs if (!isset($bidderID) || ($purchase['bidder_id'] == $bidderID)) { + + // Check if a receipt for that buyer is already started if (isset($receipts[$purchase['bidder_id']])) { - $receipts[$purchase['bidder_id']]['total'] = $receipts[$purchase['bidder_id']]['total'] == '______' ? '______' : ($purchase['value'] > 0 ? $receipts[$purchase['bidder_id']]['total'] + $purchase['value'] : '______'); - $receipts[$purchase['bidder_id']]['items'][count($receipts[$purchase['bidder_id']]['items'])] = array( + $receipts[$purchase['bidder_id']]['total'] += $purchase['price'] * $purchase['quantity']; + $receipts[$purchase['bidder_id']]['items'][] = array( "auction_id" => $purchase['auction_id'], - "value" => $purchase['value'] > 0 ? $purchase['value'] : "______", + "price" => $purchase['price'] * $purchase['quantity'], "description" => $purchase['description'] ); } else { $receipts[$purchase['bidder_id']] = array( "bidder_id" => $purchase['bidder_id'], "name" => $purchase['name'], - "total" => $purchase['value'] > 0 ? $purchase['value'] : '______', + "total" => $purchase['price'] * $purchase['quantity'], "items" => array( array( "auction_id" => $purchase['auction_id'], - "value" => $purchase['value'] > 0 ? $purchase['value'] : "______", + "price" => $purchase['price'] * $purchase['quantity'], "description" => $purchase['description'] ) ) ); } - } else { - } } @@ -85,7 +85,7 @@ function GetDonorsAndTotals($donations) { // Check if a receipt for that buyer is already started if (isset($donors[$donation['donated_by']])) { $donors[$donation['donated_by']]['total'] = $donors[$donation['donated_by']]['total'] == '______' ? '______' : ($donation['value'] > 0 ? $donors[$donation['donated_by']]['total'] + $donation['value'] : '______'); - $donors[$donation['donated_by']]['items'][count($donors[$donation['donated_by']]['items'])] = array( + $donors[$donation['donated_by']]['items'][] = array( "auction_id" => $donation['auction_id'], "value" => $donation['value'] > 0 ? $donation['value'] : "______", "description" => $donation['description'] diff --git a/PhpScripts/Templates/Nav.php b/PhpScripts/Templates/Nav.php index b83c3d3..c7e35bd 100644 --- a/PhpScripts/Templates/Nav.php +++ b/PhpScripts/Templates/Nav.php @@ -33,7 +33,10 @@ break; case("AccountEditor.php"): echo("Account Editor"); - break; + break; + case("BuyNow.php"): + echo("Buy Now"); + break; default: echo(basename($_SERVER['PHP_SELF'])); break; @@ -57,6 +60,9 @@
  • Add Bid

  • +
  • +

    Buy Now

    +
  • Reports

  • diff --git a/PhpScripts/ViewSixHundreds.php b/PhpScripts/ViewSixHundreds.php new file mode 100644 index 0000000..485aa52 --- /dev/null +++ b/PhpScripts/ViewSixHundreds.php @@ -0,0 +1,20 @@ +query("SELECT * FROM view_six_hundreds"); + $data = array(); + + while( $rows = mysqli_fetch_assoc($result) ) { + $data[] = $rows; + } + + echo json_encode(array( + "sEcho" => 1, + "iTotalRecords" => count($data), + "iTotalDisplayRecords" => count($data), + "aaData" => $data + )); + +?> \ No newline at end of file diff --git a/Templates/AuctionReceipt.txt b/Templates/AuctionReceipt.txt index 4155de7..059d9c3 100644 --- a/Templates/AuctionReceipt.txt +++ b/Templates/AuctionReceipt.txt @@ -8,7 +8,7 @@ Purchased By ID Number: {{bidder_id}} { "size": 15, "weight": "B", "align": "L", "height": "10", "width": "-60", "left": "30" } {{auction_id}}. {{description}} { "size": 15, "weight": "B", "height": "10", "align": "R", "top": "-10" } -${{value}} +${{price}} { "endRepeatable": 1, "repeatOn": "items" } { "size": 15, "weight": "B", "align": "L", "height": "10", "left": "30" } diff --git a/css/customStyles.css b/css/customStyles.css index d8a7410..65a331e 100644 --- a/css/customStyles.css +++ b/css/customStyles.css @@ -67,10 +67,12 @@ border-top: none; cursor: pointer; padding-left: 5px; + z-index: 1000; + background-color: white; } .dropdown:hover { - background-color: rgba(0,0,0, .05); + background-color:#f2f2f2; } .drop { @@ -236,4 +238,28 @@ .bid-hist-title { display: inline; margin-left: 15px; +} + +.table-input { + border-radius: 5px; +} + +.after-table { + margin-top: 20px; +} + +.bidder-id-numbers { + display: inline-block; + width: auto; + margin-right: 40px; +} + +.bidder-id-search { + display: inline-block; + position: absolute; +} + +.search { + height: 65px; + overflow: visible; } \ No newline at end of file diff --git a/procsViewsTriggers.sql b/procsViewsTriggers.sql index 340ac00..d8bec70 100644 --- a/procsViewsTriggers.sql +++ b/procsViewsTriggers.sql @@ -1,10 +1,9 @@ drop view if exists viewunmarked; drop view if exists viewtwohundreds; drop view if exists viewthreehundreds; -drop view if exists viewsixhundreds; drop procedure if exists viewAuctionItemGroups; -USE auctionit; +USE `fbcmtown_auctionITdb`; /* View Donators */ drop view if exists viewDonators; @@ -36,6 +35,32 @@ VIEW `viewBidders` AS SELECT * FROM `bidders`; +drop view if exists view_six_hundreds; +CREATE + ALGORITHM = UNDEFINED + SQL SECURITY DEFINER +VIEW `view_six_hundreds` AS + SELECT * + FROM `view_auction_items_sheet` + where `auction_id` >= 600; + +drop procedure if exists buy_now; + +delimiter $$ +CREATE PROCEDURE buy_now (IN AuctionId INT, IN BidderId INT, IN Amount INT) +BEGIN +IF (AuctionId > 599 AND AuctionId < 700) THEN + IF EXISTS (SELECT * FROM purchases WHERE auction_id = AuctionId AND bidder_id = BidderId) THEN + UPDATE purchases + SET purchases.quantity = (purchases.quantity + Amount), purchases.price = (select `value` from auction_items where auction_id = AuctionId) + WHERE auction_id = AuctionId AND bidder_id = BidderId; + ELSE + INSERT INTO purchases (auction_id, bidder_id, price, quantity) + VALUES (AuctionId, BidderId, (select `value` from auction_items where auction_id = AuctionId), Amount); + End IF; +END IF; +END $$ + /*View AuctionItemsSheet */ DROP VIEW IF EXISTS viewauctionitemssheet;