[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/admin/ -> products_to_categories.php (source)

   1  <?php
   2  //

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

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

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

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

   7  // |                                                                      |

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

   9  // |                                                                      |

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

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

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

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

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

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

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

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

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

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

  20  //  $Id: products_to_categories.php 2909 2006-01-29 21:29:35Z ajeh $

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

  25    $chk_products = $db->Execute("select * from " . TABLE_PRODUCTS . " limit 1");
  26    if ($chk_products->RecordCount() < 1) {
  27      $messageStack->add_session(ERROR_DEFINE_PRODUCTS, 'caution');
  28      zen_redirect(zen_href_link(FILENAME_CATEGORIES));
  29    }
  30  
  31    // verify product has a master_categories_id

  32    $chk_products = $db->Execute("select master_categories_id from " . TABLE_PRODUCTS . " where products_id='" . $_GET['products_filter'] . "'");
  33    if ($chk_products->fields['master_categories_id'] <= 0) {
  34      $messageStack->add(ERROR_DEFINE_PRODUCTS_MASTER_CATEGORIES_ID, 'caution');
  35  //    zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));

  36    }
  37  
  38    require (DIR_WS_CLASSES . 'currencies.php');
  39    $currencies = new currencies();
  40  
  41    $languages = zen_get_languages();
  42  
  43  function array_minus_array($a, $b) {
  44         $c=array_diff($a,$b);
  45         $c=array_intersect($c, $a);
  46         return $c;
  47  }
  48  
  49    $products_filter = ((isset($_GET['products_filter']) and $_GET['products_filter'] > 0) ? $_GET['products_filter'] : $_POST['products_filter']);
  50  
  51    $action = (isset($_GET['action']) ? $_GET['action'] : '');
  52  
  53    $current_category_id = (isset($_GET['current_category_id']) ? $_GET['current_category_id'] : $current_category_id);
  54  
  55    if ($action == 'new_cat') {
  56      $current_category_id = (isset($_GET['current_category_id']) ? $_GET['current_category_id'] : $current_category_id);
  57      $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");
  58      $products_filter = $new_product_query->fields['products_id'];
  59  //    $messageStack->add_session('SUCCESSFUL! SWITCHED CATEGORIES', 'success');

  60      zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  61    }
  62  
  63  // set categories and products if not set

  64    if ($products_filter == '' and $current_category_id != '') {
  65      $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");
  66      $products_filter = $new_product_query->fields['products_id'];
  67      if ($products_filter != '') {
  68        $messageStack->add_session(WARNING_PRODUCTS_LINK_TO_CATEGORY_REMOVED, 'caution');
  69        zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  70      }
  71    } else {
  72      if ($products_filter == '' and $current_category_id == '') {
  73        $reset_categories_id = zen_get_category_tree('', '', '0', '', '', true);
  74        $current_category_id = $reset_categories_id[0]['id'];
  75        $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");
  76        $products_filter = $new_product_query->fields['products_id'];
  77        $_GET['products_filter'] = $products_filter;
  78      }
  79    }
  80  
  81    require(DIR_WS_MODULES . FILENAME_PREV_NEXT);
  82  
  83  
  84    if (zen_not_null($action)) {
  85      switch ($action) {
  86        case 'set_products_filter':
  87          $_GET['products_filter'] = $_POST['products_filter'];
  88  
  89          zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_POST['current_category_id']));
  90          break;
  91        case 'copy_categories_products_to_another_category_linked':
  92          $zv_invalid_copy_linked = 'false';
  93          $zv_complete_message_linked = '';
  94          $copy_from_linked = $_POST['copy_categories_id_from_linked'];
  95          $copy_to_linked = $_POST['copy_categories_id_to_linked'];
  96  
  97          // do not proceed unless categories are different

  98          if ($copy_from_linked == $copy_to_linked) {
  99            $messageStack->add_session(WARNING_DUPLICATE_PRODUCTS_TO_CATEGORY_LINKED, 'warning');
 100            zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
 101          }
 102  
 103          $check_category_from = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $copy_from_linked . "' limit 1");
 104          $check_category_to = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $copy_to_linked . "' limit 1");
 105  
 106          // check if from is valid category

 107          if ($check_category_from->RecordCount() < 1) {
 108            $zv_invalid_copy_linked = 'true';
 109            $zv_complete_message_linked .= WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . $copy_from_linked . '&nbsp;';
 110          } else {
 111            $zv_complete_message_linked .= SUCCESS_COPY_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . $copy_from_linked . '&nbsp;';
 112          }
 113  
 114          // check if to is valid category

 115          if ($check_category_to->RecordCount() < 1) {
 116            if (zen_childs_in_category_count($copy_to_linked) > 0) {
 117              $zv_invalid_copy_linked = 'true';
 118              $zv_complete_message_linked .= WARNING_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . $copy_to_linked . '&nbsp;';
 119            }
 120          } else {
 121            $zv_complete_message_linked .= SUCCESS_COPY_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . $copy_to_linked . '&nbsp;';
 122          }
 123  
 124          if ($zv_invalid_copy_linked == 'true') {
 125            $messageStack->add_session($zv_complete_message_linked, 'warning');
 126            zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
 127          }
 128  
 129          ///////////////////////////////////////////////////////////////

 130          // if either category was invalid nothing processes below

 131          ///////////////////////////////////////////////////////////////

 132  
 133          // get products to be linked from

 134          $products_to_categories_from_linked = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $copy_from_linked . "'");
 135          while (!$products_to_categories_from_linked->EOF) {
 136            $add_links_array[] = array('products_id' => $products_to_categories_from_linked->fields['products_id']);
 137            $products_to_categories_from_linked->MoveNext();
 138          }
 139  
 140          // get products already in category to be linked to

 141          $products_to_categories_to_linked = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $copy_to_linked . "'");
 142          while (!$products_to_categories_to_linked->EOF) {
 143            $remove_links_array[] = array('products_id' => $products_to_categories_to_linked->fields['products_id']);
 144            $products_to_categories_to_linked->MoveNext();
 145          }
 146  
 147  // cannot count added/removed due to the nature of the how these are done

 148  //        $cnt_added = 0;

 149          // remove elements in $remove_links_array that are in $add_links_array

 150          for ($i=0, $n=sizeof($add_links_array); $i<$n; $i++) {
 151            $good = 'true';
 152            for ($j=0, $nn=sizeof($remove_links_array); $j<$nn; $j++) {
 153              if ($add_links_array[$i]['products_id'] == $remove_links_array[$j]['products_id']) {
 154                $good = 'false';
 155                break;
 156              }
 157            }
 158            // build final of good products

 159            if ($good == 'true') {
 160              $make_links_result[] = array('products_id' => $add_links_array[$i]['products_id']);
 161            }
 162          }
 163  
 164          for ($i=0, $n=sizeof($make_links_result); $i<$n; $i++) {
 165  //          $cnt_added++;

 166            $new_product = $make_links_result[$i]['products_id'];
 167            $sql = "insert into " . TABLE_PRODUCTS_TO_CATEGORIES . "
 168                    (products_id, categories_id)
 169                    values ($new_product, $copy_to_linked)";
 170  
 171            $db->Execute($sql);
 172          }
 173  
 174          // set message of completion

 175          if (sizeof($make_links_result) == 0) {
 176              $zv_complete_message_linked = WARNING_COPY_FROM_IN_TO_LINKED . $zv_complete_message_linked;
 177              $warning_color = 'caution';
 178          } else {
 179            if ($check_category_from->RecordCount() < 1 or $check_category_to->RecordCount() < 1) {
 180              $zv_complete_message_linked = WARNING_COPY_LINKED . $zv_complete_message_linked;
 181              $warning_color = 'error';
 182            } else {
 183              $zv_complete_message_linked = SUCCESS_COPY_LINKED . $zv_complete_message_linked;
 184              $warning_color = 'success';
 185            }
 186          }
 187  
 188          if (sizeof($make_links_result) == 0) {
 189            $messageStack->add_session($zv_complete_message_linked, $warning_color);
 190          } else {
 191            $messageStack->add_session($zv_complete_message_linked, $warning_color);
 192          }
 193  
 194          zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
 195          break;
 196  
 197        case 'remove_categories_products_to_another_category_linked':
 198          $zv_invalid_remove_linked = 'false';
 199          $zv_complete_message_linked = '';
 200          $remove_from_linked = $_POST['remove_categories_id_from_linked'];
 201          $remove_to_linked = $_POST['remove_categories_id_to_linked'];
 202  
 203          // do not proceed unless categories are different

 204          if ($remove_from_linked == $remove_to_linked) {
 205            $messageStack->add_session(WARNING_DUPLICATE_PRODUCTS_TO_CATEGORY_LINKED, 'warning');
 206            zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
 207          }
 208  
 209          $check_category_from = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $remove_from_linked . "' limit 1");
 210          $check_category_to = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $remove_to_linked . "' limit 1");
 211  
 212  
 213          // check if from is valid category

 214          if ($check_category_from->RecordCount() < 1) {
 215            $zv_invalid_remove_linked = 'true';
 216            $zv_complete_message_linked .= WARNING_REMOVE_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . $remove_from_linked . '&nbsp;';
 217         } else {
 218            $zv_complete_message_linked .= SUCCESS_REMOVE_ALL_PRODUCTS_TO_CATEGORY_FROM_LINKED . $remove_from_linked . '&nbsp;';
 219          }
 220  
 221          // check if to is valid category

 222          if ($check_category_to->RecordCount() < 1) {
 223            $zv_invalid_remove_linked = 'true';
 224            $zv_complete_message_linked .= WARNING_REMOVE_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . $remove_to_linked . '&nbsp;';
 225          } else {
 226            $zv_complete_message_linked .= SUCCESS_REMOVE_ALL_PRODUCTS_TO_CATEGORY_TO_LINKED . $remove_to_linked . '&nbsp;';
 227          }
 228  
 229          if ($zv_invalid_remove_linked == 'true') {
 230            $messageStack->add_session($zv_complete_message_linked, 'warning');
 231            zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
 232          }
 233  
 234          ///////////////////////////////////////////////////////////////

 235          // if either category was invalid nothing processes below

 236          ///////////////////////////////////////////////////////////////

 237  
 238  
 239          // get products to be removed as added linked from

 240          $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 . "'");
 241  
 242          while (!$products_to_categories_from_linked->EOF) {
 243            if ($products_to_categories_from_linked->fields['master_categories_id'] == $remove_to_linked) {
 244              //die('THIS IS THE MASTER CATEGORIES ID!! ' . $remove_to_linked . '<br>');

 245              //break;

 246              $master_categories_id_stop[] = array('products_id' => $products_to_categories_from_linked->fields['products_id'],
 247                                       'master_categories_id' => $products_to_categories_from_linked->fields['master_categories_id']);
 248            }
 249            $add_links_array[] = array('products_id' => $products_to_categories_from_linked->fields['products_id'],
 250                                       'master_categories_id' => $products_to_categories_from_linked->fields['master_categories_id']);
 251            $products_to_categories_from_linked->MoveNext();
 252          }
 253  
 254          $stop_warning = '';
 255          if (sizeof($master_categories_id_stop) > 0) {
 256            for ($i=0, $n=sizeof($master_categories_id_stop); $i<$n; $i++) {
 257              $stop_warning .= TEXT_PRODUCTS_ID . $master_categories_id_stop[$i]['products_id'] . ': ' . zen_get_products_name($master_categories_id_stop[$i]['products_id']) . '<br>';
 258            }
 259  
 260            $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 />';
 261            $messageStack->add_session($stop_warning_message, 'warning');
 262            zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $master_categories_id_stop[0]['products_id'] . '&current_category_id=' . $current_category_id));
 263  //          die('THIS IS THE MASTER CATEGORIES ID!! ' . $remove_to_linked . ' - stop: ' . sizeof($master_categories_id_stop) . '<br>');

 264          }
 265  
 266          // get products already in category to be removed as linked to

 267          $products_to_categories_to_linked = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $remove_to_linked . "'");
 268          while (!$products_to_categories_to_linked->EOF) {
 269            $remove_links_array[] = array('products_id' => $products_to_categories_to_linked->fields['products_id']);
 270            $products_to_categories_to_linked->MoveNext();
 271          }
 272  
 273  //        $cnt_removed = 0;

 274          // remove elements in $remove_links_array that are in $add_links_array

 275          for ($i=0, $n=sizeof($add_links_array); $i<$n; $i++) {
 276            $good = 'true';
 277            for ($j=0, $nn=sizeof($remove_links_array); $j<$nn; $j++) {
 278              if ($add_links_array[$i]['products_id'] == $remove_links_array[$j]['products_id']) {
 279                $good = 'true';
 280                break;
 281              }
 282            }
 283            // build final of good products

 284            if ($good == 'true') {
 285              $make_links_result[] = array('products_id' => $add_links_array[$i]['products_id']);
 286            }
 287          }
 288  
 289          for ($i=0, $n=sizeof($make_links_result); $i<$n; $i++) {
 290  //          $cnt_removed++;

 291            $remove_product = $make_links_result[$i]['products_id'];
 292            $sql = "delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id='" . $remove_product . "' and categories_id='" . $remove_to_linked . "'";
 293            $db->Execute($sql);
 294          }
 295  
 296          // set message of completion

 297          if (sizeof($make_links_result) == 0) {
 298              $zv_complete_message_linked = WARNING_REMOVE_FROM_IN_TO_LINKED . $zv_complete_message_linked;
 299              $warning_color = 'caution';
 300          } else {
 301            if ($check_category_from->RecordCount() < 1 or $check_category_to->RecordCount() < 1) {
 302              $zv_complete_message_linked = WARNING_REMOVE_LINKED . $zv_complete_message_linked;
 303              $warning_color = 'warning';
 304            } else {
 305              $zv_complete_message_linked = SUCCESS_REMOVE_LINKED . $zv_complete_message_linked;
 306              $warning_color = 'success';
 307            }
 308          }
 309  
 310          if (sizeof($make_links_result) == 0) {
 311            $messageStack->add_session($zv_complete_message_linked, $warning_color);
 312          } else {
 313            $messageStack->add_session($zv_complete_message_linked, $warning_color);
 314          }
 315  
 316          zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
 317          break;
 318  
 319        case 'reset_categories_products_to_another_category_master':
 320          // reset the master_categories_id for all products in selected category

 321  
 322          $zv_invalid_reset_master= 'false';
 323          $zv_complete_message_master = '';
 324          $reset_from_master = $_POST['reset_categories_id_from_master'];
 325  
 326          $check_category_from = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $reset_from_master . "' limit 1");
 327  
 328          // check if from is valid category

 329          if ($check_category_from->RecordCount() < 1) {
 330            $zv_invalid_reset_master = 'true';
 331            $zv_complete_message_master .= WARNING_RESET_ALL_PRODUCTS_TO_CATEGORY_FROM_MASTER . $reset_from_master . '&nbsp;';
 332          } else {
 333            $zv_complete_message_master .= SUCCESS_RESET_ALL_PRODUCTS_TO_CATEGORY_FROM_MASTER . $reset_from_master . '&nbsp;';
 334          }
 335  
 336          if ($zv_invalid_reset_master == 'true') {
 337            $messageStack->add_session($zv_complete_message_master, 'warning');
 338            zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
 339          }
 340  
 341          ///////////////////////////////////////////////////////////////

 342          // if either category was invalid nothing processes below

 343          ///////////////////////////////////////////////////////////////

 344  
 345          $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 . "'");
 346  
 347          while (!$reset_master_categories_id->EOF) {
 348            $db->Execute("update " . TABLE_PRODUCTS . " set master_categories_id='" . $reset_from_master . "' where products_id='" . $reset_master_categories_id->fields['products_id'] . "'");
 349            // reset products_price_sorter for searches etc.

 350            zen_update_products_price_sorter($reset_master_categories_id->fields['products_id']);
 351            $reset_master_categories_id->MoveNext();
 352          }
 353  
 354          $messageStack->add_session($zv_complete_message_master, 'success');
 355          zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
 356          break;
 357  
 358        case 'set_master_categories_id':
 359          $db->Execute("update " . TABLE_PRODUCTS . " set master_categories_id='" . $_GET['master_category'] . "' where products_id='" . $products_filter . "'");
 360          // reset products_price_sorter for searches etc.

 361          zen_update_products_price_sorter($products_filter);
 362  
 363          zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $current_category_id));
 364          break;
 365  
 366        case 'update_product':
 367          $zv_check_master_categories_id = 'true';
 368          $new_categories_sort_array[] = $_POST['current_master_categories_id'];
 369          $current_master_categories_id = $_POST['current_master_categories_id'];
 370  
 371          // set the linked products master_categories_id product(s)

 372          for ($i=0, $n=sizeof($_POST['categories_add']); $i<$n; $i++) {
 373            // is current master_categories_id in the list?

 374            if ($zv_check_master_categories_id == 'true' and $_POST['categories_add'][$i] == $current_master_categories_id->fields['master_categories_id']) {
 375              $zv_check_master_categories_id = 'true';
 376              // array is set above to master category

 377            } else {
 378              $new_categories_sort_array[] = $_POST['categories_add'][$i];
 379            }
 380          }
 381  
 382          // remove existing products_to_categories for current product

 383          $db->Execute("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id='" . $products_filter . "'");
 384  
 385          $reset_master_categories_id = '';
 386          $old_master_categories_id = $current_master_categories_id;
 387          // add products to categories in order of master_categories_id first then others

 388          $verify_current_category_id = false;
 389          for ($i=0, $n=sizeof($new_categories_sort_array); $i<$n; $i++) {
 390            // is current master_categories_id in the list?

 391            if ($new_categories_sort_array[$i] <= 0) {
 392              die('I WOULD NOT ADD ' . $new_categories_sort_array[$i] . '<br>');
 393            } else {
 394              if ($current_category_id == $new_categories_sort_array[$i]) {
 395                $verify_current_category_id = true;
 396              }
 397              $db->Execute("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . "
 398                      (products_id, categories_id)
 399                      values ($products_filter, $new_categories_sort_array[$i])");
 400              if ($reset_master_categories_id == '') {
 401                $reset_master_categories_id = $new_categories_sort_array[$i];
 402              }
 403              if ($old_master_categories_id == $new_categories_sort_array[$i]) {
 404                $reset_master_categories_id = $new_categories_sort_array[$i];
 405              }
 406            }
 407          }
 408  
 409          // reset master_categories_id in products table

 410          if ($zv_check_master_categories_id == 'true') {
 411            // make sure master_categories_id is set to current master_categories_id

 412            $db->Execute("update " . TABLE_PRODUCTS . " set master_categories_id='" . $current_master_categories_id . "' where products_id='" . $products_filter . "'");
 413          } else {
 414            // reset master_categories_id to current_category_id because it was unselected

 415            $db->Execute("update " . TABLE_PRODUCTS . " set master_categories_id='" . $reset_master_categories_id . "' where products_id='" . $products_filter . "'");
 416          }
 417  
 418          // recalculate price based on new master_categories_id

 419          zen_update_products_price_sorter($products_filter);
 420  
 421          if ($zv_check_master_categories_id == 'true') {
 422            $messageStack->add_session(SUCCESS_MASTER_CATEGORIES_ID, 'success');
 423          } else {
 424            $messageStack->add_session(WARNING_MASTER_CATEGORIES_ID, 'warning');
 425          }
 426  
 427          // if product was removed from current categories_id stay in same category

 428          if (!$verify_current_category_id) {
 429            zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'current_category_id=' . $current_category_id));
 430          } else {
 431            zen_redirect(zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
 432          }
 433          break;
 434  
 435      }
 436    }
 437  
 438    $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
 439                                    from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd " . "
 440                           where p.products_id = '" . $products_filter . "'
 441                           and p.products_id = pd.products_id
 442                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'");
 443  
 444  //  $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'] . "'";

 445    $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";
 446    $categories_list = $db->Execute($catagories_query);
 447  
 448  // current products to categories

 449    $products_list = $db->Execute("select products_id, categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $products_filter . "'");
 450  
 451  ?>
 452  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
 453  <html <?php echo HTML_PARAMS; ?>>
 454  <head>
 455  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
 456  <title><?php echo TITLE; ?></title>
 457  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
 458  <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
 459  <script language="javascript" src="includes/menu.js"></script>
 460  <script language="javascript" src="includes/general.js"></script>
 461  <script language="javascript"><!--
 462  function go_option() {
 463    if (document.option_order_by.selected.options[document.option_order_by.selected.selectedIndex].value != "none") {
 464      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;
 465    }
 466  }
 467  //--></script>

 468  <script type="text/javascript">
 469    <!--
 470    function init()
 471    {
 472      cssjsmenu('navbar');
 473      if (document.getElementById)
 474      {
 475        var kill = document.getElementById('hoverJS');
 476        kill.disabled = true;
 477      }
 478    }
 479    // -->

 480  </script>
 481  </head>
 482  <!-- <body onload="init()"> -->
 483  <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="init()">
 484  <!-- header //-->
 485  <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
 486  <!-- header_eof //-->
 487  
 488  <!-- body //-->
 489  <table border="0" width="100%" cellspacing="2" cellpadding="2">
 490    <tr>
 491  <!-- body_text //-->
 492      <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 493  <?php
 494  ///////////////////////////////////////////////////////////

 495  // BOF: NEW CODE TO KEEP

 496  ?>
 497  
 498  <?php
 499    if ($action != 'edit_update') {
 500      require(DIR_WS_MODULES . FILENAME_PREV_NEXT_DISPLAY);
 501  ?>
 502  
 503        <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('products_filter', $_GET['products_filter']); ?><?php echo zen_draw_hidden_field('current_category_id', $_GET['current_category_id']); ?>
 504          <td colspan="2"><table border="0" cellspacing="0" cellpadding="2">
 505  
 506  <?php
 507  if ($_GET['products_filter'] != '') {
 508  ?>
 509            <tr>
 510              <td class="main" width="200" align="left" valign="top">&nbsp;</td>
 511              <td colspan="2" class="main"><?php echo TEXT_PRODUCT_TO_VIEW; ?></td>
 512            </tr>
 513            <tr>
 514              <td class="main" width="200" align="center" valign="top">
 515  
 516  <?php
 517  // FIX HERE

 518    $display_priced_by_attributes = zen_get_products_price_is_priced_by_attributes($_GET['products_filter']);
 519    echo ($display_priced_by_attributes ? '<span class="alert">' . TEXT_PRICED_BY_ATTRIBUTES . '</span>' . '<br />' : '');
 520    echo zen_get_products_display_price($_GET['products_filter']) . '<br /><br />';
 521    echo zen_get_products_quantity_min_units_display($_GET['products_filter'], $include_break = true);
 522    $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'");
 523    while (!$not_for_cart->EOF) {
 524      $not_for_cart_array[] = $not_for_cart->fields['products_id'];
 525      $not_for_cart->MoveNext();
 526     }
 527  ?>
 528              </td>
 529              <td class="attributes-even" align="center"><?php echo zen_draw_products_pull_down('products_filter', 'size="5"', $not_for_cart->fields, true, $_GET['products_filter'], true, true); ?></td>
 530              <td class="main" align="center" valign="top">
 531                <?php
 532                  echo zen_image_submit('button_display.gif', IMAGE_DISPLAY);
 533                ?>
 534              </td>
 535            </tr>
 536  <?php
 537  } else {
 538    $not_for_cart = '';
 539  } // $_GET['products_filter'] != ''

 540  ?>
 541  
 542  <?php
 543  // show when product is linked

 544  // not used in multiple products link manager

 545  ?>
 546  
 547          </table></td>
 548        </form></tr>
 549  <?php } // $action != 'edit_update' ?>

 550  <?php
 551  // EOF: NEW CODE TO KEEP

 552  ///////////////////////////////////////////////////////////

 553  ?>
 554        <tr>
 555          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 556  <?php if ($product_to_copy->EOF) { ?>
 557            <tr>
 558              <td class="pageHeading"><?php echo HEADING_TITLE . '<br />' . '<span class="alert">' . TEXT_PRODUCTS_ID . $products_filter . TEXT_PRODUCTS_ID_INVALID . '</span>'; ?></td>
 559            </tr>
 560            <tr>
 561              <td class="main"><?php echo TEXT_PRODUCTS_ID_NOT_REQUIRED; ?></td>
 562            </tr>
 563            <tr>
 564              <td><?php echo zen_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
 565            </tr>
 566  <?php } else { ?>
 567            <tr>
 568              <td class="pageHeading"><?php echo HEADING_TITLE . '<br />' . TEXT_PRODUCTS_ID . $product_to_copy->fields['products_id'] . ' ' . $product_to_copy->fields['products_name']; ?></td>
 569            </tr>
 570            <tr>
 571              <td><?php echo zen_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
 572            </tr>
 573            <tr>
 574              <td class="main"><?php echo TEXT_INFO_PRODUCTS_TO_CATEGORIES_LINKER_INTRO; ?></td>
 575            </tr>
 576            <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']); ?>
 577              <td class="main">
 578                <?php
 579                  echo '&nbsp;&nbsp;&nbsp;' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . '&nbsp;&nbsp;';
 580                  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();"');
 581                  echo zen_hide_session_id();
 582                  if ($product_to_copy->fields['master_categories_id'] <= 0) {
 583                    echo '&nbsp;&nbsp;' . '<span class="alert">' . WARNING_MASTER_CATEGORIES_ID . '</span>';
 584                  }
 585                  echo TEXT_INFO_LINKED_TO_COUNT . $products_list->RecordCount();
 586                ?>
 587              </td>
 588            </form></tr>
 589            <tr>
 590              <td><?php echo zen_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
 591            </tr>
 592          </table></td>
 593        </tr>
 594  
 595  <!-- bof: link to categories //-->
 596        <tr>
 597          <td width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
 598            <tr>
 599              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 600            <tr>
 601              <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td>
 602            </tr>
 603            <tr class="dataTableHeadingRow">
 604              <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>" class="pageHeading" align="center"><?php echo TEXT_INFO_PRODUCTS_TO_CATEGORIES_AVAILABLE; ?></td>
 605            </tr>
 606  <?php
 607      while(!$products_list->EOF) {
 608        $selected_categories_check .= $products_list->fields['categories_id'];
 609        $products_list->MoveNext();
 610        if (!$products_list->EOF) {
 611          $selected_categories_check .= ',';
 612        }
 613      }
 614      $selected_categories = explode(',', $selected_categories_check);
 615      echo zen_draw_form('update', FILENAME_PRODUCTS_TO_CATEGORIES, 'action=update_product&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id, 'post');
 616  ?>
 617            <tr class="dataTableHeadingRow">
 618              <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>" height="50" align="center" valign="middle" class="dataTableHeadingContent">
 619                <?php
 620                  if ($product_to_copy->fields['master_categories_id'] < 1) {
 621                    echo '<span class="alert">' . TEXT_SET_MASTER_CATEGORIES_ID . '</span>';
 622                  } else {
 623                ?>
 624                    <input type="submit" value="<?php echo BUTTON_UPDATE_CATEGORY_LINKS; ?>">
 625                <?php } ?>
 626              </td>
 627            </tr>
 628  <?php
 629      $cnt_columns = 0;
 630      echo '<tr class="dataTableHeadingRow">';
 631      while ($cnt_columns != MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS) {
 632        $cnt_columns++;
 633        echo '<td class="dataTableHeadingContent" align="right">' . TEXT_INFO_ID . '</td>' . '<td class="dataTableHeadingContent" align="left">' . '&nbsp;&nbsp;Categories Name' . '</td>';
 634      }
 635          echo '</tr>';
 636  //        echo '<tr class="dataTableHeadingRow">';

 637  
 638      $cnt_columns = 0;
 639      while (!$categories_list->EOF) {
 640        $cnt_columns++;
 641        if (zen_not_null($selected_categories_check)) {
 642          $selected = in_array($categories_list->fields['categories_id'], $selected_categories);
 643        } else {
 644          $selected = false;
 645        }
 646        $zc_categories_checkbox = zen_draw_checkbox_field('categories_add[]', $categories_list->fields['categories_id'], $selected);
 647        if ($cnt_columns == 1) {
 648          echo '<tr class="dataTableHeadingRow">';
 649        }
 650        echo '  <td class="dataTableContent" align="right">' . $categories_list->fields['categories_id'] . '</td>' . "\n";
 651        if ($product_to_copy->fields['master_categories_id'] == $categories_list->fields['categories_id']) {
 652  //        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";

 653          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";
 654        } else {
 655          echo '  <td class="dataTableContent" align="left">' . ($selected ? '<strong>' : '') . $zc_categories_checkbox . '&nbsp;' . $categories_list->fields['categories_name'] . ($selected ? '</strong>' : '') . '</td>' . "\n";
 656        }
 657        $categories_list->MoveNext();
 658        if ($cnt_columns == MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS or $categories_list->EOF) {
 659          if ($categories_list->EOF and $cnt_columns != MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS) {
 660            while ($cnt_columns < MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS) {
 661              $cnt_columns++;
 662              echo '  <td class="dataTableContent" align="right">' . '&nbsp;' . '</td>' . "\n";
 663              echo '  <td class="dataTableContent" align="left">' . '&nbsp;' . '</td>' . "\n";
 664            }
 665          }
 666          echo '</tr>' . "\n";
 667          $cnt_columns = 0;
 668        }
 669      }
 670  ?>
 671            <tr class="dataTableHeadingRow">
 672              <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>" height="50" align="center" valign="middle" class="dataTableHeadingContent">
 673                <?php
 674                  if ($product_to_copy->fields['master_categories_id'] < 1) {
 675                    echo '<span class="alert">' . TEXT_SET_MASTER_CATEGORIES_ID . '</span>';
 676                  } else {
 677                ?>
 678                    <input type="submit" value="<?php echo BUTTON_UPDATE_CATEGORY_LINKS; ?>">
 679                <?php } ?>
 680              </td>
 681  
 682            </tr>
 683            </form>
 684            <tr>
 685              <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>" valign="top"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td>
 686            </tr>
 687            <tr>
 688              <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>" ><?php echo zen_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
 689            </tr>
 690            <tr>
 691              <td colspan="<?php echo MAX_DISPLAY_PRODUCTS_TO_CATEGORIES_COLUMNS*2; ?>" class="main"><?php echo TEXT_INFO_PRODUCTS_TO_CATEGORIES_LINKER; ?></td>
 692            </tr>
 693            <tr>
 694              <td><?php echo zen_draw_separator('pixel_trans.gif', '100%', '20'); ?></td>
 695            </tr>
 696  <?php } ?>
 697              </table>
 698  <!-- eof: link to categories //-->
 699              <table border="5" class="dataTableHeadingRow">
 700                <tr class="dataTableHeadingRow">
 701                  <td class="dataTableHeadingContent">
 702              <table border="0" class="dataTableHeadingRow" width="100%">
 703                <tr class="dataTableHeadingRow">
 704                  <td class="pageHeading" align="center"><?php echo HEADER_CATEGORIES_GLOBAL_CHANGES; ?></td>
 705                </tr>
 706              </table>
 707  <!-- copy products from one category to another as linked or new products -->
 708              <table border="0" class="dataTableHeadingRow" width="100%">
 709                <tr>
 710                  <td colspan="3" valign="middle" height="10"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td>
 711                </tr>
 712                <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'); ?>">
 713                <tr class="dataTableHeadingRow">
 714                  <td colspan="3" class="dataTableContent"><?php echo TEXT_INFO_COPY_ALL_PRODUCTS_TO_CATEGORY_LINKED; ?></td>
 715                </tr>
 716                <tr class="dataTableHeadingRow">
 717                  <td class="dataTableContent">
 718                    <?php
 719                      $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;';
 720                      echo $categories_id_from_linked;
 721                    ?>
 722                  </td>
 723                  <td class="dataTableContent">
 724                    <?php
 725                      $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;';
 726                      echo $categories_id_to_linked;
 727                    ?>
 728                  </td>
 729                  <td align="right" class="dataTableHeadingContent" valign="top">&nbsp;<input type="submit" value="<?php echo BUTTON_COPY_CATEGORY_LINKED; ?>">&nbsp;</td>
 730                </tr>
 731                </form>
 732              </table>
 733  <!-- eof: copy products //-->
 734  <!-- remove products from one category that are linked to another category -->
 735              <table border="0" class="dataTableHeadingRow" width="100%">
 736                <tr>
 737                  <td colspan="3" valign="middle" height="10"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td>
 738                </tr>
 739                <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'); ?>">
 740                <tr class="dataTableHeadingRow">
 741                  <td colspan="3" class="dataTableContent"><?php echo TEXT_INFO_REMOVE_ALL_PRODUCTS_TO_CATEGORY_LINKED; ?></td>
 742                </tr>
 743                <tr class="dataTableHeadingRow">
 744                  <td class="dataTableContent">
 745                    <?php
 746                      $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;';
 747                      echo $categories_id_from_linked;
 748                    ?>
 749                  </td>
 750                  <td class="dataTableHeadingContent">
 751                    <?php
 752                      $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;';
 753                      echo $categories_id_to_linked;
 754                    ?>
 755                  </td>
 756                  <td align="right" class="dataTableHeadingContent" valign="top">&nbsp;<input type="submit" value="<?php echo BUTTON_REMOVE_CATEGORY_LINKED; ?>">&nbsp;</td>
 757                </tr>
 758                </form>
 759                <tr>
 760                  <td colspan="3"><?php echo zen_draw_separator('pixel_trans.gif', '100%', '3'); ?></td>
 761                </tr>
 762              </table>
 763  <!-- eof: remove products //-->
 764  <!-- reset master_categories_id to request Categories -->
 765              <table border="0" class="dataTableHeadingRow" width="100%">
 766                <tr>
 767                  <td colspan="3" valign="middle" height="10"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td>
 768                </tr>
 769                <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'); ?>">
 770                <tr class="dataTableHeadingRow">
 771                  <td colspan="3" class="dataTableContent"><?php echo TEXT_INFO_RESET_ALL_PRODUCTS_TO_CATEGORY_MASTER; ?></td>
 772                </tr>
 773                <tr class="dataTableHeadingRow">
 774                  <td class="dataTableContent">
 775                    <?php
 776                      $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;';
 777                      echo $categories_id_from_linked;
 778                    ?>
 779                  </td>
 780                  <td align="right" class="dataTableHeadingContent" valign="top">&nbsp;<input type="submit" value="<?php echo BUTTON_RESET_CATEGORY_MASTER; ?>">&nbsp;</td>
 781                </tr>
 782                </form>
 783                <tr>
 784                  <td colspan="3"><?php echo zen_draw_separator('pixel_trans.gif', '100%', '3'); ?></td>
 785                </tr>
 786              </table>
 787  <!-- eof: reset master_categories_id //-->
 788                  </td>
 789                </tr>
 790              </table>
 791  
 792              </td>
 793  <?php
 794    $heading = array();
 795    $contents = array();
 796  
 797    switch ($action) {
 798      case 'edit':
 799        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_PRODUCTS_TO_CATEGORIES . '</b>');
 800        $contents = array('form' => zen_draw_form('products_downloads_edit', FILENAME_PRODUCTS_TO_CATEGORIES, ''));
 801        if ($products_filter > 0) {
 802          $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));
 803        }
 804        $contents[] = array('text' => '<b>' . TEXT_PRODUCTS_NAME . $product_to_copy->fields['products_name'] . '<br />' . TEXT_PRODUCTS_MODEL . $product_to_copy->fields['products_model'] . '</b>');
 805        $contents[] = array('text' => '<br />' . TEXT_SET_PRODUCTS_TO_CATEGORIES_LINKS . '<br />' . TEXT_PRODUCTS_ID . zen_draw_input_field('products_filter', $products_filter));
 806  //      $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>');

 807        $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']) . '">xxxx' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>' . '</form>');
 808        break;
 809      default:
 810        $heading[] = array('text' => '<b>' . $product_to_copy->fields['products_id'] . ' ' . $product_to_copy->fields['products_name'] . '</b>');
 811        if ($products_filter > 0) {
 812          $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));
 813        }
 814        $contents[] = array('text' => '<br />' . TEXT_PRODUCTS_NAME . $product_to_copy->fields['products_name']);
 815        $contents[] = array('text' => TEXT_PRODUCTS_MODEL . $product_to_copy->fields['products_model']);
 816        $contents[] = array('text' => TEXT_PRODUCTS_PRICE . zen_get_products_display_price($products_filter));
 817        switch (true) {
 818          case ($product_to_copy->fields['master_categories_id'] == 0 and $products_filter > 0):
 819            $contents[] = array('text' => '<br /><span class="alert">' . WARNING_MASTER_CATEGORIES_ID . '</span><br />&nbsp;');
 820            break;
 821          default:
 822            $contents[] = array('text' => '<form action="' . FILENAME_PRODUCTS_TO_CATEGORIES . '.php' . '?action=edit&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id . '" method="post">');
 823            $contents[] = array('align' => 'center', 'text' => '<input type="submit" value="' . BUTTON_NEW_PRODUCTS_TO_CATEGORIES . '"></form>');
 824            $contents[] = array('text' => '<br />' . zen_image(DIR_WS_IMAGES . 'pixel_black.gif','','100%','3') . '<br />&nbsp;');
 825            $contents[] = array('align' => 'center', 'text' =>
 826              '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter) . '">' . zen_image_button('button_edit_attribs.gif', IMAGE_EDIT_ATTRIBUTES) . '</a>&nbsp;&nbsp;' .
 827              '<a href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, '&products_filter=' . $products_filter) . '">' . zen_image_button('button_products_price_manager.gif', IMAGE_PRODUCTS_PRICE_MANAGER) . '</a><br /><br />' .
 828              '<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;' .
 829              '<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;'
 830              );
 831            break;
 832        }
 833      break;
 834    }
 835  
 836    if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
 837      echo '            <td width="25%" valign="top">' . "\n";
 838  
 839      $box = new box;
 840      echo $box->infoBox($heading, $contents);
 841  
 842      echo '            </td>' . "\n";
 843    }
 844  ?>
 845            </tr>
 846          </td></table>
 847        </tr>
 848  
 849      </table></td>
 850  <!-- downloads by product_name_eof //-->
 851    </tr>
 852  </table>
 853  <!-- body_text_eof //-->
 854  <!-- footer //-->
 855  <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
 856  <!-- footer_eof //-->
 857  </body>
 858  </html>
 859  <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>


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