}
     $messageStack->add_session(SUCCESS_BILLING, 'success');
     olc_redirect(olc_href_link(FILENAME_AFFILIATE_PAYMENT, olc_get_all_get_params(array('action')) . 'action=edit'));
     break;
 case 'update_payment':
     $pID = olc_db_prepare_input($_GET['pID']);
     $status = olc_db_prepare_input($_POST['status']);
     $payment_updated = false;
     $check_status_query = olc_db_query("select af.affiliate_email_address, ap.affiliate_lastname, ap.affiliate_firstname, ap.affiliate_payment_status, ap.affiliate_payment_date, ap.affiliate_payment_date from " . TABLE_AFFILIATE_PAYMENT . " ap, " . TABLE_AFFILIATE . " af where affiliate_payment_id = '" . olc_db_input($pID) . "' and af.affiliate_id = ap.affiliate_id ");
     $check_status = olc_db_fetch_array($check_status_query);
     if ($check_status['affiliate_payment_status'] != $status) {
         olc_db_query(SQL_UPDATE . TABLE_AFFILIATE_PAYMENT . " set affiliate_payment_status = '" . olc_db_input($status) . "', affiliate_last_modified = now() where affiliate_payment_id = '" . olc_db_input($pID) . APOS);
         $affiliate_notified = '0';
         // Notify Affiliate
         if ($_POST['notify'] == 'on') {
             $email = STORE_NAME . NEW_LINE . EMAIL_SEPARATOR . NEW_LINE . EMAIL_TEXT_AFFILIATE_PAYMENT_NUMBER . BLANK . $pID . NEW_LINE . EMAIL_TEXT_INVOICE_URL . BLANK . olc_catalog_href_link(FILENAME_CATALOG_AFFILIATE_PAYMENT_INFO, 'payment_id=' . $pID, SSL) . NEW_LINE . EMAIL_TEXT_PAYMENT_BILLED . BLANK . olc_date_long($check_status['affiliate_payment_date']) . "\n\n" . sprintf(EMAIL_TEXT_STATUS_UPDATE, $payments_status_array[$status]);
             olc_mail($check_status['affiliate_firstname'] . BLANK . $check_status['affiliate_lastname'], $check_status['affiliate_email_address'], EMAIL_TEXT_SUBJECT, nl2br($email), STORE_OWNER, AFFILIATE_EMAIL_ADDRESS);
             $affiliate_notified = '1';
         }
         olc_db_query(INSERT_INTO . TABLE_AFFILIATE_PAYMENT_STATUS_HISTORY . " (affiliate_payment_id, affiliate_new_value, affiliate_old_value, affiliate_date_added, affiliate_notified) values ('" . olc_db_input($pID) . "', '" . olc_db_input($status) . "', '" . $check_status['affiliate_payment_status'] . "', now(), '" . $affiliate_notified . "')");
         $order_updated = true;
     }
     if ($order_updated) {
         $messageStack->add_session(SUCCESS_PAYMENT_UPDATED, 'success');
     }
     olc_redirect(olc_href_link(FILENAME_AFFILIATE_PAYMENT, olc_get_all_get_params(array('action')) . 'action=edit'));
     break;
 case 'deleteconfirm':
     $pID = olc_db_prepare_input($_GET['pID']);
     olc_db_query(DELETE_FROM . TABLE_AFFILIATE_PAYMENT . " where affiliate_payment_id = '" . olc_db_input($pID) . APOS);
     olc_db_query(DELETE_FROM . TABLE_AFFILIATE_PAYMENT_STATUS_HISTORY . " where affiliate_payment_id = '" . olc_db_input($pID) . APOS);
