Esempio n. 1
0
function zen_start_specials()
{
    global $db;
    $date_range = time();
    $zc_specials_date = date('Ymd', $date_range);
    // turn on special if active
    $specials_query = "select specials_id, products_id\r\n                       from " . TABLE_SPECIALS . "\r\n                       where status = '0'\r\n                       and (((specials_date_available <= " . $zc_specials_date . " and specials_date_available != '0001-01-01') and (expires_date > " . $zc_specials_date . "))\r\n                       or ((specials_date_available <= " . $zc_specials_date . " and specials_date_available != '0001-01-01') and (expires_date = '0001-01-01'))\r\n                       or (specials_date_available = '0001-01-01' and expires_date > " . $zc_specials_date . "))\r\n                       ";
    $specials = $db->Execute($specials_query);
    if ($specials->RecordCount() > 0) {
        while (!$specials->EOF) {
            zen_set_specials_status($specials->fields['specials_id'], '1');
            zen_update_products_price_sorter($specials->fields['products_id']);
            $specials->MoveNext();
        }
    }
    // turn off special if not active yet
    $specials_query = "select specials_id, products_id\r\n                       from " . TABLE_SPECIALS . "\r\n                       where status = '1'\r\n                       and (" . $zc_specials_date . " < specials_date_available and specials_date_available != '0001-01-01')\r\n                       ";
    $specials = $db->Execute($specials_query);
    if ($specials->RecordCount() > 0) {
        while (!$specials->EOF) {
            zen_set_specials_status($specials->fields['specials_id'], '0');
            zen_update_products_price_sorter($specials->fields['products_id']);
            $specials->MoveNext();
        }
    }
}
Esempio n. 2
0
function zen_start_specials()
{
    global $gBitDb;
    // turn on special if active
    $specials_query = "select `specials_id`, `products_id`\n                       from " . TABLE_SPECIALS . "\n                       where `status` = '0'\n                       and (((`specials_date_available` <= 'NOW' and `specials_date_available` != '0001-01-01') and (`expires_date` >= 'NOW'))\n                       or ((`specials_date_available` <= 'NOW' and `specials_date_available` != '0001-01-01') and (`expires_date` = '0001-01-01'))\n                       or (`specials_date_available` = '0001-01-01' and `expires_date` >= 'NOW'))\n                       ";
    if ($rs = $gBitDb->Execute($specials_query)) {
        while ($specials = $rs->FetchRow()) {
            zen_set_specials_status($specials['specials_id'], '1');
            zen_update_lowest_purchase_price($specials['products_id']);
        }
    }
    // turn off special if not active yet
    $specials_query = "select `specials_id`, `products_id`\n                       from " . TABLE_SPECIALS . "\n                       where `status` = '1'\n                       and ('NOW' < `specials_date_available` and `specials_date_available` != '0001-01-01')\n                       ";
    if ($rs = $gBitDb->Execute($specials_query)) {
        while ($specials = $rs->FetchRow()) {
            zen_set_specials_status($specials['specials_id'], '0');
            zen_update_lowest_purchase_price($specials['products_id']);
        }
    }
}
Esempio n. 3
0
/**
 * @package admin
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: specials.php 6346 2007-05-20 14:20:46Z ajeh $
 */
require 'includes/application_top.php';
require DIR_WS_CLASSES . 'currencies.php';
$currencies = new currencies();
$action = isset($_GET['action']) ? $_GET['action'] : '';
if (zen_not_null($action)) {
    switch ($action) {
        case 'setflag':
            zen_set_specials_status($_GET['id'], $_GET['flag']);
            // reset products_price_sorter for searches etc.
            $update_price = $db->Execute("select products_id from " . TABLE_SPECIALS . " where specials_id = '" . $_GET['id'] . "'");
            zen_update_products_price_sorter($update_price->fields['products_id']);
            zen_redirect(zen_href_link(FILENAME_SPECIALS, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'sID=' . $_GET['id'], 'NONSSL'));
            break;
        case 'insert':
            if ($_POST['products_id'] < 1) {
                $messageStack->add_session(ERROR_NOTHING_SELECTED, 'caution');
            } else {
                $products_id = zen_db_prepare_input($_POST['products_id']);
                $products_price = zen_db_prepare_input($_POST['products_price']);
                $tmp_value = zen_db_prepare_input($_POST['specials_price']);
                $specials_price = !zen_not_null($tmp_value) || $tmp_value == '' || $tmp_value == 0 ? 0 : $tmp_value;
                if (substr($specials_price, -1) == '%') {
                    $new_special_insert = $db->Execute("select products_id, products_price, products_priced_by_attribute\n                                              from " . TABLE_PRODUCTS . "\n                                              where products_id = '" . (int) $products_id . "'");