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

Zen Cart 源代码 products_to_categories.php




下载文件

文件名: products_to_categories.php
文件类型: PHP文件
文件大小: 48.6 KiB
MD5: 70e6195507e72e35ddaf907eec78e11c

products_to_categories.php - 关闭高亮
  1. <?php
  2. /**
  3.  * @package admin
  4.  * @copyright Copyright 2003-2011 Zen Cart Development Team
  5.  * @copyright Portions Copyright 2003 osCommerce
  6.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  7.  * @version $Id: products_to_categories.php 18695 2011-05-04 05:24:19Z drbyte $
  8.  */
  9.  
  10.   require('includes/application_top.php');
  11.  
  12.   // verify products exist
  13.   $chk_products = $db->Execute("select * from " . TABLE_PRODUCTS . " limit 1");
  14.   if ($chk_products->RecordCount() < 1) {
  15.     $messageStack->add_session(ERROR_DEFINE_PRODUCTS, 'caution');
  16.     zen_redirect(zen_href_link(FILENAME_CATEGORIES));
  17.   }
  18.  
  19.   // verify product has a master_categories_id
  20.   $chk_products = $db->Execute("select master_categories_id from " . TABLE_PRODUCTS . " where products_id='" . (int)$_GET['products_filter'] . "'");
  21.   if ($chk_products->fields['master_categories_id'] <= 0) {
  22.     $messageStack->add(ERROR_DEFINE_PRODUCTS_MASTER_CATEGORIES_ID, 'caution');
  23. //    zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  24.   }
  25.  
  26.   require(DIR_WS_CLASSES . 'currencies.php');
  27.   $currencies = new currencies();
  28.  
  29.   $languages = zen_get_languages();
  30.  
  31. function array_minus_array($a, $b) {
  32.        $c=array_diff($a,$b);
  33.        $c=array_intersect($c, $a);
  34.        return $c;
  35. }
  36.  
  37.   $_GET['products_filter'] = $products_filter = ((isset($_GET['products_filter']) and $_GET['products_filter'] > 0) ? (int)$_GET['products_filter'] : (int)$_POST['products_filter']);
  38.  
  39.   $action = (isset($_GET['action']) ? $_GET['action'] : '');
  40.  
  41.   $current_category_id = (isset($_GET['current_category_id']) ? (int)$_GET['current_category_id'] : (int)$current_category_id);
  42.  
  43.   if ($action == 'new_cat') {
  44.     $current_category_id = (isset($_GET['current_category_id']) ? (int)$_GET['current_category_id'] : $current_category_id);
  45.     $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");
  46.     $products_filter = $new_product_query->fields['products_id'];
  47. //    $messageStack->add_session('SUCCESSFUL! SWITCHED CATEGORIES', 'success');
  48.     zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  49.   }
  50.  
  51. // set categories and products if not set
  52.   if ($products_filter == '' and $current_category_id != '') {
  53.     $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");
  54.     $products_filter = $new_product_query->fields['products_id'];
  55.     if ($products_filter != '') {
  56.       $messageStack->add_session(WARNING_PRODUCTS_LINK_TO_CATEGORY_REMOVED, 'caution');
  57.       zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  58.     }
  59.   } else {
  60.     if ($products_filter == '' and $current_category_id == '') {
  61.       $reset_categories_id = zen_get_category_tree('', '', '0', '', '', true);
  62.       $current_category_id = $reset_categories_id[0]['id'];
  63.       $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");
  64.       $products_filter = $new_product_query->fields['products_id'];
  65.       $_GET['products_filter'] = $products_filter;
  66.     }
  67.   }
  68.  
  69.   require(DIR_WS_MODULES . FILENAME_PREV_NEXT);
  70.  
  71.  
  72.   if (zen_not_null($action)) {
  73.     switch ($action) {
  74.       case 'set_products_filter':
  75.         $_GET['products_filter'] = $_POST['products_filter'];
  76.  
  77.         zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_POST['current_category_id']));
  78.         break;
  79.       case 'copy_categories_products_to_another_category_linked':
  80.         $zv_invalid_copy_linked = 'false';
  81.         $zv_complete_message_linked = '';
  82.         $copy_from_linked = (int)$_POST['copy_categories_id_from_linked'];
  83.         $copy_to_linked = (int)$_POST['copy_categories_id_to_linked'];
  84.  
  85.         // do not proceed unless categories are different
  86.         if ($copy_from_linked == $copy_to_linked) {
  87.           $messageStack->add_session(WARNING_DUPLICATE_PRODUCTS_TO_CATEGORY_LINKED, 'warning');
  88.           zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  89.         }
  90.  
  91.         $check_category_from = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $copy_from_linked . "' limit 1");
  92.         $check_category_to = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $copy_to_linked . "' limit 1");
  93.  
  94.         // check if from is valid category
  95.         if ($check_category_from->RecordCount() < 1) {
  96.           $zv_invalid_copy_linked = 'true';
  97.           $zv_complete_message_linked .= WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . $copy_from_linked . '&nbsp;';
  98.         } else {
  99.           $zv_complete_message_linked .= SUCCESS_COPY_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . $copy_from_linked . '&nbsp;';
  100.         }
  101.  
  102.         // check if to is valid category
  103.         if ($check_category_to->RecordCount() < 1) {
  104.           if (zen_childs_in_category_count($copy_to_linked) > 0) {
  105.             $zv_invalid_copy_linked = 'true';
  106.             $zv_complete_message_linked .= WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . $copy_to_linked . '&nbsp;';
  107.           }
  108.           $zv_complete_message_linked .= WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED_MISSING . $copy_to_linked . '&nbsp;';
  109.         } else {
  110.           $zv_complete_message_linked .= SUCCESS_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . $copy_to_linked . '&nbsp;';
  111.         }
  112.  
  113.         if ($zv_invalid_copy_linked == 'true') {
  114.           $messageStack->add_session($zv_complete_message_linked, 'warning');
  115.           zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  116.         }
  117.  
  118.         ///////////////////////////////////////////////////////////////
  119.         // if either category was invalid nothing processes below
  120.         ///////////////////////////////////////////////////////////////
  121.  
  122.         // get products to be linked from
  123.         $products_to_categories_from_linked = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $copy_from_linked . "'");
  124.         while (!$products_to_categories_from_linked->EOF) {
  125.           $add_links_array[] = array('products_id' => $products_to_categories_from_linked->fields['products_id']);
  126.           $products_to_categories_from_linked->MoveNext();
  127.         }
  128.  
  129.         // get products already in category to be linked to
  130.         $products_to_categories_to_linked = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $copy_to_linked . "'");
  131.         while (!$products_to_categories_to_linked->EOF) {
  132.           $remove_links_array[] = array('products_id' => $products_to_categories_to_linked->fields['products_id']);
  133.           $products_to_categories_to_linked->MoveNext();
  134.         }
  135.  
  136. // cannot count added/removed due to the nature of the how these are done
  137. //        $cnt_added = 0;
  138.         // remove elements in $remove_links_array that are in $add_links_array
  139.         for ($i=0, $n=sizeof($add_links_array); $i<$n; $i++) {
  140.           $good = 'true';
  141.           for ($j=0, $nn=sizeof($remove_links_array); $j<$nn; $j++) {
  142.             if ($add_links_array[$i]['products_id'] == $remove_links_array[$j]['products_id']) {
  143.               $good = 'false';
  144.               break;
  145.             }
  146.           }
  147.           // build final of good products
  148.           if ($good == 'true') {
  149.             $make_links_result[] = array('products_id' => $add_links_array[$i]['products_id']);
  150.           }
  151.         }
  152.  
  153.         for ($i=0, $n=sizeof($make_links_result); $i<$n; $i++) {
  154. //          $cnt_added++;
  155.           $new_product = $make_links_result[$i]['products_id'];
  156.           $sql = "insert into " . TABLE_PRODUCTS_TO_CATEGORIES . "
  157.                  (products_id, categories_id)
  158.                  values ($new_product, $copy_to_linked)";
  159.  
  160.           $db->Execute($sql);
  161.         }
  162.  
  163.         // set message of completion
  164.         if (sizeof($make_links_result) == 0) {
  165.             $zv_complete_message_linked = WARNING_COPY_FROM_IN_TO_LINKED . $zv_complete_message_linked;
  166.             $warning_color = 'caution';
  167.         } else {
  168.           if ($check_category_from->RecordCount() < 1 or $check_category_to->RecordCount() < 1) {
  169.             $zv_complete_message_linked = WARNING_COPY_LINKED . $zv_complete_message_linked;
  170.             $warning_color = 'error';
  171.           } else {
  172.             $zv_complete_message_linked = SUCCESS_COPY_LINKED . $zv_complete_message_linked;
  173.             $warning_color = 'success';
  174.           }
  175.         }
  176.  
  177.         if (sizeof($make_links_result) == 0) {
  178.           $messageStack->add_session($zv_complete_message_linked, $warning_color);
  179.         } else {
  180.           $messageStack->add_session($zv_complete_message_linked, $warning_color);
  181.         }
  182.  
  183.         zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  184.         break;
  185.  
  186.       case 'remove_categories_products_to_another_category_linked':
  187.         $zv_invalid_remove_linked = 'false';
  188.         $zv_complete_message_linked = '';
  189.         $remove_from_linked = (int)$_POST['remove_categories_id_from_linked'];
  190.         $remove_to_linked = (int)$_POST['remove_categories_id_to_linked'];
  191.  
  192.         // do not proceed unless categories are different
  193.         if ($remove_from_linked == $remove_to_linked) {
  194.           $messageStack->add_session(WARNING_DUPLICATE_PRODUCTS_TO_CATEGORY_LINKED, 'warning');
  195.           zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  196.         }
  197.  
  198.         $check_category_from = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $remove_from_linked . "' limit 1");
  199.         $check_category_to = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $remove_to_linked . "' limit 1");
  200.  
  201.  
  202.         // check if from is valid category
  203.         if ($check_category_from->RecordCount() < 1) {
  204.           $zv_invalid_remove_linked = 'true';
  205.           $zv_complete_message_linked .= WARNING_REMOVE_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . $remove_from_linked . '&nbsp;';
  206.        } else {
  207.           $zv_complete_message_linked .= SUCCESS_REMOVE_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . $remove_from_linked . '&nbsp;';
  208.         }
  209.  
  210.         // check if to is valid category
  211.         if ($check_category_to->RecordCount() < 1) {
  212.           $zv_invalid_remove_linked = 'true';
  213.           $zv_complete_message_linked .= WARNING_REMOVE_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . $remove_to_linked . '&nbsp;';
  214.         } else {
  215.           $zv_complete_message_linked .= SUCCESS_REMOVE_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . $remove_to_linked . '&nbsp;';
  216.         }
  217.  
  218.         if ($zv_invalid_remove_linked == 'true') {
  219.           $messageStack->add_session($zv_complete_message_linked, 'warning');
  220.           zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  221.         }
  222.  
  223.         ///////////////////////////////////////////////////////////////
  224.         // if either category was invalid nothing processes below
  225.         ///////////////////////////////////////////////////////////////
  226.  
  227.  
  228.         // get products to be removed as added linked from
  229.         $products_to_categories_from_linked = $db->Execute("select ptoc.products_id, p.master_categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " ptoc left join " . TABLE_PRODUCTS . " p on ptoc.products_id=p.products_id where ptoc.categories_id='" . $remove_from_linked . "'");
  230.  
  231.         while (!$products_to_categories_from_linked->EOF) {
  232.           if ($products_to_categories_from_linked->fields['master_categories_id'] == $remove_to_linked) {
  233.             //die('THIS IS THE MASTER CATEGORIES ID!! ' . $remove_to_linked . '<br>');
  234.             //break;
  235.             $master_categories_id_stop[] = array('products_id' => $products_to_categories_from_linked->fields['products_id'],
  236.                                      'master_categories_id' => $products_to_categories_from_linked->fields['master_categories_id']);
  237.           }
  238.           $add_links_array[] = array('products_id' => $products_to_categories_from_linked->fields['products_id'],
  239.                                      'master_categories_id' => $products_to_categories_from_linked->fields['master_categories_id']);
  240.           $products_to_categories_from_linked->MoveNext();
  241.         }
  242.  
  243.         $stop_warning = '';
  244.         if (sizeof($master_categories_id_stop) > 0) {
  245.           for ($i=0, $n=sizeof($master_categories_id_stop); $i<$n; $i++) {
  246.             $stop_warning .= TEXT_PRODUCTS_ID . $master_categories_id_stop[$i]['products_id'] . ': ' . zen_get_products_name($master_categories_id_stop[$i]['products_id']) . '<br>';
  247.           }
  248.  
  249.           $stop_warning_message = WARNING_MASTER_CATEGORIES_ID_CONFLICT . ' ' . TEXT_MASTER_CATEGORIES_ID_CONFLICT_FROM . $remove_from_linked . TEXT_MASTER_CATEGORIES_ID_CONFLICT_TO . $remove_to_linked . '<br />' . TEXT_INFO_MASTER_CATEGORIES_ID_PURPOSE . WARNING_MASTER_CATEGORIES_ID_CONFLICT_FIX . '<br /><br />' . TEXT_INFO_MASTER_CATEGORIES_ID_CONFLICT . $remove_to_linked . '<br />' . $stop_warning . '<br />';
  250.           $messageStack->add_session($stop_warning_message, 'warning');
  251.           zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $master_categories_id_stop[0]['products_id'] . '&current_category_id=' . $current_category_id));
  252. //          die('THIS IS THE MASTER CATEGORIES ID!! ' . $remove_to_linked . ' - stop: ' . sizeof($master_categories_id_stop) . '<br>');
  253.         }
  254.  
  255.         // get products already in category to be removed as linked to
  256.         $products_to_categories_to_linked = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $remove_to_linked . "'");
  257.         while (!$products_to_categories_to_linked->EOF) {
  258.           $remove_links_array[] = array('products_id' => $products_to_categories_to_linked->fields['products_id']);
  259.           $products_to_categories_to_linked->MoveNext();
  260.         }
  261.  
  262. //        $cnt_removed = 0;
  263.         // remove elements in $remove_links_array that are in $add_links_array
  264.         for ($i=0, $n=sizeof($add_links_array); $i<$n; $i++) {
  265.           $good = 'true';
  266.           for ($j=0, $nn=sizeof($remove_links_array); $j<$nn; $j++) {
  267.             if ($add_links_array[$i]['products_id'] == $remove_links_array[$j]['products_id']) {
  268.               $good = 'true';
  269.               break;
  270.             }
  271.           }
  272.           // build final of good products
  273.           if ($good == 'true') {
  274.             $make_links_result[] = array('products_id' => $add_links_array[$i]['products_id']);
  275.           }
  276.         }
  277.  
  278.         for ($i=0, $n=sizeof($make_links_result); $i<$n; $i++) {
  279. //          $cnt_removed++;
  280.           $remove_product = $make_links_result[$i]['products_id'];
  281.           $sql = "delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id='" . $remove_product . "' and categories_id='" . $remove_to_linked . "'";
  282.           $db->Execute($sql);
  283.         }
  284.  
  285.         // set message of completion
  286.         if (sizeof($make_links_result) == 0) {
  287.             $zv_complete_message_linked = WARNING_REMOVE_FROM_IN_TO_LINKED . $zv_complete_message_linked;
  288.             $warning_color = 'caution';
  289.         } else {
  290.           if ($check_category_from->RecordCount() < 1 or $check_category_to->RecordCount() < 1) {
  291.             $zv_complete_message_linked = WARNING_REMOVE_LINKED . $zv_complete_message_linked;
  292.             $warning_color = 'warning';
  293.           } else {
  294.             $zv_complete_message_linked = SUCCESS_REMOVE_LINKED . $zv_complete_message_linked;
  295.             $warning_color = 'success';
  296.           }
  297.         }
  298.  
  299.         if (sizeof($make_links_result) == 0) {
  300.           $messageStack->add_session($zv_complete_message_linked, $warning_color);
  301.         } else {
  302.           $messageStack->add_session($zv_complete_message_linked, $warning_color);
  303.         }
  304.  
  305.         zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  306.         break;
  307.  
  308.       case 'reset_categories_products_to_another_category_master':
  309.         // reset the master_categories_id for all products in selected category
  310.  
  311.         $zv_invalid_reset_master= 'false';
  312.         $zv_complete_message_master = '';
  313.         $reset_from_master = (int)$_POST['reset_categories_id_from_master'];
  314.  
  315.         $check_category_from = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $reset_from_master . "' limit 1");
  316.  
  317.         // check if from is valid category
  318.         if ($check_category_from->RecordCount() < 1) {
  319.           $zv_invalid_reset_master = 'true';
  320.           $zv_complete_message_master .= WARNING_RESET_ALL_PRODUCTS_TO_CATEGORY_FROM_MASTER . $reset_from_master . '&nbsp;';
  321.         } else {
  322.           $zv_complete_message_master .= SUCCESS_RESET_ALL_PRODUCTS_TO_CATEGORY_FROM_MASTER . $reset_from_master . '&nbsp;';
  323.         }
  324.  
  325.         if ($zv_invalid_reset_master == 'true') {
  326.           $messageStack->add_session($zv_complete_message_master, 'warning');
  327.           zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  328.         }
  329.  
  330.         ///////////////////////////////////////////////////////////////
  331.         // if either category was invalid nothing processes below
  332.         ///////////////////////////////////////////////////////////////
  333.  
  334.         $reset_master_categories_id = $db->Execute("select p.products_id, p.master_categories_id, ptoc.categories_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " ptoc on ptoc.products_id= p.products_id and ptoc.categories_id='" . $reset_from_master . "' where ptoc.categories_id='" . $reset_from_master . "'");
  335.  
  336.         while (!$reset_master_categories_id->EOF) {
  337.           $db->Execute("update " . TABLE_PRODUCTS . " set master_categories_id='" . (int)$reset_from_master . "' where products_id='" . $reset_master_categories_id->fields['products_id'] . "'");
  338.           // reset products_price_sorter for searches etc.
  339.           zen_update_products_price_sorter($reset_master_categories_id->fields['products_id']);
  340.           $reset_master_categories_id->MoveNext();
  341.         }
  342.  
  343.         $messageStack->add_session($zv_complete_message_master, 'success');
  344.         zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  345.         break;
  346.  
  347.       case 'set_master_categories_id':
  348.         $db->Execute("update " . TABLE_PRODUCTS . " set master_categories_id='" . (int)$_GET['master_category'] . "' where products_id='" . $products_filter . "'");
  349.         // reset products_price_sorter for searches etc.
  350.         zen_update_products_price_sorter($products_filter);
  351.  
  352.         zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . (int)$_GET['products_filter'] . '&current_category_id=' . $current_category_id));
  353.         break;
  354.  
  355.       case 'update_product':
  356.         $zv_check_master_categories_id = 'true';
  357.         $new_categories_sort_array[] = $_POST['current_master_categories_id'];
  358.         $current_master_categories_id = $_POST['current_master_categories_id'];
  359.  
  360.         // set the linked products master_categories_id product(s)
  361.         for ($i=0, $n=sizeof($_POST['categories_add']); $i<$n; $i++) {
  362.           // is current master_categories_id in the list?
  363.           if ($zv_check_master_categories_id == 'true' and $_POST['categories_add'][$i] == $current_master_categories_id->fields['master_categories_id']) {
  364.             $zv_check_master_categories_id = 'true';
  365.             // array is set above to master category
  366.           } else {
  367.             $new_categories_sort_array[] = (int)$_POST['categories_add'][$i];
  368.           }
  369.         }
  370.  
  371.         // remove existing products_to_categories for current product
  372.         $db->Execute("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id='" . $products_filter . "'");
  373.  
  374.         $reset_master_categories_id = '';
  375.         $old_master_categories_id = $current_master_categories_id;
  376.         // add products to categories in order of master_categories_id first then others
  377.         $verify_current_category_id = false;
  378.         for ($i=0, $n=sizeof($new_categories_sort_array); $i<$n; $i++) {
  379.           // is current master_categories_id in the list?
  380.           if ($new_categories_sort_array[$i] <= 0) {
  381.             die('I WOULD NOT ADD ' . $new_categories_sort_array[$i] . '<br>');
  382.           } else {
  383.             if ($current_category_id == $new_categories_sort_array[$i]) {
  384.               $verify_current_category_id = true;
  385.             }
  386.             $db->Execute("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . "
  387.                    (products_id, categories_id)
  388.                    values (" . $products_filter . ", " . (int)$new_categories_sort_array[$i] . ")");
  389.             if ($reset_master_categories_id == '') {
  390.               $reset_master_categories_id = $new_categories_sort_array[$i];
  391.             }
  392.             if ($old_master_categories_id == $new_categories_sort_array[$i]) {
  393.               $reset_master_categories_id = $new_categories_sort_array[$i];
  394.             }
  395.           }
  396.         }
  397.  
  398.         // reset master_categories_id in products table
  399.         if ($zv_check_master_categories_id == 'true') {
  400.           // make sure master_categories_id is set to current master_categories_id
  401.           $db->Execute("update " . TABLE_PRODUCTS . " set master_categories_id='" . (int)$current_master_categories_id . "' where products_id='" . $products_filter . "'");
  402.         } else {
  403.           // reset master_categories_id to current_category_id because it was unselected
  404.           $db->Execute("update " . TABLE_PRODUCTS . " set master_categories_id='" . (int)$reset_master_categories_id . "' where products_id='" . $products_filter . "'");
  405.         }
  406.  
  407.         // recalculate price based on new master_categories_id
  408.         zen_update_products_price_sorter($products_filter);
  409.  
  410.         if ($zv_check_master_categories_id == 'true') {
  411.           $messageStack->add_session(SUCCESS_MASTER_CATEGORIES_ID, 'success');
  412.         } else {
  413.           $messageStack->add_session(WARNING_MASTER_CATEGORIES_ID, 'warning');
  414.         }
  415.  
  416.         // if product was removed from current categories_id stay in same category
  417.         if (!$verify_current_category_id) {
  418.           zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'current_category_id=' . $current_category_id));
  419.         } else {
  420.           zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  421.         }
  422.         break;
  423.  
  424.     }
  425.   }
  426.  
  427.   $product_to_copy = $db->Execute("select p.products_id, pd.products_name, p.products_price_sorter, p.products_model, p.master_categories_id, p.products_image
  428.                                  from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd " . "
  429.                         where p.products_id = '" . $products_filter . "'
  430.                         and p.products_id = pd.products_id
  431.                         and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'");
  432.  
  433. //  $catagories_query = "select distinct cd.categories_id from " . TABLE_CATEGORIES_DESCRIPTION . " cd left join " . TABLE_PRODUCTS_TO_CATEGORIES . " ptoc on cd.categories_id = ptoc.categories_id and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
  434.   $catagories_query = "select distinct ptoc.categories_id, cd.* from " . TABLE_PRODUCTS_TO_CATEGORIES. " ptoc left join " . TABLE_CATEGORIES_DESCRIPTION  . " cd on cd.categories_id = ptoc.categories_id and cd.language_id = '" . (int)$_SESSION['languages_id'] . "' order by cd.categories_name";
  435.   $categories_list = $db->Execute($catagories_query);
  436.  
  437. // current products to categories
  438.   $products_list = $db->Execute("select products_id, categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $products_filter . "'");
  439.  
  440. ?>
  441. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  442. <html <?php echo HTML_PARAMS; ?>>
  443. <head>
  444. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  445. <title><?php echo TITLE; ?></title>
  446. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  447. <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
  448. <script language="javascript" src="includes/menu.js"></script>
  449. <script language="javascript" src="includes/general.js"></script>
  450. <script language="javascript"><!--
  451. function go_option() {
  452.   if (document.option_order_by.selected.options[document.option_order_by.selected.selectedIndex].value != "none") {
  453.     location = "<?php echo zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'option_page=' . ($_GET['option_page'] ? $_GET['option_page'] : 1)); ?>&option_order_by="+document.option_order_by.selected.options[document.option_order_by.selected.selectedIndex].value;
  454.   }
  455. }
  456. //--></script>
  457. <script type="text/javascript">
  458.   <!--
  459.   function init()
  460.   {
  461.     cssjsmenu('navbar');
  462.     if (document.getElementById)
  463.     {
  464.       var kill = document.getElementById('hoverJS');
  465.       kill.disabled = true;
  466.     }
  467.   }
  468.   // -->
  469. </script>
  470. </head>
  471. <!-- <body onload="init()"> -->
  472. <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="init()">
  473. <!-- header //-->
  474. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  475. <!-- header_eof //-->
  476.  
  477. <!-- body //-->
  478. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  479.   <tr>
  480. <!-- body_text //-->
  481.     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  482. <?php
  483. ///////////////////////////////////////////////////////////
  484. // BOF: NEW CODE TO KEEP
  485. ?>
  486.  
  487. <?php
  488.   if ($action != 'edit_update') {
  489.     require(DIR_WS_MODULES . FILENAME_PREV_NEXT_DISPLAY);
  490. ?>
  491.  
  492.       <tr><form name="set_products_filter_id" <?php echo 'action="' . zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'action=set_products_filter') . '"'; ?> method="post"><?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?><?php echo zen_draw_hidden_field('products_filter', $_GET['products_filter']); ?><?php echo zen_draw_hidden_field('current_category_id', $_GET['current_category_id']); ?>
  493.         <td colspan="2"><table border="0" cellspacing="0" cellpadding="2">
  494.  
  495. <?php
  496. if ($_GET['products_filter'] != '') {
  497. ?>
  498.           <tr>
  499.             <td class="main" width="200" align="left" valign="top">&nbsp;</td>
  500.             <td colspan="2" class="main"><?php echo TEXT_PRODUCT_TO_VIEW; ?></td>
  501.           </tr>
  502.           <tr>
  503.             <td class="main" width="200" align="center" valign="top">
  504.  
  505. <?php
  506. // FIX HERE
  507.   $display_priced_by_attributes = zen_get_products_price_is_priced_by_attributes($_GET['products_filter']);
  508.   echo ($display_priced_by_attributes ? '<span class="alert">' . TEXT_PRICED_BY_ATTRIBUTES . '</span>' . '<br />' : '');
  509.   echo zen_get_products_display_price($_GET['products_filter']) . '<br /><br />';
  510.   echo zen_get_products_quantity_min_units_display($_GET['products_filter'], $include_break = true);
  511.   $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'");
  512.   while (!$not_for_cart->EOF) {
  513.     $not_for_cart_array[] = $not_for_cart->fields['products_id'];
  514.     $not_for_cart->MoveNext();
  515.    }
  516. ?>
  517.             </td>
  518.             <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>
  519.             <td class="main" align="center" valign="top">
  520.               <?php
  521.                 echo zen_image_submit('button_display.gif', IMAGE_DISPLAY);
  522.               ?>
  523.             </td>
  524.           </tr>
  525. <?php
  526. } else {
  527.   $not_for_cart = '';
  528. } // $_GET['products_filter'] != ''
  529. ?>
  530.  
  531. <?php
  532. // show when product is linked
  533. // not used in multiple products link manager
  534. ?>
  535.  
  536.         </table></td>
  537.       </form></tr>
  538. <?php } // $action != 'edit_update' ?>
  539. <?php
  540. // EOF: NEW CODE TO KEEP
  541. ///////////////////////////////////////////////////////////
  542. ?>
  543.       <tr>
  544.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  545. <?php if ($product_to_copy->EOF) { ?>
  546.           <tr>
  547.             <td class="pageHeading"><?php echo HEADING_TITLE . '<br />' . '<span class="alert">' . TEXT_PRODUCTS_ID . $products_filter . TEXT_PRODUCTS_ID_INVALID . '</span>'; ?></td>
  548.           </tr>
  549.           <tr>
  550.             <td class="main"><?php echo TEXT_PRODUCTS_ID_NOT_REQUIRED; ?></td>
  551.           </tr>
  552.           <tr>
  553.             <td><?php echo zen_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  554.           </tr>
  555. <?php } else { ?>
  556.           <tr>
  557.             <td class="pageHeading"><?php echo HEADING_TITLE . '<br />' . TEXT_PRODUCTS_ID . $product_to_copy->fields['products_id'] . ' ' . $product_to_copy->fields['products_name']; ?></td>
  558.           </tr>
  559.           <tr>
  560.             <td><?php echo zen_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  561.           </tr>
  562.           <tr>
  563.             <td class="main"><?php echo TEXT_INFO_PRODUCTS_TO_CATEGORIES_LINKER_INTRO; ?></td>
  564.           </tr>
  565.           <tr><?php echo zen_draw_form('restrict_product', FILENAME_PRODUCTS_TO_CATEGORIES, '', 'get', '', true) . zen_draw_hidden_field('action', 'set_master_categories_id') . zen_draw_hidden_field('products_filter', $products_filter) . zen_draw_hidden_field('current_category_id', $_GET['current_category_id']); ?>
  566.             <td class="main">
  567.               <?php
  568.                 echo '&nbsp;&nbsp;&nbsp;' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . '&nbsp;&nbsp;';
  569.                 echo '<strong>' . TEXT_MASTER_CATEGORIES_ID . '</strong> ' . zen_draw_pull_down_menu('master_category', zen_get_master_categories_pulldown($products_filter), $product_to_copy->fields['master_categories_id'], 'onChange="this.form.submit();"');
  570.                 echo zen_hide_session_id();
  571.                 if ($product_to_copy->fields['master_categories_id'] <= 0) {
  572.                   echo '&nbsp;&nbsp;' . '<span class="alert">' . WARNING_MASTER_CATEGORIES_ID . '</span>';
  573.                 }
  574.                 echo TEXT_INFO_LINKED_TO_COUNT . $products_list->RecordCount();
  575.               ?>
  576.             </td>
  577.           </form></tr>
  578.           <tr>
  579.             <td><?php echo zen_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  580.           </tr>
  581.         </table></td>
  582.       </tr>
  583.  
  584. <!-- bof: link to categories //-->
  585.       <tr>
  586.         <td width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  587.           <tr>
  588.             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  589.           <tr>
  590.             <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td>
  591.           </tr>
  592.           <tr class="dataTableHeadingRow">
  593.             <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>" class="pageHeading" align="center"><?php echo TEXT_INFO_PRODUCTS_TO_CATEGORIES_AVAILABLE; ?></td>
  594.           </tr>
  595. <?php
  596.     while(!$products_list->EOF) {
  597.       $selected_categories_check .= $products_list->fields['categories_id'];
  598.       $products_list->MoveNext();
  599.       if (!$products_list->EOF) {
  600.         $selected_categories_check .= ',';
  601.       }
  602.     }
  603.     $selected_categories = explode(',', $selected_categories_check);
  604.     echo zen_draw_form('update', FILENAME_PRODUCTS_TO_CATEGORIES, 'action=update_product&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id, 'post');
  605. ?>
  606.           <tr class="dataTableHeadingRow">
  607.             <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>" height="50" align="center" valign="middle" class="dataTableHeadingContent">
  608.               <?php
  609.                 if ($product_to_copy->fields['master_categories_id'] < 1) {
  610.                   echo '<span class="alert">' . TEXT_SET_MASTER_CATEGORIES_ID . '</span>';
  611.                 } else {
  612.               ?>
  613.                   <input type="submit" value="<?php echo BUTTON_UPDATE_CATEGORY_LINKS; ?>">
  614.               <?php } ?>
  615.             </td>
  616.           </tr>
  617. <?php
  618.     $cnt_columns = 0;
  619.     echo '<tr class="dataTableHeadingRow">';
  620.     while ($cnt_columns != MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS) {
  621.       $cnt_columns++;
  622.       echo '<td class="dataTableHeadingContent" align="right">' . TEXT_INFO_ID . '</td>' . '<td class="dataTableHeadingContent" align="left">' . '&nbsp;&nbsp;Categories Name' . '</td>';
  623.     }
  624.         echo '</tr>';
  625. //        echo '<tr class="dataTableHeadingRow">';
  626.  
  627.     $cnt_columns = 0;
  628.     while (!$categories_list->EOF) {
  629.       $cnt_columns++;
  630.       if (zen_not_null($selected_categories_check)) {
  631.         $selected = in_array($categories_list->fields['categories_id'], $selected_categories);
  632.       } else {
  633.         $selected = false;
  634.       }
  635.       $zc_categories_checkbox = zen_draw_checkbox_field('categories_add[]', $categories_list->fields['categories_id'], $selected);
  636.       if ($cnt_columns == 1) {
  637.         echo '<tr class="dataTableHeadingRow">';
  638.       }
  639.       echo '  <td class="dataTableContent" align="right">' . $categories_list->fields['categories_id'] . '</td>' . "\n";
  640.       if ($product_to_copy->fields['master_categories_id'] == $categories_list->fields['categories_id']) {
  641. //        echo '  <td class="dataTableContent" align="left">' . ($selected ? '<strong>' : '') . $zc_categories_checkbox . '&nbsp;' . $categories_list->fields['categories_name'] . ($selected ? '</strong>' : '') . '&nbsp;' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . '</td>' . "\n";
  642.         echo '  <td class="dataTableContent" align="left">' . '&nbsp;' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . '&nbsp;' . $categories_list->fields['categories_name'] . zen_draw_hidden_field('current_master_categories_id', $categories_list->fields['categories_id']) . '</td>' . "\n";
  643.       } else {
  644.         echo '  <td class="dataTableContent" align="left">' . ($selected ? '<strong>' : '') . $zc_categories_checkbox . '&nbsp;' . $categories_list->fields['categories_name'] . ($selected ? '</strong>' : '') . '</td>' . "\n";
  645.       }
  646.       $categories_list->MoveNext();
  647.       if ($cnt_columns == MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS or $categories_list->EOF) {
  648.         if ($categories_list->EOF and $cnt_columns != MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS) {
  649.           while ($cnt_columns < MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS) {
  650.             $cnt_columns++;
  651.             echo '  <td class="dataTableContent" align="right">' . '&nbsp;' . '</td>' . "\n";
  652.             echo '  <td class="dataTableContent" align="left">' . '&nbsp;' . '</td>' . "\n";
  653.           }
  654.         }
  655.         echo '</tr>' . "\n";
  656.         $cnt_columns = 0;
  657.       }
  658.     }
  659. ?>
  660.           <tr class="dataTableHeadingRow">
  661.             <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>" height="50" align="center" valign="middle" class="dataTableHeadingContent">
  662.               <?php
  663.                 if ($product_to_copy->fields['master_categories_id'] < 1) {
  664.                   echo '<span class="alert">' . TEXT_SET_MASTER_CATEGORIES_ID . '</span>';
  665.                 } else {
  666.               ?>
  667.                   <input type="submit" value="<?php echo BUTTON_UPDATE_CATEGORY_LINKS; ?>">
  668.               <?php } ?>
  669.             </td>
  670.  
  671.           </tr>
  672.           </form>
  673.           <tr>
  674.             <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>" valign="top"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td>
  675.           </tr>
  676.           <tr>
  677.             <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>" ><?php echo zen_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  678.           </tr>
  679.           <tr>
  680.             <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>" class="main"><?php echo TEXT_INFO_PRODUCTS_TO_CATEGORIES_LINKER; ?></td>
  681.           </tr>
  682.           <tr>
  683.             <td><?php echo zen_draw_separator('pixel_trans.gif', '100%', '20'); ?></td>
  684.           </tr>
  685. <?php } ?>
  686.             </table>
  687. <!-- eof: link to categories //-->
  688.             <table border="5" class="dataTableHeadingRow">
  689.               <tr class="dataTableHeadingRow">
  690.                 <td class="dataTableHeadingContent">
  691.             <table border="0" class="dataTableHeadingRow" width="100%">
  692.               <tr class="dataTableHeadingRow">
  693.                 <td class="pageHeading" align="center"><?php echo HEADER_CATEGORIES_GLOBAL_CHANGES; ?></td>
  694.               </tr>
  695.             </table>
  696. <!-- copy products from one category to another as linked or new products -->
  697.             <table border="0" class="dataTableHeadingRow" width="100%">
  698.               <tr>
  699.                 <td colspan="3" valign="middle" height="10"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td>
  700.               </tr>
  701.               <form name="linked_copy" method="post" action="<?php echo zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'action=copy_categories_products_to_another_category_linked' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id, 'NONSSL'); ?>">
  702.               <?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?>
  703.               <tr class="dataTableHeadingRow">
  704.                 <td colspan="3" class="dataTableContent"><?php echo TEXT_INFO_COPY_ALL_PRODUCTS_TO_CATEGORY_LINKED; ?></td>
  705.               </tr>
  706.               <tr class="dataTableHeadingRow">
  707.                 <td class="dataTableContent">
  708.                   <?php
  709.                     $categories_id_from_linked = TEXT_INFO_COPY_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . '&nbsp;<input type="text" name="copy_categories_id_from_linked" size="4">&nbsp;';
  710.                     echo $categories_id_from_linked;
  711.                   ?>
  712.                 </td>
  713.                 <td class="dataTableContent">
  714.                   <?php
  715.                     $categories_id_to_linked = TEXT_INFO_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . '&nbsp;<input type="text" name="copy_categories_id_to_linked" size="4">&nbsp;';
  716.                     echo $categories_id_to_linked;
  717.                   ?>
  718.                 </td>
  719.                 <td align="right" class="dataTableHeadingContent" valign="top">&nbsp;<input type="submit" value="<?php echo BUTTON_COPY_CATEGORY_LINKED; ?>">&nbsp;</td>
  720.               </tr>
  721.               </form>
  722.             </table>
  723. <!-- eof: copy products //-->
  724. <!-- remove products from one category that are linked to another category -->
  725.             <table border="0" class="dataTableHeadingRow" width="100%">
  726.               <tr>
  727.                 <td colspan="3" valign="middle" height="10"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td>
  728.               </tr>
  729.               <form name="linked_remove" method="post" action="<?php echo zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'action=remove_categories_products_to_another_category_linked' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id, 'NONSSL'); ?>">
  730.               <?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?>
  731.               <tr class="dataTableHeadingRow">
  732.                 <td colspan="3" class="dataTableContent"><?php echo TEXT_INFO_REMOVE_ALL_PRODUCTS_TO_CATEGORY_LINKED; ?></td>
  733.               </tr>
  734.               <tr class="dataTableHeadingRow">
  735.                 <td class="dataTableContent">
  736.                   <?php
  737.                     $categories_id_from_linked = TEXT_INFO_REMOVE_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . '&nbsp;<input type="text" name="remove_categories_id_from_linked" size="4">&nbsp;';
  738.                     echo $categories_id_from_linked;
  739.                   ?>
  740.                 </td>
  741.                 <td class="dataTableHeadingContent">
  742.                   <?php
  743.                     $categories_id_to_linked = TEXT_INFO_REMOVE_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . '&nbsp;<input type="text" name="remove_categories_id_to_linked" size="4">&nbsp;';
  744.                     echo $categories_id_to_linked;
  745.                   ?>
  746.                 </td>
  747.                 <td align="right" class="dataTableHeadingContent" valign="top">&nbsp;<input type="submit" value="<?php echo BUTTON_REMOVE_CATEGORY_LINKED; ?>">&nbsp;</td>
  748.               </tr>
  749.               </form>
  750.               <tr>
  751.                 <td colspan="3"><?php echo zen_draw_separator('pixel_trans.gif', '100%', '3'); ?></td>
  752.               </tr>
  753.             </table>
  754. <!-- eof: remove products //-->
  755. <!-- reset master_categories_id to request Categories -->
  756.             <table border="0" class="dataTableHeadingRow" width="100%">
  757.               <tr>
  758.                 <td colspan="3" valign="middle" height="10"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td>
  759.               </tr>
  760.               <form name="master_reset" method="post" action="<?php echo zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'action=reset_categories_products_to_another_category_master' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id, 'NONSSL'); ?>">
  761.               <?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?>
  762.               <tr class="dataTableHeadingRow">
  763.                 <td colspan="3" class="dataTableContent"><?php echo TEXT_INFO_RESET_ALL_PRODUCTS_TO_CATEGORY_MASTER; ?></td>
  764.               </tr>
  765.               <tr class="dataTableHeadingRow">
  766.                 <td class="dataTableContent">
  767.                   <?php
  768.                     $categories_id_from_linked = TEXT_INFO_RESET_ALL_PRODUCTS_TO_CATEGORY_FROM_MASTER . '&nbsp;<input type="text" name="reset_categories_id_from_master" size="4">&nbsp;';
  769.                     echo $categories_id_from_linked;
  770.                   ?>
  771.                 </td>
  772.                 <td align="right" class="dataTableHeadingContent" valign="top">&nbsp;<input type="submit" value="<?php echo BUTTON_RESET_CATEGORY_MASTER; ?>">&nbsp;</td>
  773.               </tr>
  774.               </form>
  775.               <tr>
  776.                 <td colspan="3"><?php echo zen_draw_separator('pixel_trans.gif', '100%', '3'); ?></td>
  777.               </tr>
  778.             </table>
  779. <!-- eof: reset master_categories_id //-->
  780.                 </td>
  781.               </tr>
  782.             </table>
  783.  
  784.             </td>
  785. <?php
  786.   $heading = array();
  787.   $contents = array();
  788.  
  789.   switch ($action) {
  790.     case 'edit':
  791.       $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_PRODUCTS_TO_CATEGORIES . '</b>');
  792.       $contents = array('form' => zen_draw_form('products_downloads_edit', FILENAME_PRODUCTS_TO_CATEGORIES, ''));
  793.       if ($products_filter > 0) {
  794.         $contents[] = array('text' => zen_image(DIR_WS_CATALOG_IMAGES . $product_to_copy->fields['products_image'], $product_to_copy->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT));
  795.       }
  796.       $contents[] = array('text' => '<b>' . TEXT_PRODUCTS_NAME . $product_to_copy->fields['products_name'] . '<br />' . TEXT_PRODUCTS_MODEL . $product_to_copy->fields['products_model'] . '</b>');
  797.       $contents[] = array('text' => '<br />' . TEXT_SET_PRODUCTS_TO_CATEGORIES_LINKS . '<br />' . TEXT_PRODUCTS_ID . zen_draw_input_field('products_filter', $products_filter));
  798. //      $contents[] = array('align' => 'center', 'text' => '<br />' . zen_image_submit('button_update.gif', IMAGE_UPDATE) . '&nbsp;<a href="' . zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>' . '</form>');
  799.       $contents[] = array('align' => 'center', 'text' => '<br />' . zen_image_submit('button_update.gif', IMAGE_UPDATE) . '&nbsp;<a href="' . zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>' . '</form>');
  800.       break;
  801.     default:
  802.       $heading[] = array('text' => '<b>' . $product_to_copy->fields['products_id'] . ' ' . $product_to_copy->fields['products_name'] . '</b>');
  803.       if ($products_filter > 0) {
  804.         $contents[] = array('text' => zen_image(DIR_WS_CATALOG_IMAGES . $product_to_copy->fields['products_image'], $product_to_copy->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT));
  805.       }
  806.       $contents[] = array('text' => '<br />' . TEXT_PRODUCTS_NAME . $product_to_copy->fields['products_name']);
  807.       $contents[] = array('text' => TEXT_PRODUCTS_MODEL . $product_to_copy->fields['products_model']);
  808.       $contents[] = array('text' => TEXT_PRODUCTS_PRICE . zen_get_products_display_price($products_filter));
  809.       switch (true) {
  810.         case ($product_to_copy->fields['master_categories_id'] == 0 and $products_filter > 0):
  811.           $contents[] = array('text' => '<br /><span class="alert">' . WARNING_MASTER_CATEGORIES_ID . '</span><br />&nbsp;');
  812.           break;
  813.         default:
  814.           $contents[] = array('text' => '<form action="' . FILENAME_PRODUCTS_TO_CATEGORIES . '.php' . '?action=edit&current_category_id=' . $current_category_id . '" method="post"><input type="hidden" name="securityToken" value="' . $_SESSION['securityToken'] . '" /><input type="hidden" name="products_filter" value="' . $products_filter . '" />');
  815.           $contents[] = array('align' => 'center', 'text' => '<input type="submit" value="' . BUTTON_NEW_PRODUCTS_TO_CATEGORIES . '"></form>');
  816.           $contents[] = array('text' => '<br />' . zen_image(DIR_WS_IMAGES . 'pixel_black.gif','','100%','3') . '<br />&nbsp;');
  817.           $contents[] = array('align' => 'center', 'text' =>
  818.             '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_edit_attribs.gif', IMAGE_EDIT_ATTRIBUTES) . '</a>&nbsp;&nbsp;' .
  819.             '<a href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_products_price_manager.gif', IMAGE_PRODUCTS_PRICE_MANAGER) . '</a><br /><br />' .
  820.             '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . zen_get_parent_category_id($products_filter) . '&pID=' . $products_filter . '&product_type=' . zen_get_products_type($products_filter)) . '">' . zen_image_button('button_details.gif', IMAGE_DETAILS) . '</a>&nbsp;&nbsp;' .
  821.             '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=new_product' . '&cPath=' . zen_get_parent_category_id($products_filter) . '&pID=' . $products_filter . '&product_type=' . zen_get_products_type($products_filter)) . '">' . zen_image_button('button_edit_product.gif', IMAGE_EDIT_PRODUCT) . '</a>' . '<br />&nbsp;'
  822.             );
  823.           break;
  824.       }
  825.     break;
  826.   }
  827.  
  828.   if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
  829.     echo '            <td width="25%" valign="top">' . "\n";
  830.  
  831.     $box = new box;
  832.     echo $box->infoBox($heading, $contents);
  833.  
  834.     echo '            </td>' . "\n";
  835.   }
  836. ?>
  837.           </tr>
  838.         </td></table>
  839.       </tr>
  840.  
  841.     </table></td>
  842. <!-- downloads by product_name_eof //-->
  843.   </tr>
  844. </table>
  845. <!-- body_text_eof //-->
  846. <!-- footer //-->
  847. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  848. <!-- footer_eof //-->
  849. </body>
  850. </html>
  851. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>


cron