| [ Index ] | osCommerce
Docs :: PHP Cross Reference For osCommerce 2.2 MS2 Provided By OSCdox.com |
1 <?php 2 /* 3 $Id: categories.php,v 1.146 2003/07/11 14:40:27 hpdl Exp $ 4 5 osCommerce, Open Source E-Commerce Solutions 6 http://www.oscommerce.com 7 8 Copyright (c) 2003 osCommerce 9 10 Released under the GNU General Public License 11 */ 12 13 require ('includes/application_top.php'); 14 15 require (DIR_WS_CLASSES . 'currencies.php'); 16 $currencies = new currencies(); 17 18 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : ''); 19 20 if (tep_not_null($action)) { 21 switch ($action) { 22 case 'setflag': 23 if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) { 24 if (isset($HTTP_GET_VARS['pID'])) { 25 tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']); 26 } 27 28 if (USE_CACHE == 'true') { 29 tep_reset_cache_block('categories'); 30 tep_reset_cache_block('also_purchased'); 31 } 32 } 33 34 tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID'])); 35 break; 36 case 'insert_category': 37 case 'update_category': 38 if (isset($HTTP_POST_VARS['categories_id'])) $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); 39 $sort_order = tep_db_prepare_input($HTTP_POST_VARS['sort_order']); 40 41 $sql_data_array = array('sort_order' => $sort_order); 42 43 if ($action == 'insert_category') { 44 $insert_sql_data = array('parent_id' => $current_category_id, 45 'date_added' => 'now()'); 46 47 $sql_data_array = array_merge($sql_data_array, $insert_sql_data); 48 49 tep_db_perform(TABLE_CATEGORIES, $sql_data_array); 50 51 $categories_id = tep_db_insert_id(); 52 } elseif ($action == 'update_category') { 53 $update_sql_data = array('last_modified' => 'now()'); 54 55 $sql_data_array = array_merge($sql_data_array, $update_sql_data); 56 57 tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'"); 58 } 59 60 $languages = tep_get_languages(); 61 for ($i=0, $n=sizeof($languages); $i<$n; $i++) { 62 $categories_name_array = $HTTP_POST_VARS['categories_name']; 63 64 $language_id = $languages[$i]['id']; 65 66 $sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id])); 67 68 if ($action == 'insert_category') { 69 $insert_sql_data = array('categories_id' => $categories_id, 70 'language_id' => $languages[$i]['id']); 71 72 $sql_data_array = array_merge($sql_data_array, $insert_sql_data); 73 74 tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array); 75 } elseif ($action == 'update_category') { 76 tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'"); 77 } 78 } 79 80 if ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES)) { 81 tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'"); 82 } 83 84 if (USE_CACHE == 'true') { 85 tep_reset_cache_block('categories'); 86 tep_reset_cache_block('also_purchased'); 87 } 88 89 tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id)); 90 break; 91 case 'delete_category_confirm': 92 if (isset($HTTP_POST_VARS['categories_id'])) { 93 $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); 94 95 $categories = tep_get_category_tree($categories_id, '', '0', '', true); 96 $products = array(); 97 $products_delete = array(); 98 99 for ($i=0, $n=sizeof($categories); $i<$n; $i++) { 100 $product_ids_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$categories[$i]['id'] . "'"); 101 102 while ($product_ids = tep_db_fetch_array($product_ids_query)) { 103 $products[$product_ids['products_id']]['categories'][] = $categories[$i]['id']; 104 } 105 } 106 107 reset($products); 108 while (list($key, $value) = each($products)) { 109 $category_ids = ''; 110 111 for ($i=0, $n=sizeof($value['categories']); $i<$n; $i++) { 112 $category_ids .= "'" . (int)$value['categories'][$i] . "', "; 113 } 114 $category_ids = substr($category_ids, 0, -2); 115 116 $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$key . "' and categories_id not in (" . $category_ids . ")"); 117 $check = tep_db_fetch_array($check_query); 118 if ($check['total'] < '1') { 119 $products_delete[$key] = $key; 120 } 121 } 122 123 // removing categories can be a lengthy process 124 tep_set_time_limit(0); 125 for ($i=0, $n=sizeof($categories); $i<$n; $i++) { 126 tep_remove_category($categories[$i]['id']); 127 } 128 129 reset($products_delete); 130 while (list($key) = each($products_delete)) { 131 tep_remove_product($key); 132 } 133 } 134 135 if (USE_CACHE == 'true') { 136 tep_reset_cache_block('categories'); 137 tep_reset_cache_block('also_purchased'); 138 } 139 140 tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath)); 141 break; 142 case 'delete_product_confirm': 143 if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['product_categories']) && is_array($HTTP_POST_VARS['product_categories'])) { 144 $product_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); 145 $product_categories = $HTTP_POST_VARS['product_categories']; 146 147 for ($i=0, $n=sizeof($product_categories); $i<$n; $i++) { 148 tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "' and categories_id = '" . (int)$product_categories[$i] . "'"); 149 } 150 151 $product_categories_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'"); 152 $product_categories = tep_db_fetch_array($product_categories_query); 153 154 if ($product_categories['total'] == '0') { 155 tep_remove_product($product_id); 156 } 157 } 158 159 if (USE_CACHE == 'true') { 160 tep_reset_cache_block('categories'); 161 tep_reset_cache_block('also_purchased'); 162 } 163 164 tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath)); 165 break; 166 case 'move_category_confirm': 167 if (isset($HTTP_POST_VARS['categories_id']) && ($HTTP_POST_VARS['categories_id'] != $HTTP_POST_VARS['move_to_category_id'])) { 168 $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); 169 $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']); 170 171 $path = explode('_', tep_get_generated_category_path_ids($new_parent_id)); 172 173 if (in_array($categories_id, $path)) { 174 $messageStack->add_session(ERROR_CANNOT_MOVE_CATEGORY_TO_PARENT, 'error'); 175 176 tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id)); 177 } else { 178 tep_db_query("update " . TABLE_CATEGORIES . " set parent_id = '" . (int)$new_parent_id . "', last_modified = now() where categories_id = '" . (int)$categories_id . "'"); 179 180 if (USE_CACHE == 'true') { 181 tep_reset_cache_block('categories'); 182 tep_reset_cache_block('also_purchased'); 183 } 184 185 tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&cID=' . $categories_id)); 186 } 187 } 188 189 break; 190 case 'move_product_confirm': 191 $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); 192 $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']); 193 194 $duplicate_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$new_parent_id . "'"); 195 $duplicate_check = tep_db_fetch_array($duplicate_check_query); 196 if ($duplicate_check['total'] < 1) tep_db_query("update " . TABLE_PRODUCTS_TO_CATEGORIES . " set categories_id = '" . (int)$new_parent_id . "' where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$current_category_id . "'"); 197 198 if (USE_CACHE == 'true') { 199 tep_reset_cache_block('categories'); 200 tep_reset_cache_block('also_purchased'); 201 } 202 203 tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&pID=' . $products_id)); 204 break; 205 case 'insert_product': 206 case 'update_product': 207 if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) { 208 $action = 'new_product'; 209 } else { 210 if (isset($HTTP_GET_VARS['pID'])) $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']); 211 $products_date_available = tep_db_prepare_input($HTTP_POST_VARS['products_date_available']); 212 213 $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null'; 214 215 $sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']), 216 'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']), 217 'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']), 218 'products_date_available' => $products_date_available, 219 'products_weight' => tep_db_prepare_input($HTTP_POST_VARS['products_weight']), 220 'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']), 221 'products_tax_class_id' => tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']), 222 'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id'])); 223 224 if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) { 225 $sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']); 226 } 227 228 if ($action == 'insert_product') { 229 $insert_sql_data = array('products_date_added' => 'now()'); 230 231 $sql_data_array = array_merge($sql_data_array, $insert_sql_data); 232 233 tep_db_perform(TABLE_PRODUCTS, $sql_data_array); 234 $products_id = tep_db_insert_id(); 235 236 tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')"); 237 } elseif ($action == 'update_product') { 238 $update_sql_data = array('products_last_modified' => 'now()'); 239 240 $sql_data_array = array_merge($sql_data_array, $update_sql_data); 241 242 tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'"); 243 } 244 245 $languages = tep_get_languages(); 246 for ($i=0, $n=sizeof($languages); $i<$n; $i++) { 247 $language_id = $languages[$i]['id']; 248 249 $sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]), 250 'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]), 251 'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id])); 252 253 if ($action == 'insert_product') { 254 $insert_sql_data = array('products_id' => $products_id, 255 'language_id' => $language_id); 256 257 $sql_data_array = array_merge($sql_data_array, $insert_sql_data); 258 259 tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array); 260 } elseif ($action == 'update_product') { 261 tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'"); 262 } 263 } 264 265 if (USE_CACHE == 'true') { 266 tep_reset_cache_block('categories'); 267 tep_reset_cache_block('also_purchased'); 268 } 269 270 tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id)); 271 } 272 break; 273 case 'copy_to_confirm': 274 if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['categories_id'])) { 275 $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); 276 $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); 277 278 if ($HTTP_POST_VARS['copy_as'] == 'link') { 279 if ($categories_id != $current_category_id) { 280 $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$categories_id . "'"); 281 $check = tep_db_fetch_array($check_query); 282 if ($check['total'] < '1') { 283 tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$categories_id . "')"); 284 } 285 } else { 286 $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error'); 287 } 288 } elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') { 289 $product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); 290 $product = tep_db_fetch_array($product_query); 291 292 tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "', now(), '" . tep_db_input($product['products_date_available']) . "', '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')"); 293 $dup_products_id = tep_db_insert_id(); 294 295 $description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'"); 296 while ($description = tep_db_fetch_array($description_query)) { 297 tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')"); 298 } 299 300 tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')"); 301 $products_id = $dup_products_id; 302 } 303 304 if (USE_CACHE == 'true') { 305 tep_reset_cache_block('categories'); 306 tep_reset_cache_block('also_purchased'); 307 } 308 } 309 310 tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $categories_id . '&pID=' . $products_id)); 311 break; 312 case 'new_product_preview': 313 // copy image only if modified 314 $products_image = new upload('products_image'); 315 $products_image->set_destination(DIR_FS_CATALOG_IMAGES); 316 if ($products_image->parse() && $products_image->save()) { 317 $products_image_name = $products_image->filename; 318 } else { 319 $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : ''); 320 } 321 break; 322 } 323 } 324 325 // check if the catalog image directory exists 326 if (is_dir(DIR_FS_CATALOG_IMAGES)) { 327 if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error'); 328 } else { 329 $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error'); 330 } 331 ?> 332 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 333 <html <?php echo HTML_PARAMS; ?>> 334 <head> 335 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 336 <title><?php echo TITLE; ?></title> 337 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> 338 <script language="javascript" src="includes/general.js"></script> 339 </head> 340 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();"> 341 <div id="spiffycalendar" class="text"></div> 342 <!-- header //--> 343 <?php require (DIR_WS_INCLUDES . 'header.php'); ?> 344 <!-- header_eof //--> 345 346 <!-- body //--> 347 <table border="0" width="100%" cellspacing="2" cellpadding="2"> 348 <tr> 349 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> 350 <!-- left_navigation //--> 351 <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?> 352 <!-- left_navigation_eof //--> 353 </table></td> 354 <!-- body_text //--> 355 <td width="100%" valign="top"> 356 <?php 357 if ($action == 'new_product') { 358 $parameters = array('products_name' => '', 359 'products_description' => '', 360 'products_url' => '', 361 'products_id' => '', 362 'products_quantity' => '', 363 'products_model' => '', 364 'products_image' => '', 365 'products_price' => '', 366 'products_weight' => '', 367 'products_date_added' => '', 368 'products_last_modified' => '', 369 'products_date_available' => '', 370 'products_status' => '', 371 'products_tax_class_id' => '', 372 'manufacturers_id' => ''); 373 374 $pInfo = new objectInfo($parameters); 375 376 if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) { 377 $product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); 378 $product = tep_db_fetch_array($product_query); 379 380 $pInfo->objectInfo($product); 381 } elseif (tep_not_null($HTTP_POST_VARS)) { 382 $pInfo->objectInfo($HTTP_POST_VARS); 383 $products_name = $HTTP_POST_VARS['products_name']; 384 $products_description = $HTTP_POST_VARS['products_description']; 385 $products_url = $HTTP_POST_VARS['products_url']; 386 } 387 388 $manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE)); 389 $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name"); 390 while ($manufacturers = tep_db_fetch_array($manufacturers_query)) { 391 $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'], 392 'text' => $manufacturers['manufacturers_name']); 393 } 394 395 $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE)); 396 $tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title"); 397 while ($tax_class = tep_db_fetch_array($tax_class_query)) { 398 $tax_class_array[] = array('id' => $tax_class['tax_class_id'], 399 'text' => $tax_class['tax_class_title']); 400 } 401 402 $languages = tep_get_languages(); 403 404 if (!isset($pInfo->products_status)) $pInfo->products_status = '1'; 405 switch ($pInfo->products_status) { 406 case '0': $in_status = false; $out_status = true; break; 407 case '1': 408 default: $in_status = true; $out_status = false; 409 } 410 ?> 411 <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css"> 412 <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script> 413 <script language="javascript"><!-- 414 var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE); 415 //--></script> 416 <script language="javascript"><!-- 417 var tax_rates = new Array(); 418 <?php 419 for ($i=0, $n=sizeof($tax_class_array); $i<$n; $i++) { 420 if ($tax_class_array[$i]['id'] > 0) { 421 echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . tep_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "\n"; 422 } 423 } 424 ?> 425 426 function doRound(x, places) { 427 return Math.round(x * Math.pow(10, places)) / Math.pow(10, places); 428 } 429 430 function getTaxRate() { 431 var selected_value = document.forms["new_product"].products_tax_class_id.selectedIndex; 432 var parameterVal = document.forms["new_product"].products_tax_class_id[selected_value].value; 433 434 if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) { 435 return tax_rates[parameterVal]; 436 } else { 437 return 0; 438 } 439 } 440 441 function updateGross() { 442 var taxRate = getTaxRate(); 443 var grossValue = document.forms["new_product"].products_price.value; 444 445 if (taxRate > 0) { 446 grossValue = grossValue * ((taxRate / 100) + 1); 447 } 448 449 document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4); 450 } 451 452 function updateNet() { 453 var taxRate = getTaxRate(); 454 var netValue = document.forms["new_product"].products_price_gross.value; 455 456 if (taxRate > 0) { 457 netValue = netValue / ((taxRate / 100) + 1); 458 } 459 460 document.forms["new_product"].products_price.value = doRound(netValue, 4); 461 } 462 //--></script> 463 <?php echo tep_draw_form('new_product', FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=new_product_preview', 'post', 'enctype="multipart/form-data"'); ?> 464 <table border="0" width="100%" cellspacing="0" cellpadding="2"> 465 <tr> 466 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 467 <tr> 468 <td class="pageHeading"><?php echo sprintf(TEXT_NEW_PRODUCT, tep_output_generated_category_path($current_category_id)); ?></td> 469 <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> 470 </tr> 471 </table></td> 472 </tr> 473 <tr> 474 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 475 </tr> 476 <tr> 477 <td><table border="0" cellspacing="0" cellpadding="2"> 478 <tr> 479 <td class="main"><?php echo TEXT_PRODUCTS_STATUS; ?></td> 480 <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_radio_field('products_status', '1', $in_status) . ' ' . TEXT_PRODUCT_AVAILABLE . ' ' . tep_draw_radio_field('products_status', '0', $out_status) . ' ' . TEXT_PRODUCT_NOT_AVAILABLE; ?></td> 481 </tr> 482 <tr> 483 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 484 </tr> 485 <tr> 486 <td class="main"><?php echo TEXT_PRODUCTS_DATE_AVAILABLE; ?><br><small>(YYYY-MM-DD)</small></td> 487 <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' '; ?><script language="javascript">dateAvailable.writeControl(); dateAvailable.dateFormat="yyyy-MM-dd";</script></td> 488 </tr> 489 <tr> 490 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 491 </tr> 492 <tr> 493 <td class="main"><?php echo TEXT_PRODUCTS_MANUFACTURER; ?></td> 494 <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $pInfo->manufacturers_id); ?></td> 495 </tr> 496 <tr> 497 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 498 </tr> 499 <?php 500 for ($i=0, $n=sizeof($languages); $i<$n; $i++) { 501 ?> 502 <tr> 503 <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_NAME; ?></td> 504 <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('products_name[' . $languages[$i]['id'] . ']', (isset($products_name[$languages[$i]['id']]) ? $products_name[$languages[$i]['id']] : tep_get_products_name($pInfo->products_id, $languages[$i]['id']))); ?></td> 505 </tr> 506 <?php 507 } 508 ?> 509 <tr> 510 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 511 </tr> 512 <tr bgcolor="#ebebff"> 513 <td class="main"><?php echo TEXT_PRODUCTS_TAX_CLASS; ?></td> 514 <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('products_tax_class_id', $tax_class_array, $pInfo->products_tax_class_id, 'onchange="updateGross()"'); ?></td> 515 </tr> 516 <tr bgcolor="#ebebff"> 517 <td class="main"><?php echo TEXT_PRODUCTS_PRICE_NET; ?></td> 518 <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price', $pInfo->products_price, 'onKeyUp="updateGross()"'); ?></td> 519 </tr> 520 <tr bgcolor="#ebebff"> 521 <td class="main"><?php echo TEXT_PRODUCTS_PRICE_GROSS; ?></td> 522 <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price_gross', $pInfo->products_price, 'OnKeyUp="updateNet()"'); ?></td> 523 </tr> 524 <tr> 525 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 526 </tr> 527 <script language="javascript"><!-- 528 updateGross(); 529 //--></script> 530 <?php 531 for ($i=0, $n=sizeof($languages); $i<$n; $i++) { 532 ?> 533 <tr> 534 <td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_DESCRIPTION; ?></td> 535 <td><table border="0" cellspacing="0" cellpadding="0"> 536 <tr> 537 <td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td> 538 <td class="main"><?php echo tep_draw_textarea_field('products_description[' . $languages[$i]['id'] . ']', 'soft', '70', '15', (isset($products_description[$languages[$i]['id']]) ? $products_description[$languages[$i]['id']] : tep_get_products_description($pInfo->products_id, $languages[$i]['id']))); ?></td> 539 </tr> 540 </table></td> 541 </tr> 542 <?php 543 } 544 ?> 545 <tr> 546 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 547 </tr> 548 <tr> 549 <td class="main"><?php echo TEXT_PRODUCTS_QUANTITY; ?></td> 550 <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_quantity', $pInfo->products_quantity); ?></td> 551 </tr> 552 <tr> 553 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 554 </tr> 555 <tr> 556 <td class="main"><?php echo TEXT_PRODUCTS_MODEL; ?></td> 557 <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_model', $pInfo->products_model); ?></td> 558 </tr> 559 <tr> 560 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 561 </tr> 562 <tr> 563 <td class="main"><?php echo TEXT_PRODUCTS_IMAGE; ?></td> 564 <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_file_field('products_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . $pInfo->products_image . tep_draw_hidden_field('products_previous_image', $pInfo->products_image); ?></td> 565 </tr> 566 <tr> 567 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 568 </tr> 569 <?php 570 for ($i=0, $n=sizeof($languages); $i<$n; $i++) { 571 ?> 572 <tr> 573 <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_URL . '<br><small>' . TEXT_PRODUCTS_URL_WITHOUT_HTTP . '</small>'; ?></td> 574 <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('products_url[' . $languages[$i]['id'] . ']', (isset($products_url[$languages[$i]['id']]) ? $products_url[$languages[$i]['id']] : tep_get_products_url($pInfo->products_id, $languages[$i]['id']))); ?></td> 575 </tr> 576 <?php 577 } 578 ?> 579 <tr> 580 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 581 </tr> 582 <tr> 583 <td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td> 584 <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_weight', $pInfo->products_weight); ?></td> 585 </tr> 586 </table></td> 587 </tr> 588 <tr> 589 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 590 </tr> 591 <tr> 592 <td class="main" align="right"><?php echo tep_draw_hidden_field('products_date_added', (tep_not_null($pInfo->products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))) . tep_image_submit('button_preview.gif', IMAGE_PREVIEW) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td> 593 </tr> 594 </table></form> 595 <?php 596 } elseif ($action == 'new_product_preview') { 597 if (tep_not_null($HTTP_POST_VARS)) { 598 $pInfo = new objectInfo($HTTP_POST_VARS); 599 $products_name = $HTTP_POST_VARS['products_name']; 600 $products_description = $HTTP_POST_VARS['products_description']; 601 $products_url = $HTTP_POST_VARS['products_url']; 602 } else { 603 $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'"); 604 $product = tep_db_fetch_array($product_query); 605 606 $pInfo = new objectInfo($product); 607 $products_image_name = $pInfo->products_image; 608 } 609 610 $form_action = (isset($HTTP_GET_VARS['pID'])) ? 'update_product' : 'insert_product'; 611 612 echo tep_draw_form($form_action, FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"'); 613 614 $languages = tep_get_languages(); 615 for ($i=0, $n=sizeof($languages); $i<$n; $i++) { 616 if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) { 617 $pInfo->products_name = tep_get_products_name($pInfo->products_id, $languages[$i]['id']); 618 $pInfo->products_description = tep_get_products_description($pInfo->products_id, $languages[$i]['id']); 619 $pInfo->products_url = tep_get_products_url($pInfo->products_id, $languages[$i]['id']); 620 } else { 621 $pInfo->products_name = tep_db_prepare_input($products_name[$languages[$i]['id']]); 622 $pInfo->products_description = tep_db_prepare_input($products_description[$languages[$i]['id']]); 623 $pInfo->products_url = tep_db_prepare_input($products_url[$languages[$i]['id']]); 624 } 625 ?> 626 <table border="0" width="100%" cellspacing="0" cellpadding="2"> 627 <tr> 628 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 629 <tr> 630 <td class="pageHeading"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . $pInfo->products_name; ?></td> 631 <td class="pageHeading" align="right"><?php echo $currencies->format($pInfo->products_price); ?></td> 632 </tr> 633 </table></td> 634 </tr> 635 <tr> 636 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 637 </tr> 638 <tr> 639 <td class="main"><?php echo tep_image(DIR_WS_CATALOG_IMAGES . $products_image_name, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') . $pInfo->products_description; ?></td> 640 </tr> 641 <?php 642 if ($pInfo->products_url) { 643 ?> 644 <tr> 645 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 646 </tr> 647 <tr> 648 <td class="main"><?php echo sprintf(TEXT_PRODUCT_MORE_INFORMATION, $pInfo->products_url); ?></td> 649 </tr> 650 <?php 651 } 652 ?> 653 <tr> 654 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 655 </tr> 656 <?php 657 if ($pInfo->products_date_available > date('Y-m-d')) { 658 ?> 659 <tr> 660 <td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_AVAILABLE, tep_date_long($pInfo->products_date_available)); ?></td> 661 </tr> 662 <?php 663 } else { 664 ?> 665 <tr> 666 <td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_ADDED, tep_date_long($pInfo->products_date_added)); ?></td> 667 </tr> 668 <?php 669 } 670 ?> 671 <tr> 672 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 673 </tr> 674 <?php 675 } 676 677 if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) { 678 if (isset($HTTP_GET_VARS['origin'])) { 679 $pos_params = strpos($HTTP_GET_VARS['origin'], '?', 0); 680 if ($pos_params != false) { 681 $back_url = substr($HTTP_GET_VARS['origin'], 0, $pos_params); 682 $back_url_params = substr($HTTP_GET_VARS['origin'], $pos_params + 1); 683 } else { 684 $back_url = $HTTP_GET_VARS['origin']; 685 $back_url_params = ''; 686 } 687 } else { 688 $back_url = FILENAME_CATEGORIES; 689 $back_url_params = 'cPath=' . $cPath . '&pID=' . $pInfo->products_id; 690 } 691 ?> 692 <tr> 693 <td align="right"><?php echo '<a href="' . tep_href_link($back_url, $back_url_params, 'NONSSL') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td> 694 </tr> 695 <?php 696 } else { 697 ?> 698 <tr> 699 <td align="right" class="smallText"> 700 <?php 701 /* Re-Post all POST'ed variables */ 702 reset($HTTP_POST_VARS); 703 while (list($key, $value) = each($HTTP_POST_VARS)) { 704 if (!is_array($HTTP_POST_VARS[$key])) { 705 echo tep_draw_hidden_field($key, htmlspecialchars(stripslashes($value))); 706 } 707 } 708 $languages = tep_get_languages(); 709 for ($i=0, $n=sizeof($languages); $i<$n; $i++) { 710 echo tep_draw_hidden_field('products_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_name[$languages[$i]['id']]))); 711 echo tep_draw_hidden_field('products_description[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_description[$languages[$i]['id']]))); 712 echo tep_draw_hidden_field('products_url[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_url[$languages[$i]['id']]))); 713 } 714 echo tep_draw_hidden_field('products_image', stripslashes($products_image_name)); 715 716 echo tep_image_submit('button_back.gif', IMAGE_BACK, 'name="edit"') . ' '; 717 718 if (isset($HTTP_GET_VARS['pID'])) { 719 echo tep_image_submit('button_update.gif', IMAGE_UPDATE); 720 } else { 721 echo tep_image_submit('button_insert.gif', IMAGE_INSERT); 722 } 723 echo ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; 724 ?></td> 725 </tr> 726 </table></form> 727 <?php 728 } 729 } else { 730 ?> 731 <table border="0" width="100%" cellspacing="0" cellpadding="2"> 732 <tr> 733 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 734 <tr> 735 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 736 <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td> 737 <td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 738 <tr> 739 <td class="smallText" align="right"> 740 <?php 741 echo tep_draw_form('search', FILENAME_CATEGORIES, '', 'get'); 742 echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search'); 743 echo '</form>'; 744 ?> 745 </td> 746 </tr> 747 <tr> 748 <td class="smallText" align="right"> 749 <?php 750 echo tep_draw_form('goto', FILENAME_CATEGORIES, '', 'get'); 751 echo HEADING_TITLE_GOTO . ' ' . tep_draw_pull_down_menu('cPath', tep_get_category_tree(), $current_category_id, 'onChange="this.form.submit();"'); 752 echo '</form>'; 753 ?> 754 </td> 755 </tr> 756 </table></td> 757 </tr> 758 </table></td> 759 </tr> 760 <tr> 761 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 762 <tr> 763 <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 764 <tr class="dataTableHeadingRow"> 765 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CATEGORIES_PRODUCTS; ?></td> 766 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td> 767 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td> 768 </tr> 769 <?php 770 $categories_count = 0; 771 $rows = 0; 772 if (isset($HTTP_GET_VARS['search'])) { 773 $search = tep_db_prepare_input($HTTP_GET_VARS['search']); 774 775 $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and cd.categories_name like '%" . tep_db_input($search) . "%' order by c.sort_order, cd.categories_name"); 776 } else { 777 $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by c.sort_order, cd.categories_name"); 778 } 779 while ($categories = tep_db_fetch_array($categories_query)) { 780 $categories_count++; 781 $rows++; 782 783 // Get parent_id for subcategories if search 784 if (isset($HTTP_GET_VARS['search'])) $cPath= $categories['parent_id']; 785 786 if ((!isset($HTTP_GET_VARS['cID']) && !isset($HTTP_GET_VARS['pID']) || (isset($HTTP_GET_VARS['cID']) && ($HTTP_GET_VARS['cID'] == $categories['categories_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) { 787 $category_childs = array('childs_count' => tep_childs_in_category_count($categories['categories_id'])); 788 $category_products = array('products_count' => tep_products_in_category_count($categories['categories_id'])); 789 790 $cInfo_array = array_merge($categories, $category_childs, $category_products); 791 $cInfo = new objectInfo($cInfo_array); 792 } 793 794 if (isset($cInfo) && is_object($cInfo) && ($categories['categories_id'] == $cInfo->categories_id) ) { 795 echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, tep_get_path($categories['categories_id'])) . '\'">' . "\n"; 796 } else { 797 echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories['categories_id']) . '\'">' . "\n"; 798 } 799 ?> 800 <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, tep_get_path($categories['categories_id'])) . '">' . tep_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . '</a> <b>' . $categories['categories_name'] . '</b>'; ?></td> 801 <td class="dataTableContent" align="center"> </td> 802 <td class="dataTableContent" align="right"><?php if (isset($cInfo) && is_object($cInfo) && ($categories['categories_id'] == $cInfo->categories_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories['categories_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td> 803 </tr> 804 <?php 805 } 806 807 $products_count = 0; 808 if (isset($HTTP_GET_VARS['search'])) { 809 $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name"); 810 } else { 811 $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name"); 812 } 813 while ($products = tep_db_fetch_array($products_query)) { 814 $products_count++; 815 $rows++; 816 817 // Get categories_id for product if search 818 if (isset($HTTP_GET_VARS['search'])) $cPath = $products['categories_id']; 819 820 if ( (!isset($HTTP_GET_VARS['pID']) && !isset($HTTP_GET_VARS['cID']) || (isset($HTTP_GET_VARS['pID']) && ($HTTP_GET_VARS['pID'] == $products['products_id']))) && !isset($pInfo) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) { 821 // find out the rating average from customer reviews 822 $reviews_query = tep_db_query("select (avg(reviews_rating) / 5 * 100) as average_rating from " . TABLE_REVIEWS . " where products_id = '" . (int)$products['products_id'] . "'"); 823 $reviews = tep_db_fetch_array($reviews_query); 824 $pInfo_array = array_merge($products, $reviews); 825 $pInfo = new objectInfo($pInfo_array); 826 } 827 828 if (isset($pInfo) && is_object($pInfo) && ($products['products_id'] == $pInfo->products_id) ) { 829 echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id'] . '&action=new_product_preview&read=only') . '\'">' . "\n"; 830 } else { 831 echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '\'">' . "\n"; 832 } 833 ?> 834 <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id'] . '&action=new_product_preview&read=only') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $products['products_name']; ?></td> 835 <td class="dataTableContent" align="center"> 836 <?php 837 if ($products['products_status'] == '1') { 838 echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=0&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>'; 839 } else { 840 echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=1&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a> ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10); 841 } 842 ?></td> 843 <td class="dataTableContent" align="right"><?php if (isset($pInfo) && is_object($pInfo) && ($products['products_id'] == $pInfo->products_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td> 844 </tr> 845 <?php 846 } 847 848 $cPath_back = ''; 849 if (sizeof($cPath_array) > 0) { 850 for ($i=0, $n=sizeof($cPath_array)-1; $i<$n; $i++) { 851 if (empty($cPath_back)) { 852 $cPath_back .= $cPath_array[$i]; 853 } else { 854 $cPath_back .= '_' . $cPath_array[$i]; 855 } 856 } 857 } 858 859 $cPath_back = (tep_not_null($cPath_back)) ? 'cPath=' . $cPath_back . '&' : ''; 860 ?> 861 <tr> 862 <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 863 <tr> 864 <td class="smallText"><?php echo TEXT_CATEGORIES . ' ' . $categories_count . '<br>' . TEXT_PRODUCTS . ' ' . $products_count; ?></td> 865 <td align="right" class="smallText"><?php if (sizeof($cPath_array) > 0) echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, $cPath_back . 'cID=' . $current_category_id) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a> '; if (!isset($HTTP_GET_VARS['search'])) echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&action=new_category') . '">' . tep_image_button('button_new_category.gif', IMAGE_NEW_CATEGORY) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&action=new_product') . '">' . tep_image_button('button_new_product.gif', IMAGE_NEW_PRODUCT) . '</a>'; ?> </td> 866 </tr> 867 </table></td> 868 </tr> 869 </table></td> 870 <?php 871 $heading = array(); 872 $contents = array(); 873 switch ($action) { 874 case 'new_category': 875 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_CATEGORY . '</b>'); 876 877 $contents = array('form' => tep_draw_form('newcategory', FILENAME_CATEGORIES, 'action=insert_category&cPath=' . $cPath, 'post', 'enctype="multipart/form-data"')); 878 $contents[] = array('text' => TEXT_NEW_CATEGORY_INTRO); 879 880 $category_inputs_string = ''; 881 $languages = tep_get_languages(); 882 for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { 883 $category_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('categories_name[' . $languages[$i]['id'] . ']'); 884 } 885 886 $contents[] = array('text' => '<br>' . TEXT_CATEGORIES_NAME . $category_inputs_string); 887 $contents[] = array('text' => '<br>' . TEXT_CATEGORIES_IMAGE . '<br>' . tep_draw_file_field('categories_image')); 888 $contents[] = array('text' => '<br>' . TEXT_SORT_ORDER . '<br>' . tep_draw_input_field('sort_order', '', 'size="2"')); 889 $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); 890 break; 891 case 'edit_category': 892 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_CATEGORY . '</b>'); 893 894 $contents = array('form' => tep_draw_form('categories', FILENAME_CATEGORIES, 'action=update_category&cPath=' . $cPath, 'post', 'enctype="multipart/form-data"') . tep_draw_hidden_field('categories_id', $cInfo->categories_id)); 895 $contents[] = array('text' => TEXT_EDIT_INTRO); 896 897 $category_inputs_string = ''; 898 $languages = tep_get_languages(); 899 for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { 900 $category_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('categories_name[' . $languages[$i]['id'] . ']', tep_get_category_name($cInfo->categories_id, $languages[$i]['id'])); 901 } 902 903 $contents[] = array('text' => '<br>' . TEXT_EDIT_CATEGORIES_NAME . $category_inputs_string); 904 $contents[] = array('text' => '<br>' . tep_image(DIR_WS_CATALOG_IMAGES . $cInfo->categories_image, $cInfo->categories_name) . '<br>' . DIR_WS_CATALOG_IMAGES . '<br><b>' . $cInfo->categories_image . '</b>'); 905 $contents[] = array('text' => '<br>' . TEXT_EDIT_CATEGORIES_IMAGE . '<br>' . tep_draw_file_field('categories_image')); 906 $contents[] = array('text' => '<br>' . TEXT_EDIT_SORT_ORDER . '<br>' . tep_draw_input_field('sort_order', $cInfo->sort_order, 'size="2"')); 907 $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); 908 break; 909 case 'delete_category': 910 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_CATEGORY . '</b>'); 911 912 $contents = array('form' => tep_draw_form('categories', FILENAME_CATEGORIES, 'action=delete_category_confirm&cPath=' . $cPath) . tep_draw_hidden_field('categories_id', $cInfo->categories_id)); 913 $contents[] = array('text' => TEXT_DELETE_CATEGORY_INTRO); 914 $contents[] = array('text' => '<br><b>' . $cInfo->categories_name . '</b>'); 915 if ($cInfo->childs_count > 0) $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_CHILDS, $cInfo->childs_count)); 916 if ($cInfo->products_count > 0) $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_PRODUCTS, $cInfo->products_count)); 917 $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); 918 break; 919 case 'move_category': 920 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_MOVE_CATEGORY . '</b>'); 921 922 $contents = array('form' => tep_draw_form('categories', FILENAME_CATEGORIES, 'action=move_category_confirm&cPath=' . $cPath) . tep_draw_hidden_field('categories_id', $cInfo->categories_id)); 923 $contents[] = array('text' => sprintf(TEXT_MOVE_CATEGORIES_INTRO, $cInfo->categories_name)); 924 $contents[] = array('text' => '<br>' . sprintf(TEXT_MOVE, $cInfo->categories_name) . '<br>' . tep_draw_pull_down_menu('move_to_category_id', tep_get_category_tree(), $current_category_id)); 925 $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_move.gif', IMAGE_MOVE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); 926 break; 927 case 'delete_product': 928 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_PRODUCT . '</b>'); 929 930 $contents = array('form' => tep_draw_form('products', FILENAME_CATEGORIES, 'action=delete_product_confirm&cPath=' . $cPath) . tep_draw_hidden_field('products_id', $pInfo->products_id)); 931 $contents[] = array('text' => TEXT_DELETE_PRODUCT_INTRO); 932 $contents[] = array('text' => '<br><b>' . $pInfo->products_name . '</b>'); 933 934 $product_categories_string = ''; 935 $product_categories = tep_generate_category_path($pInfo->products_id, 'product'); 936 for ($i = 0, $n = sizeof($product_categories); $i < $n; $i++) { 937 $category_path = ''; 938 for ($j = 0, $k = sizeof($product_categories[$i]); $j < $k; $j++) { 939 $category_path .= $product_categories[$i][$j]['text'] . ' > '; 940 } 941 $category_path = substr($category_path, 0, -16); 942 $product_categories_string .= tep_draw_checkbox_field('product_categories[]', $product_categories[$i][sizeof($product_categories[$i])-1]['id'], true) . ' ' . $category_path . '<br>'; 943 } 944 $product_categories_string = substr($product_categories_string, 0, -4); 945 946 $contents[] = array('text' => '<br>' . $product_categories_string); 947 $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); 948 break; 949 case 'move_product': 950 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_MOVE_PRODUCT . '</b>'); 951 952 $contents = array('form' => tep_draw_form('products', FILENAME_CATEGORIES, 'action=move_product_confirm&cPath=' . $cPath) . tep_draw_hidden_field('products_id', $pInfo->products_id)); 953 $contents[] = array('text' => sprintf(TEXT_MOVE_PRODUCTS_INTRO, $pInfo->products_name)); 954 $contents[] = array('text' => '<br>' . TEXT_INFO_CURRENT_CATEGORIES . '<br><b>' . tep_output_generated_category_path($pInfo->products_id, 'product') . '</b>'); 955 $contents[] = array('text' => '<br>' . sprintf(TEXT_MOVE, $pInfo->products_name) . '<br>' . tep_draw_pull_down_menu('move_to_category_id', tep_get_category_tree(), $current_category_id)); 956 $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_move.gif', IMAGE_MOVE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); 957 break; 958 case 'copy_to': 959 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_COPY_TO . '</b>'); 960 961 $contents = array('form' => tep_draw_form('copy_to', FILENAME_CATEGORIES, 'action=copy_to_confirm&cPath=' . $cPath) . tep_draw_hidden_field('products_id', $pInfo->products_id)); 962 $contents[] = array('text' => TEXT_INFO_COPY_TO_INTRO); 963 $contents[] = array('text' => '<br>' . TEXT_INFO_CURRENT_CATEGORIES . '<br><b>' . tep_output_generated_category_path($pInfo->products_id, 'product') . '</b>'); 964 $contents[] = array('text' => '<br>' . TEXT_CATEGORIES . '<br>' . tep_draw_pull_down_menu('categories_id', tep_get_category_tree(), $current_category_id)); 965 $contents[] = array('text' => '<br>' . TEXT_HOW_TO_COPY . '<br>' . tep_draw_radio_field('copy_as', 'link', true) . ' ' . TEXT_COPY_AS_LINK . '<br>' . tep_draw_radio_field('copy_as', 'duplicate') . ' ' . TEXT_COPY_AS_DUPLICATE); 966 $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_copy.gif', IMAGE_COPY) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'); 967 break; 968 default: 969 if ($rows > 0) { 970 if (isset($cInfo) && is_object($cInfo)) { // category info box contents 971 $heading[] = array('text' => '<b>' . $cInfo->categories_name . '</b>'); 972 973 $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=edit_category') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=delete_category') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=move_category') . '">' . tep_image_button('button_move.gif', IMAGE_MOVE) . '</a>'); 974 $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . tep_date_short($cInfo->date_added)); 975 if (tep_not_null($cInfo->last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($cInfo->last_modified)); 976 $contents[] = array('text' => '<br>' . tep_info_image($cInfo->categories_image, $cInfo->categories_name, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT) . '<br>' . $cInfo->categories_image); 977 $contents[] = array('text' => '<br>' . TEXT_SUBCATEGORIES . ' ' . $cInfo->childs_count . '<br>' . TEXT_PRODUCTS . ' ' . $cInfo->products_count); 978 } elseif (isset($pInfo) && is_object($pInfo)) { // product info box contents 979 $heading[] = array('text' => '<b>' . tep_get_products_name($pInfo->products_id, $languages_id) . '</b>'); 980 981 $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=new_product') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=delete_product') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=move_product') . '">' . tep_image_button('button_move.gif', IMAGE_MOVE) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=copy_to') . '">' . tep_image_button('button_copy_to.gif', IMAGE_COPY_TO) . '</a>'); 982 $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . tep_date_short($pInfo->products_date_added)); 983 if (tep_not_null($pInfo->products_last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($pInfo->products_last_modified)); 984 if (date('Y-m-d') < $pInfo->products_date_available) $contents[] = array('text' => TEXT_DATE_AVAILABLE . ' ' . tep_date_short($pInfo->products_date_available)); 985 $contents[] = array('text' => '<br>' . tep_info_image($pInfo->products_image, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $pInfo->products_image); 986 $contents[] = array('text' => '<br>' . TEXT_PRODUCTS_PRICE_INFO . ' ' . $currencies->format($pInfo->products_price) . '<br>' . TEXT_PRODUCTS_QUANTITY_INFO . ' ' . $pInfo->products_quantity); 987 $contents[] = array('text' => '<br>' . TEXT_PRODUCTS_AVERAGE_RATING . ' ' . number_format($pInfo->average_rating, 2) . '%'); 988 } 989 } else { // create category/product info 990 $heading[] = array('text' => '<b>' . EMPTY_CATEGORY . '</b>'); 991 992 $contents[] = array('text' => TEXT_NO_CHILD_CATEGORIES_OR_PRODUCTS); 993 } 994 break; 995 } 996 997 if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { 998 echo ' <td width="25%" valign="top">' . "\n"; 999 1000 $box = new box; 1001 echo $box->infoBox($heading, $contents); 1002 1003 echo ' </td>' . "\n"; 1004 } 1005 ?> 1006 </tr> 1007 </table></td> 1008 </tr> 1009 </table> 1010 <?php 1011 } 1012 ?> 1013 </td> 1014 <!-- body_text_eof //--> 1015 </tr> 1016 </table> 1017 <!-- body_eof //--> 1018 1019 <!-- footer //--> 1020 <?php require (DIR_WS_INCLUDES . 'footer.php'); ?> 1021 <!-- footer_eof //--> 1022 <br> 1023 </body> 1024 </html> 1025 <?php require (DIR_WS_INCLUDES . 'application_bottom.php'); ?>
title
Description
Body
title
Description
Body
| Generated: Tue Nov 4 23:53:39 2003 | Hosted By :: AABox.com |
Cross-referenced by PHPXref 0.4 |