[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/admin/ -> products_price_manager.php (source)

   1  <?php
   2  //

   3  // +----------------------------------------------------------------------+

   4  // |zen-cart Open Source E-commerce                                       |

   5  // +----------------------------------------------------------------------+

   6  // | Copyright (c) 2006 The zen-cart developers                           |

   7  // |                                                                      |

   8  // | http://www.zen-cart.com/index.php                                    |

   9  // |                                                                      |

  10  // | Portions Copyright (c) 2003 osCommerce                               |

  11  // +----------------------------------------------------------------------+

  12  // | This source file is subject to version 2.0 of the GPL license,       |

  13  // | that is bundled with this package in the file LICENSE, and is        |

  14  // | available through the world-wide-web at the following url:           |

  15  // | http://www.zen-cart.com/license/2_0.txt.                             |

  16  // | If you did not receive a copy of the zen-cart license and are unable |

  17  // | to obtain it through the world-wide-web, please send a note to       |

  18  // | license@zen-cart.com so we can mail you a copy immediately.          |

  19  // +----------------------------------------------------------------------+

  20  //  $Id: products_price_manager.php 4573 2006-09-20 23:46:43Z ajeh $

  21  //

  22  
  23    require ('includes/application_top.php');
  24  
  25    // verify products exist

  26    $chk_products = $db->Execute("select * from " . TABLE_PRODUCTS . " limit 1");
  27    if ($chk_products->RecordCount() < 1) {
  28      $messageStack->add_session(ERROR_DEFINE_PRODUCTS, 'caution');
  29      zen_redirect(zen_href_link(FILENAME_CATEGORIES));
  30    }
  31  
  32    require (DIR_WS_CLASSES . 'currencies.php');
  33    $currencies = new currencies();
  34  
  35    $products_filter = (isset($_GET['products_filter']) ? $_GET['products_filter'] : $products_filter);
  36  
  37    $action = (isset($_GET['action']) ? $_GET['action'] : '');
  38  
  39    $current_category_id = (isset($_GET['current_category_id']) ? $_GET['current_category_id'] : $current_category_id);
  40  
  41    if ($action == 'new_cat') {
  42      $current_category_id = (isset($_GET['current_category_id']) ? $_GET['current_category_id'] : $current_category_id);
  43      $new_product_query = $db->Execute("select ptc.* from " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc  left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on ptc.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' where ptc.categories_id='" . $current_category_id . "' order by pd.products_name");
  44      $products_filter = $new_product_query->fields['products_id'];
  45      zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  46    }
  47  
  48  // set categories and products if not set

  49    if ($products_filter == '' and $current_category_id != '') {
  50      $new_product_query = $db->Execute("select ptc.* from " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc  left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on ptc.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' where ptc.categories_id='" . $current_category_id . "' order by pd.products_name");
  51      $products_filter = $new_product_query->fields['products_id'];
  52      if ($products_filter != '') {
  53        zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  54      }
  55    } else {
  56      if ($products_filter == '' and $current_category_id == '') {
  57        $reset_categories_id = zen_get_category_tree('', '', '0', '', '', true);
  58        $current_category_id = $reset_categories_id[0]['id'];
  59        $new_product_query = $db->Execute("select ptc.* from " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc  left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on ptc.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' where ptc.categories_id='" . $current_category_id . "' order by pd.products_name");
  60        $products_filter = $new_product_query->fields['products_id'];
  61        $_GET['products_filter'] = $products_filter;
  62      }
  63    }
  64  
  65    require(DIR_WS_MODULES . FILENAME_PREV_NEXT);
  66  
  67    if ($action == 'delete_special') {
  68      $delete_special = $db->Execute("delete from " . TABLE_SPECIALS . " where products_id='" . $products_filter . "'");
  69  
  70      // reset products_price_sorter for searches etc.

  71      zen_update_products_price_sorter($products_filter);
  72  
  73      zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  74    }
  75  
  76    if ($action == 'delete_featured') {
  77      $delete_featured = $db->Execute("delete from " . TABLE_FEATURED . " where products_id='" . $products_filter . "'");
  78  
  79      zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  80    }
  81  
  82    if ($action == 'add_discount_qty_id') {
  83      $add_id = $db->Execute("select discount_id from " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " where products_id='" . $products_filter . "' order by discount_id desc limit 1");
  84      $add_cnt = 1;
  85      $add_id = $add_id->fields['discount_id'];
  86      while ($add_cnt <= DISCOUNT_QTY_ADD) {
  87        $db->Execute("insert into " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . "
  88                      (discount_id, products_id)
  89                      values ('" . ($add_id + $add_cnt) . "', '" . $products_filter . "')");
  90        $add_cnt++;
  91      }
  92      zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'action=edit' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  93    }
  94  
  95    if (zen_not_null($action)) {
  96      switch ($action) {
  97        case ('update'):
  98  
  99          if ($_POST['master_category']) {
 100            $master_categories_id = $_POST['master_category'];
 101          } else {
 102            $master_categories_id = $_POST['master_categories_id'];
 103          }
 104  
 105          $products_date_available = ((zen_db_prepare_input($_POST['product_start']) == '') ? 'null' : "'".zen_date_raw($_POST['product_start'])."'");
 106  
 107          $specials_date_available = ((zen_db_prepare_input($_POST['special_start']) == '') ? '0001-01-01' : zen_date_raw($_POST['special_start']));
 108          $specials_expires_date = ((zen_db_prepare_input($_POST['special_end']) == '') ? '0001-01-01' : zen_date_raw($_POST['special_end']));
 109  
 110          $featured_date_available = ((zen_db_prepare_input($_POST['featured_start']) == '') ? '0001-01-01' : zen_date_raw($_POST['featured_start']));
 111          $featured_expires_date = ((zen_db_prepare_input($_POST['featured_end']) == '') ? '0001-01-01' : zen_date_raw($_POST['featured_end']));
 112  
 113      $tmp_value = zen_db_prepare_input($_POST['products_price_sorter']);
 114      $products_price_sorter = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;
 115  
 116  
 117          $db->Execute("update " . TABLE_PRODUCTS . " set
 118              products_price='" . zen_db_prepare_input($_POST['products_price']) . "',
 119              products_tax_class_id='" . zen_db_prepare_input($_POST['products_tax_class_id']) . "',
 120              products_date_available=" . $products_date_available . ",
 121              products_last_modified=now(),
 122              products_status='" . zen_db_prepare_input($_POST['products_status']) . "',
 123              products_quantity_order_min='" . zen_db_prepare_input($_POST['products_quantity_order_min']) . "',
 124              products_quantity_order_units='" . zen_db_prepare_input($_POST['products_quantity_order_units']) . "',
 125              products_quantity_order_max='" . zen_db_prepare_input($_POST['products_quantity_order_max']) . "',
 126              product_is_free='" . zen_db_prepare_input($_POST['product_is_free']) . "',
 127              product_is_call='" . zen_db_prepare_input($_POST['product_is_call']) . "',
 128              products_quantity_mixed='" . zen_db_prepare_input($_POST['products_quantity_mixed']) . "',
 129              products_priced_by_attribute='" . zen_db_prepare_input($_POST['products_priced_by_attribute']) . "',
 130              products_discount_type='" . zen_db_prepare_input($_POST['products_discount_type']) . "',
 131              products_discount_type_from='" . zen_db_prepare_input($_POST['products_discount_type_from']) . "',
 132              products_price_sorter='" . $products_price_sorter . "',
 133              master_categories_id='" . zen_db_prepare_input($master_categories_id) . "',
 134              products_mixed_discount_quantity='" . zen_db_prepare_input($_POST['products_mixed_discount_quantity']) . "'
 135              where products_id='" . $products_filter . "'");
 136  
 137          if ($_POST['specials_id'] != '') {
 138  
 139            $specials_id = zen_db_prepare_input($_POST['specials_id']);
 140  
 141            if ($_POST['products_priced_by_attribute'] == '1') {
 142              $products_price = zen_get_products_base_price($products_filter);
 143            } else {
 144              $products_price = zen_db_prepare_input($_POST['products_price']);
 145            }
 146  
 147            $specials_price = zen_db_prepare_input($_POST['specials_price']);
 148            if (substr($specials_price, -1) == '%') $specials_price = ($products_price - (($specials_price / 100) * $products_price));
 149            $db->Execute("update " . TABLE_SPECIALS . " set
 150                specials_new_products_price='" . zen_db_input($specials_price) . "',
 151                specials_date_available='" . zen_db_input($specials_date_available) . "',
 152                specials_last_modified=now(),
 153                expires_date='" . zen_db_input($specials_expires_date) . "',
 154                status='" . zen_db_input($_POST['special_status']) . "'
 155                where products_id='" . $products_filter . "'");
 156          }
 157  
 158          if ($_POST['featured_id'] != '') {
 159  
 160          $db->Execute("update " . TABLE_FEATURED . " set
 161              featured_date_available='" . zen_db_input($featured_date_available) . "',
 162              expires_date='" . zen_db_input($featured_expires_date) . "',
 163              featured_last_modified=now(),
 164              status='" . zen_db_input($_POST['featured_status']) . "'
 165              where products_id='" . $products_filter . "'");
 166          }
 167  
 168          $db->Execute("delete from " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " where products_id='" . $products_filter . "'");
 169          $i=1;
 170          $new_id = 0;
 171          $discount_cnt = 0;
 172          for ($i=1, $n=sizeof($_POST['discount_qty']); $i<=$n; $i++) {
 173            if ($_POST['discount_qty'][$i] > 0) {
 174              $new_id++;
 175              $db->Execute("insert into " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . "
 176                            (discount_id, products_id, discount_qty, discount_price)
 177                            values ('" . $new_id . "', '" . $products_filter . "', '" . $_POST['discount_qty'][$i] . "', '" . $_POST['discount_price'][$i] . "')");
 178              $discount_cnt++;
 179            } else {
 180              loop;
 181            }
 182          }
 183  
 184          if ($discount_cnt <= 0) {
 185            $db->Execute("update " . TABLE_PRODUCTS . " set products_discount_type='0' where products_id='" . $products_filter . "'");
 186          }
 187  
 188          // reset products_price_sorter for searches etc.

 189          zen_update_products_price_sorter($products_filter);
 190          $messageStack->add_session(PRODUCT_UPDATE_SUCCESS, 'success');
 191  
 192          zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
 193          break;
 194        case 'set_products_filter':
 195          $_GET['products_filter'] = $_POST['products_filter'];
 196  
 197          zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_POST['current_category_id']));
 198          break;
 199        case 'deleteconfirm':
 200          // demo active test

 201          if (zen_admin_demo()) {
 202            $_GET['action']= '';
 203            $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
 204            zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'page=' . $_GET['page']));
 205          }
 206          $featured_id = zen_db_prepare_input($_GET['fID']);
 207  
 208          $db->Execute("delete from " . TABLE_FEATURED . "
 209                        where featured_id = '" . (int)$featured_id . "'");
 210  
 211          zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'page=' . $_GET['page']));
 212          break;
 213        case 'edit':
 214        // set edit message

 215        $messageStack->add_session(PRODUCT_WARNING_UPDATE, 'caution');
 216        zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'action=edit_update' . '&products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $current_category_id));
 217        break;
 218        case 'cancel':
 219        // set edit message

 220        $messageStack->add_session(PRODUCT_WARNING_UPDATE_CANCEL, 'warning');
 221        zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $current_category_id));
 222        break;
 223      }
 224    }
 225  
 226  ?>
 227  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
 228  <html <?php echo HTML_PARAMS; ?>>
 229  <head>
 230  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
 231  <title><?php echo TITLE; ?></title>
 232  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
 233  <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
 234  <script language="javascript" src="includes/menu.js"></script>
 235  <script language="javascript" src="includes/general.js"></script>
 236  <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
 237  <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
 238  
 239  <script type="text/javascript">
 240    <!--
 241    function init()
 242    {
 243      cssjsmenu('navbar');
 244      if (document.getElementById)
 245      {
 246        var kill = document.getElementById('hoverJS');
 247        kill.disabled = true;
 248      }
 249    }
 250    // -->

 251  </script>
 252  </head>
 253  <body onload="init()">
 254  <div id="spiffycalendar" class="text"></div>
 255  <!-- header //-->
 256  <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
 257  <!-- header_eof //-->
 258  
 259  <!-- body //-->
 260  <table border="0" width="100%" cellspacing="2" cellpadding="2">
 261    <tr>
 262  <!-- body_text //-->
 263      <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 264                <tr>
 265                  <td class="smallText" align="right">
 266  <?php
 267      echo zen_draw_form('search', FILENAME_CATEGORIES, '', 'get');
 268  // show reset search

 269      if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
 270        echo '<a href="' . zen_href_link(FILENAME_CATEGORIES) . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a>&nbsp;&nbsp;';
 271      }
 272      echo HEADING_TITLE_SEARCH_DETAIL . ' ' . zen_draw_input_field('search') . zen_hide_session_id();
 273      if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
 274        $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
 275        echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER . $keywords;
 276      }
 277      echo '</form>';
 278  ?>
 279                  </td>
 280                </tr>
 281  <?php
 282  ///////////////////////////////////////////////////////////

 283  // BOF: NEW CODE TO KEEP

 284  ?>
 285  
 286  <?php
 287    if ($action != 'edit_update') {
 288      require(DIR_WS_MODULES . FILENAME_PREV_NEXT_DISPLAY);
 289  ?>
 290  
 291        <tr><form name="set_products_filter_id" <?php echo 'action="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'action=set_products_filter') . '"'; ?> method="post"><?php echo zen_draw_hidden_field('products_filter', $_GET['products_filter']); ?><?php echo zen_draw_hidden_field('current_category_id', $_GET['current_category_id']); ?>
 292          <td colspan="2"><table border="0" cellspacing="0" cellpadding="2">
 293  
 294  <?php
 295  if ($_GET['products_filter'] != '') {
 296  ?>
 297            <tr>
 298              <td class="main" width="200" align="left" valign="top">&nbsp;</td>
 299              <td colspan="2" class="main"><?php echo TEXT_PRODUCT_TO_VIEW; ?></td>
 300            </tr>
 301            <tr>
 302              <td class="main" width="200" align="center" valign="top">
 303  
 304  <?php
 305  // FIX HERE

 306    $display_priced_by_attributes = zen_get_products_price_is_priced_by_attributes($_GET['products_filter']);
 307    echo ($display_priced_by_attributes ? '<span class="alert">' . TEXT_PRICED_BY_ATTRIBUTES . '</span>' . '<br />' : '');
 308    echo zen_get_products_display_price($_GET['products_filter']) . '<br /><br />';
 309    echo zen_get_products_quantity_min_units_display($_GET['products_filter'], $include_break = true);
 310    $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'");
 311    while (!$not_for_cart->EOF) {
 312      $not_for_cart_array[] = $not_for_cart->fields['products_id'];
 313      $not_for_cart->MoveNext();
 314     }
 315  ?>
 316              </td>
 317              <td class="attributes-even" align="center"><?php echo zen_draw_products_pull_down('products_filter', 'size="5"', $not_for_cart->fields, true, $_GET['products_filter'], true, true); ?></td>
 318              <td class="main" align="center" valign="top">
 319                <?php
 320                  echo zen_image_submit('button_display.gif', IMAGE_DISPLAY);
 321                ?>
 322              </td>
 323            </tr>
 324  <?php
 325  } else {
 326    $not_for_cart = '';
 327  } // $_GET['products_filter'] != ''

 328  ?>
 329          <tr>
 330            <td colspan="3">
 331              <table>
 332  
 333  <?php
 334  // show when product is linked

 335  if ($products_filter != '' && zen_get_product_is_linked($products_filter) == 'true') {
 336  ?>
 337                <tr>
 338                  <td class="main" align="center" valign="bottom">
 339                    <?php echo zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . '&nbsp;&nbsp;' . TEXT_LEGEND_LINKED . ' ' . zen_get_product_is_linked($products_filter, 'true'); ?>
 340                  </td>
 341                </tr>
 342  <?php } ?>
 343                <tr>
 344                  <td class="main" align="center" valign="bottom">
 345  <?php
 346    if ($_GET['products_filter'] != '') {
 347      echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $current_category_id . '&pID=' . $products_filter . '&product_type=' . zen_get_products_type($products_filter)) . '">' . zen_image_button('button_details.gif', IMAGE_DETAILS) . '<br />' . TEXT_PRODUCT_DETAILS . '</a>' . '&nbsp;&nbsp;&nbsp;';
 348      echo '</td><td class="main" align="center" valign="bottom">';
 349      echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=new_product' . '&cPath=' . $current_category_id . '&pID=' . $products_filter . '&product_type=' . zen_get_products_type($products_filter)) . '">' . zen_image_button('button_edit_product.gif', IMAGE_EDIT_PRODUCT) . '<br />' . TEXT_PRODUCT_EDIT . '</a>';
 350      echo '</td><td class="main" align="center" valign="bottom">';
 351        echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id, 'NONSSL') . '">' . zen_image_button('button_edit_attribs.gif', IMAGE_EDIT_ATTRIBUTES) . '<br />' . TEXT_ATTRIBUTE_EDIT . '</a>' . '&nbsp;&nbsp;&nbsp;';
 352    }
 353  ?>
 354                  </td>
 355                </tr>
 356  <?php if ($products_filter != '') { ?>
 357              <tr>
 358              <td class="smallText" align="center" colspan="3"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, '&products_filter=' . $products_filter) . '">' . IMAGE_PRODUCTS_TO_CATEGORIES . '</a>'; ?></td>
 359              </tr>
 360  <?php } ?>
 361              </table>
 362            </td>
 363          </tr>
 364  
 365          </table></td>
 366        </form></tr>
 367  <?php } // $action != 'edit_update' ?>

 368  <?php
 369  // EOF: NEW CODE TO KEEP

 370  ///////////////////////////////////////////////////////////

 371  ?>
 372  <?php
 373  // start of attributes display

 374  if ($products_filter == '') {
 375  ?>
 376        <tr>
 377          <td colspan="2" class="pageHeading" align="center" valign="middle" height="200"><?php echo HEADING_TITLE_PRODUCT_SELECT; ?></td>
 378        </tr>
 379  <?php } ?>
 380  
 381  <?php
 382  // only show if allowed in cart

 383    if ($zc_products->get_allow_add_to_cart($products_filter) == 'Y') {
 384  ?>
 385  
 386  <?php
 387  // featured information

 388        $product = $db->Execute("select p.products_id,
 389                                        f.featured_id, f.expires_date, f.featured_date_available, f.status
 390                                 from " . TABLE_PRODUCTS . " p, " .
 391                                          TABLE_FEATURED . " f
 392                                 where p.products_id = f.products_id
 393                                 and f.products_id = '" . $_GET['products_filter'] . "'");
 394  
 395  
 396        if ($product->RecordCount() > 0) {
 397          $fInfo = new objectInfo($product->fields);
 398        }
 399  
 400  // specials information

 401        $product = $db->Execute("select p.products_id,
 402                                        s.specials_id, s.specials_new_products_price, s.expires_date, s.specials_date_available, s.status
 403                                 from " . TABLE_PRODUCTS . " p, " .
 404                                          TABLE_SPECIALS . " s
 405                                 where p.products_id = s.products_id
 406                                 and s.products_id = '" . $_GET['products_filter'] . "'");
 407  
 408        if ($product->RecordCount() > 0) {
 409          $sInfo = new objectInfo($product->fields);
 410        }
 411  
 412  // products information

 413        $product = $db->Execute("select p.products_id, p.products_model,
 414                                        p.products_price, p.products_date_available,
 415                                        p.products_tax_class_id,
 416                                        p.products_quantity_order_min, products_quantity_order_units, p.products_quantity_order_max,
 417                                        p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.products_priced_by_attribute, p.products_status,
 418                                        p.products_discount_type, p.products_discount_type_from, p.products_price_sorter,
 419                                        pd.products_name,
 420                                        p.master_categories_id, p.products_mixed_discount_quantity
 421                                 from " . TABLE_PRODUCTS . " p, " .
 422                                          TABLE_PRODUCTS_DESCRIPTION . " pd
 423                                 where p.products_id = '" . $_GET['products_filter'] . "'
 424                                 and p.products_id = pd.products_id
 425                                 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'");
 426  
 427  
 428        if ($product->RecordCount() > 0) {
 429          $pInfo = new objectInfo($product->fields);
 430        }
 431  
 432  // set statuses

 433        if (!isset($pInfo->products_status)) $pInfo->products_status = '1';
 434          switch ($pInfo->products_status) {
 435          case '0': $products_in_status = false; $products_out_status = true; break;
 436          case '1':
 437          default: $products_in_status = true; $products_out_status = false;
 438        }
 439        if (!isset($fInfo->status)) $fInfo->status = '1';
 440          switch ($fInfo->status) {
 441          case '0': $featured_in_status = false; $featured_out_status = true; break;
 442          case '1':
 443          default: $featured_in_status = true; $featured_out_status = false;
 444        }
 445        if (!isset($sInfo->status)) $sInfo->status = '1';
 446          switch ($sInfo->status) {
 447          case '0': $special_in_status = false; $special_out_status = true; break;
 448          case '1':
 449          default: $special_in_status = true; $special_out_status = false;
 450        }
 451  
 452  // Product is Priced by Attributes

 453      if (!isset($pInfo->products_priced_by_attribute)) $pInfo->products_priced_by_attribute = '0';
 454      switch ($pInfo->products_priced_by_attribute) {
 455        case '0': $is_products_priced_by_attribute = false; $not_products_priced_by_attribute = true; break;
 456        case '1': $is_products_priced_by_attribute = true; $not_products_priced_by_attribute = false; break;
 457        default: $is_products_priced_by_attribute = false; $not_products_priced_by_attribute = true;
 458      }
 459  // Product is Free

 460      if (!isset($pInfo->product_is_free)) $pInfo->product_is_free = '0';
 461      switch ($pInfo->product_is_free) {
 462        case '0': $in_product_is_free = false; $out_product_is_free = true; break;
 463        case '1': $in_product_is_free = true; $out_product_is_free = false; break;
 464        default: $in_product_is_free = false; $out_product_is_free = true;
 465      }
 466  // Product is Call for price

 467      if (!isset($pInfo->product_is_call)) $pInfo->product_is_call = '0';
 468      switch ($pInfo->product_is_call) {
 469        case '0': $in_product_is_call = false; $out_product_is_call = true; break;
 470        case '1': $in_product_is_call = true; $out_product_is_call = false; break;
 471        default: $in_product_is_call = false; $out_product_is_call = true;
 472      }
 473  // Products can be purchased with mixed attributes retail

 474      if (!isset($pInfo->products_quantity_mixed)) $pInfo->products_quantity_mixed = '0';
 475      switch ($pInfo->products_quantity_mixed) {
 476        case '0': $in_products_quantity_mixed = false; $out_products_quantity_mixed = true; break;
 477        case '1': $in_products_quantity_mixed = true; $out_products_quantity_mixed = false; break;
 478        default: $in_products_quantity_mixed = true; $out_products_quantity_mixed = false;
 479      }
 480  // Products can be purchased with mixed attributes for discount

 481      if (!isset($pInfo->products_mixed_discount_quantity)) $pInfo->products_mixed_discount_quantity = '1';
 482      switch ($pInfo->products_mixed_discount_quantity) {
 483        case '0': $in_products_mixed_discount_quantity = false; $out_products_mixed_discount_quantity = true; break;
 484        case '1': $in_products_mixed_discount_quantity = true; $out_products_mixed_discount_quantity = false; break;
 485        default: $in_products_mixed_discount_quantity = true; $out_products_mixed_discount_quantity = false;
 486      }
 487  
 488  // Product is product discount type - None, Percentage, Actual Price, $$ off

 489    $discount_type_array = array(array('id' => '0', 'text' => DISCOUNT_TYPE_DROPDOWN_0),
 490                                  array('id' => '1', 'text' => DISCOUNT_TYPE_DROPDOWN_1),
 491                                  array('id' => '2', 'text' => DISCOUNT_TYPE_DROPDOWN_2),
 492                                  array('id' => '3', 'text' => DISCOUNT_TYPE_DROPDOWN_3));
 493  
 494  // Product is product discount type from price or special

 495    $discount_type_from_array = array(array('id' => '0', 'text' => DISCOUNT_TYPE_FROM_DROPDOWN_0),
 496                                array('id' => '1', 'text' => DISCOUNT_TYPE_FROM_DROPDOWN_1));
 497  
 498  // tax class id

 499      $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
 500      $tax_class = $db->Execute("select tax_class_id, tax_class_title
 501                                       from " . TABLE_TAX_CLASS . " order by tax_class_title");
 502      while (!$tax_class->EOF) {
 503        $tax_class_array[] = array('id' => $tax_class->fields['tax_class_id'],
 504                                   'text' => $tax_class->fields['tax_class_title']);
 505        $tax_class->MoveNext();
 506      }
 507  ?>
 508  <?php if ($pInfo->products_id != '') { ?>
 509  <script language="javascript">
 510  var ProductStartDate = new ctlSpiffyCalendarBox("ProductStartDate", "new_prices", "product_start", "btnDate1","<?php echo (($pInfo->products_date_available <= '0001-01-01') ? '' : zen_date_short($pInfo->products_date_available)); ?>",scBTNMODE_CUSTOMBLUE);
 511  </script>
 512  <?php } ?>
 513  
 514  <?php if ($fInfo->products_id != '') { ?>
 515  <script language="javascript">
 516  var FeaturedStartDate = new ctlSpiffyCalendarBox("FeaturedStartDate", "new_prices", "featured_start", "btnDate2","<?php echo (($fInfo->featured_date_available <= '0001-01-01') ? '' : zen_date_short($fInfo->featured_date_available)); ?>",scBTNMODE_CUSTOMBLUE);
 517  var FeaturedEndDate = new ctlSpiffyCalendarBox("FeaturedEndDate", "new_prices", "featured_end", "btnDate3","<?php echo (($fInfo->expires_date <= '0001-01-01') ? '' : zen_date_short($fInfo->expires_date)); ?>",scBTNMODE_CUSTOMBLUE);
 518  </script>
 519  <?php } ?>
 520  
 521  <?php if ($sInfo->products_id != '') { ?>
 522  <script language="javascript">
 523  var SpecialStartDate = new ctlSpiffyCalendarBox("SpecialStartDate", "new_prices", "special_start", "btnDate4","<?php echo (($sInfo->specials_date_available <= '0001-01-01') ? '' : zen_date_short($sInfo->specials_date_available)); ?>",scBTNMODE_CUSTOMBLUE);
 524  var SpecialEndDate = new ctlSpiffyCalendarBox("SpecialEndDate", "new_prices", "special_end", "btnDate5","<?php echo (($sInfo->expires_date <= '0001-01-01') ? '' : zen_date_short($sInfo->expires_date)); ?>",scBTNMODE_CUSTOMBLUE);
 525  </script>
 526  <?php } ?>
 527  
 528  <?php
 529  // auto fix bad or missing products master_categories_id

 530    if (zen_get_product_is_linked($products_filter) == 'false' and $pInfo->master_categories_id != zen_get_products_category_id($products_filter)) {
 531      $sql = "update " . TABLE_PRODUCTS . " set master_categories_id='" . zen_get_products_category_id($products_filter) . "' where products_id='" . $products_filter . "'";
 532      $db->Execute($sql);
 533      $pInfo->master_categories_id = zen_get_products_category_id($products_filter);
 534    }
 535  ?>
 536  
 537  <?php
 538    if ($pInfo->products_id != '') {
 539  ?>
 540        <tr>
 541          <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
 542        </tr>
 543        <tr>
 544          <td class="pageHeading"><?php echo TEXT_PRODUCT_INFO . ' #' . $pInfo->products_id . '&nbsp;&nbsp;' . $pInfo->products_name; ?>&nbsp;&nbsp;&nbsp;<?php echo TEXT_PRODUCTS_MODEL . ' ' . $pInfo->products_model; ?></td>
 545        </tr>
 546        <tr>
 547          <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
 548        </tr>
 549        <form name="new_prices" <?php echo 'action="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, zen_get_all_get_params(array('action', 'info', $_GET['products_filter'])) . 'action=' . 'update', 'NONSSL') . '"'; ?> method="post"><?php echo zen_draw_hidden_field('products_id', $_GET['products_filter']); echo zen_draw_hidden_field('specials_id', $sInfo->specials_id); echo zen_draw_hidden_field('featured_id', $fInfo->featured_id); echo zen_draw_hidden_field('discounts_list', $discounts_qty); ?>
 550        <tr>
 551          <td colspan="4"><table border="0" cellspacing="0" cellpadding="2" align="center" width="100%">
 552            <tr>
 553              <td class="pageHeading" align="center" valign="middle">
 554                <?php echo ($action == '' ? '<span class="alert">' . TEXT_INFO_PREVIEW_ONLY . '</span>' : ''); ?>
 555              </td>
 556            </tr>
 557            <tr>
 558              <td class="main" align="center" valign="middle">
 559              <?php
 560              if ($action == '') {
 561                echo '<a href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'action=edit' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT_PRODUCT) . '</a>' . '<br />' . TEXT_INFO_EDIT_CAUTION;
 562              } else {
 563                echo zen_image_submit('button_update.gif', IMAGE_UPDATE_PRICE_CHANGES) . '&nbsp;&nbsp;' . '<a href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'action=cancel' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>' . '<br />' . TEXT_UPDATE_COMMIT;
 564              }
 565              ?>
 566              </td>
 567            </tr>
 568            <tr>
 569              <td colspan="2"><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
 570            </tr>
 571          </table></td>
 572        </tr>
 573  
 574        <tr>
 575          <td><table border="0" cellspacing="0" cellpadding="2">
 576  
 577  <?php
 578  // show when product is linked

 579  if (zen_get_product_is_linked($products_filter) == 'true') {
 580  ?>
 581            <tr>
 582              <td class="main" width="200"><?php echo TEXT_MASTER_CATEGORIES_ID; ?></td>
 583              <td colspan="4" class="main">
 584                <?php
 585                  // echo zen_draw_pull_down_menu('products_tax_class_id', $tax_class_array, $pInfo->products_tax_class_id);

 586                  echo zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . '&nbsp;&nbsp;';
 587                  echo zen_draw_pull_down_menu('master_category', zen_get_master_categories_pulldown($products_filter), $pInfo->master_categories_id); ?>
 588              </td>
 589            </tr>
 590            <tr>
 591              <td colspan="5" class="main"><?php echo TEXT_INFO_MASTER_CATEGORIES_ID; ?></td>
 592            </tr>
 593            <tr>
 594              <td colspan="5" class="main" align="center"><?php echo ($action == '' ? '<span class="alert">' . TEXT_INFO_PREVIEW_ONLY . '</span>' : TEXT_INFO_UPDATE_REMINDER); ?></td>
 595            </tr>
 596  <?php } // master category linked ?>

 597  
 598  <?php
 599  if (zen_get_product_is_linked($products_filter) == 'false' and $pInfo->master_categories_id != zen_get_products_category_id($products_filter)) {
 600  ?>
 601            <tr>
 602              <td colspan="5" class="main"><span class="alert">
 603                <?php echo sprintf(TEXT_INFO_MASTER_CATEGORIES_ID_WARNING, $pInfo->master_categories_id, zen_get_products_category_id($products_filter)); ?></span>
 604                <br /><strong><?php echo sprintf(TEXT_INFO_MASTER_CATEGORIES_ID_UPDATE_TO_CURRENT, $pInfo->master_categories_id, zen_get_products_category_id($products_filter)); ?></strong>
 605              </td>
 606           </tr>
 607  <?php } ?>
 608  <?php
 609  echo zen_draw_hidden_field('master_categories_id', $pInfo->master_categories_id);
 610  ?>
 611  
 612  
 613            <tr>
 614              <td class="main" width="200"><?php echo TEXT_PRODUCTS_TAX_CLASS; ?></td>
 615              <td colspan="4" class="main"><?php echo zen_draw_pull_down_menu('products_tax_class_id', $tax_class_array, $pInfo->products_tax_class_id); ?></td>
 616            </tr>
 617            <tr>
 618              <td class="main" width="200"><?php echo TEXT_PRODUCTS_PRICE_INFO; ?></td>
 619              <td class="main"><?php echo TEXT_PRICE . '<br />' . zen_draw_input_field('products_price', (isset($pInfo->products_price) ? $pInfo->products_price : '')); ?></td>
 620              <td class="main"><?php echo TEXT_PRODUCT_AVAILABLE_DATE; ?><br /><script language="javascript">ProductStartDate.writeControl(); ProductStartDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></td>
 621              <td colspan="2" class="main"><?php echo zen_draw_radio_field('products_status', '1', $products_in_status) . '&nbsp;' . TEXT_PRODUCT_AVAILABLE . '<br />' . zen_draw_radio_field('products_status', '0', $products_out_status) . '&nbsp;' . TEXT_PRODUCT_NOT_AVAILABLE; ?></td>
 622            </tr>
 623  
 624            <tr>
 625              <td class="main" width="200">&nbsp;</td>
 626              <td class="main">
 627                <?php echo TEXT_PRODUCTS_QUANTITY_MIN_RETAIL; ?><br /><?php echo zen_draw_input_field('products_quantity_order_min', ($pInfo->products_quantity_order_min == 0 ? 1 : $pInfo->products_quantity_order_min), 'size="6"'); ?>
 628              </td>
 629              <td class="main">
 630                <?php echo TEXT_PRODUCTS_QUANTITY_UNITS_RETAIL; ?><br /><?php echo zen_draw_input_field('products_quantity_order_units', ($pInfo->products_quantity_order_units == 0 ? 1 : $pInfo->products_quantity_order_units), 'size="6"'); ?>
 631              </td>
 632              <td class="main">
 633                <?php echo TEXT_PRODUCTS_QUANTITY_MAX_RETAIL; ?><br /><?php echo zen_draw_input_field('products_quantity_order_max', $pInfo->products_quantity_order_max, 'size="6"'); ?>
 634              </td>
 635              <td class="main">
 636                <?php echo TEXT_PRODUCTS_MIXED; ?><br /><?php echo zen_draw_radio_field('products_quantity_mixed', '1', $in_products_quantity_mixed==1) . '&nbsp;' . TEXT_YES . '&nbsp;&nbsp;' . zen_draw_radio_field('products_quantity_mixed', '0', $out_products_quantity_mixed) . '&nbsp;' . TEXT_NO; ?>
 637              </td>
 638            </tr>
 639            <tr>
 640              <td colspan="3" class="main">&nbsp;</td>
 641              <td colspan="2" class="main">
 642                <?php echo TEXT_PRODUCTS_QUANTITY_MAX_RETAIL_EDIT; ?>
 643              </td>
 644            </tr>
 645            <tr>
 646              <td class="main" width="200">&nbsp;</td>
 647              <td class="main" valign="top"><?php echo TEXT_PRODUCT_IS_FREE; ?><br /><?php echo zen_draw_radio_field('product_is_free', '1', ($in_product_is_free==1)) . '&nbsp;' . TEXT_YES . '&nbsp;&nbsp;' . zen_draw_radio_field('product_is_free', '0', ($in_product_is_free==0)) . '&nbsp;' . TEXT_NO . ' ' . ($pInfo->product_is_free == 1 ? '<span class="errorText">' . TEXT_PRODUCTS_IS_FREE_EDIT . '</span>' : ''); ?></td>
 648              <td class="main" valign="top"><?php echo TEXT_PRODUCT_IS_CALL; ?><br /><?php echo zen_draw_radio_field('product_is_call', '1', ($in_product_is_call==1)) . '&nbsp;' . TEXT_YES . '&nbsp;&nbsp;' . zen_draw_radio_field('product_is_call', '0', ($in_product_is_call==0)) . '&nbsp;' . TEXT_NO . ' ' . ($pInfo->product_is_call == 1 ? '<span class="errorText">' . TEXT_PRODUCTS_IS_CALL_EDIT . '</span>' : ''); ?></td>
 649              <td colspan="2" class="main" valign="top"><?php echo TEXT_PRODUCTS_PRICED_BY_ATTRIBUTES; ?><br /><?php echo zen_draw_radio_field('products_priced_by_attribute', '1', $is_products_priced_by_attribute==1) . '&nbsp;' . TEXT_PRODUCT_IS_PRICED_BY_ATTRIBUTE . '&nbsp;&nbsp;' . zen_draw_radio_field('products_priced_by_attribute', '0', $not_products_priced_by_attribute) . '&nbsp;' . TEXT_PRODUCT_NOT_PRICED_BY_ATTRIBUTE . ' ' . ($pInfo->products_priced_by_attribute == 1 ? '<span class="errorText">' . TEXT_PRODUCTS_PRICED_BY_ATTRIBUTES_EDIT . '</span>' : ''); ?></td>
 650            </tr>
 651          </table></td>
 652        </tr>
 653  <?php
 654    } else {
 655  // show nothing

 656  ?>
 657        <tr>
 658          <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
 659        </tr>
 660        <tr>
 661          <td class="pageHeading"><?php echo TEXT_PRODUCT_INFO_NONE; ?></td>
 662        </tr>
 663  <?php  } ?>
 664  
 665  
 666  <?php
 667    if ($pInfo->products_id != '') {
 668  ?>
 669  <?php
 670    if ($sInfo->products_id != '') {
 671  ?>
 672        <tr>
 673          <td><br><table border="0" cellspacing="0" cellpadding="2">
 674            <tr>
 675              <td class="main" width="200"><?php echo TEXT_SPECIALS_PRODUCT_INFO; ?></td>
 676              <td class="main"><?php echo TEXT_SPECIALS_SPECIAL_PRICE . '<br />' . zen_draw_input_field('specials_price', (isset($sInfo->specials_new_products_price) ? $sInfo->specials_new_products_price : '')); ?></td>
 677              <td class="main"><?php echo TEXT_SPECIALS_AVAILABLE_DATE; ?><br /><script language="javascript">SpecialStartDate.writeControl(); SpecialStartDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></td>
 678              <td class="main"><?php echo TEXT_SPECIALS_EXPIRES_DATE; ?><br /><script language="javascript">SpecialEndDate.writeControl(); SpecialEndDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></td>
 679              <td class="main"><?php echo TEXT_SPECIALS_PRODUCTS_STATUS; ?><br />
 680                <?php echo zen_draw_radio_field('special_status', '1', $special_in_status) . '&nbsp;' . TEXT_SPECIALS_PRODUCT_AVAILABLE . '&nbsp;' . zen_draw_radio_field('special_status', '0', $special_out_status) . '&nbsp;' . TEXT_SPECIALS_PRODUCT_NOT_AVAILABLE; ?>
 681              </td>
 682              <td class="main" align="center" width="100"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $current_category_id . '&action=delete_special') . '">' .  zen_image_button('button_remove.gif', IMAGE_REMOVE_SPECIAL) . '</a>'; ?></td>
 683            </tr>
 684  <?php
 685    if ($sInfo->status == 0) {
 686  ?>
 687            <tr>
 688              <td colspan="6"><?php echo '<span class="errorText">' . TEXT_SPECIAL_DISABLED . '</span>'; ?></td>
 689            </tr>
 690  <?php } ?>
 691            <tr>
 692              <td colspan="6" class="main"><br><?php echo TEXT_SPECIALS_PRICE_TIP; ?></td>
 693            </tr>
 694          </table></td>
 695        </tr>
 696  <?php  } else {
 697  ?>
 698        <tr>
 699          <td><br><table border="0" cellspacing="0" cellpadding="2">
 700            <tr>
 701              <td class="main" width="200"><?php echo TEXT_SPECIALS_PRODUCT_INFO; ?></td>
 702  <?php
 703  // Specials cannot be added to Gift Vouchers

 704        if(substr($pInfo->products_model, 0, 4) != 'GIFT') {
 705  ?>
 706              <td class="main" align="center"><?php echo '<a href="' . zen_href_link(FILENAME_SPECIALS, 'add_products_id=' . $_GET['products_filter'] . '&action=new' . '&sID=' . $sInfo->specials_id . '&go_back=ON') . '">' .  zen_image_button('button_install.gif', IMAGE_INSTALL_SPECIAL) . '</a>'; ?></td>
 707  <?php  } else { ?>
 708              <td class="main" align="center"><?php echo TEXT_SPECIALS_NO_GIFTS; ?></td>
 709  <?php } ?>
 710            </tr>
 711          </table></td>
 712        </tr>
 713  <?php  } ?>
 714  
 715  <?php
 716    if ($fInfo->products_id != '') {
 717  ?>
 718        <tr>
 719          <td><br><table border="0" cellspacing="0" cellpadding="2">
 720            <tr>
 721              <td class="main" width="200"><?php echo TEXT_FEATURED_PRODUCT_INFO; ?></td>
 722              <td class="main"><?php echo TEXT_FEATURED_AVAILABLE_DATE ; ?><br /><script language="javascript">FeaturedStartDate.writeControl(); FeaturedStartDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></td>
 723              <td class="main"><?php echo TEXT_FEATURED_EXPIRES_DATE; ?><br /><script language="javascript">FeaturedEndDate.writeControl(); FeaturedEndDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></td>
 724              <td class="main"><?php echo TEXT_FEATURED_PRODUCTS_STATUS; ?><br />
 725                <?php echo zen_draw_radio_field('featured_status', '1', $featured_in_status) . '&nbsp;' . TEXT_FEATURED_PRODUCT_AVAILABLE . '&nbsp;' . zen_draw_radio_field('featured_status', '0', $featured_out_status) . '&nbsp;' . TEXT_FEATURED_PRODUCT_NOT_AVAILABLE; ?>
 726              </td>
 727              <td class="main" align="center" width="100"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $current_category_id . '&action=delete_featured') . '">' .  zen_image_button('button_remove.gif', IMAGE_REMOVE_FEATURED) . '</a>'; ?></td>
 728            </tr>
 729  <?php
 730    if ($fInfo->status == 0) {
 731  ?>
 732            <tr>
 733              <td colspan="5"><?php echo '<span class="errorText">' . TEXT_FEATURED_DISABLED . '</span>'; ?></td>
 734            </tr>
 735  <?php } ?>
 736          </table></td>
 737        </tr>
 738  <?php  } else { ?>
 739        <tr>
 740          <td><br><table border="0" cellspacing="0" cellpadding="2">
 741            <tr>
 742              <td class="main" width="200"><?php echo TEXT_FEATURED_PRODUCT_INFO; ?></td>
 743              <td class="main" align="center"><?php echo '<a href="' . zen_href_link(FILENAME_FEATURED, 'add_products_id=' . $_GET['products_filter'] . '&go_back=ON' . '&action=new') . '">' . zen_image_button('button_install.gif', IMAGE_INSTALL_FEATURED) . '</a>'; ?></td>
 744            </tr>
 745          </table></td>
 746        </tr>
 747  <?php  } ?>
 748  
 749  
 750        <tr>
 751          <td><br><table border="4" cellspacing="0" cellpadding="2">
 752  <?php
 753  // fix here

 754  // discount

 755      $discounts_qty = $db->Execute("select * from " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " where products_id='" . $products_filter . "' order by discount_qty");
 756      $discount_cnt = $discounts_qty->RecordCount();
 757      $make = 1;
 758      $i = 0;
 759      while (!$discounts_qty->EOF) {
 760        $i++;
 761        $discount_name[] = array('id' => $i,
 762                                   'discount_qty' => $discounts_qty->fields['discount_qty'],
 763                                   'discount_price' => $discounts_qty->fields['discount_price']);
 764        $discounts_qty->MoveNext();
 765      }
 766  ?>
 767  
 768  <?php
 769    if ($discounts_qty->RecordCount() > 0) {
 770  ?>
 771  
 772            <tr>
 773              <td colspan="5" class="main" valign="top"><?php echo TEXT_PRODUCTS_MIXED_DISCOUNT_QUANTITY; ?>&nbsp;&nbsp;<?php echo zen_draw_radio_field('products_mixed_discount_quantity', '1', $in_products_mixed_discount_quantity==1) . '&nbsp;' . TEXT_YES . '&nbsp;&nbsp;' . zen_draw_radio_field('products_mixed_discount_quantity', '0', $out_products_mixed_discount_quantity) . '&nbsp;' . TEXT_NO; ?></td>
 774            </tr>
 775            <tr>
 776              <td colspan="5" class="main" align="center">
 777                <?php
 778                  if ($action != '') {
 779                    echo TEXT_ADD_ADDITIONAL_DISCOUNT . '<br />';
 780                    echo '<a href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id . '&action=add_discount_qty_id') . '">' .  zen_image_button('button_blank_discounts.gif', IMAGE_ADD_BLANK_DISCOUNTS) . '</a>' . '<br />';
 781                    echo TEXT_BLANKS_INFO;
 782                  } else {
 783                    echo ($action == '' ? '<span class="alert">' . TEXT_INFO_PREVIEW_ONLY . '</span>' : '');
 784                  }
 785                ?>
 786              </td>
 787            </tr>
 788            <tr>
 789              <td colspan="5"><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
 790            </tr>
 791            <tr>
 792              <td class="main">
 793                <?php echo TEXT_DISCOUNT_TYPE_INFO; ?>
 794              </td>
 795              <td colspan="2" class="main">
 796                <?php echo TEXT_DISCOUNT_TYPE . ' ' . zen_draw_pull_down_menu('products_discount_type', $discount_type_array, $pInfo->products_discount_type); ?>
 797              </td>
 798              <td colspan="2" class="main">
 799                <?php echo TEXT_DISCOUNT_TYPE_FROM . ' ' . zen_draw_pull_down_menu('products_discount_type_from', $discount_type_from_array, $pInfo->products_discount_type_from); ?>
 800              </td>
 801            </tr>
 802            <tr>
 803              <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_QTY_TITLE; ?></td>
 804              <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_QTY; ?></td>
 805              <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_PRICE; ?></td>
 806  <?php
 807    if (DISPLAY_PRICE_WITH_TAX_ADMIN == 'true') {
 808  ?>
 809              <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_PRICE_EACH_TAX; ?></td>
 810              <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_PRICE_EXTENDED_TAX; ?></td>
 811  <?php } else { ?>
 812              <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_PRICE_EACH; ?></td>
 813              <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_PRICE_EXTENDED; ?></td>
 814  <?php } ?>
 815            </tr>
 816  <?php
 817  /*

 818    $display_priced_by_attributes = zen_get_products_price_is_priced_by_attributes($_GET['products_filter']);

 819    $display_price = zen_get_products_base_price($_GET['products_filter']);

 820    $display_specials_price = zen_get_products_special_price($_GET['products_filter'], true);

 821    $display_sale_price = zen_get_products_special_price($_GET['products_filter'], false);

 822    $display_free_price = zen_get_products_price_is_free($_GET['products_filter']);

 823    $display_call_price = zen_get_products_price_is_call($_GET['products_filter']);

 824  */
 825      for ($i=0, $n=sizeof($discount_name); $i<$n; $i++) {
 826        switch ($pInfo->products_discount_type) {
 827          // none

 828          case '0':
 829            $discounted_price = 0;
 830            break;
 831          // percentage discount

 832          case '1':
 833            $display_price = zen_get_products_base_price($_GET['products_filter']);
 834            if ($pInfo->products_discount_type_from == '0') {
 835              $discounted_price = $display_price - ($display_price * ($discount_name[$i]['discount_price']/100));
 836            } else {
 837              if (!$display_specials_price) {
 838                $discounted_price = $display_price - ($display_price * ($discount_name[$i]['discount_price']/100));
 839              } else {
 840                $discounted_price = $display_specials_price - ($display_specials_price * ($discount_name[$i]['discount_price']/100));
 841              }
 842            }
 843  
 844            break;
 845          // actual price

 846          case '2':
 847            if ($pInfo->products_discount_type_from == '0') {
 848              $discounted_price = $discount_name[$i]['discount_price'];
 849            } else {
 850              $discounted_price = $discount_name[$i]['discount_price'];
 851            }
 852            break;
 853          // amount offprice

 854          case '3':
 855            $display_price = zen_get_products_base_price($_GET['products_filter']);
 856            if ($pInfo->products_discount_type_from == '0') {
 857              $discounted_price = $display_price - $discount_name[$i]['discount_price'];
 858            } else {
 859              if (!$display_specials_price) {
 860                $discounted_price = $display_price - $discount_name[$i]['discount_price'];
 861              } else {
 862                $discounted_price = $display_specials_price - $discount_name[$i]['discount_price'];
 863              }
 864            }
 865            break;
 866        }
 867  ?>
 868            <tr>
 869              <td class="main"><?php echo TEXT_PRODUCTS_DISCOUNT . ' ' . $discount_name[$i]['id']; ?></td>
 870              <td class="main"><?php echo zen_draw_input_field('discount_qty[' . $discount_name[$i]['id'] . ']', $discount_name[$i]['discount_qty']); ?></td>
 871              <td class="main"><?php echo zen_draw_input_field('discount_price[' . $discount_name[$i]['id'] . ']', $discount_name[$i]['discount_price']); ?></td>
 872  <?php
 873    if (DISPLAY_PRICE_WITH_TAX == 'true') {
 874  ?>
 875              <td class="main" align="right"><?php echo $currencies->display_price($discounted_price, '', 1) . ' ' . $currencies->display_price($discounted_price, zen_get_tax_rate(1), 1); ?></td>
 876              <td class="main" align="right"><?php echo ' x ' . number_format($discount_name[$i]['discount_qty']) . ' = ' . $currencies->display_price($discounted_price, '', $discount_name[$i]['discount_qty']) . ' ' . $currencies->display_price($discounted_price, zen_get_tax_rate(1), $discount_name[$i]['discount_qty']); ?></td>
 877  <?php } else { ?>
 878              <td class="main" align="right"><?php echo $currencies->display_price($discounted_price, '', 1); ?></td>
 879              <td class="main" align="right"><?php echo ' x ' . number_format($discount_name[$i]['discount_qty']) . ' = ' . $currencies->display_price($discounted_price, '', $discount_name[$i]['discount_qty']); ?></td>
 880  <?php } ?>
 881            </tr>
 882  <?php
 883      }
 884  ?>
 885  <?php
 886    } else {
 887  ?>
 888            <tr>
 889            <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
 890            </tr>
 891            <tr>
 892              <td class="main" align="center" width="500">
 893                <?php
 894                  if ($action != '') {
 895                    echo TEXT_ADD_ADDITIONAL_DISCOUNT . '<br />';
 896                    echo '<a href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_filter . '&action=add_discount_qty_id') . '">' .  zen_image_button('button_blank_discounts.gif', IMAGE_ADD_BLANK_DISCOUNTS) . '</a>' . '<br />';
 897                    echo TEXT_BLANKS_INFO;
 898                  } else {
 899                    echo ($action == '' ? '<span class="alert">' . TEXT_INFO_PREVIEW_ONLY . '</span>' : '') . '<br />';
 900                    echo TEXT_INFO_NO_DISCOUNTS;
 901                  }
 902                ?>
 903              </td>
 904            </tr>
 905  <?php
 906    } // $discounts_qty->RecordCount() > 0

 907  ?>
 908  
 909          </table></td>
 910        </tr>
 911  
 912        <tr>
 913          <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
 914        </tr>
 915        <tr>
 916          <td><table border="0" cellspacing="0" cellpadding="2" align="center">
 917            <?php if ($action == '') { ?>
 918            <tr>
 919              <td class="pageHeading" align="center" valign="middle">
 920                <?php echo ($action == '' ? '<span class="alert">' . TEXT_INFO_PREVIEW_ONLY . '</span>' : ''); ?>
 921              </td>
 922            </tr>
 923            <?php } ?>
 924            <tr>
 925              <td class="main" align="center" valign="middle" width="100%">
 926              <?php
 927              if ($action == '') {
 928                echo '<a href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'action=edit' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT_PRODUCT) . '</a>' . '<br />' . TEXT_INFO_EDIT_CAUTION;
 929              } else {
 930                echo zen_image_submit('button_update.gif', IMAGE_UPDATE_PRICE_CHANGES) . '&nbsp;&nbsp;' . '<a href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'action=cancel' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>' . '<br />' . TEXT_UPDATE_COMMIT;
 931              }
 932              ?>
 933              </td>
 934            </tr>
 935          </table></td>
 936        </tr>
 937        <tr>
 938          <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
 939        </tr>
 940          </table></td>
 941        </tr></form>
 942  <?php } // no product selected ?>

 943  <?php } // allow_add_to_cart == 'Y' ?>

 944  
 945        </tr>
 946      </table></td>
 947  <!-- body_text_eof //-->
 948    </tr>
 949  </table>
 950  <!-- body_eof //-->
 951  
 952  <!-- footer //-->
 953  <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
 954  <!-- footer_eof //-->
 955  </body>
 956  </html>
 957  <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics