* Created on 24-Jan-09 * ShowItem..Item Page . FACE OF MY APPLICATION :) Naren k */ include 'Services/ItemServices.php'; //include 'Services/RatingServices.php'; $itemDesc = ""; $itemClass = ""; $itemName = ""; $itemID = $_REQUEST["item"]; if ($itemID == null) { echo "<div class='errorMsgBlock'/>Invalid URL. Please click here to go to home page.</div>"; exit; } $editUrl = "editItem.php?item=" . $itemID; $avgRating = getItemAvgRating($itemID); $itemRecs = getItemDetails($itemID); while ($row = mysql_fetch_assoc($itemRecs)) { $itemName = $row['prod_name']; $itemClass = $row['class_name']; $itemDesc = $row['prod_desc']; } ?> <table width="100%"><tr><td class="bar" align="left"> <td class="headeritem"><?php echo $itemName; ?> </td> <td class="text1" align="right"><img src="images/Gift_box.gif">wishlist <img src="images/heart_32.png">favorite <img src="images/book_mark1.gif">bookmark <img src="images/reply.png">edit</td> </tr></table>
function basket($referral) { $itemsInBask = count($_SESSION['basket']); if ($itemsInBask == 0 && $referral == 'basket') { echo "<p id='emptyBasket'>There are no items in your shopping basket</p>"; } else { if ($referral == 'basket') { echo "<div id='continueShopping'><a href='sheetMusic.php'><< Continue Shopping</a></div>"; } else { echo "\n\t\t\t<div id='checkoutHeading'>\n\t\t\t\t<p id='listTitle'>Items</p>\n\t\t\t</div>\n\t\t\t<div id='checkoutTip'>Please make any final alterations to what is in your basket and check their quantities are correct.</div>\n\t\t\t<div id='checkoutBasketWrap'>"; } echo "<table id='basketTable'>"; if ($referral == 'basket') { echo "<tr class='basketColour'>"; } else { echo "<tr class='basketColourGray'>"; } echo "\n\t\t\t<th>Item</th>\n\t\t\t<th>Quantity</th>\n\t\t\t<th>Price</th>\n\t\t\t<th>Total</th>\n\t\t</tr>"; for ($i = 0; $i < $itemsInBask; $i++) { $itemId = $_SESSION['basket'][$i]['itemId']; $q = $_SESSION['basket'][$i]['quantity']; $price = $_SESSION['basket'][$i]['price']; $discount = $_SESSION['basket'][$i]['discount']; $discountFlag = 0; $tmp = getItemDetails($itemId); if ($tmp['discount'] != 1) { $discountFlag = 1; $price = $tmp['price'] * $tmp['discount']; $price = number_format($price, 2, '.', ''); } else { $discountFlag = 0; } $totalForEach = $q * $price; // for each item, multiply the quantity by the price $formatNumber = number_format($totalForEach, 2, '.', ''); // format the resulting number to ensure it has 2 decimal places. This avoids £1.5 echo "\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<div id='basketItem'>\n\t\t\t\t\t\t<p id='basketImage'><img alt='Product Image' src='images/Covers/" . $tmp['image'] . ".jpg' style='width:85px;'></p>\n\t\t\t\t\t\t<p id='basketItemName'><a href='details.php?itemID=" . $itemId . "'>" . $tmp['name'] . "</a></p>\n\t\t\t\t\t\t<div id='itemAttributes'>\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<span class='label'>Item No: </span>\n\t\t\t\t\t\t\t\t<span class='value'>" . $itemId . "</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<span class='label'>Artist: </span>\n\t\t\t\t\t\t\t\t<span class='value'>" . $tmp['artist'] . "</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<span class='label'>Arrangement: </span>\n\t\t\t\t\t\t\t\t<span class='value'>" . $tmp['arrangement'] . "</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<div id='basketQuantity'>\n\t\t\t\t\t\t<p id='setQuantity'>" . $q . "</p>\n\t\t\t\t\t\t<p id='changeQuantity'><input class='changeQuantityInput' id='changeQuantityInput" . $itemId . "' name='{$itemId}' type='text' maxlength='3' size='2'></p>\n\t\t\t\t\t\t<p id='updateRemoveLinks'><a href='javascript: updateBasket({$itemId});'>Update</a> | <a href='" . $referral . ".php?remove=1&itemId=" . $itemId . "'> Remove</a></p>\n\t\t\t\t\t</div>\n\t\t\t\t</td>\n\t\t\t\t<td id='price'>£" . $price . " x " . $q . "</td>\n\t\t\t\t<td id='total'>£" . $formatNumber . "</td>\n\t\t\t</tr>"; $orderTotal += $formatNumber; } echo "\n\t\t\t<tr>\n\t\t\t\t<td style='padding:5px;'></td>\n\t\t\t</tr>"; $formatOrderTotal = number_format($orderTotal, 2, '.', ''); $userId = $_SESSION['UserSession'][0]['userId']; if ($referral == 'basket') { echo "\n\t\t\t\t<tfoot>\n\t\t\t\t\t<tr class='basketColour'><td colspan='4' style='padding: 5px;'>\n\t\t\t\t\t\t<a href='basket.php?remove=2' style='font-size:13px;float:right;'>Clear Basket</a>\n\t\t\t\t\t</tr>\n\t\t\t\t</tfoot>\n\t\t\t</table>\n\t\t\t<div id='orderTotalWrap'><p id='orderTotal'>Order Total: £" . $formatOrderTotal . "</p></div>\n\t\t\t<form method='link' action='functions/startCheckout.php?id=" . $userId . "'>\n\t\t\t\t<div class='buttonHover'>\n\t\t\t\t\t<button class='blueButton' id='checkout' type='submit'>Proceed to Checkout</button>\n\t\t\t\t</div>\n\t\t\t</form>"; } else { echo "\n\t\t\t\t</table>\n\t\t\t\t<div id='checkoutBasketTotal'>Total: £" . $formatOrderTotal . "</div>\n\t\t\t</div>\n\t\t\t<form method='link' action='checkoutAddr.php'>\n\t\t\t\t<div class='buttonHover'>\n\t\t\t\t\t<button id='back' class='blueButton'>Back</button>\n\t\t\t\t</div>\n\t\t\t</form>\n\t\t\t<form method='link' action='checkoutPay.php'>\n\t\t\t\t<div class='buttonHover'>\n\t\t\t\t\t<button id='next' class='blueButton'>Next</button>\n\t\t\t\t</div>\n\t\t\t</form>"; } } }
?> </div> <?php showSingleItem($_GET["itemID"]); ?> <div class="triColumnDiv" id="purchaseOptions"> <form id="purchase" name="purchaseForm"> <input type="hidden" name="hItemId"> <input type="hidden" name="action"> <input type="hidden" name="hQuantity"> </form> <div id="itemOptions" style="padding-top:80px;"> <p id="quantityLabel">Quantity: <input id="quantity" type="text" value="1" name="quantity"> x £<?php $tmp = getItemDetails($_GET["itemID"]); $res = $tmp["price"] * $tmp["discount"]; $res = number_format($res, 2, '.', ''); echo $res; ?> </p> <p class="errorMessage" id="quantityError"></p> </div> <div id="purchaseButtons"> <?php inBasketButton($_GET['itemID']); // show either blue or green add to basket button ?> <?php inWishlistButton($_GET['itemID']); // show either blue or green add to wishlist button
<?php include_once 'header.php'; include "essential.php"; ?> <div class="post"> <h2 class="title"><a href="#">Edit Item Details </a></h2> <script type='text/javascript' src='./js/jquery.min.js'></script> <script type='text/javascript' src='./js/editItem.js'></script> <div style="clear: both;"> </div> <div class="entry"> <form id="editItem" method="POST" action="dbentry.php"> <table> <?php $query = "SELECT * FROM Items NATURAL JOIN " . $_GET['Category'] . " WHERE ID=" . $_GET['ID'] . ";"; echo getItemDetails($query); ?> </table> <input type=submit class="more" value="Submit"> </form> </form> </div> </div> <?php include_once 'footer.php';
$remove = $_GET['remove']; $update = $_GET['u']; $quantity = $_GET['quant']; $basket = $_GET['bask']; $id = $_SESSION['UserSession'][0]['userId']; if ($remove == 1) { removeWishlistItem($itemId); } // remove one item if ($remove == 2) { removeAllWishlist($id); } // remove all items if ($basket == 1) { $flag = 1; $getPrice = getItemDetails($itemId); $price = $getPrice['price']; $discount = $getPrice['discount']; addToBask($itemId, $quantity, $flag, $price, $discount); removeWishlistItem($itemId); } if ($update == 1) { preg_match('/^[0-9]{1,2}$/', $quantity, $result); if ($result == 0 || $quantity == 0) { header("Location: wishlist.php"); } else { updateWishlist($id, $itemId, $quantity); } } ?> <!DOCTYPE html>
function checkoutConfirm($userId) { $con = pg_connect("host=db.dcs.aber.ac.uk port=5432 dbname=cs394_12_13_sib12 user=sib12 password=Sagaris99"); $itemsInBask = count($_SESSION['basket']); echo "\n\t<div id='checkoutHeading'>\n\t\t<p id='listTitle'>Confirm</p>\n\t</div>\n\t<div id='checkoutTip'>Please review your order details and then place your order.</div>\n\t<div id='confirmItems'>\n\t\t<table id='confirmItemsTable'>\n\t\t\t<tr class='basketColourGray'>\n\t\t\t\t<th style='width:500px;'>Item</th>\n\t\t\t\t<th></th>\n\t\t\t\t<th>Quantity</th>\n\t\t\t\t<th>Price</th>\n\t\t\t</tr>"; for ($i = 0; $i < $itemsInBask; $i++) { $itemId = $_SESSION['basket'][$i]['itemId']; $q = $_SESSION['basket'][$i]['quantity']; $price = $_SESSION['basket'][$i]['price']; $discount = $_SESSION['basket'][$i]['discount']; $get = getItemDetails($itemId); $discountFlag = 0; if ($discount != 1) { $discountFlag = 1; $price = $price * $discount; $price = number_format($price, 2, '.', ''); } else { $discountFlag = 0; } $totalForEach = $q * $price; // for each item, multiply the quantity by the price times discount $formatNumber = number_format($totalForEach, 2, '.', ''); // format the resulting number to ensure it has 2 decimal places. This avoids £1.5 echo "\n\t\t<tr>\n\t\t\t<td colspan='2'>\n\t\t\t\t<div id='confirmItem'>\n\t\t\t\t\t<p id='confirmItemName'>" . $get['name'] . "</p>\n\t\t\t\t\t<div style='float:left;padding-right:15px;'><span class='label'> - Artist: </span><span class='value'>" . $get['artist'] . "</span></div>\n\t\t\t\t\t<div><span class='label'>Arrangement: </span><span class='value'>" . $get['arrangement'] . "</span></div></div>\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<p id='confirmQuantity'>" . $q . "</p>\n\t\t\t</td>\n\t\t\t<td id='price'>£" . $price . " x " . $q . "</td>"; $orderTotal += $formatNumber; } echo "<tr><td style='padding:5px;'></td></tr>"; $formatOrderTotal = number_format($orderTotal, 2, '.', ''); echo "<tr class='basketColourGray'><td colspan='4' style='padding: 2px;'><p id='confirmTotal'>Total: £" . $formatOrderTotal . "</p></td></tr>"; // ADDRESS AND CARD DETAILS ROW $newfetch = pg_query($con, "SELECT * FROM customer WHERE customer_id='{$userId}'"); $b = pg_fetch_array($newfetch); $block = '"block"'; $div = '"updateBillAddrWrap"'; // BILLING ADDRESS echo "\n\t<tr>\n\t\t<td>\n\t\t\t<div id='addrLabel'>Your Billing Address:</div>\n\t\t\t<div id='yourAddr'>\n\t\t\t\t<p class='addr'>" . $b['address_1'] . "</p>\n\t\t\t\t<p class='addr'>" . $b['address_2'] . "</p>\n\t\t\t\t<p class='addr'>" . $b['city'] . "</p>\n\t\t\t\t<p class='addr'>" . $b['county'] . "</p>\n\t\t\t\t<p class='addr'>" . $b['postcode'] . "</p>\n\t\t\t\t<p class='addr'>" . $b['phone'] . "</p>\n\t\t\t</div>\n\t\t</td>"; // CARD if ($_POST['action'] == 'select') { $pid = $_POST['id']; $getCardInfo = pg_query($con, "SELECT * FROM payment WHERE customer_id='{$userId}' AND payment_id='{$pid}'"); $card = pg_fetch_array($getCardInfo); $getName = $card['name_on_card']; $getCard = $card['card_number']; $getMonth = $card['expiry_month']; $getCardType = $card['card_type']; $getYear = $card['expiry_year']; } else { $getName = $_SESSION['payment'][0]['name']; $getCard = $_SESSION['payment'][0]['cardNo']; $getMonth = $_SESSION['payment'][0]['expMonth']; $getCardType = $_SESSION['payment'][0]['cardType']; $getYear = $_SESSION['payment'][0]['expYear']; } $cardNo = substr($getCard, -4); // gets the last 4 digits of the card number if ($getMonth < 10) { // if the month is less than 10 i.e 1,2,3,4,5 $month = str_pad($getMonth, 2, "0", STR_PAD_LEFT); // put a 0 at the front } else { $month = $getMonth; // if it's larger than 9 } echo "\n\t<td colspan='3' style='vertical-align:top;'>\n\t\t<div id='addrLabel'>Paying with:</div>\n\t\t<div id='yourAddr'>\n\t\t\t<p class='addr'>" . $getCardType . "</p>\n\t\t\t<p class='addr'>**** **** **** " . $cardNo . "</p>\n\t\t\t<p class='addr'>" . $month . "/" . $getYear . "</p>\n\t\t</div>\n\t</td>\n\t</tr>"; // TABLE FOOTER, PLACE ORDER BUTTON, AGREE TO TERMS echo "\n\t<tfoot>\n\t\t<tr class='basketColourGray'>\n\t\t\t<td colspan='4' style='padding: 2px;'>\n\t\t\t\t<form method='post' id='confirmSubmit' name='TC' action='functions/placeOrder.php?pid=" . $pid . "'>\n\t\t\t\t<button style='float:right;' type='submit' class='greenButton'>Place Order</button>\n\t\t\t\t<input id='agree' type='checkbox' name='agree' value='1'><div id='TCConfirm'>Please check this box to agree with our <a style='text-decoration:underline;' href='about.php' target='_blank'>Terms & Conditions</a></div></form>\n\t\t\t\t<script type ='text/javascript'> validate_TC();</script>\n\t\t\t\t<p id='TCWarning'></p>\n\t\t\t\t<form method='link' id='confirmBack' action='checkoutPay.php'><button class='blueButton'>Back</button></form>\n\t\t\t</td>\n\t\t</tr>\n\t</tfoot>\n\t</table>\n\t</div>"; }