<!--#include file="../owFunctions/I_GeneralFunctions.asp"-->
<!--#include file="../owTemplates/Template_AllLeft.asp"-->
<%
	'************************************************************************************
	'*																					*
	'*	MODIFICATION TO THIS SCRIPT OR ANY FILES INCLUDED WITH 							*
	'*		ONEWORLDSTORE IS DONE AT YOUR OWN RISK!										*
	'*	Product  : OneWorldStore														*
	'*	Version  : 9.0000																*
	'*	Modified : June 2004															*
	'*	Copyright:	Copyright (C) 2004 OneWorldStore.Com								*
	'*				Registration Number: 1024507										*
	'*				http://strategis.ic.gc.ca/											*
	'*																					*
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub ActionSubroutine()

		total = 0
		
		If ( sOWCurrencyCode <> "" ) Then
			sTempCurrencyCode = "(" & sOWCurrencyCode & ")"
		End If

		%>
		<center>
		<table width=<%=sOWStoreTableWidth%> border=0 style='border: 1px solid #000000;' cellspacing=0 cellpadding=5>
		<form method="post" action="owRecalc.asp" name="recalculate">
			<tr bgcolor="#eeeeee"><td colspan=6 style='border-bottom: 1px solid #000000;'><b><%=LANG_DT( "SHOWCART_HEAD", "Your Cart" )%></b></td></tr>
			<tr>
				<td width="5%" bgcolor="#eeeecc"><b><%=LANG_DT( "SHOWCART_QTY", "Quantity" )%></td>
				<td width="20%" bgcolor="#eeeecc"><b><%=LANG_DT( "SHOWCART_SQK", "SKU" )%></td>
				<td bgcolor="#eeeecc"><b><%=LANG_DT( "SHOWCART_DESC", "Description" )%></td>
				<td width="20%" bgcolor="#eeeecc"><b><%=LANG_DT( "SHOWCART_OPT", "Options" )%></td>
				<td width="10%" bgcolor="#eeeecc" colspan=2><b><%=LANG_DT( "SHOWCART_PRICE", "Price" )%></b>&nbsp;<%=sTempCurrencyCode%></td>
			</tr>
      		<%    
			sSQLText = "SELECT idCartRow, CartProducts.idProduct, quantity, unitPrice, unitBtoBPrice, unitWeight, description, sku FROM CartProducts, products WHERE CartProducts.idProduct=products.idProduct AND CartProducts.IDCart = " & sIDCart
			Call DB_getFromDatabase(sSQLText, rsStoreData, "showCart") 
			If ( NOT rsStoreData.EOF ) Then
				While ( NOT rsStoreData.EOF )
					sIDCartRow				= rsStoreData("idCartRow")
					sIDProduct				= rsStoreData("idProduct")
					sQuantity				= rsStoreData("quantity")
					sUnitPrice				= Cdbl(rsStoreData("unitPrice"))
					sUnitBtoBPrice			= Cdbl(rsStoreData("unitBtoBPrice"))
					sDescription			= rsStoreData("description")
					sSKU					= rsStoreData("sku")
					sOptionGroupsTotal		= 0
					%> 
					<tr> 
						<td>
							<input type='text' name='cant<%=sIDCartRow%>' value='<%=sQuantity%>' size=2>
						</td>
						<td>
							<a href="../owProductDetail.asp?idProduct=<%=sIDProduct%>"><%if sSKU="" then response.write sIDProduct else response.write sSKU End If%></a>
						</td>
				        <td>
				        	<%=sDescription%>
				        </td>
						<td>
							<% 
							' get options for current cart row
							sSQLText = "SELECT O.idOption, CPO.optionDescrip, CPO.priceToAdd, CPO.TextDetail FROM Options O, CartProductsOptions CPO WHERE O.idOption = CPO.idOption AND CPO.idCartRow = " & sIDCartRow
							Call DB_getFromDatabase(sSQLText, rsStoreData2, "")
							While ( NOT rsStoreData2.EOF )
								sPriceToAdd		= rsStoreData2("priceToAdd")
								sTextDetail		= Trim(rsStoreData2("TextDetail"))
								response.write rsStoreData2("optionDescrip")
								if sPriceToAdd>0 then
									response.write "&nbsp;" & CONVERSION_Currency(sPriceToAdd)
								End If
								response.write "<br>"
								If ( sTextDetail <> "" ) Then
									Response.Write "<input type='text' name='' value=""" & Server.HTMLEncode(sTextDetail) & """ readonly><br>"
								End If
								sOptionGroupsTotal = sOptionGroupsTotal + sPriceToAdd        
								rsStoreData2.MoveNext
							Wend
							Call DB_closeRecordset(rsStoreData2)
							%>
						</td>
						<%
						' for Retail or WholeSale without btob price assigned shows Retail Price
						If ( ( ACCNT_InGroup(iLoginAccountUnq, C_GROUP_WHOLESALE) ) And ( sUnitBtoBPrice > 0 ) ) Then
							sRowPrice = Cdbl(sQuantity * (sOptionGroupsTotal+sUnitBtoBPrice) )
						Else
							sRowPrice = Cdbl(sQuantity * (sOptionGroupsTotal+sUnitPrice) )
						End If
						%>
						<td style='border-right: 1px solid CCCCCC'>
							<%=CONVERSION_Currency(sRowPrice) %>
						</td>
						<td align=center>
							<a href="owRemoveFromCart.asp?idCartRow=<%=sIDCartRow%>&IDCart=<%=sIDCart%>"><%=LANG_DT( "SHOWCART_REMOVE", "Remove" )%></a>
						</td>
					</tr>      
					<%     
					total = total + sRowPrice
					rsStoreData.moveNext
				Wend
				%> 
				<tr>
					<td colspan=3 style='border-top: 1px solid #000000;' valign=top>
						<%=LANG_DT( "SHOWCART_AVAIL", "Estimated total availability: same day" )%>
					</td>
					<td colspan=2 align=right style='border-top: 1px solid #000000;'>
						<b> <%=LANG_DT( "SHOWCART_TTL", "Total" )%>: <%=CONVERSION_Currency(total) %></b> 
						<%if NOT bOWTaxIncluded then%>
						<br><i>(<%=LANG_DT( "SHOWCART_TAXNOTINC", "Tax not included" )%>)</i><br>
						<%Else%>
						<br><i>(<%=LANG_DT( "SHOWCART_TAXINC", "Tax included" )%>)</i><br>
						<%End If%>
					</td>
					<td colspan=2 align=right style='border-top: 1px solid #000000;'>&nbsp;</td>
				</tr>
				<tr>
					<td colspan=3 style='border-top: 1px solid #000000;'><input type="submit" name="Submit" value=" <%=LANG_DT( "SHOWCART_RECALC", "Recalculate Quantity" )%> "></td>
					<td colspan=3 align=right style='border-top: 1px solid #000000;'><input type='button' value=" <%=LANG_DT( "SHOWCART_PROCEED", "Proceed to Checkout" )%> &gt; " onClick='location="owCheckOut.asp";'></td>
				</tr>
			</table>
			</form>
			<table width=<%=sOWStoreTableWidth%> border=0 cellspacing=0 cellpadding=5>
				<tr>
					<td>
						<%
						' if the customer is logged-in retrieve shipping address 
						If ( bHasAccount ) Then
							sSQLText = "SELECT * FROM CustAltShip CAS, CustAltBill CAB WHERE CAS.AccountUnq = CAB.AccountUnq AND CAB.AccountUnq = " & iLoginAccountUnq & " AND CAS.Position = 0"
							Call DB_getFromDatabase(sSQLText, rsStoreData2, "") 
							If ( NOT rsStoreData2.EOF ) Then
								if rsStoreData2("shippingZip")<>"" then
									sShippingZip			= rsStoreData2("ShippingZip")
									sShippingState			= rsStoreData2("ShippingState")
									sShippingStateCode		= rsStoreData2("ShippingStateCode") 
									sShippingCountryCode	= rsStoreData2("ShippingCountryCode")
								else
									sShippingZip			= rsStoreData2("BillingZip")
									sShippingState			= rsStoreData2("BillingState")
									sShippingStateCode		= rsStoreData2("BillingStateCode") 
									sShippingCountryCode	= rsStoreData2("BillingCountryCode")  	
								End If
							End If 
							Call DB_closeRecordset(rsStoreData2)
							%>
							<input type='button' value=" <%=LANG_DT( "SHOWCART_CHECKCOST", "Check Shipping Cost" )%> " onClick='location="owShippingCostQueryExec.asp?sCountryCode=<%=sShippingCountryCode%>&sZip=<%=sShippingZip%>";'>
							<%
						Else
							%>
							<input type='button' value=" <%=LANG_DT( "SHOWCART_CHECKCOST", "Check Shipping Cost" )%> " onClick='location="owShippingCostQuery.asp";'>
							<%
						End If
						%>
					</td>
				</tr>
			</table>
			<%
		Else
			Response.Write "<tr><td colspan=5 align=center>" & LANG_DT( "SHOWCART_CARTEMPTY", "Your cart is empty. <a href='/Default.asp'>Click Here</a> to continue shopping." ) & "</td></tr></table>"
		End If
		Call DB_closeRecordset(rsStoreData)

	End Sub
	'************************************************************************************
%>