<?php
/*
  $Id: checkout_success.php,v 1.49 2003/06/09 23:03:53 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

// if the customer is not logged on, redirect them to the shopping cart page
  if (!tep_session_is_registered('customer_id')) {
    tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
  }

  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'update')) {
    $notify_string = 'action=notify&';
    $notify = $HTTP_POST_VARS['notify'];
    if (!is_array($notify)) $notify = array($notify);
    for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
      $notify_string .= 'notify[]=' . $notify[$i] . '&';
    }
    if (strlen($notify_string) > 0) $notify_string = substr($notify_string, 0, -1);

    tep_redirect(tep_href_link(FILENAME_DEFAULT, $notify_string));
  }

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_SUCCESS);

  $breadcrumb->add(NAVBAR_TITLE_1);
  $breadcrumb->add(NAVBAR_TITLE_2);

  $global_query = tep_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'");
  $global = tep_db_fetch_array($global_query);

  if ($global['global_product_notifications'] != '1') {
    $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1");
    $orders = tep_db_fetch_array($orders_query);

    $products_array = array();
    $products_query = tep_db_query("select products_id, products_name from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$orders['orders_id'] . "' order by products_name");
    while ($products = tep_db_fetch_array($products_query)) {
      $products_array[] = array('id' => $products['products_id'],
                                'text' => $products['products_name']);
    }
  }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="pg">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<div id="bdmain" class="layout">
<!-- body //-->
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
<div id="bdcenter">
<!-- body_text //-->
<p style="color:#FF0000">
<?php echo tep_draw_form('order', tep_href_link(FILENAME_CHECKOUT_SUCCESS, 'action=update', 'SSL')); ?></p>
<p align="center" class="pageHeading"><?php echo HEADING_TITLE; ?></p>
<div style="text-align:left;">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo TEXT_SUCCESS; ?>
<?php
  if ($global['global_product_notifications'] != '1') {
    echo TEXT_NOTIFY_PRODUCTS . '<br><p class="productsNotifications">';

    $products_displayed = array();
    for ($i=0, $n=sizeof($products_array); $i<$n; $i++) {
      if (!in_array($products_array[$i]['id'], $products_displayed)) {
        echo tep_draw_checkbox_field('notify[]', $products_array[$i]['id']) . ' ' . $products_array[$i]['text'] . '<br>';
        $products_displayed[] = $products_array[$i]['id'];
      }
    }

    echo '</p>';
  } else {
    echo TEXT_SEE_ORDERS . '<br><br>' . TEXT_CONTACT_STORE_OWNER;
  }
?>
            <h3><?php echo TEXT_THANKS_FOR_SHOPPING; ?></h3>

<!-- Start Affiliate Program - Sales Tracking -->
<?php
//echo "<br>orders_total====".$orders_total;
//echo "<br>post_orders_total====".$_POST['orders_total'];
//echo "<br>SESSION_orders_total====".$_SESSION['orders_total'];
//echo "<br>orders_id====".$orders_id;
//echo "<br>post_orders_id====".$_POST['orders_id'];
//echo "<br>SESSION_orders_id====".$_SESSION['orders_id'];
//print_r($_SESSION);
//if (empty($orders_total)) $orders_total=$_SESSION['orders_total'];
//if (empty($orders_id)) $orders_id=$_SESSION['orders_id'];
//echo '<img src="https://shareasale.com/sale.cfm?amount='.$orders_total.'&tracking='.$orders_id.'&transtype=sale&merchantID=12304" width="1" height="1">'; 
//tep_session_unregister('orders_total'); 
//tep_session_unregister('orders_id'); 
?> 
<!-- // End Affiliate Program - Sales Tracking -->
</div>
		
		<table border="0" width="100%" cellspacing="3" cellpadding="0">
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td align="right" class="main"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
          <tr>
            <td><span ><?php echo CHECKOUT_BAR_DELIVERY; ?></span></td>
            <td width="18%" align="left"><span ><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></span></td>
            <td width="8"><img src="images/arr_to.gif" width="8" height="8" /></td>
            <td><?php echo CHECKOUT_BAR_PAYMENT; ?></span></td>
            <td width="18%" align="left"><span ><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></span></td>
            <td width="8"><img src="images/arr_to.gif" width="8" height="8" /></td>
            <td><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
            <td width="18%" align="left"><span ><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></span></td>
            <td width="8"><img src="images/arr_to.gif" width="8" height="8" /></td>
            <td><span style="color:red; font-weight:bold;"><?php echo CHECKOUT_BAR_FINISHED; ?></span></td>
          </tr>
        </table>
        </td>
      </tr>
<?php if (DOWNLOAD_ENABLED == 'true') include(DIR_WS_MODULES . 'downloads.php'); ?>
    </table></form>
<!-- body_text_eof //-->
</div>
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->

<!-- body_eof //-->
</div>
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</div>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
