?> </td> <td class="smallText" align="center"><?php echo TEXT_DOWNLOAD_MAX_COUNT; ?> </td> </tr> <?php // add legend while (!$orders_download->EOF) { // $order->info['date_purchased'] . ' vs ' . (zen_date_diff($order->info['date_purchased'], date('Y-m-d')) > $orders_download->fields['download_maxdays'] ? 'NO' : 'YES') . ' vs ' . switch (true) { case $orders_download->fields['download_maxdays'] <= 0 && $orders_download->fields['download_count'] <= 0: $zc_file_status = TEXT_INFO_EXPIRED_DATE . '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $_GET['oID'] . '&action=edit&download_reset_on=' . $orders_download->fields['orders_products_download_id'], 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_STATUS_EXPIRED) . '</a>'; break; case $orders_download->fields['download_maxdays'] != 0 && zen_date_diff($order->info['date_purchased'], date('Y-m-d')) > $orders_download->fields['download_maxdays']: $zc_file_status = TEXT_INFO_EXPIRED_DATE . '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $_GET['oID'] . '&action=edit&download_reset_on=' . $orders_download->fields['orders_products_download_id'], 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_STATUS_EXPIRED) . '</a>'; break; case $orders_download->fields['download_maxdays'] == 0: $zc_file_status = '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $_GET['oID'] . '&action=edit&download_reset_off=' . $orders_download->fields['orders_products_download_id'], 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_CURRENT) . '</a>'; break; case $orders_download->fields['download_maxdays'] > 0 and $orders_download->fields['download_count'] > 0: $zc_file_status = '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $_GET['oID'] . '&action=edit&download_reset_off=' . $orders_download->fields['orders_products_download_id'], 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_CURRENT) . '</a>'; break; /* * case ($orders_download->fields['download_maxdays'] <= 1 or $orders_download->fields['download_count'] <= 1): $zc_file_status = TEXT_INFO_EXPIRED_COUNT . '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $_GET['oID'] . '&action=edit&download_reset_on=' . $orders_download->fields['orders_products_download_id'], 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_STATUS_EXPIRED) . '</a>'; break; */ /* * case ($orders_download->fields['download_maxdays'] <= 1 or $orders_download->fields['download_count'] <= 1): $zc_file_status = TEXT_INFO_EXPIRED_COUNT . '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $_GET['oID'] . '&action=edit&download_reset_on=' . $orders_download->fields['orders_products_download_id'], 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_STATUS_EXPIRED) . '</a>'; break; */ case $orders_download->fields['download_maxdays'] != 0 && $orders_download->fields['download_count'] <= 1:
/** * Write order-history update to ZC tables denoting the update supplied by the IPN */ function ipn_update_orders_status_and_history($ordersID, $new_status = 1, $txn_type) { global $db; ipn_debug_email('IPN NOTICE :: Updating order #' . (int) $ordersID . ' to status: ' . (int) $new_status . ' (txn_type: ' . $txn_type . ')'); $db->Execute("update " . TABLE_ORDERS . "\n set orders_status = '" . (int) $new_status . "'\n where orders_id = '" . (int) $ordersID . "'"); $sql_data_array = array('orders_id' => (int) $ordersID, 'orders_status_id' => (int) $new_status, 'date_added' => 'now()', 'comments' => 'PayPal status: ' . $_POST['payment_status'] . ' ' . ' @ ' . $_POST['payment_date'] . ($_POST['parent_txn_id'] != '' ? "\n" . ' Parent Trans ID:' . $_POST['parent_txn_id'] : '') . "\n" . ' Trans ID:' . $_POST['txn_id'] . "\n" . ' Amount: ' . $_POST['mc_gross'] . ' ' . $_POST['mc_currency'], 'customer_notified' => false); zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array); ipn_debug_email('IPN NOTICE :: Update complete.'); /** * Activate any downloads associated with an order which has now been cleared */ if ($txn_type == 'echeck-cleared' || $txn_type == 'express-checkout-cleared' || substr($txn_type, 0, 8) == 'cleared-') { $check_status = $db->Execute("select date_purchased from " . TABLE_ORDERS . " where orders_id = '" . (int) $ordersID . "'"); $zc_max_days = zen_date_diff($check_status->fields['date_purchased'], date('Y-m-d H:i:s', time())) + (int) DOWNLOAD_MAX_DAYS; ipn_debug_email('IPN NOTICE :: Updating order #' . (int) $ordersID . ' downloads (if any). New max days: ' . (int) $zc_max_days . ', New count: ' . (int) DOWNLOAD_MAX_COUNT); $update_downloads_query = "update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_maxdays='" . (int) $zc_max_days . "', download_count='" . (int) DOWNLOAD_MAX_COUNT . "' where orders_id='" . (int) $ordersID . "'"; $db->Execute($update_downloads_query); } }
} } } if ($order_updated == true) { if ($status == DOWNLOADS_ORDERS_STATUS_UPDATED_VALUE) { // adjust download_maxdays based on current date $chk_downloads_query = "SELECT opd.*, op.products_id from " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " opd, " . TABLE_ORDERS_PRODUCTS . " op\n WHERE op.orders_id='" . (int) $oID . "'\n and opd.orders_products_id = op.orders_products_id"; $chk_downloads = $db->Execute($chk_downloads_query); while (!$chk_downloads->EOF) { $chk_products_download_time_query = "SELECT pa.products_attributes_id, pa.products_id, pad.products_attributes_filename, pad.products_attributes_maxdays, pad.products_attributes_maxcount\n from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n WHERE pa.products_attributes_id = pad.products_attributes_id\n and pad.products_attributes_filename = '" . $chk_downloads->fields['orders_products_filename'] . "'\n and pa.products_id = '" . $chk_downloads->fields['products_id'] . "'"; $chk_products_download_time = $db->Execute($chk_products_download_time_query); if ($chk_products_download_time->EOF) { $zc_max_days = DOWNLOAD_MAX_DAYS == 0 ? 0 : zen_date_diff($check_status->fields['date_purchased'], date('Y-m-d H:i:s', time())) + DOWNLOAD_MAX_DAYS; $update_downloads_query = "update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_maxdays='" . $zc_max_days . "', download_count='" . DOWNLOAD_MAX_COUNT . "' where orders_id='" . (int) $oID . "' and orders_products_download_id='" . $_GET['download_reset_on'] . "'"; } else { $zc_max_days = $chk_products_download_time->fields['products_attributes_maxdays'] == 0 ? 0 : zen_date_diff($check_status->fields['date_purchased'], date('Y-m-d H:i:s', time())) + $chk_products_download_time->fields['products_attributes_maxdays']; $update_downloads_query = "update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_maxdays='" . $zc_max_days . "', download_count='" . $chk_products_download_time->fields['products_attributes_maxcount'] . "' where orders_id='" . (int) $oID . "' and orders_products_download_id='" . $chk_downloads->fields['orders_products_download_id'] . "'"; } $db->Execute($update_downloads_query); $chk_downloads->MoveNext(); } } $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success'); } else { $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning'); } zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL')); break; case 'deleteconfirm': // demo active test if (zen_admin_demo()) {
$zv_db_patch_ok = false; $messageStack->add(WARNING_DATABASE_VERSION_OUT_OF_DATE, 'warning'); } } // Check that shipping/payment modules have been defined if (zen_get_configuration_key_value('MODULE_PAYMENT_INSTALLED') == '') { $messageStack->add(ERROR_PAYMENT_MODULES_NOT_DEFINED, 'caution'); } if (zen_get_configuration_key_value('MODULE_SHIPPING_INSTALLED') == '') { $messageStack->add(ERROR_SHIPPING_MODULES_NOT_DEFINED, 'caution'); } // if welcome email coupon is set and <= 21 days warn shop owner if (NEW_SIGNUP_DISCOUNT_COUPON > 0) { $zc_welcome_check = $db->Execute("SELECT coupon_expire_date from " . TABLE_COUPONS . " WHERE coupon_id=" . (int) NEW_SIGNUP_DISCOUNT_COUPON); $zc_current_date = date('Y-m-d'); $zc_days_to_expire = zen_date_diff($zc_current_date, $zc_welcome_check->fields['coupon_expire_date']); if ($zc_days_to_expire <= 21) { $zc_caution_warning = $zc_days_to_expire <= 5 ? 'warning' : 'caution'; $messageStack->add(sprintf(WARNING_WELCOME_DISCOUNT_COUPON_EXPIRES_IN, $zc_days_to_expire), $zc_caution_warning); } } // Alerts for EZ-Pages if (EZPAGES_STATUS_HEADER == '2' and strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])) { $messageStack->add(TEXT_EZPAGES_STATUS_HEADER_ADMIN, 'caution'); } if (EZPAGES_STATUS_FOOTER == '2' and strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])) { $messageStack->add(TEXT_EZPAGES_STATUS_FOOTER_ADMIN, 'caution'); } if (EZPAGES_STATUS_SIDEBOX == '2' and strstr(EXCLUDE_ADMIN_IP_FOR_MAINTENANCE, $_SERVER['REMOTE_ADDR'])) { $messageStack->add(TEXT_EZPAGES_STATUS_SIDEBOX_ADMIN, 'caution'); }
// trigger any appropriate updates which should be sent back to the payment gateway: $order = new order((int) $oID); if ($order->info['payment_module_code']) { if (file_exists(DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php')) { require_once DIR_FS_CATALOG_MODULES . 'payment/' . $order->info['payment_module_code'] . '.php'; require_once DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php'; $module = new $order->info['payment_module_code'](); if (method_exists($module, '_doStatusUpdate')) { $response = $module->_doStatusUpdate($oID, $status, $comments, $customer_notified, $check_status->fields['orders_status']); } } } if ($order_updated == true) { if ($status == DOWNLOADS_ORDERS_STATUS_UPDATED_VALUE) { // adjust download_maxdays based on current date $zc_max_days = zen_date_diff($check_status->fields['date_purchased'], date('Y-m-d H:i:s', time())) + DOWNLOAD_MAX_DAYS; $update_downloads_query = "update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_maxdays='" . $zc_max_days . "', download_count='" . DOWNLOAD_MAX_COUNT . "' where orders_id='" . (int) $oID . "'"; $db->Execute($update_downloads_query); } $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success'); } else { $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning'); } zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('action')) . 'action=edit', 'NONSSL')); break; case 'deleteconfirm': // demo active test if (zen_admin_demo()) { $_GET['action'] = ''; $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution'); zen_redirect(zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')), 'NONSSL'));