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