[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 specials.php

Zen Cart 源代码 specials.php




下载文件

文件名: specials.php
文件类型: PHP文件
文件大小: 31.98 KiB
MD5: 5efbd67e398fdf00572abe0eccd95286

specials.php - 关闭高亮
  1. <?php
  2. /**
  3.  * @package admin
  4.  * @copyright Copyright 2003-2010 Zen Cart Development Team
  5.  * @copyright Portions Copyright 2003 osCommerce
  6.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  7.  * @version $Id: specials.php 17980 2010-10-17 14:15:39Z ajeh $
  8.  */
  9.  
  10.   require('includes/application_top.php');
  11.  
  12.   require(DIR_WS_CLASSES . 'currencies.php');
  13.   $currencies = new currencies();
  14.  
  15.   $action = (isset($_GET['action']) ? $_GET['action'] : '');
  16.  
  17.   if (zen_not_null($action)) {
  18.     switch ($action) {
  19.       case 'setflag':
  20.         zen_set_specials_status($_GET['id'], $_GET['flag']);
  21.  
  22.         // reset products_price_sorter for searches etc.
  23.         $update_price = $db->Execute("select products_id from " . TABLE_SPECIALS . " where specials_id = '" . $_GET['id'] . "'");
  24.         zen_update_products_price_sorter($update_price->fields['products_id']);
  25.  
  26.         zen_redirect(zen_href_link(FILENAME_SPECIALS, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'sID=' . $_GET['id'], 'NONSSL'));
  27.         break;
  28.       case 'insert':
  29.         if ($_POST['products_id'] < 1) {
  30.           $messageStack->add_session(ERROR_NOTHING_SELECTED, 'caution');
  31.         } else {
  32.         $products_id = zen_db_prepare_input($_POST['products_id']);
  33.         $products_price = zen_db_prepare_input($_POST['products_price']);
  34.  
  35.         $tmp_value = zen_db_prepare_input($_POST['specials_price']);
  36.         $specials_price = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;
  37.  
  38.         if (substr($specials_price, -1) == '%') {
  39.           $new_special_insert = $db->Execute("select products_id, products_price, products_priced_by_attribute
  40.                                              from " . TABLE_PRODUCTS . "
  41.                                              where products_id = '" . (int)$products_id . "'");
  42.  
  43. // check if priced by attribute
  44.           if ($new_special_insert->fields['products_priced_by_attribute'] == '1') {
  45.             $products_price = zen_get_products_base_price($products_id);
  46.           } else {
  47.             $products_price = $new_special_insert->fields['products_price'];
  48.           }
  49.  
  50.           $specials_price = ($products_price - (($specials_price / 100) * $products_price));
  51.         }
  52.  
  53.         $specials_date_available = ((zen_db_prepare_input($_POST['start']) == '') ? '0001-01-01' : zen_date_raw($_POST['start']));
  54.         $expires_date = ((zen_db_prepare_input($_POST['end']) == '') ? '0001-01-01' : zen_date_raw($_POST['end']));
  55.  
  56.         $products_id = zen_db_prepare_input($_POST['products_id']);
  57.         $db->Execute("insert into " . TABLE_SPECIALS . "
  58.                    (products_id, specials_new_products_price, specials_date_added, expires_date, status, specials_date_available)
  59.                    values ('" . (int)$products_id . "',
  60.                            '" . zen_db_input($specials_price) . "',
  61.                            now(),
  62.                            '" . zen_db_input($expires_date) . "', '1', '" . zen_db_input($specials_date_available) . "')");
  63.  
  64.         $new_special = $db->Execute("select specials_id from " . TABLE_SPECIALS . " where products_id='" . (int)$products_id . "'");
  65.  
  66.         // reset products_price_sorter for searches etc.
  67.         zen_update_products_price_sorter((int)$products_id);
  68.  
  69.         } // nothing selected
  70.         if ($_GET['go_back'] == 'ON'){
  71.           zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_id . '&current_category_id=' . $_GET['current_category_id']));
  72.         } else {
  73.           zen_redirect(zen_href_link(FILENAME_SPECIALS, (isset($_GET['page']) && $_GET['page'] > 0 ? 'page=' . $_GET['page'] . '&' : '') . 'sID=' . $new_special->fields['specials_id']));
  74.         }
  75.         break;
  76.       case 'update':
  77.         $specials_id = zen_db_prepare_input($_POST['specials_id']);
  78.  
  79.         if ($_POST['products_priced_by_attribute'] == '1') {
  80.           $products_price = zen_get_products_base_price($_POST['update_products_id']);
  81.         } else {
  82.           $products_price = zen_db_prepare_input($_POST['products_price']);
  83.         }
  84.  
  85.         $tmp_value = zen_db_prepare_input($_POST['specials_price']);
  86.         $specials_price = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;
  87.  
  88.         if (substr($specials_price, -1) == '%') $specials_price = ($products_price - (($specials_price / 100) * $products_price));
  89.  
  90.         $specials_date_available = ((zen_db_prepare_input($_POST['start']) == '') ? '0001-01-01' : zen_date_raw($_POST['start']));
  91.         $expires_date = ((zen_db_prepare_input($_POST['end']) == '') ? '0001-01-01' : zen_date_raw($_POST['end']));
  92.  
  93.         $db->Execute("update " . TABLE_SPECIALS . "
  94.                      set specials_new_products_price = '" . zen_db_input($specials_price) . "',
  95.                          specials_last_modified = now(),
  96.                          expires_date = '" . zen_db_input($expires_date) . "',
  97.                          specials_date_available = '" . zen_db_input($specials_date_available) . "'
  98.                      where specials_id = '" . (int)$specials_id . "'");
  99.  
  100.         // reset products_price_sorter for searches etc.
  101.         $update_price = $db->Execute("select products_id from " . TABLE_SPECIALS . " where specials_id = '" . (int)$specials_id . "'");
  102.         zen_update_products_price_sorter($update_price->fields['products_id']);
  103.  
  104.         zen_redirect(zen_href_link(FILENAME_SPECIALS, (isset($_GET['page']) && $_GET['page'] > 0 ? 'page=' . $_GET['page'] . '&' : '') . 'sID=' . $specials_id));
  105.         break;
  106.       case 'deleteconfirm':
  107.         // demo active test
  108.         if (zen_admin_demo()) {
  109.           $_GET['action']= '';
  110.           $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
  111.           zen_redirect(zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page']));
  112.         }
  113.         $specials_id = zen_db_prepare_input($_GET['sID']);
  114.  
  115.         // reset products_price_sorter for searches etc.
  116.         $update_price = $db->Execute("select products_id from " . TABLE_SPECIALS . " where specials_id = '" . $specials_id . "'");
  117.         $update_price_id = $update_price->fields['products_id'];
  118.  
  119.         $db->Execute("delete from " . TABLE_SPECIALS . "
  120.                      where specials_id = '" . (int)$specials_id . "'");
  121.  
  122.         zen_update_products_price_sorter($update_price_id);
  123.  
  124.         zen_redirect(zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page']));
  125.         break;
  126.       case 'pre_add_confirmation':
  127.       // check for blank or existing special
  128.         $skip_special = false;
  129.         if (empty($_POST['pre_add_products_id'])) {
  130.           $skip_special = true;
  131.           $messageStack->add_session(WARNING_SPECIALS_PRE_ADD_EMPTY, 'caution');
  132.         }
  133.  
  134.         if ($skip_special == false) {
  135.           $sql = "select products_id, products_model from " . TABLE_PRODUCTS . " where products_id='" . (int)$_POST['pre_add_products_id'] . "'";
  136.           $check_special = $db->Execute($sql);
  137.           if ($check_special->RecordCount() < 1 || substr($check_special->fields['products_model'], 0, 4) == 'GIFT') {
  138.             $skip_special = true;
  139.             $messageStack->add_session(WARNING_SPECIALS_PRE_ADD_BAD_PRODUCTS_ID, 'caution');
  140.           }
  141.         }
  142.  
  143.         if ($skip_special == false) {
  144.           $sql = "select specials_id from " . TABLE_SPECIALS . " where products_id='" . (int)$_POST['pre_add_products_id'] . "'";
  145.           $check_special = $db->Execute($sql);
  146.           if ($check_special->RecordCount() > 0) {
  147.             $skip_special = true;
  148.             $messageStack->add_session(WARNING_SPECIALS_PRE_ADD_DUPLICATE, 'caution');
  149.           }
  150.         }
  151.  
  152.         if ($skip_special == true) {
  153.           zen_redirect(zen_href_link(FILENAME_SPECIALS, (isset($_GET['page']) && $_GET['page'] > 0 ? 'page=' . $_GET['page'] . '&' : '') . ($check_special->fields['specials_id'] > 0 ? 'sID=' . $check_special->fields['specials_id'] : '')));
  154.         }
  155.       // add empty special
  156.  
  157.         $specials_date_available = ((zen_db_prepare_input($_POST['start']) == '') ? '0001-01-01' : zen_date_raw($_POST['start']));
  158.         $expires_date = ((zen_db_prepare_input($_POST['end']) == '') ? '0001-01-01' : zen_date_raw($_POST['end']));
  159.  
  160.         $products_id = zen_db_prepare_input($_POST['pre_add_products_id']);
  161.         $db->Execute("insert into " . TABLE_SPECIALS . "
  162.                    (products_id, specials_new_products_price, specials_date_added, expires_date, status, specials_date_available)
  163.                    values ('" . (int)$products_id . "',
  164.                            '" . zen_db_input($specials_price) . "',
  165.                            now(),
  166.                            '" . zen_db_input($expires_date) . "', '1', '" . zen_db_input($specials_date_available) . "')");
  167.  
  168.         $new_special = $db->Execute("select specials_id from " . TABLE_SPECIALS . " where products_id='" . (int)$products_id . "'");
  169.  
  170.         $messageStack->add_session(SUCCESS_SPECIALS_PRE_ADD, 'success');
  171.         zen_redirect(zen_href_link(FILENAME_SPECIALS, 'action=edit' . '&sID=' . $new_special->fields['specials_id'] . '&manual=1'));
  172.         break;
  173.     }
  174.   }
  175. ?>
  176. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  177. <html <?php echo HTML_PARAMS; ?>>
  178. <head>
  179. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  180. <title><?php echo TITLE; ?></title>
  181. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  182. <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
  183. <script language="javascript" src="includes/menu.js"></script>
  184. <script language="javascript" src="includes/general.js"></script>
  185. <?php
  186.   if ( ($action == 'new') || ($action == 'edit') ) {
  187. ?>
  188. <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
  189. <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
  190. <?php
  191.   }
  192. ?>
  193. <script type="text/javascript">
  194.   <!--
  195.   function init()
  196.   {
  197.     cssjsmenu('navbar');
  198.     if (document.getElementById)
  199.     {
  200.       var kill = document.getElementById('hoverJS');
  201.       kill.disabled = true;
  202.     }
  203.   }
  204.   // -->
  205. </script>
  206. </head>
  207. <body onLoad="init()">
  208. <div id="spiffycalendar" class="text"></div>
  209. <!-- header //-->
  210. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  211. <!-- header_eof //-->
  212.  
  213. <!-- body //-->
  214. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  215.   <tr>
  216. <!-- body_text //-->
  217.     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  218.  
  219.       <tr>
  220.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  221.          <tr><?php echo zen_draw_form('search', FILENAME_SPECIALS, '', 'get'); ?>
  222.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  223.             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
  224.             <td class="smallText" align="right">
  225. <?php
  226. // show reset search
  227.   if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
  228.     echo '<a href="' . zen_href_link(FILENAME_SPECIALS) . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a>&nbsp;&nbsp;';
  229.   }
  230.   echo HEADING_TITLE_SEARCH_DETAIL . ' ' . zen_draw_input_field('search') . zen_hide_session_id();
  231.   if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
  232.     $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
  233.     echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER . $keywords;
  234.   }
  235. ?>
  236.             </td>
  237.           </form></tr>
  238.           <tr>
  239.             <td colspan="3" class="main"><?php echo TEXT_STATUS_WARNING; ?></td>
  240.           </tr>
  241.         </table></td>
  242.       </tr>
  243. <?php
  244.   if (empty($action)) {
  245. ?>
  246.                     <td align="center"><?php echo '<a href="' . zen_href_link(FILENAME_SPECIALS, ((isset($_GET['page']) && $_GET['page'] > 0) ? 'page=' . $_GET['page'] . '&' : '') . 'action=new') . '">' . zen_image_button('button_new_product.gif', IMAGE_NEW_PRODUCT) . '</a>'; ?></td>
  247. <?php
  248.   }
  249. ?>
  250. <?php
  251.   if ( ($action == 'new') || ($action == 'edit') ) {
  252.     $form_action = 'insert';
  253.     if ( ($action == 'edit') && isset($_GET['sID']) ) {
  254.       $form_action = 'update';
  255.  
  256.       $product = $db->Execute("select p.products_id, pd.products_name, p.products_price, p.products_priced_by_attribute,
  257.                                      s.specials_new_products_price, s.expires_date, s.specials_date_available
  258.                               from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " .
  259.                                         TABLE_SPECIALS . " s
  260.                               where p.products_id = pd.products_id
  261.                               and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  262.                               and p.products_id = s.products_id
  263.                               and s.specials_id = '" . (int)$_GET['sID'] . "'");
  264.  
  265.       $sInfo = new objectInfo($product->fields);
  266.  
  267.       if ($sInfo->products_priced_by_attribute == '1') {
  268.         $sInfo->products_price = zen_get_products_base_price($product->fields['products_id']);
  269.       }
  270.  
  271.     } else {
  272.       $sInfo = new objectInfo(array());
  273.  
  274. // create an array of products on special, which will be excluded from the pull down menu of products
  275. // (when creating a new product on special)
  276.       $specials_array = array();
  277.       $specials = $db->Execute("select p.products_id, p.products_model
  278.                                from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s
  279.                                where s.products_id = p.products_id");
  280.  
  281.       while (!$specials->EOF) {
  282.         $specials_array[] = $specials->fields['products_id'];
  283.         $specials->MoveNext();
  284.       }
  285.  
  286. // never include Gift Vouchers for specials
  287.       $gift_vouchers = $db->Execute("select distinct p.products_id, p.products_model
  288.                                from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s
  289.                                where p.products_model rlike '" . "GIFT" . "'");
  290.  
  291.       while (!$gift_vouchers->EOF) {
  292.         if(substr($gift_vouchers->fields['products_model'], 0, 4) == 'GIFT') {
  293.           $specials_array[] = $gift_vouchers->fields['products_id'];
  294.         }
  295.         $gift_vouchers->MoveNext();
  296.       }
  297.  
  298. // do not include things that cannot go in the cart
  299.       $not_for_cart = $db->Execute("select p.products_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCT_TYPES . " pt on p.products_type= pt.type_id where pt.allow_add_to_cart = 'N'");
  300.  
  301.       while (!$not_for_cart->EOF) {
  302.         $specials_array[] = $not_for_cart->fields['products_id'];
  303.         $not_for_cart->MoveNext();
  304.       }
  305.     }
  306. ?>
  307. <script language="javascript">
  308. var StartDate = new ctlSpiffyCalendarBox("StartDate", "new_special", "start", "btnDate1","<?php echo (($sInfo->specials_date_available == '0001-01-01') ? '' : zen_date_short($sInfo->specials_date_available)); ?>",scBTNMODE_CUSTOMBLUE);
  309. var EndDate = new ctlSpiffyCalendarBox("EndDate", "new_special", "end", "btnDate2","<?php echo (($sInfo->expires_date == '0001-01-01') ? '' : zen_date_short($sInfo->expires_date)); ?>",scBTNMODE_CUSTOMBLUE);
  310. </script>
  311.       <tr><?php echo zen_draw_form("new_special", FILENAME_SPECIALS, zen_get_all_get_params(array('action', 'info', 'sID')) . 'action=' . $form_action . '&go_back=' . $_GET['go_back']); ?><?php if ($form_action == 'update') echo zen_draw_hidden_field('specials_id', $_GET['sID']); ?>
  312.         <td><br><table border="0" cellspacing="0" cellpadding="2">
  313.           <tr>
  314.             <td class="main"><?php echo TEXT_SPECIALS_PRODUCT; ?>&nbsp;</td>
  315.             <td class="main"><?php echo (isset($sInfo->products_name)) ? $sInfo->products_name . ' <small>(' . $currencies->format($sInfo->products_price) . ')</small>' : zen_draw_products_pull_down('products_id', 'size="15" style="font-size:12px"', $specials_array, true, $_GET['add_products_id'], true); echo zen_draw_hidden_field('products_price', (isset($sInfo->products_price) ? $sInfo->products_price : '')); ?></td>
  316.           </tr>
  317.           <tr>
  318.             <td class="main"><?php echo TEXT_SPECIALS_SPECIAL_PRICE; ?>&nbsp;</td>
  319.             <td class="main"><?php echo zen_draw_input_field('specials_price', (isset($sInfo->specials_new_products_price) ? $sInfo->specials_new_products_price : '')); echo zen_draw_hidden_field('products_priced_by_attribute', $sInfo->products_priced_by_attribute); echo zen_draw_hidden_field('update_products_id', $sInfo->products_id); ?></td>
  320.           </tr>
  321.  
  322.           <tr>
  323.             <td class="main"><?php echo TEXT_SPECIALS_AVAILABLE_DATE; ?>&nbsp;</td>
  324.             <td class="main"><script language="javascript">StartDate.writeControl(); StartDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></td>
  325.           </tr>
  326.           <tr>
  327.             <td class="main"><?php echo TEXT_SPECIALS_EXPIRES_DATE; ?>&nbsp;</td>
  328.             <td class="main"><script language="javascript">EndDate.writeControl(); EndDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></td>
  329.           </tr>
  330.  
  331.         </table></td>
  332.       </tr>
  333.       <tr>
  334.         <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  335.           <tr>
  336.             <td class="main"><br><?php echo TEXT_SPECIALS_PRICE_TIP; ?></td>
  337.             <td class="main" align="right" valign="top"><br><?php echo (($form_action == 'insert') ? zen_image_submit('button_insert.gif', IMAGE_INSERT) : zen_image_submit('button_update.gif', IMAGE_UPDATE)) . ((int)$_GET['manual'] == 0 ? '&nbsp;&nbsp;&nbsp;<a href="' . ($_GET['go_back'] == 'ON' ? zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $_GET['add_products_id'] . '&current_category_id=' . $_GET['current_category_id']) : zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . ((isset($_GET['sID']) and $_GET['sID'] != '') ? '&sID=' . $_GET['sID'] : ''))) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>' : ''); ?></td>
  338.           </tr>
  339.         </table></td>
  340.       </form></tr>
  341. <?php
  342.   } else {
  343. ?>
  344.       <tr>
  345.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  346.           <tr>
  347.             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  348.               <tr class="dataTableHeadingRow">
  349.                 <td class="dataTableHeadingContent" align="right"><?php echo 'ID#'; ?>&nbsp;</td>
  350.                 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
  351.                 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>
  352.                 <td colspan="2" class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRODUCTS_PRICE; ?></td>
  353.                 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_AVAILABLE_DATE; ?></td>
  354.                 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_EXPIRES_DATE; ?></td>
  355.                 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
  356.                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;&nbsp;</td>
  357.               </tr>
  358. <?php
  359. // create search filter
  360.   $search = '';
  361.   if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
  362.     $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
  363.     $search = " and (pd.products_name like '%" . $keywords . "%' or pd.products_description like '%" . $keywords . "%' or p.products_model like '%" . $keywords . "%')";
  364.   }
  365.  
  366. // order of display
  367.   $order_by = " order by pd.products_name ";
  368.   $specials_query_raw = "select p.products_id, pd.products_name, p.products_model, p.products_price, p.products_priced_by_attribute, s.specials_id, s.specials_new_products_price, s.specials_date_added, s.specials_last_modified, s.expires_date, s.date_status_change, s.status, s.specials_date_available from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.products_id = s.products_id" . $search . $order_by;
  369.  
  370. // Split Page
  371. // reset page when page is unknown
  372. if (($_GET['page'] == '1' or $_GET['page'] == '') and $_GET['sID'] != '') {
  373.   $old_page = $_GET['page'];
  374.   $check_page = $db->Execute($specials_query_raw);
  375.   if ($check_page->RecordCount() > MAX_DISPLAY_SEARCH_RESULTS) {
  376.     $check_count=1;
  377.     while (!$check_page->EOF) {
  378.       if ($check_page->fields['specials_id'] == $_GET['sID']) {
  379.         break;
  380.       }
  381.       $check_count++;
  382.       $check_page->MoveNext();
  383.     }
  384.     $_GET['page'] = round((($check_count/MAX_DISPLAY_SEARCH_RESULTS)+(fmod_round($check_count,MAX_DISPLAY_SEARCH_RESULTS) !=0 ? .5 : 0)),0);
  385.     $page = $_GET['page'];
  386.     if ($old_page != $_GET['page']) {
  387. // do nothing
  388.     }
  389.   } else {
  390.     $_GET['page'] = 1;
  391.   }
  392. }
  393.  
  394. // create split page control
  395.     $specials_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $specials_query_raw, $specials_query_numrows);
  396.     $specials = $db->Execute($specials_query_raw);
  397.     while (!$specials->EOF) {
  398.       if ((!isset($_GET['sID']) || (isset($_GET['sID']) && ($_GET['sID'] == $specials->fields['specials_id']))) && !isset($sInfo)) {
  399.         $products = $db->Execute("select products_image
  400.                                  from " . TABLE_PRODUCTS . "
  401.                                  where products_id = '" . (int)$specials->fields['products_id'] . "'");
  402.  
  403.         $sInfo_array = array_merge($specials->fields, $products->fields);
  404.         $sInfo = new objectInfo($sInfo_array);
  405.       }
  406.  
  407.       if (isset($sInfo) && is_object($sInfo) && ($specials->fields['specials_id'] == $sInfo->specials_id)) {
  408.         echo '                  <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $sInfo->specials_id . '&action=edit') . '\'">' . "\n";
  409.       } else {
  410.         echo '                  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $specials->fields['specials_id'] . '&action=edit') . '\'">' . "\n";
  411.       }
  412.  
  413.       if ($specials->fields['products_priced_by_attribute'] == '1') {
  414.         $specials_current_price = zen_get_products_base_price($specials->fields['products_id']);
  415.       } else {
  416.         $specials_current_price = $specials->fields['products_price'];
  417.       }
  418.  
  419.       $sale_price = zen_get_products_special_price($specials->fields['products_id'], false);
  420.  
  421. ?>
  422.                 <td  class="dataTableContent" align="right"><?php echo $specials->fields['products_id']; ?>&nbsp;</td>
  423.                 <td  class="dataTableContent"><?php echo $specials->fields['products_name']; ?></td>
  424.                 <td  class="dataTableContent" align="left"><?php echo $specials->fields['products_model']; ?>&nbsp;</td>
  425.                 <td colspan="2" class="dataTableContent" align="right"><?php echo zen_get_products_display_price($specials->fields['products_id']); ?></td>
  426.                 <td  class="dataTableContent" align="center"><?php echo (($specials->fields['specials_date_available'] != '0001-01-01' and $specials->fields['specials_date_available'] !='') ? zen_date_short($specials->fields['specials_date_available']) : TEXT_NONE); ?></td>
  427.                 <td  class="dataTableContent" align="center"><?php echo (($specials->fields['expires_date'] != '0001-01-01' and $specials->fields['expires_date'] !='') ? zen_date_short($specials->fields['expires_date']) : TEXT_NONE); ?></td>
  428.                 <td  class="dataTableContent" align="center">
  429. <?php
  430.       if ($specials->fields['status'] == '1') {
  431.         echo '<a href="' . zen_href_link(FILENAME_SPECIALS, 'action=setflag&flag=0&id=' . $specials->fields['specials_id'] . '&page=' . $_GET['page'], 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON) . '</a>';
  432.       } else {
  433.         echo '<a href="' . zen_href_link(FILENAME_SPECIALS, 'action=setflag&flag=1&id=' . $specials->fields['specials_id'] . '&page=' . $_GET['page'], 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . '</a>';
  434.       }
  435. ?>
  436.                 </td>
  437.                 <td class="dataTableContent" align="right">
  438.                   <?php echo '<a href="' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $specials->fields['specials_id'] . '&action=edit') . '">' . zen_image(DIR_WS_IMAGES . 'icon_edit.gif', ICON_EDIT) . '</a>'; ?>
  439.                           <?php echo '<a href="' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $specials->fields['specials_id'] . '&action=delete') . '">' . zen_image(DIR_WS_IMAGES . 'icon_delete.gif', ICON_DELETE) . '</a>'; ?>
  440.                   <?php if (isset($sInfo) && is_object($sInfo) && ($specials->fields['specials_id'] == $sInfo->specials_id)) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . zen_href_link(FILENAME_SPECIALS, zen_get_all_get_params(array('sID')) . 'sID=' . $specials->fields['specials_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>
  441.                         </td>
  442.       </tr>
  443. <?php
  444.       $specials->MoveNext();
  445.     }
  446. ?>
  447.               <tr>
  448.                 <td colspan="8"><table border="0" width="100%" cellpadding="0"cellspacing="2">
  449.                   <tr>
  450.                     <td class="smallText" valign="top"><?php echo $specials_split->display_count($specials_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_SPECIALS); ?></td>
  451.                     <td class="smallText" align="right"><?php echo $specials_split->display_links($specials_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></td>
  452.                   </tr>
  453. <?php
  454.   if (empty($action)) {
  455. ?>
  456.                   <tr>
  457.                     <td colspan="2" align="right"><?php echo '<a href="' . zen_href_link(FILENAME_SPECIALS, ((isset($_GET['page']) && $_GET['page'] > 0) ? 'page=' . $_GET['page'] . '&' : '') . 'action=new') . '">' . zen_image_button('button_new_product.gif', IMAGE_NEW_PRODUCT) . '</a>'; ?></td>
  458.                   </tr>
  459. <?php
  460.   }
  461. ?>
  462.                 </table></td>
  463.               </tr>
  464.             </table></td>
  465. <?php
  466.   $heading = array();
  467.   $contents = array();
  468.  
  469.   switch ($action) {
  470.     case 'delete':
  471.       $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_SPECIALS . '</b>');
  472.  
  473.       $contents = array('form' => zen_draw_form('specials', FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $sInfo->specials_id . '&action=deleteconfirm'));
  474.       $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
  475.       $contents[] = array('text' => '<br><b>' . $sInfo->products_name . '</b>');
  476.       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . '&nbsp;<a href="' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $sInfo->specials_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  477.       break;
  478.     case 'pre_add':
  479.       $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_PRE_ADD_SPECIALS . '</b>');
  480.       $contents = array('form' => zen_draw_form('specials', FILENAME_SPECIALS, 'action=pre_add_confirmation' . ((isset($_GET['page']) && $_GET['page'] > 0) ? '&page=' . $_GET['page'] : '')));
  481.       $contents[] = array('text' => TEXT_INFO_PRE_ADD_INTRO);
  482.       $contents[] = array('text' => '<br />' . TEXT_PRE_ADD_PRODUCTS_ID . '<br>' . zen_draw_input_field('pre_add_products_id', '', zen_set_field_length(TABLE_SPECIALS, 'products_id')));
  483.       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_confirm.gif', IMAGE_CONFIRM) . '&nbsp;<a href="' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $sInfo->specials_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  484.       break;
  485.     default:
  486.       if (is_object($sInfo)) {
  487.         $heading[] = array('text' => '<b>' . $sInfo->products_name . '</b>');
  488.  
  489.       if ($sInfo->products_priced_by_attribute == '1') {
  490.         $specials_current_price = zen_get_products_base_price($sInfo->products_id);
  491.       } else {
  492.         $specials_current_price = $sInfo->products_price;
  493.       }
  494.  
  495.         $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $sInfo->specials_id . '&action=edit') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] . '&sID=' . $sInfo->specials_id . '&action=delete') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
  496.         $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'action=edit&products_filter=' . $sInfo->products_id) . '">' . zen_image_button('button_products_price_manager.gif', IMAGE_PRODUCTS_PRICE_MANAGER) . '</a>');
  497.         $contents[] = array('text' => '<br>' . TEXT_INFO_DATE_ADDED . ' ' . zen_date_short($sInfo->specials_date_added));
  498.         $contents[] = array('text' => '' . TEXT_INFO_LAST_MODIFIED . ' ' . zen_date_short($sInfo->specials_last_modified));
  499.         $contents[] = array('align' => 'center', 'text' => '<br>' . zen_info_image($sInfo->products_image, $sInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT));
  500.         $contents[] = array('text' => '<br>' . TEXT_INFO_ORIGINAL_PRICE . ' ' . $currencies->format($specials_current_price));
  501.         $contents[] = array('text' => '' . TEXT_INFO_NEW_PRICE . ' ' . $currencies->format($sInfo->specials_new_products_price));
  502.         $contents[] = array('text' => '' . TEXT_INFO_DISPLAY_PRICE . ' ' . zen_get_products_display_price($sInfo->products_id));
  503.  
  504.         $contents[] = array('text' => '<br>' . TEXT_INFO_AVAILABLE_DATE . ' <b>' . (($sInfo->specials_date_available != '0001-01-01' and $sInfo->specials_date_available !='') ? zen_date_short($sInfo->specials_date_available) : TEXT_NONE) . '</b>');
  505.         $contents[] = array('text' => '<br>' . TEXT_INFO_EXPIRES_DATE . ' <b>' . (($sInfo->expires_date != '0001-01-01' and $sInfo->expires_date !='') ? zen_date_short($sInfo->expires_date) : TEXT_NONE) . '</b>');
  506.         $contents[] = array('text' => '' . TEXT_INFO_STATUS_CHANGE . ' ' . zen_date_short($sInfo->date_status_change));
  507.         $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_CATEGORIES, '&action=new_product' . '&cPath=' . zen_get_product_path($sInfo->products_id, 'override') . '&pID=' . $sInfo->products_id . '&product_type=' . zen_get_products_type($sInfo->products_id)) . '">' . zen_image_button('button_edit_product.gif', IMAGE_EDIT_PRODUCT) . '<br />' . TEXT_PRODUCT_EDIT . '</a>');
  508.  
  509.         $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_SPECIALS, 'action=pre_add' . ((isset($_GET['page']) && $_GET['page'] > 0) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image_button('button_select.gif', IMAGE_SELECT) . '<br />' . TEXT_INFO_MANUAL . '</a><br /><br />');
  510.       } else {
  511.         $heading[] = array('text' => '<b>' . TEXT_NONE . '</b>');
  512.         $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_SPECIALS, 'action=pre_add' . ((isset($_GET['page']) && $_GET['page'] > 0) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image_button('button_select.gif', IMAGE_SELECT) . '<br />' . TEXT_INFO_MANUAL . '</a><br /><br />');
  513.       }
  514.       break;
  515.   }
  516.   if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
  517.     echo '            <td width="25%" valign="top">' . "\n";
  518.  
  519.     $box = new box;
  520.     echo $box->infoBox($heading, $contents);
  521.  
  522.     echo '            </td>' . "\n";
  523.   }
  524. }
  525. ?>
  526.           </tr>
  527.         </table></td>
  528.       </tr>
  529.     </table></td>
  530. <!-- body_text_eof //-->
  531.   </tr>
  532. </table>
  533. <!-- body_eof //-->
  534.  
  535. <!-- footer //-->
  536. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  537. <!-- footer_eof //-->
  538. </body>
  539. </html>
  540. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
  541.  


cron