<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Programmer<programmer@armia.com>        		              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com � 2007                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
?>

<?php

			
		
	if($_SESSION["sess_adminname"] != "")
	{

?>		


	

		
		<div align="left" class="container_rgt">
		<!--news area start -->
				
				<div align="left" id="news_body">
						<div align="left" class="news_date">
							<a href="admin/adminmain.php" title="Administrator Home" style="cursor:pointer">
							<img src="images/admin_home.jpg" border="0"></a>&nbsp;<span class="text_information">Admin Logged in</span></div>
				</div>
		<!--news area start -->
		</div>
		
		
		
		
		
<?php

	}

		



	if($shopingcartdisplay=="Y")
	{
	
?>
		<div align="left" class="container_rgt">
		<!--shopping cart area start -->
		<div align="center" style="width:191; height:24;" class="subheading">Shopping Cart</div>
						
		<div align="left" id="news_body">
<?php

/*------------Multicart 2.0 Upgradation------------*/			

	$currency_attributes = displayCurrencyType();
	
/*------------Multicart 2.0 Upgradation------------*/				

	$total = 0;
	$cartitems = "";
	if(isset( $_SESSION["sess_userid"]) and $_SESSION["sess_userid"]!= "")
	{
		$sql = "SELECT c.*, p.product_name,p.product_price,p.discount FROM ".$tableprefix."cart c INNER JOIN ".$tableprefix."products p ON c.product_id = p.product_id WHERE  c.user_id = '".addslashes($_SESSION["sess_userid"])."' ";
	}
	else
	{
		$sql = "SELECT c.*, p.product_name,p.product_price,p.discount FROM ".$tableprefix."cart c INNER JOIN ".$tableprefix."products p ON c.product_id = p.product_id WHERE  c.visitor_cart_id = '".addslashes(session_id())."' ";
	}

	$res = mysql_query($sql);
	if(mysql_num_rows($res) > 0 )
	{
		while($rw = mysql_fetch_array($res))
		{
			$productname = $rw["product_name"];
			
/*------------Multicart 2.0 Upgradation------------*/	

			$get_convert_price = getSellerCurrency($rw["product_id"]);
			
			$defaultCurrencyrate=getDefaultCurrencyrate();
							 		
			if($currency_attributes[2]!="USD")
			{											 							 
			 if($get_convert_price != "")
			 {	
			 	// geting currency value correspoding to USD
				
				  //Below line is commented on 03-01-2010 by Ramith	
				 
				 //$get_convert_price=1/$get_convert_price;
				 //$converted_price = ($rw["product_price"]*$get_convert_price)/$defaultCurrencyrate;
				 
				 $get_convert_price=1/getUserCurrencyExvalue($currency_attributes[2]);
				 $converted_price = ($rw["product_price"]*$get_convert_price);
				 //$converted_price = ($rw["product_price"]/$get_convert_price);
			 }
			} 
			 else
			 {
				$converted_price = $rw["product_price"];
			 } 	 
			$rate = number_format(($converted_price),2 ,".","" );
			
			
			
			//$currency_attributes = displayCurrencyType();
			//$rate =	number_format(($currency_attributes[1] * $converted_price),2,".","");	
/*------------Multicart 2.0 Upgradation------------*/

			$qty = $rw["quantity"];
									
			$price = $qty * $rate;
			$discountstr="";
			if($rw["discount"] !="0")
			{
				$price=$price- ($price*$rw["discount"])/100;
				$discountstr="<br>discount(".$rw["discount"]."%)";
			}	
		
		
		$total += $price;
		//$link="<a class=\"links\" href=\"viewcart.php\" style=\"text-decoration:none;\">";
		
?>
		<div align="left" class="news_discription"><?php echo $rw["quantity"]?>&nbsp;x&nbsp;<?php echo htmlentities($productname)?></div>

<?php	
		$cartitems .= "," . $rw["cart_id"];

		}			
		
		//echo "<tr><td width=\"8%\" align=\"right\"><img src=\"images/dot.jpg\" width=\"9\" height=\"9\"></td><td width=\"10%\">$link".$rw["quantity"]."&nbsp;x&nbsp;</a></td><td align=left style='word-break:break-all;'>$link".htmlentities($productname)."</a></td></tr>";
		
	$cartitems = substr($cartitems,1 );
	
	

?>		
	<div align="left" class="news_discription">Total :&nbsp;<?php echo $currency_attributes[0]."&nbsp;".$total?></div>	
	
<?php	
	
	}
	else
	{
?>	
	
		<div align="center" class="text_information">Shopping cart is empty !!</div>	
		
	
<?php

	}
	
			
?>	
			
		</div>
	
		<!--shopping cart area ends-->
		</div>

		<div align="left" class="container_rgt">
		<!--news area start -->
		
		<div align="center" style="width:191; height:24;" class="subheading">Currency</div>
				
		<div align="left" id="news_body">
			<div align="left" class="news_date">
			
			<!---Currency Type changing starts-->


				<form name="frmCurrencyType" method="post">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					
					<tr>
						<td>
							<select name="currency_type" onChange="Javascript:document.frmCurrencyType.submit();">
<?php


	
	
	$select_currency = "SELECT ncurrency_id,vcurrency_name FROM ".$tableprefix."currency_master WHERE vactive = 'Y'";
	$result_currency = mysql_query($select_currency) or die(mysql_error());
	
	while($currency_row = mysql_fetch_array($result_currency))
	{
	
		if($_SESSION['SESS_currency_type'] == $currency_row['ncurrency_id'])
		{
		
			$currency_selected = "selected";
		
		}
		else
		{
				
			$currency_selected = "";
		
		}
				

?>									
									<option value="<?php echo $currency_row['ncurrency_id']?>" <?php echo $currency_selected?>><?php echo $currency_row['vcurrency_name']?></option>	
									
<?php

	}
	
?>										
								</select>
								
							</td>
						</tr>
					</table>
					</form>
						
<!---Currency Type changing ends-->
			
			
			
			
			
			</div>
		</div>
		<!--news area start -->
		</div>
		
				
				
				
				
				
				
				<!--body right area end -->
				</div>
		
		<!--mainbody area end -->
		</div>											
		
<?php

	}
?>		