ZenCart_Documentation  1.5.0
http://www.collinsharper.com
C:/xampp/htdocs/zen-cart/admin/products_price_manager.php
Go to the documentation of this file.
00001 <?php
00010   require('includes/application_top.php');
00011 
00012   // verify products exist
00013   $chk_products = $db->Execute("select * from " . TABLE_PRODUCTS . " limit 1");
00014   if ($chk_products->RecordCount() < 1) {
00015     $messageStack->add_session(ERROR_DEFINE_PRODUCTS, 'caution');
00016     zen_redirect(zen_href_link(FILENAME_CATEGORIES));
00017   }
00018 
00019   require(DIR_WS_CLASSES . 'currencies.php');
00020   $currencies = new currencies();
00021 
00022   $products_filter = (isset($_GET['products_filter']) ? (int)$_GET['products_filter'] : (int)$products_filter);
00023 
00024   $action = (isset($_GET['action']) ? $_GET['action'] : '');
00025 
00026   $current_category_id = (isset($_GET['current_category_id']) ? (int)$_GET['current_category_id'] : (int)$current_category_id);
00027 
00028   if ($action == 'new_cat') {
00029     $current_category_id = (isset($_GET['current_category_id']) ? (int)$_GET['current_category_id'] : $current_category_id);
00030     $sql = "SELECT ptc.*
00031             FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc
00032             LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd
00033             ON ptc.products_id = pd.products_id
00034             AND pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
00035             LEFT join " . TABLE_PRODUCTS . " p
00036             ON p.products_id = pd.products_id
00037             LEFT JOIN " . TABLE_PRODUCT_TYPES  . " pt
00038             ON p.products_type = pt.type_id
00039             WHERE ptc.categories_id='" . $current_category_id . "'
00040             AND pt.allow_add_to_cart = 'Y'
00041             ORDER by pd.products_name";
00042     $new_product_query = $db->Execute($sql);
00043     $products_filter = $new_product_query->fields['products_id'];
00044     zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
00045   }
00046 
00047 // set categories and products if not set
00048   if ($products_filter == '' and $current_category_id != '') {
00049     $sql = "SELECT ptc.*
00050             FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc
00051             LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd
00052             ON ptc.products_id = pd.products_id
00053             AND pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
00054             LEFT join " . TABLE_PRODUCTS . " p
00055             ON p.products_id = pd.products_id
00056             LEFT JOIN " . TABLE_PRODUCT_TYPES  . " pt
00057             ON p.products_type = pt.type_id
00058             WHERE ptc.categories_id='" . $current_category_id . "'
00059             AND pt.allow_add_to_cart = 'Y'
00060             ORDER by pd.products_name";
00061     $new_product_query = $db->Execute($sql);
00062     $products_filter = $new_product_query->fields['products_id'];
00063     if ($products_filter != '') {
00064       zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
00065     }
00066   } else {
00067     if ($products_filter == '' and $current_category_id == '') {
00068       $reset_categories_id = zen_get_category_tree('', '', '0', '', '', true);
00069       $current_category_id = $reset_categories_id[0]['id'];
00070     $sql = "SELECT ptc.*
00071             FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc
00072             LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd
00073             ON ptc.products_id = pd.products_id
00074             AND pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
00075             LEFT join " . TABLE_PRODUCTS . " p
00076             ON p.products_id = pd.products_id
00077             LEFT JOIN " . TABLE_PRODUCT_TYPES  . " pt
00078             ON p.products_type = pt.type_id
00079             WHERE ptc.categories_id='" . $current_category_id . "'
00080             AND pt.allow_add_to_cart = 'Y'
00081             ORDER by pd.products_name";
00082     $new_product_query = $db->Execute($sql);
00083       $products_filter = $new_product_query->fields['products_id'];
00084       $_GET['products_filter'] = $products_filter;
00085     }
00086   }
00087 
00088   require(DIR_WS_MODULES . FILENAME_PREV_NEXT);
00089 
00090   if ($action == 'delete_special_confirm')
00091   {
00092     if (isset($_POST['product_id']))
00093     {
00094       $delete_special = $db->Execute("delete from " . TABLE_SPECIALS . " where products_id='" . (int)$_POST['product_id'] . "'");
00095 
00096       // reset products_price_sorter for searches etc.
00097       zen_update_products_price_sorter($products_filter);
00098 
00099       zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
00100     }
00101   }
00102 
00103   if ($action == 'delete_featured_confirm') {
00104     if (isset($_POST['product_id']))
00105     {
00106       $delete_featured = $db->Execute("delete from " . TABLE_FEATURED . " where products_id='" . (int)$_POST['product_id'] . "'");
00107 
00108       zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
00109     }
00110   }
00111 
00112   if ($action == 'add_discount_qty_id') {
00113     $add_id = $db->Execute("select discount_id from " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " where products_id='" . $products_filter . "' order by discount_id desc limit 1");
00114     $add_cnt = 1;
00115     $add_id = $add_id->fields['discount_id'];
00116     while ($add_cnt <= DISCOUNT_QTY_ADD) {
00117       $db->Execute("insert into " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . "
00118                     (discount_id, products_id)
00119                     values ('" . ($add_id + $add_cnt) . "', '" . $products_filter . "')");
00120       $add_cnt++;
00121     }
00122     zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'action=edit' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
00123   }
00124 
00125   if (zen_not_null($action)) {
00126     switch ($action) {
00127       case ('update'):
00128 
00129         if ($_POST['master_category']) {
00130           $master_categories_id = $_POST['master_category'];
00131         } else {
00132           $master_categories_id = $_POST['master_categories_id'];
00133         }
00134 
00135         $products_date_available = ((zen_db_prepare_input($_POST['product_start']) == '') ? '0001-01-01' : zen_date_raw($_POST['product_start']));
00136 
00137         $specials_date_available = ((zen_db_prepare_input($_POST['special_start']) == '') ? '0001-01-01' : zen_date_raw($_POST['special_start']));
00138         $specials_expires_date = ((zen_db_prepare_input($_POST['special_end']) == '') ? '0001-01-01' : zen_date_raw($_POST['special_end']));
00139 
00140         $featured_date_available = ((zen_db_prepare_input($_POST['featured_start']) == '') ? '0001-01-01' : zen_date_raw($_POST['featured_start']));
00141         $featured_expires_date = ((zen_db_prepare_input($_POST['featured_end']) == '') ? '0001-01-01' : zen_date_raw($_POST['featured_end']));
00142 
00143     $tmp_value = zen_db_prepare_input($_POST['products_price_sorter']);
00144     $products_price_sorter = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;
00145 
00146         $sql = "update " . TABLE_PRODUCTS . " set
00147             products_price=:price:,
00148             products_tax_class_id=:taxClass:,
00149             products_date_available=:dateAvailable:,
00150             products_last_modified=now(),
00151             products_status=:status:,
00152             products_quantity_order_min=:orderMin:,
00153             products_quantity_order_units=:orderUnits:,
00154             products_quantity_order_max=:orderMax:,
00155             product_is_free=:isFree:,
00156             product_is_call=:isCall:,
00157             products_quantity_mixed=:qtyMixed:,
00158             products_priced_by_attribute=:pricedByAttr:,
00159             products_discount_type=:discType:,
00160             products_discount_type_from=:discTypeFrom:,
00161             products_price_sorter=:discPriceSorter:,
00162             master_categories_id=:masterCatId:,
00163             products_mixed_discount_quantity=:discQty:
00164             where products_id='" . $products_filter . "'";
00165 
00166         $sql = $db->bindVars($sql, ':price:', $_POST['products_price'], 'string');
00167         $sql = $db->bindVars($sql, ':taxClass:', $_POST['products_tax_class_id'], 'integer');
00168         $sql = $db->bindVars($sql, ':dateAvailable:', $products_date_available, 'string');
00169         $sql = $db->bindVars($sql, ':status:', $_POST['products_status'], 'integer');
00170         $sql = $db->bindVars($sql, ':orderMin:', $_POST['products_quantity_order_min'], 'string');
00171         $sql = $db->bindVars($sql, ':orderUnits:', $_POST['products_quantity_order_units'], 'string');
00172         $sql = $db->bindVars($sql, ':orderMax:', $_POST['products_quantity_order_max'], 'string');
00173         $sql = $db->bindVars($sql, ':isFree:', $_POST['product_is_free'], 'integer');
00174         $sql = $db->bindVars($sql, ':isCall:', $_POST['product_is_call'], 'integer');
00175         $sql = $db->bindVars($sql, ':qtyMixed:', $_POST['products_quantity_mixed'], 'integer');
00176         $sql = $db->bindVars($sql, ':pricedByAttr:', $_POST['products_priced_by_attribute'], 'integer');
00177         $sql = $db->bindVars($sql, ':discType:', $_POST['products_discount_type'], 'integer');
00178         $sql = $db->bindVars($sql, ':discTypeFrom:', $_POST['products_discount_type_from'], 'integer');
00179         $sql = $db->bindVars($sql, ':discPriceSorter:', $products_price_sorter, 'string');
00180         $sql = $db->bindVars($sql, ':masterCatId:', $master_categories_id, 'integer');
00181         $sql = $db->bindVars($sql, ':discQty:', $_POST['products_mixed_discount_quantity'], 'integer');
00182 
00183         $db->Execute($sql);
00184 
00185         if ($_POST['specials_id'] != '') {
00186 
00187           $specials_id = zen_db_prepare_input($_POST['specials_id']);
00188 
00189           if ($_POST['products_priced_by_attribute'] == '1') {
00190             $products_price = zen_get_products_base_price($products_filter);
00191           } else {
00192             $products_price = zen_db_prepare_input($_POST['products_price']);
00193           }
00194 
00195           $specials_price = zen_db_prepare_input($_POST['specials_price']);
00196           if (substr($specials_price, -1) == '%') $specials_price = ($products_price - (($specials_price / 100) * $products_price));
00197           $db->Execute("update " . TABLE_SPECIALS . " set
00198               specials_new_products_price='" . zen_db_input($specials_price) . "',
00199               specials_date_available='" . zen_db_input($specials_date_available) . "',
00200               specials_last_modified=now(),
00201               expires_date='" . zen_db_input($specials_expires_date) . "',
00202               status='" . zen_db_input($_POST['special_status']) . "'
00203               where products_id='" . $products_filter . "'");
00204         }
00205 
00206         if ($_POST['featured_id'] != '') {
00207 
00208         $db->Execute("update " . TABLE_FEATURED . " set
00209             featured_date_available='" . zen_db_input($featured_date_available) . "',
00210             expires_date='" . zen_db_input($featured_expires_date) . "',
00211             featured_last_modified=now(),
00212             status='" . zen_db_input($_POST['featured_status']) . "'
00213             where products_id='" . $products_filter . "'");
00214         }
00215 
00216         $db->Execute("delete from " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " where products_id='" . $products_filter . "'");
00217         $i=1;
00218         $new_id = 0;
00219         $discount_cnt = 0;
00220         for ($i=1, $n=sizeof($_POST['discount_qty']); $i<=$n; $i++) {
00221           if ($_POST['discount_qty'][$i] > 0) {
00222             $new_id++;
00223             $db->Execute("insert into " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . "
00224                           (discount_id, products_id, discount_qty, discount_price)
00225                           values ('" . $new_id . "', '" . $products_filter . "', '" . zen_db_input($_POST['discount_qty'][$i]) . "', '" . zen_db_input($_POST['discount_price'][$i]) . "')");
00226             $discount_cnt++;
00227           } else {
00228             loop;
00229           }
00230         }
00231 
00232         if ($discount_cnt <= 0) {
00233           $db->Execute("update " . TABLE_PRODUCTS . " set products_discount_type='0' where products_id='" . $products_filter . "'");
00234         }
00235 
00236         // reset products_price_sorter for searches etc.
00237         zen_update_products_price_sorter($products_filter);
00238         $messageStack->add_session(PRODUCT_UPDATE_SUCCESS, 'success');
00239 
00240         zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
00241         break;
00242       case 'set_products_filter':
00243         $_GET['products_filter'] = $_POST['products_filter'];
00244 
00245         zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_POST['current_category_id']));
00246         break;
00247 
00248       case 'edit':
00249       // set edit message
00250       $messageStack->add_session(PRODUCT_WARNING_UPDATE, 'caution');
00251       zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'action=edit_update' . '&products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $current_category_id));
00252       break;
00253       case 'cancel':
00254       // set edit message
00255       $messageStack->add_session(PRODUCT_WARNING_UPDATE_CANCEL, 'warning');
00256       zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $current_category_id));
00257       break;
00258     }
00259   }
00260 
00261 ?>
00262 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
00263 <html <?php echo HTML_PARAMS; ?>>
00264 <head>
00265 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
00266 <title><?php echo TITLE; ?></title>
00267 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
00268 <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
00269 <script language="javascript" src="includes/menu.js"></script>
00270 <script language="javascript" src="includes/general.js"></script>
00271 <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
00272 <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
00273 
00274 <script type="text/javascript">
00275   <!--
00276   function init()
00277   {
00278     cssjsmenu('navbar');
00279     if (document.getElementById)
00280     {
00281       var kill = document.getElementById('hoverJS');
00282       kill.disabled = true;
00283     }
00284   }
00285   // -->
00286 </script>
00287 </head>
00288 <body onLoad="init()">
00289 <div id="spiffycalendar" class="text"></div>
00290 <!-- header //-->
00291 <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
00292 <!-- header_eof //-->
00293 
00294 <!-- body //-->
00295 <table border="0" width="100%" cellspacing="2" cellpadding="2">
00296   <tr>
00297 <!-- body_text //-->
00298     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00299               <tr>
00300                 <td class="smallText" align="right">
00301 <?php
00302     echo zen_draw_form('search', FILENAME_CATEGORIES, '', 'get');
00303 // show reset search
00304     if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
00305       echo '<a href="' . zen_href_link(FILENAME_CATEGORIES) . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a>&nbsp;&nbsp;';
00306     }
00307     echo HEADING_TITLE_SEARCH_DETAIL . ' ' . zen_draw_input_field('search') . zen_hide_session_id();
00308     if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
00309       $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
00310       echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER . $keywords;
00311     }
00312     echo '</form>';
00313 ?>
00314                 </td>
00315               </tr>
00316 <?php
00318 // BOF: NEW CODE TO KEEP
00319 ?>
00320 
00321 <?php
00322   if ($action != 'edit_update') {
00323     require(DIR_WS_MODULES . FILENAME_PREV_NEXT_DISPLAY);
00324 ?>
00325 
00326       <tr>
00327       <?php echo zen_draw_form('set_products_filter', FILENAME_PRODUCTS_PRICE_MANAGER, 'action=set_products_filter', 'post'); ?>
00328       <?php echo zen_draw_hidden_field('products_filter', $_GET['products_filter']); ?><?php echo zen_draw_hidden_field('current_category_id', $_GET['current_category_id']); ?>
00329         <td colspan="2"><table border="0" cellspacing="0" cellpadding="2">
00330 
00331 <?php
00332 if ($_GET['products_filter'] != '') {
00333 ?>
00334           <tr>
00335             <td class="main" width="200" align="left" valign="top">&nbsp;</td>
00336             <td colspan="2" class="main"><?php echo TEXT_PRODUCT_TO_VIEW; ?></td>
00337           </tr>
00338           <tr>
00339             <td class="main" width="200" align="center" valign="top">
00340 
00341 <?php
00342 // FIX HERE
00343   $display_priced_by_attributes = zen_get_products_price_is_priced_by_attributes($_GET['products_filter']);
00344   echo ($display_priced_by_attributes ? '<span class="alert">' . TEXT_PRICED_BY_ATTRIBUTES . '</span>' . '<br />' : '');
00345   echo zen_get_products_display_price($_GET['products_filter']) . '<br /><br />';
00346   echo zen_get_products_quantity_min_units_display($_GET['products_filter'], $include_break = true);
00347   $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'");
00348   while (!$not_for_cart->EOF) {
00349     $not_for_cart_array[] = $not_for_cart->fields['products_id'];
00350     $not_for_cart->MoveNext();
00351    }
00352 ?>
00353             </td>
00354             <td class="attributes-even" align="center"><?php echo zen_draw_products_pull_down('products_filter', 'size="10"', $not_for_cart->fields, true, $_GET['products_filter'], true, true); ?></td>
00355             <td class="main" align="center" valign="top">
00356               <?php
00357                 echo zen_image_submit('button_display.gif', IMAGE_DISPLAY);
00358               ?>
00359             </td>
00360           </tr>
00361 <?php
00362 } else {
00363   $not_for_cart = '';
00364 } // $_GET['products_filter'] != ''
00365 ?>
00366         <tr>
00367           <td colspan="3">
00368             <table>
00369 
00370 <?php
00371 // show when product is linked
00372 if ($products_filter != '' && zen_get_product_is_linked($products_filter) == 'true') {
00373 ?>
00374               <tr>
00375                 <td class="main" align="center" valign="bottom">
00376                   <?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'); ?>
00377                 </td>
00378               </tr>
00379 <?php } ?>
00380               <tr>
00381                 <td class="main" align="center" valign="bottom">
00382 <?php
00383   if ($_GET['products_filter'] != '') {
00384     echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . zen_get_product_path($products_filter) . '&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;';
00385     echo '</td><td class="main" align="center" valign="bottom">';
00386     echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=new_product' . '&cPath=' . zen_get_product_path($products_filter) . '&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>';
00387     echo '</td><td class="main" align="center" valign="bottom">';
00388         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;';
00389   }
00390 ?>
00391                 </td>
00392               </tr>
00393 <?php if ($products_filter != '') { ?>
00394             <tr>
00395             <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>
00396             </tr>
00397 <?php } ?>
00398             </table>
00399           </td>
00400         </tr>
00401 
00402         </table></td>
00403       </form></tr>
00404 <?php } // $action != 'edit_update' ?>
00405 <?php
00406 // EOF: NEW CODE TO KEEP
00408 ?>
00409 <?php
00410 // start of attributes display
00411 if ($products_filter == '') {
00412 ?>
00413       <tr>
00414         <td colspan="2" class="pageHeading" align="center" valign="middle" height="200"><?php echo HEADING_TITLE_PRODUCT_SELECT; ?></td>
00415       </tr>
00416 <?php } ?>
00417 
00418 <?php
00419 // only show if allowed in cart
00420   if ($zc_products->get_allow_add_to_cart($products_filter) == 'Y') {
00421 ?>
00422 
00423 <?php
00424 // featured information
00425       $product = $db->Execute("select p.products_id,
00426                                       f.featured_id, f.expires_date, f.featured_date_available, f.status
00427                                from " . TABLE_PRODUCTS . " p, " .
00428                                         TABLE_FEATURED . " f
00429                                where p.products_id = f.products_id
00430                                and f.products_id = '" . (int)$_GET['products_filter'] . "'");
00431 
00432 
00433       if ($product->RecordCount() > 0) {
00434         $fInfo = new objectInfo($product->fields);
00435       }
00436 
00437 // specials information
00438       $product = $db->Execute("select p.products_id,
00439                                       s.specials_id, s.specials_new_products_price, s.expires_date, s.specials_date_available, s.status
00440                                from " . TABLE_PRODUCTS . " p, " .
00441                                         TABLE_SPECIALS . " s
00442                                where p.products_id = s.products_id
00443                                and s.products_id = '" . (int)$_GET['products_filter'] . "'");
00444 
00445       if ($product->RecordCount() > 0) {
00446         $sInfo = new objectInfo($product->fields);
00447       }
00448 
00449 // products information
00450       $product = $db->Execute("select p.products_id, p.products_model,
00451                                       p.products_price, p.products_date_available,
00452                                       p.products_tax_class_id,
00453                                       p.products_quantity_order_min, products_quantity_order_units, p.products_quantity_order_max,
00454                                       p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.products_priced_by_attribute, p.products_status,
00455                                       p.products_discount_type, p.products_discount_type_from, p.products_price_sorter,
00456                                       pd.products_name,
00457                                       p.master_categories_id, p.products_mixed_discount_quantity
00458                                from " . TABLE_PRODUCTS . " p, " .
00459                                         TABLE_PRODUCTS_DESCRIPTION . " pd
00460                                where p.products_id = '" . (int)$_GET['products_filter'] . "'
00461                                and p.products_id = pd.products_id
00462                                and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'");
00463 
00464 
00465       if ($product->RecordCount() > 0) {
00466         $pInfo = new objectInfo($product->fields);
00467       }
00468 
00469 // set statuses
00470       if (!isset($pInfo->products_status)) $pInfo->products_status = '1';
00471         switch ($pInfo->products_status) {
00472         case '0': $products_in_status = false; $products_out_status = true; break;
00473         case '1':
00474         default: $products_in_status = true; $products_out_status = false;
00475       }
00476       if (!isset($fInfo->status)) $fInfo->status = '1';
00477         switch ($fInfo->status) {
00478         case '0': $featured_in_status = false; $featured_out_status = true; break;
00479         case '1':
00480         default: $featured_in_status = true; $featured_out_status = false;
00481       }
00482       if (!isset($sInfo->status)) $sInfo->status = '1';
00483         switch ($sInfo->status) {
00484         case '0': $special_in_status = false; $special_out_status = true; break;
00485         case '1':
00486         default: $special_in_status = true; $special_out_status = false;
00487       }
00488 
00489 // Product is Priced by Attributes
00490     if (!isset($pInfo->products_priced_by_attribute)) $pInfo->products_priced_by_attribute = '0';
00491     switch ($pInfo->products_priced_by_attribute) {
00492       case '0': $is_products_priced_by_attribute = false; $not_products_priced_by_attribute = true; break;
00493       case '1': $is_products_priced_by_attribute = true; $not_products_priced_by_attribute = false; break;
00494       default: $is_products_priced_by_attribute = false; $not_products_priced_by_attribute = true;
00495     }
00496 // Product is Free
00497     if (!isset($pInfo->product_is_free)) $pInfo->product_is_free = '0';
00498     switch ($pInfo->product_is_free) {
00499       case '0': $in_product_is_free = false; $out_product_is_free = true; break;
00500       case '1': $in_product_is_free = true; $out_product_is_free = false; break;
00501       default: $in_product_is_free = false; $out_product_is_free = true;
00502     }
00503 // Product is Call for price
00504     if (!isset($pInfo->product_is_call)) $pInfo->product_is_call = '0';
00505     switch ($pInfo->product_is_call) {
00506       case '0': $in_product_is_call = false; $out_product_is_call = true; break;
00507       case '1': $in_product_is_call = true; $out_product_is_call = false; break;
00508       default: $in_product_is_call = false; $out_product_is_call = true;
00509     }
00510 // Products can be purchased with mixed attributes retail
00511     if (!isset($pInfo->products_quantity_mixed)) $pInfo->products_quantity_mixed = '0';
00512     switch ($pInfo->products_quantity_mixed) {
00513       case '0': $in_products_quantity_mixed = false; $out_products_quantity_mixed = true; break;
00514       case '1': $in_products_quantity_mixed = true; $out_products_quantity_mixed = false; break;
00515       default: $in_products_quantity_mixed = true; $out_products_quantity_mixed = false;
00516     }
00517 // Products can be purchased with mixed attributes for discount
00518     if (!isset($pInfo->products_mixed_discount_quantity)) $pInfo->products_mixed_discount_quantity = '1';
00519     switch ($pInfo->products_mixed_discount_quantity) {
00520       case '0': $in_products_mixed_discount_quantity = false; $out_products_mixed_discount_quantity = true; break;
00521       case '1': $in_products_mixed_discount_quantity = true; $out_products_mixed_discount_quantity = false; break;
00522       default: $in_products_mixed_discount_quantity = true; $out_products_mixed_discount_quantity = false;
00523     }
00524 
00525 // Product is product discount type - None, Percentage, Actual Price, $$ off
00526   $discount_type_array = array(array('id' => '0', 'text' => DISCOUNT_TYPE_DROPDOWN_0),
00527                                 array('id' => '1', 'text' => DISCOUNT_TYPE_DROPDOWN_1),
00528                                 array('id' => '2', 'text' => DISCOUNT_TYPE_DROPDOWN_2),
00529                                 array('id' => '3', 'text' => DISCOUNT_TYPE_DROPDOWN_3));
00530 
00531 // Product is product discount type from price or special
00532   $discount_type_from_array = array(array('id' => '0', 'text' => DISCOUNT_TYPE_FROM_DROPDOWN_0),
00533                               array('id' => '1', 'text' => DISCOUNT_TYPE_FROM_DROPDOWN_1));
00534 
00535 // tax class id
00536     $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
00537     $tax_class = $db->Execute("select tax_class_id, tax_class_title
00538                                      from " . TABLE_TAX_CLASS . " order by tax_class_title");
00539     while (!$tax_class->EOF) {
00540       $tax_class_array[] = array('id' => $tax_class->fields['tax_class_id'],
00541                                  'text' => $tax_class->fields['tax_class_title']);
00542       $tax_class->MoveNext();
00543     }
00544 ?>
00545 <?php if ($pInfo->products_id != '') { ?>
00546 <script language="javascript">
00547 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);
00548 </script>
00549 <?php } ?>
00550 
00551 <?php if ($fInfo->products_id != '') { ?>
00552 <script language="javascript">
00553 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);
00554 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);
00555 </script>
00556 <?php } ?>
00557 
00558 <?php if ($sInfo->products_id != '') { ?>
00559 <script language="javascript">
00560 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);
00561 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);
00562 </script>
00563 <?php } ?>
00564 
00565 <?php
00566 // auto fix bad or missing products master_categories_id
00567   if (zen_get_product_is_linked($products_filter) == 'false' and $pInfo->master_categories_id != zen_get_products_category_id($products_filter)) {
00568     $sql = "update " . TABLE_PRODUCTS . " set master_categories_id='" . zen_get_products_category_id($products_filter) . "' where products_id='" . $products_filter . "'";
00569     $db->Execute($sql);
00570     $pInfo->master_categories_id = zen_get_products_category_id($products_filter);
00571   }
00572 ?>
00573 
00574 <?php
00575   if ($pInfo->products_id != '') {
00576 ?>
00577       <tr>
00578         <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
00579       </tr>
00580       <tr>
00581         <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>
00582       </tr>
00583       <tr>
00584         <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
00585       </tr>
00586       <?php if ($action == 'delete_special') { ?>
00587       <tr>
00588         <td>
00589           <table border="0" cellspacing="2" cellpadding="2">
00590             <tr class="pageHeading">
00591               <td class="alert" align="center" colspan="2"><?php echo TEXT_SPECIALS_CONFIRM_DELETE; ?></td>
00592             </tr>
00593             <tr>
00594               <td class="main" align="left">
00595               <?php echo zen_draw_form('delete_special', FILENAME_PRODUCTS_PRICE_MANAGER, 'action=delete_special_confirm&products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_GET['current_category_id']); ?>
00596               <input type="hidden" name="product_id" value="<?php echo $_GET['products_filter']; ?>" />
00597               <?php echo zen_image_submit('button_delete.gif', IMAGE_REMOVE_SPECIAL); ?>&nbsp;&nbsp;<a href="<?php echo zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_GET['current_category_id']); ?>"><?php echo zen_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a>
00598               </td>
00599             </tr>
00600           </table>
00601       </td>
00602       </tr>
00603       <?php } ?>
00604       <?php if ($action == 'delete_featured') { ?>
00605       <tr>
00606         <td>
00607           <table border="0" cellspacing="2" cellpadding="2">
00608             <tr class="pageHeading">
00609               <td class="alert" align="center" colspan="2"><?php echo TEXT_FEATURED_CONFIRM_DELETE; ?></td>
00610             </tr>
00611             <tr>
00612               <td class="main" align="left">
00613               <?php echo zen_draw_form('delete_special', FILENAME_PRODUCTS_PRICE_MANAGER, 'action=delete_featured_confirm&products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_GET['current_category_id']); ?>
00614               <input type="hidden" name="product_id" value="<?php echo $_GET['products_filter']; ?>" />
00615               <?php echo zen_image_submit('button_delete.gif', IMAGE_REMOVE_FEATURED); ?>&nbsp;&nbsp;<a href="<?php echo zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_GET['current_category_id']); ?>"><?php echo zen_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a>
00616               </td>
00617             </tr>
00618           </table>
00619       </td>
00620       </tr>
00621       <?php } ?>
00622 
00623       <?php echo zen_draw_form('new_prices', FILENAME_PRODUCTS_PRICE_MANAGER, zen_get_all_get_params(array('action', 'info', $_GET['products_filter'])) . 'action=' . 'update', 'post'); ?>
00624       <?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); ?>
00625       <tr>
00626         <td colspan="4"><table border="0" cellspacing="0" cellpadding="2" align="center" width="100%">
00627           <tr>
00628             <td class="pageHeading" align="center" valign="middle">
00629               <?php echo ($action == '' ? '<span class="alert">' . TEXT_INFO_PREVIEW_ONLY . '</span>' : ''); ?>
00630             </td>
00631           </tr>
00632           <tr>
00633             <td class="main" align="center" valign="middle">
00634             <?php
00635             if ($action == '' || $action == 'delete_special' || $action == 'delete_featured') {
00636               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;
00637             } else {
00638               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;
00639             }
00640             ?>
00641             </td>
00642           </tr>
00643           <tr>
00644             <td colspan="2"><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
00645           </tr>
00646         </table></td>
00647       </tr>
00648 
00649       <tr>
00650         <td><table border="0" cellspacing="0" cellpadding="2">
00651 
00652 <?php
00653 // show when product is linked
00654 if (zen_get_product_is_linked($products_filter) == 'true') {
00655 ?>
00656           <tr>
00657             <td class="main" width="200"><?php echo TEXT_MASTER_CATEGORIES_ID; ?></td>
00658             <td colspan="4" class="main">
00659               <?php
00660                 // echo zen_draw_pull_down_menu('products_tax_class_id', $tax_class_array, $pInfo->products_tax_class_id);
00661                 echo zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . '&nbsp;&nbsp;';
00662                 echo zen_draw_pull_down_menu('master_category', zen_get_master_categories_pulldown($products_filter), $pInfo->master_categories_id); ?>
00663             </td>
00664           </tr>
00665           <tr>
00666             <td colspan="5" class="main"><?php echo TEXT_INFO_MASTER_CATEGORIES_ID; ?></td>
00667           </tr>
00668           <tr>
00669             <td colspan="5" class="main" align="center"><?php echo ($action == '' ? '<span class="alert">' . TEXT_INFO_PREVIEW_ONLY . '</span>' : TEXT_INFO_UPDATE_REMINDER); ?></td>
00670           </tr>
00671 <?php } // master category linked ?>
00672 
00673 <?php
00674 if (zen_get_product_is_linked($products_filter) == 'false' and $pInfo->master_categories_id != zen_get_products_category_id($products_filter)) {
00675 ?>
00676           <tr>
00677             <td colspan="5" class="main"><span class="alert">
00678               <?php echo sprintf(TEXT_INFO_MASTER_CATEGORIES_ID_WARNING, $pInfo->master_categories_id, zen_get_products_category_id($products_filter)); ?></span>
00679               <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>
00680             </td>
00681          </tr>
00682 <?php } ?>
00683 <?php
00684 echo zen_draw_hidden_field('master_categories_id', $pInfo->master_categories_id);
00685 ?>
00686 
00687 
00688           <tr>
00689             <td class="main" width="200"><?php echo TEXT_PRODUCTS_TAX_CLASS; ?></td>
00690             <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>
00691           </tr>
00692           <tr>
00693             <td class="main" width="200"><?php echo TEXT_PRODUCTS_PRICE_INFO; ?></td>
00694             <td class="main"><?php echo TEXT_PRICE . '<br />' . zen_draw_input_field('products_price', (isset($pInfo->products_price) ? $pInfo->products_price : '')); ?></td>
00695             <td class="main"><?php echo TEXT_PRODUCT_AVAILABLE_DATE; ?><br /><script language="javascript">ProductStartDate.writeControl(); ProductStartDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></td>
00696             <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>
00697           </tr>
00698 
00699           <tr>
00700             <td class="main" width="200">&nbsp;</td>
00701             <td class="main">
00702               <?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"'); ?>
00703             </td>
00704             <td class="main">
00705               <?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"'); ?>
00706             </td>
00707             <td class="main">
00708               <?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"'); ?>
00709             </td>
00710             <td class="main">
00711               <?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; ?>
00712             </td>
00713           </tr>
00714           <tr>
00715             <td colspan="3" class="main">&nbsp;</td>
00716             <td colspan="2" class="main">
00717               <?php echo TEXT_PRODUCTS_QUANTITY_MAX_RETAIL_EDIT; ?>
00718             </td>
00719           </tr>
00720           <tr>
00721             <td class="main" width="200">&nbsp;</td>
00722             <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>
00723             <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>
00724             <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>
00725           </tr>
00726         </table></td>
00727       </tr>
00728 <?php
00729   } else {
00730 // show nothing
00731 ?>
00732       <tr>
00733         <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
00734       </tr>
00735       <tr>
00736         <td class="pageHeading"><?php echo TEXT_PRODUCT_INFO_NONE; ?></td>
00737       </tr>
00738 <?php  } ?>
00739 
00740 
00741 <?php
00742   if ($pInfo->products_id != '') {
00743 ?>
00744 <?php
00745   if ($sInfo->products_id != '') {
00746 ?>
00747       <tr>
00748         <td><br><table border="0" cellspacing="0" cellpadding="2">
00749           <tr>
00750             <td class="main" width="200"><?php echo TEXT_SPECIALS_PRODUCT_INFO; ?></td>
00751             <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>
00752             <td class="main"><?php echo TEXT_SPECIALS_AVAILABLE_DATE; ?><br /><script language="javascript">SpecialStartDate.writeControl(); SpecialStartDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></td>
00753             <td class="main"><?php echo TEXT_SPECIALS_EXPIRES_DATE; ?><br /><script language="javascript">SpecialEndDate.writeControl(); SpecialEndDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></td>
00754             <td class="main"><?php echo TEXT_SPECIALS_PRODUCTS_STATUS; ?><br />
00755               <?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; ?>
00756             </td>
00757             <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>
00758           </tr>
00759 <?php
00760   if ($sInfo->status == 0) {
00761 ?>
00762           <tr>
00763             <td colspan="6"><?php echo '<span class="errorText">' . TEXT_SPECIAL_DISABLED . '</span>'; ?></td>
00764           </tr>
00765 <?php } ?>
00766           <tr>
00767             <td colspan="6" class="main"><br><?php echo TEXT_SPECIALS_PRICE_TIP; ?></td>
00768           </tr>
00769         </table></td>
00770       </tr>
00771 <?php  } else {
00772 ?>
00773       <tr>
00774         <td><br><table border="0" cellspacing="0" cellpadding="2">
00775           <tr>
00776             <td class="main" width="200"><?php echo TEXT_SPECIALS_PRODUCT_INFO; ?></td>
00777 <?php
00778 // Specials cannot be added to Gift Vouchers
00779       if(substr($pInfo->products_model, 0, 4) != 'GIFT') {
00780 ?>
00781             <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' . '&current_category_id=' . $current_category_id) . '">' .  zen_image_button('button_install.gif', IMAGE_INSTALL_SPECIAL) . '</a>'; ?></td>
00782 <?php  } else { ?>
00783             <td class="main" align="center"><?php echo TEXT_SPECIALS_NO_GIFTS; ?></td>
00784 <?php } ?>
00785           </tr>
00786         </table></td>
00787       </tr>
00788 <?php  } ?>
00789 
00790 <?php
00791   if ($fInfo->products_id != '') {
00792 ?>
00793       <tr>
00794         <td><br><table border="0" cellspacing="0" cellpadding="2">
00795           <tr>
00796             <td class="main" width="200"><?php echo TEXT_FEATURED_PRODUCT_INFO; ?></td>
00797             <td class="main"><?php echo TEXT_FEATURED_AVAILABLE_DATE ; ?><br /><script language="javascript">FeaturedStartDate.writeControl(); FeaturedStartDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></td>
00798             <td class="main"><?php echo TEXT_FEATURED_EXPIRES_DATE; ?><br /><script language="javascript">FeaturedEndDate.writeControl(); FeaturedEndDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></td>
00799             <td class="main"><?php echo TEXT_FEATURED_PRODUCTS_STATUS; ?><br />
00800               <?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; ?>
00801             </td>
00802             <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>
00803           </tr>
00804 <?php
00805   if ($fInfo->status == 0) {
00806 ?>
00807           <tr>
00808             <td colspan="5"><?php echo '<span class="errorText">' . TEXT_FEATURED_DISABLED . '</span>'; ?></td>
00809           </tr>
00810 <?php } ?>
00811         </table></td>
00812       </tr>
00813 <?php  } else { ?>
00814       <tr>
00815         <td><br><table border="0" cellspacing="0" cellpadding="2">
00816           <tr>
00817             <td class="main" width="200"><?php echo TEXT_FEATURED_PRODUCT_INFO; ?></td>
00818             <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' . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_install.gif', IMAGE_INSTALL_FEATURED) . '</a>'; ?></td>
00819           </tr>
00820         </table></td>
00821       </tr>
00822 <?php  } ?>
00823 
00824 
00825       <tr>
00826         <td><br><table border="4" cellspacing="0" cellpadding="2">
00827 <?php
00828 // fix here
00829 // discount
00830     $discounts_qty = $db->Execute("select * from " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " where products_id='" . $products_filter . "' order by discount_qty");
00831     $discount_cnt = $discounts_qty->RecordCount();
00832     $make = 1;
00833     $i = 0;
00834     while (!$discounts_qty->EOF) {
00835       $i++;
00836       $discount_name[] = array('id' => $i,
00837                                  'discount_qty' => $discounts_qty->fields['discount_qty'],
00838                                  'discount_price' => $discounts_qty->fields['discount_price']);
00839       $discounts_qty->MoveNext();
00840     }
00841 ?>
00842 
00843 <?php
00844   if ($discounts_qty->RecordCount() > 0) {
00845 ?>
00846 
00847           <tr>
00848             <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>
00849           </tr>
00850           <tr>
00851             <td colspan="5" class="main" align="center">
00852               <?php
00853                 if ($action != '') {
00854                   echo TEXT_ADD_ADDITIONAL_DISCOUNT . '<br />';
00855                   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 />';
00856                   echo TEXT_BLANKS_INFO;
00857                 } else {
00858                   echo ($action == '' ? '<span class="alert">' . TEXT_INFO_PREVIEW_ONLY . '</span>' : '');
00859                 }
00860               ?>
00861             </td>
00862           </tr>
00863           <tr>
00864             <td colspan="5"><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
00865           </tr>
00866           <tr>
00867             <td class="main">
00868               <?php echo TEXT_DISCOUNT_TYPE_INFO; ?>
00869             </td>
00870             <td colspan="2" class="main">
00871               <?php echo TEXT_DISCOUNT_TYPE . ' ' . zen_draw_pull_down_menu('products_discount_type', $discount_type_array, $pInfo->products_discount_type); ?>
00872             </td>
00873             <td colspan="2" class="main">
00874               <?php echo TEXT_DISCOUNT_TYPE_FROM . ' ' . zen_draw_pull_down_menu('products_discount_type_from', $discount_type_from_array, $pInfo->products_discount_type_from); ?>
00875             </td>
00876           </tr>
00877           <tr>
00878             <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_QTY_TITLE; ?></td>
00879             <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_QTY; ?></td>
00880             <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_PRICE; ?></td>
00881 <?php
00882   if (DISPLAY_PRICE_WITH_TAX_ADMIN == 'true') {
00883 ?>
00884             <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_PRICE_EACH_TAX; ?></td>
00885             <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_PRICE_EXTENDED_TAX; ?></td>
00886 <?php } else { ?>
00887             <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_PRICE_EACH; ?></td>
00888             <td class="main" align="center"><?php echo TEXT_PRODUCTS_DISCOUNT_PRICE_EXTENDED; ?></td>
00889 <?php } ?>
00890           </tr>
00891 <?php
00892 
00893   $display_priced_by_attributes = zen_get_products_price_is_priced_by_attributes($_GET['products_filter']);
00894   $display_price = zen_get_products_base_price($_GET['products_filter']);
00895   $display_specials_price = zen_get_products_special_price($_GET['products_filter'], true);
00896 //  $display_sale_price = zen_get_products_special_price($_GET['products_filter'], false);
00897 
00898     for ($i=0, $n=sizeof($discount_name); $i<$n; $i++) {
00899       switch ($pInfo->products_discount_type) {
00900         // none
00901         case '0':
00902           $discounted_price = 0;
00903           break;
00904         // percentage discount
00905         case '1':
00906           if ($pInfo->products_discount_type_from == '0') {
00907             $discounted_price = $display_price - ($display_price * ($discount_name[$i]['discount_price']/100));
00908           } else {
00909             if (!$display_specials_price) {
00910               $discounted_price = $display_price - ($display_price * ($discount_name[$i]['discount_price']/100));
00911             } else {
00912               $discounted_price = $display_specials_price - ($display_specials_price * ($discount_name[$i]['discount_price']/100));
00913             }
00914           }
00915 
00916           break;
00917         // actual price
00918         case '2':
00919           if ($pInfo->products_discount_type_from == '0') {
00920             $discounted_price = $discount_name[$i]['discount_price'];
00921           } else {
00922             $discounted_price = $discount_name[$i]['discount_price'];
00923           }
00924           break;
00925         // amount offprice
00926         case '3':
00927           if ($pInfo->products_discount_type_from == '0') {
00928             $discounted_price = $display_price - $discount_name[$i]['discount_price'];
00929           } else {
00930             if (!$display_specials_price) {
00931               $discounted_price = $display_price - $discount_name[$i]['discount_price'];
00932             } else {
00933               $discounted_price = $display_specials_price - $discount_name[$i]['discount_price'];
00934             }
00935           }
00936           break;
00937       }
00938 ?>
00939           <tr>
00940             <td class="main"><?php echo TEXT_PRODUCTS_DISCOUNT . ' ' . $discount_name[$i]['id']; ?></td>
00941             <td class="main"><?php echo zen_draw_input_field('discount_qty[' . $discount_name[$i]['id'] . ']', $discount_name[$i]['discount_qty']); ?></td>
00942             <td class="main"><?php echo zen_draw_input_field('discount_price[' . $discount_name[$i]['id'] . ']', $discount_name[$i]['discount_price']); ?></td>
00943 <?php
00944   if (DISPLAY_PRICE_WITH_TAX == 'true') {
00945 ?>
00946             <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>
00947             <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>
00948 <?php } else { ?>
00949             <td class="main" align="right"><?php echo $currencies->display_price($discounted_price, '', 1); ?></td>
00950             <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>
00951 <?php } ?>
00952           </tr>
00953 <?php
00954     }
00955 ?>
00956 <?php
00957   } else {
00958 ?>
00959           <tr>
00960           <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
00961           </tr>
00962           <tr>
00963             <td class="main" align="center" width="500">
00964               <?php
00965                 if ($action != '') {
00966                   echo TEXT_ADD_ADDITIONAL_DISCOUNT . '<br />';
00967                   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 />';
00968                   echo TEXT_BLANKS_INFO;
00969                 } else {
00970                   echo ($action == '' ? '<span class="alert">' . TEXT_INFO_PREVIEW_ONLY . '</span>' : '') . '<br />';
00971                   echo TEXT_INFO_NO_DISCOUNTS;
00972                 }
00973               ?>
00974             </td>
00975           </tr>
00976 <?php
00977   } // $discounts_qty->RecordCount() > 0
00978 ?>
00979 
00980         </table></td>
00981       </tr>
00982 
00983       <tr>
00984         <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
00985       </tr>
00986       <tr>
00987         <td><table border="0" cellspacing="0" cellpadding="2" align="center">
00988           <?php if ($action == '') { ?>
00989           <tr>
00990             <td class="pageHeading" align="center" valign="middle">
00991               <?php echo ($action == '' ? '<span class="alert">' . TEXT_INFO_PREVIEW_ONLY . '</span>' : ''); ?>
00992             </td>
00993           </tr>
00994           <?php } ?>
00995           <tr>
00996             <td class="main" align="center" valign="middle" width="100%">
00997             <?php
00998             if ($action == '' || $action == 'delete_special' || $action == 'delete_featured') {
00999               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;
01000             } else {
01001               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;
01002             }
01003             ?>
01004             </td>
01005           </tr>
01006         </table></td>
01007       </tr>
01008       <tr>
01009         <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
01010       </tr>
01011         </table></td>
01012       </tr></form>
01013 <?php } // no product selected ?>
01014 <?php } // allow_add_to_cart == 'Y' ?>
01015 
01016       </tr>
01017     </table></td>
01018 <!-- body_text_eof //-->
01019   </tr>
01020 </table>
01021 <!-- body_eof //-->
01022 
01023 <!-- footer //-->
01024 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
01025 <!-- footer_eof //-->
01026 </body>
01027 </html>
01028 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
 All Data Structures Namespaces Files Functions Variables Enumerations