1<?php 2 3include('includes/DefineCartItemClass.php'); //must be before header.php 4include('includes/config.php'); 5include('includes/session.php'); 6 7$Title = $_SESSION['ShopName']; 8 9include('includes/header.php'); // adds deletes updates to the cart also done in header 10?> 11<script> 12 jQuery(document).ready(function() { 13 jQuery('#TermsAndConditions').click(function() { 14 jQuery('#content_block').html('<?php echo '<h1>' . _('Terms and Conditions') . '</h1>' . html_entity_decode($_SESSION['ShopTermsConditions']) ?>'); 15 return false; 16 }); 17 jQuery('#AboutUs').click(function(){ 18 jQuery('#content_block').html('<?php echo '<h1>' . _('About Us') . '</h1>' . html_entity_decode($_SESSION['ShopAboutUs']) ?>'); 19 return false; 20 }); 21 jQuery('#PrivacyPolicy').click(function(){ 22 jQuery('#content_block').html('<?php echo '<h1>' . _('Privacy Policy') . '</h1>' . html_entity_decode($_SESSION['ShopPrivacyStatement']) ?>'); 23 return false; 24 }); 25 jQuery('#FreightPolicy').click(function(){ 26 jQuery('#content_block').html('<?php echo '<h1>' . _('Freight Policy') . '</h1>' . html_entity_decode(str_replace($CarriageReturnOrLineFeed,'',$_SESSION['ShopFreightPolicy'])) ?>'); 27 return false; 28 }); 29 jQuery('#ContactUs').click(function(){ 30 jQuery('#content_block').html('<?php echo '<h1>' . _('Contact Details') . '</h1>' . html_entity_decode($_SESSION['ShopContactUs']) ?>'); 31 return false; 32 }); 33 jQuery('#cart_summary').click(function(){ 34 jQuery('#content_block').load('index.php?Page=ShoppingCart' + ' #content_block'); 35 return false; 36 }); 37 /* AJAX load results of sales category selections */ 38 jQuery('a.sales_category').click(function(){ 39 var url=jQuery(this).attr('href'); 40 jQuery('#content_block').load(url + ' #content_block'); 41 return false; 42 }); 43 /* AJAX load results of description search */ 44 jQuery('#SearchForm').submit(function(){ 45 var QueryString = 'SearchDescription=' + jQuery('#SearchForm :text').val() + '&FormID=' + jQuery('#SearchForm :hidden').val() + '&CurrCode=' + jQuery('#SearchForm :select').val(); 46 jQuery.post('index.php',QueryString,function(data) { 47 var content_block = jQuery(data).filter( '#content_block' ); 48 var cart_summary = jQuery(data).filter( '#cart_summary' ); 49 jQuery('#content_block').html(content_block.html()); 50 jQuery('#cart_summary').html(cart_summary.html()); 51 } 52 ); 53 return false; 54 }); 55 jQuery('#Currency').change(function(){ 56 var QueryString = 'FormID=' + jQuery('#SearchForm :hidden').val() + '&CurrCode=' + jQuery('#Currency').val(); 57 jQuery.post('index.php',QueryString,function(data) { 58 var content_block = jQuery(data).filter( '#content_block' ); 59 var cart_summary = jQuery(data).filter( '#cart_summary' ); 60 jQuery('#content_block').html(content_block.html()); 61 jQuery('#cart_summary').html(cart_summary.html()); 62 }); 63 }); 64 65 jQuery('#CartForm :text').change(function(){ 66 var QueryString = jQuery('#CartForm').serialize(); 67 jQuery.post('index.php',QueryString,function(data) { 68 var cart_summary = jQuery(data).filter( '#cart_summary' ); 69 var content_block = jQuery(data).filter( '#content_block' ); 70 jQuery('#content_block').html(content_block.html()); 71 jQuery('#cart_summary').html(cart_summary.html()); 72 } 73 ); 74 return false; 75 }); 76 77 }); /* End document ready */ 78</script> 79 80<?php 81 82ShowSalesCategoriesMenu(); 83 84include('includes/InfoLinks.php'); 85 86if (isset($_GET['Page'])){ 87 if ($_GET['Page']=='ShoppingCart'){ 88 echo ' <div class="column_main"> 89 <h1>' . _('Order Details') . '</h1>'; 90 //code to display the cart 91 if (count($_SESSION['ShoppingCart'])>0){ 92 echo '<form id="CartForm" method="post" action="' . $RootPath . '/index.php"> 93 <input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; 94 include('includes/DisplayShoppingCart.php'); //also used on checkout 95 echo '<div class="row"><span class="potxt">' ._('Click the Order Button to process your order and enter delivery and payment options') .' >> </span><a class="link_button" href="Checkout.php">' . _('Place Order') . '</a></div> 96 </div> 97 </form>'; 98 //Now the grand total 99 } else { 100 echo _('The shopping cart is empty'); 101 } 102 } // $_GET['Page'] != ShoppingCart 103 104} else { 105 106 $SQL = "SELECT stockmaster.stockid, 107 description, 108 longdescription, 109 taxcatid, 110 discountcategory, 111 decimalplaces, 112 mbflag, 113 units, 114 sum(locstock.quantity) AS quantity 115 FROM stockmaster INNER JOIN salescatprod 116 ON stockmaster.stockid = salescatprod.stockid 117 INNER JOIN locstock 118 ON stockmaster.stockid = locstock.stockid"; 119 120 if (isset($_GET['SalesCategory']) OR isset($_POST['SearchDescription'])) { 121 122 if (isset($_GET['SalesCategory'])){ 123 echo ' <div class="column_main"> 124 <h1 id="focuspage">' . get_sales_category_name(DB_escape_string($_GET['SalesCategory'])) . '</h1>'; 125 /* Do the search for items for this category (and perhaps we should explore below this category too) */ 126 $SQL .= " WHERE salescatprod.salescatid IN (" . DB_escape_string($_GET['SalesCategory']) . list_sales_categories($_GET['SalesCategory']) . ")"; 127 } else { //only search below the specified $RootSalesCategory in includes/config.php 128 $SQL .= " WHERE salescatprod.salescatid IN (" . DB_escape_string($RootSalesCategory) . list_sales_categories($RootSalesCategory) . ")"; 129 } 130 if (isset($_POST['SearchDescription'])){ 131 echo ' <div class="column_main"> 132 <h1>' . _('Searching for:') . ' ' . $_POST['SearchDescription'] . '</h1>'; 133 $SQL .= " AND (stockmaster.description LIKE '%" . $_POST['SearchDescription'] . "%' 134 OR stockmaster.stockid LIKE '%" . $_POST['SearchDescription'] . "%')"; 135 } 136 137 } else { 138 echo ' <div class="column_main"> 139 <h1>' . _('Featured Items') . '</h1>'; 140 $SQL .= " WHERE salescatprod.featured=1 AND salescatprod.salescatid IN (" . DB_escape_string($RootSalesCategory) . list_sales_categories($RootSalesCategory) . ")"; 141 142 143 } 144 $SQL .= " AND locstock.loccode IN ('" . str_replace(',', "','", $_SESSION['ShopStockLocations']) . "') 145 GROUP BY stockmaster.stockid, 146 description, 147 longdescription, 148 taxcatid, 149 decimalplaces, 150 mbflag, 151 units, 152 salescatid"; 153 154 155 if ($_SESSION['ShopShowOnlyAvailableItems'] != 0){/* We should show only items with QOH > 0 */ 156 $SQL .= " HAVING sum(locstock.quantity) > 0"; 157 } 158 $SQL .= " ORDER BY salescatid, stockmaster.description"; 159 160 //echo $SQL; 161 //exit; 162 163 $ItemsToDisplayResult = DB_query($SQL,_('Could not get the items to display for this category because')); 164 165 $ItemsToDisplay =0; //counter for how many items were actually displayed 166 167 $ItemsTableHTML = '<br />'; 168 169 display_messages(); //just in case the user has registered or logged in 170 while($ItemRow = DB_fetch_array($ItemsToDisplayResult)){ 171 //need to get description translation and price grossed up for tax 172 $DisplayItemRowHTML = display_item($ItemRow['stockid'], 173 html_entity_decode($ItemRow['description']), 174 html_entity_decode($ItemRow['longdescription']), 175 $ItemRow['taxcatid'], 176 $ItemRow['discountcategory'], 177 $ItemRow['quantity'], 178 $ItemRow['decimalplaces'], 179 $ItemRow['mbflag'], 180 $ItemRow['units'] ); 181 if ($DisplayItemRowHTML != '0'){ 182 $ItemsTableHTML .= $DisplayItemRowHTML; 183 $ItemsToDisplay++; 184 } 185 } // end loop around the items 186 187 if ($ItemsToDisplay ==0 ) { 188 echo _('There are no items matching this search'); 189 } else { 190 echo $ItemsTableHTML; 191 } 192} 193echo '</div>'; //end column_main 194echo '</div>'; //end content_inner 195echo '</div>'; //end content_block 196include ('includes/footer.php'); 197 198/* **************** END of main script ***************************** */ 199 200?>