'; // Get database information $dbconn =& oosDBGetConn(); $oostable =& oosDBGetTables(); $productstable = $oostable['products']; $products_descriptiontable = $oostable['products_description']; $products_result = $dbconn->Execute("SELECT p.products_id, pd.products_name, p.products_price FROM $productstable p, $products_descriptiontable pd WHERE p.products_id = pd.products_id AND pd.products_languages_id = '" . intval($_SESSION['language_id']) . "' ORDER BY products_name"); while ($products = $products_result->fields) { if (!oos_in_array($products['products_id'], $exclude)) { $select_string .= ''; } // Move that ADOdb pointer! $products_result->MoveNext(); } $select_string .= ''; return $select_string; } /** * Sets the status of a special * * @param $specials_id * @param $status */ function oos_set_specials_status($specials_id, $status) { // Get database information $dbconn =& oosDBGetConn(); $oostable =& oosDBGetTables(); if ($status == '1') { $specialstable = $oostable['specials']; return $dbconn->Execute("UPDATE $specialstable SET status = '1', expires_date = NULL, date_status_change = NULL WHERE specials_id = '" . intval($specials_id) . "'"); } elseif ($status == '0') { $specialstable = $oostable['specials']; return $dbconn->Execute("UPDATE $specialstable SET status = '0', date_status_change = now() WHERE specials_id = '" . intval($specials_id) . "'"); } else { return FALSE; } } require 'includes/classes/class_currencies.php'; $currencies = new currencies(); $nPage = (!isset($_GET['page']) || !is_numeric($_GET['page'])) ? 1 : intval($_GET['page']); $action = (isset($_GET['action']) ? $_GET['action'] : ''); if (!empty($action)) { switch ($action) { case 'setflag': if (isset($_GET['id']) && is_numeric($_GET['id'])) { oos_set_specials_status($_GET['id'], $_GET['flag']); } oos_redirect_admin(oos_href_link_admin($aContents['specials'], 'sID=' . intval($_GET['id']) . '&page=' . $nPage)); break; case 'insert': $products_id = oos_db_prepare_input($_POST['products_id']); $products_price = oos_db_prepare_input($_POST['products_price']); $specials_price = oos_db_prepare_input($_POST['specials_price']); $expires_date = oos_db_prepare_input($_POST['expires_date']); // insert a product on special if (substr($_POST['specials_price'], -1) == '%') { $productstable = $oostable['products']; $new_special_insert_result = $dbconn->Execute("SELECT products_id, products_price FROM $productstable WHERE products_id = '" . intval($products_id) . "'"); $new_special_insert = $new_special_insert_result->fields; $products_price = $new_special_insert['products_price']; $specials_price = ($products_price - (($specials_price / 100) * $products_price)); } $dbconn->Execute("INSERT INTO " . $oostable['specials'] . " (products_id, specials_new_products_price, specials_date_added, expires_date, status) VALUES ('" . intval($products_id) . "', '" . oos_db_input($specials_price) . "', now(), '" . oos_db_input($expires_date) . "', '1')"); oos_redirect_admin(oos_href_link_admin($aContents['specials'], 'page=' . $nPage)); break; case 'update': $specials_id = oos_db_prepare_input($_POST['specials_id']); $products_price = oos_db_prepare_input($_POST['products_price']); $specials_price = oos_db_prepare_input($_POST['specials_price']); $expires_date = oos_db_prepare_input($_POST['expires_date']); if (substr($specials_price, -1) == '%') $specials_price = ($products_price - (($specials_price / 100) * $products_price)); $dbconn->Execute("UPDATE " . $oostable['specials'] . " SET specials_new_products_price = '" . oos_db_input($specials_price) . "', specials_last_modified = now(), expires_date = '" . oos_db_input($expires_date) . "' WHERE specials_id = '" .intval($specials_id) . "'"); oos_redirect_admin(oos_href_link_admin($aContents['specials'], 'page=' . $nPage . '&sID=' . $specials_id)); break; case 'deleteconfirm': $specials_id = oos_db_prepare_input($_GET['sID']); $specialstable = $oostable['specials']; $dbconn->Execute("DELETE FROM $specialstable WHERE specials_id = '" . oos_db_input($specials_id) . "'"); oos_redirect_admin(oos_href_link_admin($aContents['specials'], 'page=' . $nPage)); break; } } require 'includes/header.php'; ?>

GetRow($sql); $sInfo = new objectInfo($product); } elseif ( ($action == 'new') && isset($_GET['pID']) ) { $productstable = $oostable['products']; $products_descriptiontable = $oostable['products_description']; $sql = "SELECT p.products_tax_class_id, p.products_id, p.products_image, pd.products_name, p.products_price FROM $productstable p, $products_descriptiontable pd WHERE p.products_id = pd.products_id AND pd.products_languages_id = '" . intval($_SESSION['language_id']) . "' AND p.products_id = '" . intval($_GET['pID']) . "'"; $product = $dbconn->GetRow($sql); $sInfo = new objectInfo($product); } else { $sInfo = new objectInfo(array()); // create an array of products on special, which will be excluded from the pull down menu of products // (when creating a new product on special) $specials_array = array(); $productstable = $oostable['products']; $specialstable = $oostable['specials']; $specials_result = $dbconn->Execute("SELECT p.products_id FROM $productstable p, $specialstable s WHERE s.products_id = p.products_id"); while ($specials = $specials_result->fields) { $specials_array[] = $specials['products_id']; // Move that ADOdb pointer! $specials_result->MoveNext(); } } ?> method="post">

products_price; $in_new_price = $sInfo->specials_new_products_price; $in_price=round($in_price,TAX_DECIMAL_PLACES); $in_new_price=round($in_new_price,TAX_DECIMAL_PLACES); if (isset($_GET['pID']) ) { echo ''; } else { echo ''; } ?>
products_name) ? "" : '('.TEXT_TAX_INFO.')'; ?>  products_name) ? product_info_image($sInfo->products_image, $sInfo->products_name) . '' : ''; ?> products_name) ? $sInfo->products_name . ' (' . $currencies->format($in_price) . ' - ' . TEXT_TAX_INFO . $currencies->format($in_price_netto) . ')' : oos_draw_products_pull_down('products_id', 'style="font-size:10px"', $specials_array); echo oos_draw_hidden_field('products_price', $sInfo->products_price); ?>
 
 


