	{{* if we do not have a valid cart we will redirect to shopping-cart.html page *}}
	{{assign var=CartCollection				value=133}}
	{{assign var=CartDetailsCollection		value=134}}
	{{assign var=TaxCollection				value=151}}
	{{assign var=ShippingCollection			value=139}}
	
	
	{{assign var=SessionID   		value=''|sessionid}}
	{{getCollectionByCategory CollectionID=$CartCollection Collection_133_1=$SessionID aditionalFilter=' (Collection_133_5<>"on" or Collection_133_5 IS NULL) ' var=CartData OrderColumn='ID'}}
	{{assign var=CartDataItem value=$CartData[0]}}
	{{assign var=CartID value=$CartDataItem.Collection_133_ID}}
	
	{{assign var=PaymentMethodID value=$CartDataItem.Collection_133_19}}
	{{getCollectionByCategory CollectionID=$CartDetailsCollection ColumnID=1 Value=$CartID var=CartDetails OrderColumn='ID'}}
	
	{{assign var=DoNotShowShoppingCart value=1}}
	
	{{if $CartDetails|@count eq 0 or $CartData|@count eq 0 or $PaymentMethodID lt 1}}
		{{redirect page='/shopping-cart.html'}}	
	{{/if}}
	
	{{* we need to get the email settings *}}
	{{assign var=EmailSettingCollection value=159}}
	{{getCollectionByCategory CollectionID=$EmailSettingCollection ColumnID=11 Value='on' var=EmailSettings OrderColumn='ID'}}
	{{assign var=EmailSetting value=$EmailSettings[0]}}
	{{assign var=EmailPrefix value='Collection_'}}
	{{assign var=EmailPrefix value=$EmailPrefix|concat:$EmailSettingCollection|concat:'_'}}
	{{assign var=ENforNUsers value=$EmailPrefix|concat:'1'}}
	{{assign var=EAforNUsers value=$EmailPrefix|concat:'2'}}
	{{assign var=ESforNUsers value=$EmailPrefix|concat:'3'}}
	{{assign var=ENforReceipt value=$EmailPrefix|concat:'4'}}
	{{assign var=EAforReceipt value=$EmailPrefix|concat:'5'}}
	{{assign var=ESforReceipt value=$EmailPrefix|concat:'6'}}
	{{assign var=ENforAReceipt value=$EmailPrefix|concat:'7'}}
	{{assign var=EAforAReceipt value=$EmailPrefix|concat:'8'}}
	{{assign var=ESforAReceipt value=$EmailPrefix|concat:'9'}}
	{{assign var=EEforAReceipt value=$EmailPrefix|concat:'10'}}
	
	{{* if we do not have a valid billing info page we will redirect to personal-information *}}	
	{{getCollectionByCategory CollectionID=138 ColumnID=1 Value=$CartID var=BillingInformation OrderColumn='ID'}}
	{{if $BillingInformation|@count eq 0}}
		{{redirect page='/checkout/personal-information.html'}}	
	{{else}}
		{{assign var=BillingInfo value=$BillingInformation[0]}}
	{{/if}}
	
	
	{{getCollectionByCategory CollectionID=139 ColumnID=1 Value=$CartID var=ShippingInformation OrderColumn='ID'}}
	{{if $ShippingInformation|@count eq 0}}
		{{redirect page='/checkout/shipping-information.html'}}	
	{{else}}
		{{assign var=ShippingInfo value=$ShippingInformation[0]}}
	{{/if}}
	
	{{getCollectionByCategory CollectionID=$PaymentMethodID ColumnID=1 Value=$CartID var=PayInfo OrderColumn='ID'}}
		{{if $PayInfo|@count eq 0}}
			{{redirect page='/shopping-cart.html'}}	
		{{else}}
			{{assign var=PMethodPrefix value='Collection_'}}
			{{assign var=PMethodPrefix value=$PMethodPrefix|concat:$PaymentMethodID|concat:'_ID'}}
		
			{{foreach from=$PayInfo item=v key=k }}
				{{assign var=PayInfoID value=$v.$PMethodPrefix}}
				{{CollectionDeleteRow CollectionID=$PaymentMethodID RowID=$PayInfoID}}
			{{/foreach}}
		{{/if}}	
		
	
	{{* because the transaction is finished we will close the cart *}}
	{{CollectionUpdateField CollectionID=$CartCollection ColumnID=5 Value='on' RowID=$CartID}} 
	
	{{* we will auto check the Purchase Aproved By Admin flag if the method is not check by mail *}} 
	{{if $PaymentMethodID neq 150}}
		{{CollectionUpdateField CollectionID=$CartCollection ColumnID=20 Value='on' RowID=$CartID}}
	{{/if}}	
		
	{{* if user is new we need to create an account for him *}}
	{{if $smarty.session.UserID gt 0}}
			{{CollectionUpdateField CollectionID=$CartCollection ColumnID=2 Value=$smarty.session.UserID RowID=$CartID}}
	{{else}}
			
			{{* we check to see if the email address that the user used is in use or not 8 *}}
			{{getCollectionByCategory CollectionID=1 ColumnID=5 Value=$BillingInfo.Collection_138_12 var=EmailAllready OrderColumn='ID'}}
			{{if $EmailAllready|@count eq 0}}
						{{* this means we can freely create a new username *}}
						{{CollectionAdd var=UserID CollectionID=1 Collection_1_1=$BillingInfo.Collection_138_12 Collection_1_5=$BillingInfo.Collection_138_12 Collection_1_3=$BillingInfo.Collection_138_2 Collection_1_4=$BillingInfo.Collection_138_3  Collection_1_6='on' Collection_1_10='on' Collection_1_11=$BillingInfo.Collection_138_4 Collection_1_12=$BillingInfo.Collection_138_5 Collection_1_9='on' Collection_1_13=$BillingInfo.Collection_138_6 Collection_1_14=$BillingInfo.Collection_138_7 Collection_1_15=$BillingInfo.Collection_138_8 Collection_1_16=$BillingInfo.Collection_138_9 Collection_1_17=$BillingInfo.Collection_138_10 Collection_1_2=$BillingInfo.Collection_138_12|password:'oxiem' }}
						{{Email emailTo=$BillingInfo.Collection_138_12 emailToName=$BillingInfo.Collection_138_2|concat:' '|concat:$BillingInfo.Collection_138_3 emailFrom=$EmailSetting.$EAforNUsers emailFromName=$EmailSetting.$ENforNUsers emailSubject=$EmailSetting.$ESforNUsers emailPage=42  emailData=$BillingInfo}}
						
						{{CollectionUpdateField CollectionID=$CartCollection ColumnID=2 Value=$UserID RowID=$CartID}}
						
						{{* we need to add the user to the user group *}}
						{{CollectionAdd CollectionID=3 Collection_3_1=$UserID Collection_3_2=4 }}
			{{else}}
				{{assign var=OldUserData value=$EmailAllready[0]}}
				{{CollectionUpdateField CollectionID=$CartCollection ColumnID=2 Value=$OldUserData.Collection_1_ID RowID=$CartID}}
			{{/if}}
	{{/if}}
	
	
			
	{{* we need to send email to user with the receipt *}}
	{{assign var=tmppage value=$page}}
	{{Email emailTo=$BillingInfo.Collection_138_12 emailToName=$BillingInfo.Collection_138_2|concat:' '|concat:$BillingInfo.Collection_138_3 emailFrom=$EmailSetting.$EAforReceipt emailFromName=$EmailSetting.$ENforReceipt emailSubject=$EmailSetting.$ESforReceipt emailPage=41  emailData=$CartID}}
	{{Email emailTo=$EmailSetting.$EEforAReceipt emailToName=$BillingInfo.Collection_138_2|concat:' '|concat:$BillingInfo.Collection_138_3 emailFrom=$EmailSetting.$EAforAReceipt emailFromName=$EmailSetting.$ENforAReceipt emailSubject=$EmailSetting.$ESforAReceipt emailPage=41  emailData=$CartID}}
	{{assign var=page value=$tmppage}}

<div id="middle2">



	
	<h3>Your Shopping Cart</h3>
	<div id="shopping_cart_details">
	{{if $CartData|@count gt 0 and $CartDetails|@count gt 0}}
		{{getcontent id=45}}
	{{/if}}
	</div>
	
	<ul>
	 	<li><a href="javascript: void(0);" onClick="window.print(); ">Click Here To Print This Page</a></li>
	 	<li><a href="http://{{$smarty.server.HTTP_HOST}}/store/">Click Here To Continue</a></li>
	</ul>
	

</div>