*/
include DIR_WS_CLASSES . 'order.php';
$order = new order($HTTP_GET_VARS['oID']);
require_once PAYPAL_IPN_DIR . 'Admin/languages/' . $language . '/paypal.lng.php';
require_once PAYPAL_IPN_DIR . 'Classes/TransactionDetails/TransactionDetails.class.php';
$paypal = new PayPal_TransactionDetails(TABLE_PAYPAL, $order->info['payment_id']);
if ($HTTP_GET_VARS['digest'] != $paypal->digest()) {
    $messageStack->add_session(ERROR_UNAUTHORIZED_REQUEST);
} elseif ($paypal->info['payment_status'] === 'Completed' && $order->info['orders_status'] === MODULE_PAYMENT_PAYPAL_ORDER_ONHOLD_STATUS_ID) {
    include PAYPAL_IPN_DIR . 'Functions/addressbook.func.php';
    include PAYPAL_IPN_DIR . 'Classes/osC/Order.class.php';
    $PayPal_osC_Order = new PayPal_osC_Order();
    $PayPal_osC_Order->setOrderID($HTTP_GET_VARS['oID']);
    $PayPal_osC_Order->loadOrdersSessionInfo();
    //$currency = $PayPal_osC_Order->currency;
    $PayPal_osC_Order->setAccountHistoryInfoURL(olc_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $PayPal_osC_Order->orderID, 'SSL', false));
    $PayPal_osC_Order->setCheckoutProcessLanguageFile(DIR_FS_CATALOG_LANGUAGES . $PayPal_osC_Order->language . '/' . 'checkout_process.php');
    $PayPal_osC_Order->updateProducts($order, $currencies);
    $PayPal_osC_Order->notifyCustomer($order);
    $affiliate_ref = $PayPal_osC_Order->affiliate_id;
    $affiliate_clickthroughs_id = $PayPal_osC_Order->affiliate_clickthroughs_id;
    $affiliate_clientdate = $PayPal_osC_Order->affiliate_date;
    $affiliate_clientbrowser = $PayPal_osC_Order->affiliate_browser;
    $affiliate_clientip = $PayPal_osC_Order->affiliate_ipaddress;
    if (olc_not_null($affiliate_ref) && $affiliate_ref != '0') {
        define('MODULE_PAYMENT_PAYPAL_SHOPPING_IPN_AFFILIATE', TRUE_STRING_S);
        $insert_id = $PayPal_osC_Order->orderID;
        include DIR_FS_CATALOG_MODULES . '../affiliate_checkout_process.php';
    }
    $PayPal_osC_Order->updateOrderStatus(MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID);
    $PayPal_osC_Order->removeOrdersSession();
            echo '                  <tr class="productListing-even">';
        } else {
            echo '                  <tr class="productListing-odd">';
        }
        ?>
                <td class="dataTableContent"><?php 
        echo $affiliate_clickthroughs['affiliate_firstname'] . BLANK . $affiliate_clickthroughs['affiliate_lastname'];
        ?>
</td>
                <td class="dataTableContent" align="center"><?php 
        echo olc_date_short($affiliate_clickthroughs['affiliate_clientdate']);
        ?>
</td>
<?php 
        if ($affiliate_clickthroughs['affiliate_products_id'] > 0) {
            $link_to = HTML_A_START . olc_catalog_href_link(FILENAME_CATALOG_PRODUCT_INFO, 'products_id=' . $affiliate_clickthroughs['affiliate_products_id']) . '" target="_blank">' . $affiliate_clickthroughs['products_name'] . HTML_A_END;
        } else {
            $link_to = "Startpage";
        }
        ?>
                <td class="dataTableContent"><?php 
        echo $link_to;
        ?>
</td>
                <td class="dataTableContent" align="center"><?php 
        echo $affiliate_clickthroughs['affiliate_clientbrowser'];
        ?>