' . BUTTON_CANCEL . ''; ?>
'' . TEXT_INFO_HEADING_DELETE_SPECIALS . ''); $contents = array('form' => oos_draw_form('id', 'specials', $aContents['specials'], 'page=' . $nPage . '&sID=' . $sInfo->specials_id . '&action=deleteconfirm', 'post', FALSE)); $contents[] = array('text' => TEXT_INFO_DELETE_INTRO); $contents[] = array('text' => '
' . $sInfo->products_name . ''); $contents[] = array('align' => 'center', 'text' => '
' . oos_submit_button(BUTTON_DELETE) . ' ' . BUTTON_CANCEL . ''); break; default: if (isset($sInfo) && is_object($sInfo)) { $heading[] = array('text' => '' . $sInfo->products_name . ''); $contents[] = array('align' => 'center', 'text' => '' . oos_button(BUTTON_EDIT) . '' . oos_button(BUTTON_DELETE) . ''); $contents[] = array('text' => '
' . TEXT_INFO_DATE_ADDED . ' ' . oos_date_short($sInfo->specials_date_added)); $contents[] = array('text' => '' . TEXT_INFO_LAST_MODIFIED . ' ' . oos_date_short($sInfo->specials_last_modified)); $contents[] = array('align' => 'center', 'text' => '
' . product_info_image($sInfo->products_image, $sInfo->products_name)); $tax_result = $dbconn->Execute("SELECT tax_rate FROM " . $oostable['tax_rates'] . " WHERE tax_class_id = '" . $sInfo->products_tax_class_id . "' "); $tax = $tax_result->fields; $in_price_netto = $sInfo->products_price; $in_new_price_netto = $sInfo->specials_new_products_price; $in_price = ($in_price_netto*($tax['tax_rate']+100)/100); $in_new_price = ($in_new_price_netto*($tax['tax_rate']+100)/100); $in_price_netto = round($in_price_netto,TAX_DECIMAL_PLACES); $in_new_price_netto = round($in_new_price_netto,TAX_DECIMAL_PLACES); $in_price = round($in_price,TAX_DECIMAL_PLACES); $in_new_price = round($in_new_price,TAX_DECIMAL_PLACES); $contents[] = array('text' => '
' . TEXT_INFO_ORIGINAL_PRICE . ' ' . $currencies->format($in_price) . ' - ' . TEXT_TAX_INFO . $currencies->format($in_price_netto)); $contents[] = array('text' => '' . TEXT_INFO_NEW_PRICE . ' ' . $currencies->format($in_new_price) . ' - ' . TEXT_TAX_INFO . $currencies->format($in_new_price_netto) ); $contents[] = array('text' => '' . TEXT_INFO_PERCENTAGE . ' ' . number_format(100 - (($sInfo->specials_new_products_price / $sInfo->products_price) * 100)) . '%'); if (date('Y-m-d') < $sInfo->expires_date) $contents[] = array('text' => '
' . TEXT_INFO_EXPIRES_DATE . ' ' . oos_date_short($sInfo->expires_date) . ''); if (oos_is_not_null($sInfo->date_status_change)) $contents[] = array('text' => '' . TEXT_INFO_STATUS_CHANGE . ' ' . oos_date_short($sInfo->date_status_change)); } break; } if ( (oos_is_not_null($heading)) && (oos_is_not_null($contents)) ) { ?>
Execute($specials_sql_raw); while ($specials = $specials_result->fields) { if ((!isset($_GET['sID']) || (isset($_GET['sID']) && ($_GET['sID'] == $specials['specials_id']))) && !isset($sInfo)) { $productstable = $oostable['products']; $products_result = $dbconn->Execute("SELECT products_image FROM $productstable WHERE products_id = '" . $specials['products_id'] . "'"); $products = $products_result->fields; $sInfo_array = array_merge($specials, $products); $sInfo = new objectInfo($sInfo_array); } if (isset($sInfo) && is_object($sInfo) && ($specials['specials_id'] == $sInfo->specials_id) ) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } $in_price = $sInfo->products_price; $in_new_price = $sInfo->specials_new_products_price; ?> MoveNext(); } ?>
 
format($specials['products_price']); ?> format($specials['specials_new_products_price']); ?>  '; } else { echo ' '; } ?> specials_id) ) { echo ''; } else { echo ''; } ?> 
display_count($specials_numrows, MAX_DISPLAY_SEARCH_RESULTS, $nPage, TEXT_DISPLAY_NUMBER_OF_SPECIALS); ?> display_links($specials_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $nPage); ?>
' . oos_button(IMAGE_NEW_PRODUCT) . ''; ?>
infoBox($heading, $contents); ?>