<?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 � 2005                |
// | 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
include "includes/config.php";
include "includes/session.php";
include "includes/functions.php";
if(isset( $_SESSION["sess_userid"]) and $_SESSION["sess_userid"]!= ""){
	$userid = $_SESSION["sess_userid"];
}
/*display the active template*/

$active_template = displayTemplate();


// Google Checkout Payment Mails 


if(isset($_SESSION['google_order_id'])&& $_SESSION['google_order_id']!=''){

      $orderid = $_SESSION['google_order_id'];

      if(isset($_SESSION["sess_guest_username"]) && $_SESSION["sess_guest_username"]!='')
            {
                    $usertype='guest';
            }
            else
            {
                    $usertype='user';
            }

            
    $sql_order ="SELECT * FROM ".$tableprefix."orders where order_id='".$orderid."' AND vpayment_status='C' ";

    $rs_order=mysql_query($sql_order) or die(mysql_error());

    if(mysql_num_rows($rs_order)>0) {

          $gift_coupon_flag=$_SESSION['gift_coupon_flag'];

         $product_download_flag=$_SESSION['product_download_flag'];

          // Send Giftcertificate Mails
		if($gift_coupon_flag == 1)
		{
			sendgiftCertificateMail_Buyer($orderid,$_SESSION["sess_userid"],$usertype);
			sendgiftCertificateMail_Seller($orderid,$_SESSION["sess_userid"]);
			sendgiftCertificateMail_Admin($orderid,$_SESSION["sess_userid"]);
		}

		//Send Digital Certificate Mails

		if($product_download_flag == 1)
		{
			sendDigitalCertificateMail_Buyer($orderid,$_SESSION["sess_userid"],$usertype);
			sendDigitalCertificateMail_Seller($orderid,$_SESSION["sess_userid"]);
			sendDigitalCertificateMail_Admin($orderid,$_SESSION["sess_userid"]);
		}




		if($product_download_flag!=1 && $gift_coupon_flag!=1)
		{

			sendBuyerEmail($orderid,$_SESSION["sess_userid"],$usertype);
			sendSellerEmail($orderid,$_SESSION["sess_userid"]);
			sendAdminEmail($orderid,$_SESSION["sess_userid"]);

		}


                  adjustStock($_SESSION["sess_userid"],"-" );

                    emptyCart($_SESSION["sess_userid"]);

                    $_SESSION["sess_addresses_collected"] = false;

                    $_SESSION["sess_stock_adjusted"] = false;

                    $_SESSION["sess_addresses_collected"] = false;
                            $_SESSION["sess_stock_adjusted"] = false;
                            $_SESSION['couponCode_det']='';
                            if(isset($_SESSION['guest_login']) && $_SESSION['guest_login']!='')
                            {
                              if(function_exists('session_unregister')){
                                session_unregister($_SESSION['guest_login']);
                                session_unregister($_SESSION['sess_userid']);
                                session_unregister($_SESSION['SHIPPING_TOTAL']);
                            }else{
                                unset($_SESSION['guest_login']);
                                unset($_SESSION['sess_userid']);
                                unset($_SESSION['SHIPPING_TOTAL']);
                            }
                                    $_SESSION['guest_login']='';
                                    $_SESSION["sess_userid"]='';
                            }
                            $_SESSION["sess_guest_username"]='';
                            $_SESSION["sess_guest_password"]='';
                             $_SESSION["sessShippingDisplayName"]='';
                             $_SESSION['sess_giftcertificate_code']='';
                             $_SESSION['sess_gift_amount_used']='';
                             $_SESSION['amount_paid']='';
                             $_SESSION['sess_giftcertificate_available_amt']='';
                             $_SESSION["SESS_BUYER_COMMENTS"] ='';
                             $_SESSION["TAX_TOTAL"] ='';
                             $_SESSION['google_order_id']='';
                             $_SESSION['gift_coupon_flag']='';
                             $_SESSION['product_download_flag']='';
                             
                    unset($_SESSION['SHIPPING_TOTAL']);
                    $_SESSION["SHIPPING_DETAILS"]   =array();
                     unset($_SESSION["SHIPPING_DETAILS"]);
                     unset($_SESSION["TAX_DETAILS"]);
                     unset($_SESSION['couponCode_det']);
            }

}

//


include "includes/htmltop.php";

/* Top File Name */

include_once ("includes/".$active_template[0]);

?>
			<div align="left" class="main_body">

			<!--mainbody area start -->

		<!--center content area start-->

		<div align="left" id="item_details">


		<!--items display area start -->

		<div align="left" id="items_top_area">
				<div align="left" id="items_top_area_ttl"><?php echo GC_PAY_INFO_TEXT;?></div>

		</div>

		<div>&nbsp;</div>

		<div class="text_information" align="center"><?php echo $message?></div>

		<div>

                       <table cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                        <td class="text_information" align="center">
                        <b style="background-color:#000000; margin-bottom:15px;  font-family:Arial, Helvetica, sans-serif; font-size:12px; padding:10px 10px 10px 10px; color:#67CB1A;"><?php echo ORDER_PLACED_SUCESS_TEXT;?></b>
                        </td>
                        </tr>
                        <tr>
                        <td height="8" align="center" ></td>
                        </tr>
                        <?php

                        if(isset($_SESSION['SESS_digital_product']) && $_SESSION['SESS_digital_product']!='')
                        {
                        ?>
                        <tr>
                        <td colspan="3" align="center" class="text_information">
                        <b style="background-color:#000000; margin-bottom:15px; font-family:Arial, Helvetica, sans-serif; font-size:12px; padding:10px 10px 10px 10px; color:#67CB1A;"><?php echo PRODUCT_LINK_MAIL_TEXT;?></b>
                        </td>
                        </tr>
                        <?php
                        }

                       
                        $_SESSION['SESS_digital_product']='';
                        if(function_exists('session_unregister')){
                           session_unregister($_SESSION['SESS_digital_product']);
                        }
                        else{
                            unset($_SESSION['SESS_digital_product']);
                        }
                        // Checking the paypal payment
                        ?>
                        <tr>
                        <td>&nbsp;</td>
                        </tr>
                        <tr>
                        <td align="center">
                        <input type='button' value='<?php echo HOME_LINK;?>'  class='button' onClick="window.location.href='<?php echo SITE_URL;?>/index.php'">
                        &nbsp;&nbsp;<input type='button' value='<?php echo CONTINUE_SHOPPING_BUTTON;?>'  class='button' onClick="window.location.href='<?php echo SITE_URL;?>/categorydetail.php'">
                        </td>
                        </tr>
                        </table>

		</div>

		<div align="left" class="float_clear1"></div>


	 <!--items display area end -->
	  </div>

	<!--center content area end-->


	<div align="left" class="clear"></div>
	<!--mainbody area end -->
	</div>
	<div align="left" class="clear"></div>


<?php
include "includes/".$active_template[2];	/* Bottom File Name */
?>