</td>
              </tr>
              <tr>
                <td class="dataTableContent"><?php 
     }
 }
 if ($update) {
     olc_db_query("\n\t\t\tupdate " . TABLE_ORDERS . "\n\t\t\tset\n\t\t\torders_status = '" . olc_db_input($status) . "',\n\t\t\torders_trackcode = '" . $track_code . "',\n\t\t\tlast_modified = now()\n\t\t\twhere orders_id = '" . $oID . APOS);
     $customer_notified = 0;
     if ($_POST['notify'] == 'on') {
         $notify_comments = EMPTY_STRING;
         if ($_POST['notify_comments'] == 'on') {
             if ($comment) {
                 $notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $comments) . "\n\n";
             }
         }
         $customers_name = $order->customer['name'];
         $smarty->assign('NAME', $customers_name);
         $smarty->assign('ORDER_NR', $oID);
         $smarty->assign('ORDER_LINK', olc_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, SSL));
         $smarty->assign('ORDER_DATE', olc_date_long($order->info['date_purchased']));
         $smarty->assign('NOTIFY_COMMENTS', $notify_comments);
         $smarty->assign('ORDER_STATUS', $orders_status_array[$status]);
         //	W. Kaiser - Erlaube Sendungstracking
         $smarty->assign('SHIP_DATE', date('l, j F Y H:i'));
         $txt_mail = str_replace('admin/', EMPTY_STRING, olc_href_link(FILENAME_CUSTOMER_DEFAULT, EMPTY_STRING, NONSSL, false));
         $smarty->assign('HOME_LINK', $txt_mail);
         if ($status == 3) {
             //Status "Versendet"
             if ($track_code) {
                 //Assign smarty Variable for tracking URL
                 require_once DIR_FS_INC . 'olc_get_track_code.inc.php';
                 $TrackURL = olc_get_track_code($order, $track_code);
                 $smarty->assign('TRACK_URL', $TrackURL);
             }
        // csv export
        echo date(DATE_FORMAT, $sr->showDate) . SR_SEPARATOR1 . date(DATE_FORMAT, $sr->showDateEnd) . SR_SEPARATOR1;
        echo $info[0]['order'] . SR_SEPARATOR1;
        echo $info[$last - 1]['totitem'] . SR_SEPARATOR1;
        echo $currencies->format($info[$last - 1]['totsum']) . SR_SEPARATOR1;
        echo $currencies->format($info[0]['shipping']) . SR_NEWLINE;
    }
    if ($srDetail) {
        for ($i = 0; $i < $last; $i++) {
            if ($srMax == 0 or $i < $srMax) {
                if ($srExp < 2) {
                    ?>
                    <tr class="dataTableRow" onmouseover="this.className='dataTableRowOver';this.style.cursor='hand'" onmouseout="this.className='dataTableRow'">
                    <td class="dataTableContent">&nbsp;</td>
                    <td class="dataTableContent" align="left"><?php 
                    echo HTML_A_START . olc_catalog_href_link("product_info.php?products_id=" . $info[$i]['pid']);
                    ?>
" target="_blank"><?php 
                    echo $info[$i]['pname'];
                    ?>
</a>
<?php 
                    if (is_array($info[$i]['attr'])) {
                        $attr_info = $info[$i]['attr'];
                        foreach ($attr_info as $attr) {
                            echo '<div style="font-style:italic;">&nbsp;' . $attr['quant'] . 'x ';
                            //  $attr['options'] . ': '
                            $flag = 0;
                            foreach ($attr['options_values'] as $value) {
                                if ($flag > 0) {
                                    echo "," . $value;
  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  DevosC, Developing open source Code
  http://www.devosc.com

  Copyright (c) 2003 osCommerce
  Copyright (c) 2004 DevosC.com
Copyright (c) 2006 Dipl.-Ing.(TH) Winfried Kaiser (w.kaiser@fortune.de) -- Port to OL-Commerce

  Released under the GNU General Public License
*/
require_once DIR_FS_INC . 'olc_draw_form.inc.php';
require_once DIR_FS_INC . 'olc_draw_hidden_field.inc.php';
olc_draw_form('ipn', olc_catalog_href_link(FILENAME_IPN), 'POST');
olc_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_BUSINESS_ID);
olc_draw_hidden_field('receiver_email', MODULE_PAYMENT_PAYPAL_ID);
olc_draw_hidden_field('verify_sign', 'PAYPAL_SHOPPING_CART_IPN-TEST_TRANSACTION-00000000000000');
olc_draw_hidden_field('payment_date', ate("H:i:s M d, Y T"));
olc_draw_hidden_field('digestKey', PayPal_IPN::digestKey());
?>
<table border="0" cellspacing="0" cellpadding="2" class="main">
<?php 
if (MODULE_PAYMENT_PAYPAL_IPN_TEST_MODE == 'Off') {
    ?>
  <tr>
    <td>
      <table border="0" cellspacing="0" cellpadding="0" style="padding: 4px; border:1px solid #aaaaaa; background: #ffffcc;">
        <tr>
          <td><?php