[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文件
文件大小: 33.79 KiB
MD5: 4abd422949bbb5ed33ff678f909d9d0a

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