[TEP-COMMIT] [CVS admin] update to the template structure
anonymous-OfajU3CKLf1/[email protected] 22 Jul 2004 23:26:57 -0000
| Newsgroups | gmane.comp.web.oscommerce.cvs |
|---|---|
| Message-ID | <[email protected]> |
Commit in admin/admin on MAIN
categories.php +339 -906 1.151 -> 1.152
templates/pages/categories_new_product.php +251 added 1.1
/categories_new_product_preview.php +122 added 1.1
/categories.php +328 added 1.1
+1040 -906
3 added + 1 modified, total 4 files
update to the template structure
----------
admin /admin
categories.php 1.151 -> 1.152
diff -u -r1.151 -r1.152
--- categories.php 2004/07/22 22:03:57 1.151
+++ categories.php 2004/07/22 23:26:52 1.152
@@ -5,1032 +5,465 @@
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
- Copyright (c) 2003 osCommerce
+ Copyright (c) 2004 osCommerce
Released under the GNU General Public License
*/
require('includes/application_top.php');
- require(DIR_WS_CLASSES . 'currencies.php');
- $currencies = new currencies();
+ $selected_box = 'catalog';
- $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
+// calculate category path
+ $cPath = (isset($_GET['cPath']) ? $_GET['cPath'] : '');
- if (tep_not_null($action)) {
- switch ($action) {
- case 'setflag':
- if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {
- if (isset($HTTP_GET_VARS['pID'])) {
- tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);
- }
-
- if (USE_CACHE == 'true') {
- tep_reset_cache_block('categories');
- tep_reset_cache_block('also_purchased');
- }
- }
-
- tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID']));
- break;
- case 'insert_category':
- case 'update_category':
- if (isset($HTTP_POST_VARS['categories_id'])) $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
- $sort_order = tep_db_prepare_input($HTTP_POST_VARS['sort_order']);
-
- $sql_data_array = array('sort_order' => $sort_order);
-
- if ($action == 'insert_category') {
- $insert_sql_data = array('parent_id' => $current_category_id,
- 'date_added' => 'now()');
-
- $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
-
- tep_db_perform(TABLE_CATEGORIES, $sql_data_array);
-
- $categories_id = tep_db_insert_id();
- } elseif ($action == 'update_category') {
- $update_sql_data = array('last_modified' => 'now()');
+ if (tep_not_null($cPath)) {
+ $cPath_array = tep_parse_category_path($cPath);
+ $cPath = implode('_', $cPath_array);
+ $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
+ } else {
+ $current_category_id = 0;
+ }
- $sql_data_array = array_merge($sql_data_array, $update_sql_data);
+ $action = (isset($_GET['action']) ? $_GET['action'] : '');
- tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'");
+ if (!empty($action)) {
+ switch ($action) {
+ case 'save_category':
+ $category_id = '';
+ $error = false;
+
+ $osC_Database->startTransaction();
+
+ if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
+ $Qcat = $osC_Database->query('update :table_categories set sort_order = :sort_order, last_modified = now() where categories_id = :categories_id');
+ $Qcat->bindInt(':categories_id', $_GET['cID']);
+ } else {
+ $Qcat = $osC_Database->query('insert into :table_categories (parent_id, sort_order, date_added) values (:parent_id, :sort_order, now())');
+ $Qcat->bindInt(':parent_id', $current_category_id);
}
-
- $languages = tep_get_languages();
- for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
- $categories_name_array = $HTTP_POST_VARS['categories_name'];
+ $Qcat->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qcat->bindInt(':sort_order', $_POST['sort_order']);
+ $Qcat->execute();
- $language_id = $languages[$i]['id'];
+ if ($osC_Database->isError() === false) {
+ $category_id = (isset($_GET['cID']) && is_numeric($_GET['cID'])) ? $_GET['cID'] : $osC_Database->nextID();
- $sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]));
+ $languages = tep_get_languages();
- if ($action == 'insert_category') {
- $insert_sql_data = array('categories_id' => $categories_id,
- 'language_id' => $languages[$i]['id']);
+ foreach ($languages as $l_entry) {
+ if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
+ $Qcd = $osC_Database->query('update :table_categories_description set categories_name = :categories_name where categories_id = :categories_id and language_id = :language_id');
+ } else {
+ $Qcd = $osC_Database->query('insert into :table_categories_description (categories_id, language_id, categories_name) values (:categories_id, :language_id, :categories_name)');
+ }
+ $Qcd->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
+ $Qcd->bindInt(':categories_id', $category_id);
+ $Qcd->bindInt(':language_id', $l_entry['id']);
+ $Qcd->bindValue(':categories_name', $_POST['categories_name'][$l_entry['id']]);
+ $Qcd->execute();
+
+ if ($osC_Database->isError()) {
+ $error = true;
+ break;
+ }
+ }
- $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
+ if (($error === false) && ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES))) {
+ $Qcf = $osC_Database->query('update :table_categories set categories_image = :categories_image where categories_id = :categories_id');
+ $Qcf->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qcf->bindValue(':categories_image', $categories_image->filename);
+ $Qcf->bindInt(':categories_id', $category_id);
+ $Qcf->execute();
- tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array);
- } elseif ($action == 'update_category') {
- tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
+ if ($osC_Database->isError()) {
+ $error = true;
+ }
}
+ } else {
+ $error = true;
}
- if ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES)) {
- tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");
- }
+ if ($error === false) {
+ $osC_Database->commitTransaction();
- if (USE_CACHE == 'true') {
tep_reset_cache_block('categories');
tep_reset_cache_block('also_purchased');
+
+ $messageStack->add_session(SUCCESS_DB_ROWS_UPDATED, 'success');
+ } else {
+ $osC_Database->rollbackTransaction();
+
+ $messageStack->add_session(ERROR_DB_ROWS_NOT_UPDATED, 'error');
}
- tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
+ tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $category_id));
break;
case 'delete_category_confirm':
- if (isset($HTTP_POST_VARS['categories_id'])) {
- $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
-
- $categories = tep_get_category_tree($categories_id, '', '0', '', true);
+ if (isset($_GET['cID']) && is_numeric($_GET['cID'])) {
+ $categories = tep_get_category_tree($_GET['cID'], '', '0', '', true);
$products = array();
$products_delete = array();
- for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
- $product_ids_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$categories[$i]['id'] . "'");
+ foreach ($categories as $c_entry) {
+ $Qproducts = $osC_Database->query('select products_id from :table_products_to_categories where categories_id = :categories_id');
+ $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qproducts->bindInt(':categories_id', $c_entry['id']);
+ $Qproducts->execute();
- while ($product_ids = tep_db_fetch_array($product_ids_query)) {
- $products[$product_ids['products_id']]['categories'][] = $categories[$i]['id'];
+ while ($Qproducts->next()) {
+ $products[$Qproducts->valueInt('products_id')]['categories'][] = $c_entry['id'];
}
}
- reset($products);
- while (list($key, $value) = each($products)) {
- $category_ids = '';
+ foreach ($products as $key => $value) {
+ $Qcheck = $osC_Database->query('select count(*) as total from :table_products_to_categories where products_id = :products_id and categories_id not in :categories_id');
+ $Qcheck->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qcheck->bindInt(':products_id', $key);
+ $Qcheck->bindRaw(':categories_id', '("' . implode('", "', $value['categories']) . '")');
+ $Qcheck->execute();
- for ($i=0, $n=sizeof($value['categories']); $i<$n; $i++) {
- $category_ids .= "'" . (int)$value['categories'][$i] . "', ";
- }
- $category_ids = substr($category_ids, 0, -2);
-
- $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 . ")");
- $check = tep_db_fetch_array($check_query);
- if ($check['total'] < '1') {
+ if ($Qcheck->valueInt('total') < 1) {
$products_delete[$key] = $key;
}
}
-// removing categories can be a lengthy process
tep_set_time_limit(0);
- for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
- tep_remove_category($categories[$i]['id']);
+
+ foreach ($categories as $c_entry) {
+ tep_remove_category($c_entry['id']);
}
- reset($products_delete);
- while (list($key) = each($products_delete)) {
+ foreach ($products_delete as $key => $value) {
tep_remove_product($key);
}
- }
- if (USE_CACHE == 'true') {
tep_reset_cache_block('categories');
tep_reset_cache_block('also_purchased');
+
+ $messageStack->add_session(SUCCESS_DB_ROWS_UPDATED, 'success');
}
tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
break;
case 'delete_product_confirm':
- if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['product_categories']) && is_array($HTTP_POST_VARS['product_categories'])) {
- $product_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
- $product_categories = $HTTP_POST_VARS['product_categories'];
+ if (isset($_GET['pID']) && isset($_POST['product_categories']) && is_array($_POST['product_categories']) && !empty($_POST['product_categories'])) {
+ $Qpc = $osC_Database->query('delete from :table_products_to_categories where products_id = :products_id and categories_id in :categories_id');
+ $Qpc->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qpc->bindInt(':products_id', $_GET['pID']);
+ $Qpc->bindRaw(':categories_id', '("' . implode('", "', $_POST['product_categories']) . '")');
+ $Qpc->execute();
+
+ if ($osC_Database->isError() === false) {
+ $Qcheck = $osC_Database->query('select count(*) as total from :table_products_to_categories where products_id = :products_id');
+ $Qcheck->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qcheck->bindInt(':products_id', $_GET['pID']);
+ $Qcheck->execute();
- for ($i=0, $n=sizeof($product_categories); $i<$n; $i++) {
- tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "' and categories_id = '" . (int)$product_categories[$i] . "'");
- }
+ if ($Qcheck->valueInt('total') < 1) {
+ tep_remove_product($_GET['pID']);
+ }
- $product_categories_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'");
- $product_categories = tep_db_fetch_array($product_categories_query);
+ tep_reset_cache_block('categories');
+ tep_reset_cache_block('also_purchased');
- if ($product_categories['total'] == '0') {
- tep_remove_product($product_id);
+ $messageStack->add_session(SUCCESS_DB_ROWS_UPDATED, 'success');
}
}
- if (USE_CACHE == 'true') {
- tep_reset_cache_block('categories');
- tep_reset_cache_block('also_purchased');
- }
-
tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
break;
case 'move_category_confirm':
- if (isset($HTTP_POST_VARS['categories_id']) && ($HTTP_POST_VARS['categories_id'] != $HTTP_POST_VARS['move_to_category_id'])) {
- $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
- $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);
+ if (isset($_GET['cID']) && ($_GET['cID'] != $_POST['move_to_category_id'])) {
+ $path = explode('_', tep_get_generated_category_path_ids($_POST['move_to_category_id']));
- $path = explode('_', tep_get_generated_category_path_ids($new_parent_id));
-
- if (in_array($categories_id, $path)) {
+ if (in_array($_GET['cID'], $path)) {
$messageStack->add_session(ERROR_CANNOT_MOVE_CATEGORY_TO_PARENT, 'error');
-
- tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
} else {
- tep_db_query("update " . TABLE_CATEGORIES . " set parent_id = '" . (int)$new_parent_id . "', last_modified = now() where categories_id = '" . (int)$categories_id . "'");
+ $Qupdate = $osC_Database->query('update :table_categories set parent_id = :parent_id, last_modified = now() where categories_id = :categories_id');
+ $Qupdate->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qupdate->bindInt(':parent_id', $_POST['move_to_category_id']);
+ $Qupdate->bindInt(':categories_id', $_GET['cID']);
+ $Qupdate->execute();
- if (USE_CACHE == 'true') {
+ if ($Qupdate->affectedRows()) {
tep_reset_cache_block('categories');
tep_reset_cache_block('also_purchased');
- }
- tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&cID=' . $categories_id));
+ $messageStack->add_session(SUCCESS_DB_ROWS_UPDATED, 'success');
+
+ tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $_POST['move_to_category_id'] . '&cID=' . $_GET['cID']));
+ }
}
}
+ tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $_GET['cID']));
break;
case 'move_product_confirm':
- $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
- $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);
+ if (isset($_GET['pID']) && is_numeric($_GET['pID'])) {
+ $Qcheck = $osC_Database->query('select count(*) as total from :table_products_to_categories where products_id = :products_id and categories_id = :categories_id');
+ $Qcheck->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qcheck->bindInt(':products_id', $_GET['pID']);
+ $Qcheck->bindInt(':categories_id', $_POST['move_to_category_id']);
+ $Qcheck->execute();
+
+ if ($Qcheck->valueInt('total') < 1) {
+ $Qupdate = $osC_Database->query('update :table_products_to_categories set categories_id = :categories_id where products_id = :products_id and categories_id = :current_categories_id');
+ $Qupdate->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qupdate->bindInt(':categories_id', $_POST['move_to_category_id']);
+ $Qupdate->bindInt(':products_id', $_GET['pID']);
+ $Qupdate->bindInt(':current_categories_id', $current_category_id);
+ $Qupdate->execute();
- $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 . "'");
- $duplicate_check = tep_db_fetch_array($duplicate_check_query);
- 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 . "'");
+ if ($Qupdate->affectedRows()) {
+ tep_reset_cache_block('categories');
+ tep_reset_cache_block('also_purchased');
- if (USE_CACHE == 'true') {
- tep_reset_cache_block('categories');
- tep_reset_cache_block('also_purchased');
+ $messageStack->add_session(SUCCESS_DB_ROWS_UPDATED, 'success');
+
+ tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $_POST['move_to_category_id'] . '&pID=' . $_GET['pID']));
+ } else {
+ $messageStack->add_session(WARNING_DB_ROWS_NOT_UPDATED, 'warning');
+ }
+ }
}
- tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&pID=' . $products_id));
+ tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $_GET['pID']));
break;
- case 'insert_product':
- case 'update_product':
- if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) {
+ case 'save_product':
+ if (isset($_POST['product_edit'])) {
$action = 'new_product';
} else {
- if (isset($HTTP_GET_VARS['pID'])) $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);
- $products_date_available = tep_db_prepare_input($HTTP_POST_VARS['products_date_available']);
+ $error = false;
- $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';
+ $osC_Database->startTransaction();
- $sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),
- 'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']),
- 'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']),
- 'products_date_available' => $products_date_available,
- 'products_weight' => tep_db_prepare_input($HTTP_POST_VARS['products_weight']),
- 'products_weight_class' => tep_db_prepare_input($HTTP_POST_VARS['products_weight_class']),
- 'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']),
- 'products_tax_class_id' => tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']),
- 'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']));
-
- if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) {
- $sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']);
+ if (isset($_GET['pID']) && is_numeric($_GET['pID'])) {
+ $Qproduct = $osC_Database->query('update :table_products set products_quantity = :products_quantity, products_model = :products_model, products_price = :products_price, products_date_available = :products_date_available, products_weight = :products_weight, products_weight_class = :products_weight_class, products_status = :products_status, products_tax_class_id = :products_tax_class_id, manufacturers_id = :manufacturers_id, products_last_modified = now() where products_id = :products_id');
+ $Qproduct->bindInt(':products_id', $_GET['pID']);
+ } else {
+ $Qproduct = $osC_Database->query('insert into :table_products (products_quantity, products_model, products_price, products_date_available, products_weight, products_weight_class, products_status, products_tax_class_id, manufacturers_id, products_date_added) values (:products_quantity, :products_model, :products_price, :products_date_available, :products_weight, :products_weight_class, :products_status, :products_tax_class_id, :manufacturers_id, now())');
}
-
- if ($action == 'insert_product') {
- $insert_sql_data = array('products_date_added' => 'now()');
+ $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qproduct->bindInt(':products_quantity', $_POST['products_quantity']);
+ $Qproduct->bindValue(':products_model', $_POST['products_model']);
+ $Qproduct->bindValue(':products_price', $_POST['products_price']);
+ if (date('Y-m-d') < $_POST['products_date_available']) {
+ $Qproduct->bindValue(':products_date_available', $_POST['products_date_available']);
+ } else {
+ $Qproduct->bindRaw(':products_date_available', 'null');
+ }
+ $Qproduct->bindValue(':products_weight', $_POST['products_weight']);
+ $Qproduct->bindInt(':products_weight_class', $_POST['products_weight_class']);
+ $Qproduct->bindInt(':products_status', $_POST['products_status']);
+ $Qproduct->bindInt(':products_tax_class_id', $_POST['products_tax_class_id']);
+ $Qproduct->bindInt(':manufacturers_id', $_POST['manufacturers_id']);
+ $Qproduct->execute();
- $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
+ if ($osC_Database->isError()) {
+ $error = true;
+ } else {
+ if (isset($_GET['pID']) && is_numeric($_GET['pID'])) {
+ $products_id = $_GET['pID'];
+ } else {
+ $products_id = $osC_Database->nextID();
- tep_db_perform(TABLE_PRODUCTS, $sql_data_array);
- $products_id = tep_db_insert_id();
+ $Qp2c = $osC_Database->query('insert into :table_products_to_categories (products_id, categories_id) values (:products_id, :categories_id');
+ $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qp2c->bindInt(':products_id', $products_id);
+ $Qp2c->bindInt(':categories_id', $current_category_id);
+ $Qp2c->execute();
- tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')");
- } elseif ($action == 'update_product') {
- $update_sql_data = array('products_last_modified' => 'now()');
+ if ($osC_Database->isError()) {
+ $error = true;
+ }
+ }
+ }
- $sql_data_array = array_merge($sql_data_array, $update_sql_data);
+ if ($error === false) {
+ if (isset($_POST['products_image']) && !empty($_POST['products_image']) && ($_POST['products_image'] != 'none')) {
+ $Qimage = $osC_Database->query('update :table_products set products_image = :products_image where products_id = :products_id');
+ $Qimage->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qimage->bindValue(':products_image', $_POST['products_image']);
+ $Qimage->bindInt(':products_id', $products_id);
+ $Qimage->execute();
- tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");
+ if ($osC_Database->isError()) {
+ $error = true;
+ }
+ }
}
- $languages = tep_get_languages();
- for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
- $language_id = $languages[$i]['id'];
-
- $sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]),
- 'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]),
- 'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id]));
-
- if ($action == 'insert_product') {
- $insert_sql_data = array('products_id' => $products_id,
- 'language_id' => $language_id);
-
- $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
-
- tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
- } elseif ($action == 'update_product') {
- tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");
+ if ($error === false) {
+ $languages = tep_get_languages();
+ foreach ($languages as $l_entry) {
+ if (isset($_GET['pID']) && is_numeric($_GET['pID'])) {
+ $Qpd = $osC_Database->query('update :table_products_description set products_name = :products_name, products_description = :products_description, products_url = :products_url where products_id = :products_id and language_id = :language_id');
+ } else {
+ $Qpd = $osC_Database->query('insert into :table_products_description (products_id, language_id, products_name, products_description, products_url) values (:products_id, :language_id, :products_name, :products_description, :products_url)');
+ }
+ $Qpd->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
+ $Qpd->bindInt(':products_id', $products_id);
+ $Qpd->bindInt(':language_id', $l_entry['id']);
+ $Qpd->bindValue(':products_name', $_POST['products_name'][$l_entry['id']]);
+ $Qpd->bindValue(':products_description', $_POST['products_description'][$l_entry['id']]);
+ $Qpd->bindValue(':products_url', $_POST['products_url'][$l_entry['id']]);
+ $Qpd->execute();
+
+ if ($osC_Database->isError()) {
+ $error = true;
+ break;
+ }
}
}
+
+ if ($error === false) {
+ $osC_Database->commitTransaction();
- if (USE_CACHE == 'true') {
tep_reset_cache_block('categories');
tep_reset_cache_block('also_purchased');
+
+ $messageStack->add_session(SUCCESS_DB_ROWS_UPDATED, 'success');
+ } else {
+ $osC_Database->rollbackTransaction();
+
+ $messageStack->add_session(ERROR_DB_ROWS_NOT_UPDATED, 'error');
}
tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));
}
break;
case 'copy_to_confirm':
- if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['categories_id'])) {
- $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
- $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
-
- if ($HTTP_POST_VARS['copy_as'] == 'link') {
- if ($categories_id != $current_category_id) {
- $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 . "'");
- $check = tep_db_fetch_array($check_query);
- if ($check['total'] < '1') {
- tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$categories_id . "')");
+ if (isset($_GET['pID']) && isset($_POST['categories_id'])) {
+ if ($_POST['copy_as'] == 'link') {
+ if ($_POST['categories_id'] != $current_category_id) {
+ $Qcheck = $osC_Database->query('select count(*) as total from :table_products_to_categories where products_id = :products_id and categories_id = :categories_id');
+ $Qcheck->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qcheck->bindInt(':products_id', $_GET['pID']);
+ $Qcheck->bindInt(':categories_id', $_POST['categories_id']);
+ $Qcheck->execute();
+
+ if ($Qcheck->valueInt('total') < 1) {
+ $Qcat = $osC_Database->query('insert into :table_products_to_categories (products_id, categories_id) values (:products_id, :categories_id)');
+ $Qcat->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qcat->bindInt(':products_id', $_GET['pID']);
+ $Qcat->bindInt(':categories_id', $_POST['categories_id']);
+ $Qcat->execute();
+
+ if ($Qcat->affectedRows()) {
+ $messageStack->add_session(SUCCESS_DB_ROWS_UPDATED, 'success');
+
+ tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $_POST['categories_id'] . '&pID=' . $_GET['pID']));
+ }
}
} else {
$messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error');
- }
- } elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') {
- $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 . "'");
- $product = tep_db_fetch_array($product_query);
-
- 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'] . "')");
- $dup_products_id = tep_db_insert_id();
-
- $description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
- while ($description = tep_db_fetch_array($description_query)) {
- 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')");
}
+ } elseif ($_POST['copy_as'] == 'duplicate') {
+ $Qproduct = $osC_Database->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 = :products_id');
+ $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qproduct->bindInt(':products_id', $_GET['pID']);
+ $Qproduct->execute();
+
+ if ($Qproduct->numberOfRows() === 1) {
+ $error = false;
+
+ $osC_Database->startTransaction();
+
+ $Qnew = $osC_Database->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 (:products_quantity, :products_model, :products_image, :products_price, now(), :products_date_available, :products_weight, 0, :products_tax_class_id, :manufacturers_id)');
+ $Qnew->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qnew->bindInt(':products_quantity', $Qproduct->valueInt('products_quantity'));
+ $Qnew->bindValue(':products_model', $Qproduct->value('products_model'));
+ $Qnew->bindValue(':products_image', $Qproduct->value('products_image'));
+ $Qnew->bindValue(':products_price', $Qproduct->value('products_price'));
+ $Qnew->bindValue(':products_date_available', $Qproduct->value('products_date_available'));
+ $Qnew->bindValue(':products_weight', $Qproduct->value('products_weight'));
+ $Qnew->bindInt(':products_tax_class_id', $Qproduct->valueInt('products_tax_class_id'));
+ $Qnew->bindInt(':manufacturers_id', $Qproduct->valueInt('manufacturers_id'));
+ $Qnew->execute();
+
+ if ($Qnew->affectedRows()) {
+ $new_product_id = $osC_Database->nextID();
+
+ $Qdesc = $osC_Database->query('select language_id, products_name, products_description, products_url from :table_products_description where products_id = :products_id');
+ $Qdesc->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
+ $Qdesc->bindInt(':products_id', $_GET['pID']);
+ $Qdesc->execute();
+
+ while ($Qdesc->next()) {
+ $Qnewdesc = $osC_Database->query('insert into :table_products_description (products_id, language_id, products_name, products_description, products_url, products_viewed) values (:products_id, :language_id, :products_name, :products_description, :products_url, 0)');
+ $Qnewdesc->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
+ $Qnewdesc->bindInt(':products_id', $new_product_id);
+ $Qnewdesc->bindInt(':language_id', $Qdesc->valueInt('language_id'));
+ $Qnewdesc->bindValue(':products_name', $Qdesc->value('products_name'));
+ $Qnewdesc->bindValue(':products_description', $Qdesc->value('products_description'));
+ $Qnewdesc->bindValue(':products_url', $Qdesc->value('products_url'));
+ $Qnewdesc->execute();
+
+ if ($osC_Database->isError()) {
+ $error = true;
+
+ break;
+ }
+ }
+
+ if ($error === false) {
+ $Qp2c = $osC_Database->query('insert into :table_products_to_categories (products_id, categories_id) values (:products_id, :categories_id)');
+ $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qp2c->bindInt(':products_id', $new_product_id);
+ $Qp2c->bindInt(':categories_id', $_POST['categories_id']);
+ $Qp2c->execute();
+
+ if ($osC_Database->isError()) {
+ $error = true;
+ }
+ }
+ } else {
+ $error = true;
+ }
- tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");
- $products_id = $dup_products_id;
- }
+ if ($error === false) {
+ $osC_Database->commitTransaction();
- if (USE_CACHE == 'true') {
- tep_reset_cache_block('categories');
- tep_reset_cache_block('also_purchased');
- }
- }
+ tep_reset_cache_block('categories');
+ tep_reset_cache_block('also_purchased');
- tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $categories_id . '&pID=' . $products_id));
- break;
- case 'new_product_preview':
- if (!isset($HTTP_GET_VARS['read'])) {
-// copy image only if modified
- $products_image = new upload('products_image');
- $products_image->set_destination(DIR_FS_CATALOG_IMAGES);
- if ($products_image->parse() && $products_image->save()) {
- $products_image_name = $products_image->filename;
- } else {
- $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
+ $messageStack->add_session(SUCCESS_DB_ROWS_UPDATED, 'success');
+
+ tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $_POST['categories_id'] . '&pID=' . $new_product_id));
+ } else {
+ $osC_Database->rollbackTransaction();
+
+ $messageStack->add_session(ERROR_DB_ROWS_NOT_UPDATED, 'error');
+ }
+ }
}
}
+
+ tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $_GET['pID']));
break;
}
}
+ require('../includes/classes/currencies.php');
+ $osC_Currencies = new osC_Currencies();
+
// check if the catalog image directory exists
if (is_dir(DIR_FS_CATALOG_IMAGES)) {
- if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
- } else {
- $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
- }
-?>
-<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html <?php echo HTML_PARAMS; ?>>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
-<title><?php echo TITLE; ?></title>
-<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
-<script language="javascript" src="includes/general.js"></script>
-</head>
-<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
-<div id="spiffycalendar" class="text"></div>
-<!-- header //-->
-<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
-<!-- header_eof //-->
-
-<!-- body //-->
-<table border="0" width="100%" cellspacing="2" cellpadding="2">
- <tr>
- <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
-<!-- left_navigation //-->
-<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
-<!-- left_navigation_eof //-->
- </table></td>
-<!-- body_text //-->
- <td width="100%" valign="top">
-<?php
- if ($action == 'new_product') {
- $parameters = array('products_name' => '',
- 'products_description' => '',
- 'products_url' => '',
- 'products_id' => '',
- 'products_quantity' => '',
- 'products_model' => '',
- 'products_image' => '',
- 'products_price' => '',
- 'products_weight' => '',
- 'products_weight_class' => SHIPPING_WEIGHT_UNIT,
- 'products_date_added' => '',
- 'products_last_modified' => '',
- 'products_date_available' => '',
- 'products_status' => '',
- 'products_tax_class_id' => '',
- 'manufacturers_id' => '');
-
- $pInfo = new objectInfo($parameters);
-
- if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) {
- $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_weight_class, 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 . "'");
- $product = tep_db_fetch_array($product_query);
-
- $pInfo->objectInfo($product);
- } elseif (tep_not_null($HTTP_POST_VARS)) {
- $pInfo->objectInfo($HTTP_POST_VARS);
- $products_name = $HTTP_POST_VARS['products_name'];
- $products_description = $HTTP_POST_VARS['products_description'];
- $products_url = $HTTP_POST_VARS['products_url'];
+ if (!is_writeable(DIR_FS_CATALOG_IMAGES)) {
+ $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
}
-
- $manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE));
- $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
- while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
- $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],
- 'text' => $manufacturers['manufacturers_name']);
- }
-
- $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
- $tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
- while ($tax_class = tep_db_fetch_array($tax_class_query)) {
- $tax_class_array[] = array('id' => $tax_class['tax_class_id'],
- 'text' => $tax_class['tax_class_title']);
- }
-
- $languages = tep_get_languages();
-
- if (!isset($pInfo->products_status)) $pInfo->products_status = '1';
- switch ($pInfo->products_status) {
- case '0': $in_status = false; $out_status = true; break;
- case '1':
- default: $in_status = true; $out_status = false;
- }
-
- $weight_class_array = array();
- $weight_class_query = tep_db_query("select weight_class_id, weight_class_title from " . TABLE_WEIGHT_CLASS . " where language_id = '" . (int)$languages_id . "' order by weight_class_title");
- while ($weight_class = tep_db_fetch_array($weight_class_query)) {
- $weight_class_array[] = array('id' => $weight_class['weight_class_id'],
- 'text' => $weight_class['weight_class_title']);
- }
-?>
-<link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
-<script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
-<script language="javascript"><!--
- var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE);
-//--></script>
-<script language="javascript"><!--
-var tax_rates = new Array();
-<?php
- for ($i=0, $n=sizeof($tax_class_array); $i<$n; $i++) {
- if ($tax_class_array[$i]['id'] > 0) {
- echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . tep_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "\n";
- }
- }
-?>
-
-function doRound(x, places) {
- return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
-}
-
-function getTaxRate() {
- var selected_value = document.forms["new_product"].products_tax_class_id.selectedIndex;
- var parameterVal = document.forms["new_product"].products_tax_class_id[selected_value].value;
-
- if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) {
- return tax_rates[parameterVal];
} else {
- return 0;
- }
-}
-
-function updateGross() {
- var taxRate = getTaxRate();
- var grossValue = document.forms["new_product"].products_price.value;
-
- if (taxRate > 0) {
- grossValue = grossValue * ((taxRate / 100) + 1);
+ $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
}
-
- document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4);
-}
-
-function updateNet() {
- var taxRate = getTaxRate();
- var netValue = document.forms["new_product"].products_price_gross.value;
- if (taxRate > 0) {
- netValue = netValue / ((taxRate / 100) + 1);
+ switch ($action) {
+ case 'new_product': $page_contents = 'categories_new_product.php'; break;
+ case 'new_product_preview': $page_contents = 'categories_new_product_preview.php'; break;
+ default: $page_contents = 'categories.php';
}
-
- document.forms["new_product"].products_price.value = doRound(netValue, 4);
-}
-//--></script>
- <?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"'); ?>
- <table border="0" width="100%" cellspacing="0" cellpadding="2">
- <tr>
- <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
- <tr>
- <td class="pageHeading"><?php echo sprintf(TEXT_NEW_PRODUCT, tep_output_generated_category_path($current_category_id)); ?></td>
- <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
- </tr>
- </table></td>
- </tr>
- <tr>
- <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
- <tr>
- <td><table border="0" cellspacing="0" cellpadding="2">
- <tr>
- <td class="main"><?php echo TEXT_PRODUCTS_STATUS; ?></td>
- <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>
- </tr>
- <tr>
- <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
- <tr>
- <td class="main"><?php echo TEXT_PRODUCTS_DATE_AVAILABLE; ?><br><small>(YYYY-MM-DD)</small></td>
- <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>
- </tr>
- <tr>
- <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
- <tr>
- <td class="main"><?php echo TEXT_PRODUCTS_MANUFACTURER; ?></td>
- <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>
- </tr>
- <tr>
- <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
-<?php
- for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
-?>
- <tr>
- <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_NAME; ?></td>
- <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>
- </tr>
-<?php
- }
-?>
- <tr>
- <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
- <tr bgcolor="#ebebff">
- <td class="main"><?php echo TEXT_PRODUCTS_TAX_CLASS; ?></td>
- <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>
- </tr>
- <tr bgcolor="#ebebff">
- <td class="main"><?php echo TEXT_PRODUCTS_PRICE_NET; ?></td>
- <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>
- </tr>
- <tr bgcolor="#ebebff">
- <td class="main"><?php echo TEXT_PRODUCTS_PRICE_GROSS; ?></td>
- <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>
- </tr>
- <tr>
- <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
-<script language="javascript"><!--
-updateGross();
-//--></script>
-<?php
- for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
-?>
- <tr>
- <td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_DESCRIPTION; ?></td>
- <td><table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td>
- <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>
- </tr>
- </table></td>
- </tr>
-<?php
- }
-?>
- <tr>
- <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
- <tr>
- <td class="main"><?php echo TEXT_PRODUCTS_QUANTITY; ?></td>
- <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_quantity', $pInfo->products_quantity); ?></td>
- </tr>
- <tr>
- <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
- <tr>
- <td class="main"><?php echo TEXT_PRODUCTS_MODEL; ?></td>
- <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_model', $pInfo->products_model); ?></td>
- </tr>
- <tr>
- <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
- <tr>
- <td class="main"><?php echo TEXT_PRODUCTS_IMAGE; ?></td>
- <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>
- </tr>
- <tr>
- <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
-<?php
- for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
-?>
- <tr>
- <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_URL . '<br><small>' . TEXT_PRODUCTS_URL_WITHOUT_HTTP . '</small>'; ?></td>
- <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>
- </tr>
-<?php
- }
-?>
- <tr>
- <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
- <tr>
- <td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td>
- <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_weight', $pInfo->products_weight). ' ' . tep_draw_pull_down_menu('products_weight_class', $weight_class_array, $pInfo->products_weight_class); ?></td>
- </tr>
- </table></td>
- </tr>
- <tr>
- <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
- <tr>
- <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>
- </tr>
- </table></form>
-<?php
- } elseif ($action == 'new_product_preview') {
- if (tep_not_null($HTTP_POST_VARS)) {
- $pInfo = new objectInfo($HTTP_POST_VARS);
- $products_name = $HTTP_POST_VARS['products_name'];
- $products_description = $HTTP_POST_VARS['products_description'];
- $products_url = $HTTP_POST_VARS['products_url'];
- } else {
- $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'] . "'");
- $product = tep_db_fetch_array($product_query);
-
- $pInfo = new objectInfo($product);
- $products_image_name = $pInfo->products_image;
- }
-
- $form_action = (isset($HTTP_GET_VARS['pID'])) ? 'update_product' : 'insert_product';
-
- 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"');
-
- $languages = tep_get_languages();
- for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
- if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) {
- $pInfo->products_name = tep_get_products_name($pInfo->products_id, $languages[$i]['id']);
- $pInfo->products_description = tep_get_products_description($pInfo->products_id, $languages[$i]['id']);
- $pInfo->products_url = tep_get_products_url($pInfo->products_id, $languages[$i]['id']);
- } else {
- $pInfo->products_name = tep_db_prepare_input($products_name[$languages[$i]['id']]);
- $pInfo->products_description = tep_db_prepare_input($products_description[$languages[$i]['id']]);
- $pInfo->products_url = tep_db_prepare_input($products_url[$languages[$i]['id']]);
- }
-?>
- <table border="0" width="100%" cellspacing="0" cellpadding="2">
- <tr>
- <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
- <tr>
- <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>
- <td class="pageHeading" align="right"><?php echo $currencies->format($pInfo->products_price); ?></td>
- </tr>
- </table></td>
- </tr>
- <tr>
- <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
- <tr>
- <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>
- </tr>
-<?php
- if ($pInfo->products_url) {
-?>
- <tr>
- <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
- </tr>
- <tr>
- <td class="main"><?php echo sprintf(TEXT_PRODUCT_MORE_INFORMATION, $pInfo->products_url); ?></td>
- </tr>
-<?php
- }
-?>
[truncated at 1000 lines; 375 more skipped]
----------
admin /admin /templates /pages
categories_new_product.php added at 1.1
diff -N categories_new_product.php
--- /dev/null Fri Jul 23 01:26:52 2004
+++ /tmp/cvsAAA0xai3c Fri Jul 23 01:26:52 2004
@@ -0,0 +1,251 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2004 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ if (isset($_GET['pID']) && empty($_POST)) {
+ $Qp = $osC_Database->query('select products_id, products_quantity, products_model, products_image, products_price, products_weight, products_weight_class, products_date_added, products_last_modified, date_format(products_date_available, "%Y-%m-%d") as products_date_available, products_status, products_tax_class_id, manufacturers_id from :table_products where products_id = :products_id');
+ $Qp->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qp->bindInt(':products_id', $_GET['pID']);
+ $Qp->execute();
+
+ $Qpd = $osC_Database->query('select products_name, products_description, products_url, language_id from :table_products_description where products_id = :products_id');
+ $Qpd->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
+ $Qpd->bindInt(':products_id', $_GET['pID']);
+ $Qpd->execute();
+
+ $pd_extra = array();
+ while ($Qpd->next()) {
+ $pd_extra['products_name'][$Qpd->valueInt('language_id')] = $Qpd->value('products_name');
+ $pd_extra['products_description'][$Qpd->valueInt('language_id')] = $Qpd->value('products_description');
+ $pd_extra['products_url'][$Qpd->valueInt('language_id')] = $Qpd->value('products_url');
+ }
+
+ $pInfo = new objectInfo(array_merge($Qp->toArray(), $pd_extra));
+ } elseif (!empty($_POST)) {
+ $pInfo = new objectInfo($_POST);
+ }
+
+ $Qmanufacturers = $osC_Database->query('select manufacturers_id, manufacturers_name from :table_manufacturers order by manufacturers_name');
+ $Qmanufacturers->bindTable(':table_manufacturers', TABLE_MANUFACTURERS);
+ $Qmanufacturers->execute();
+
+ $manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE));
+ while ($Qmanufacturers->next()) {
+ $manufacturers_array[] = array('id' => $Qmanufacturers->valueInt('manufacturers_id'),
+ 'text' => $Qmanufacturers->value('manufacturers_name'));
+ }
+
+ $Qtc = $osC_Database->query('select tax_class_id, tax_class_title from :table_tax_class order by tax_class_title');
+ $Qtc->bindTable(':table_tax_class', TABLE_TAX_CLASS);
+ $Qtc->execute();
+
+ $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
+ while ($Qtc->next()) {
+ $tax_class_array[] = array('id' => $Qtc->valueInt('tax_class_id'),
+ 'text' => $Qtc->value('tax_class_title'));
+ }
+
+ $Qwc = $osC_Database->query('select weight_class_id, weight_class_title from :table_weight_class where language_id = :language_id order by weight_class_title');
+ $Qwc->bindTable(':table_weight_class', TABLE_WEIGHT_CLASS);
+ $Qwc->bindInt(':language_id', $osC_Session->value('languages_id'));
+ $Qwc->execute();
+
+ $weight_class_array = array();
+ while ($Qwc->next()) {
+ $weight_class_array[] = array('id' => $Qwc->valueInt('weight_class_id'),
+ 'text' => $Qwc->value('weight_class_title'));
+ }
+
+ $languages = tep_get_languages();
+?>
+<script type="text/javascript" src="external/FCKeditor/2.0b1/fckeditor.js"></script>
+<style type="text/css">@import url('external/jscalendar/0.9.6/calendar-win2k-1.css');</style>
+<script type="text/javascript" src="external/jscalendar/0.9.6/calendar.js"></script>
+<script type="text/javascript" src="external/jscalendar/0.9.6/lang/calendar-en.js"></script>
+<script type="text/javascript" src="external/jscalendar/0.9.6/calendar-setup.js"></script>
+<script language="javascript"><!--
+var tax_rates = new Array();
+<?php
+ foreach ($tax_class_array as $tc_entry) {
+ if ($tc_entry['id'] > 0) {
+ echo 'tax_rates["' . $tc_entry['id'] . '"] = ' . tep_get_tax_rate_value($tc_entry['id']) . ';' . "\n";
+ }
+ }
+?>
+
+function doRound(x, places) {
+ return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
+}
+
+function getTaxRate() {
+ var selected_value = document.forms["new_product"].products_tax_class_id.selectedIndex;
+ var parameterVal = document.forms["new_product"].products_tax_class_id[selected_value].value;
+
+ if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) {
+ return tax_rates[parameterVal];
+ } else {
+ return 0;
+ }
+}
+
+function updateGross() {
+ var taxRate = getTaxRate();
+ var grossValue = document.forms["new_product"].products_price.value;
+
+ if (taxRate > 0) {
+ grossValue = grossValue * ((taxRate / 100) + 1);
+ }
+
+ document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4);
+}
+
+function updateNet() {
+ var taxRate = getTaxRate();
+ var netValue = document.forms["new_product"].products_price_gross.value;
+
+ if (taxRate > 0) {
+ netValue = netValue / ((taxRate / 100) + 1);
+ }
+
+ document.forms["new_product"].products_price.value = doRound(netValue, 4);
+}
+//--></script>
+
+<h1><?php echo sprintf(TEXT_NEW_PRODUCT, tep_output_generated_category_path($current_category_id)); ?></h1>
+
+<?php
+ echo tep_draw_form('new_product', FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '') . '&action=new_product_preview', 'post', 'enctype="multipart/form-data"');
+?>
+
+<table border="0" width="100%" cellspacing="0" cellpadding="2">
+ <tr>
+ <td class="main"><?php echo TEXT_PRODUCTS_STATUS; ?></td>
+ <td class="main"><?php echo osc_draw_radio_field('products_status', array(array('id' => '1', 'text' => TEXT_PRODUCT_AVAILABLE), array('id' => '0', 'text' => TEXT_PRODUCT_NOT_AVAILABLE)), (isset($pInfo) ? $pInfo->products_status : '0')); ?></td>
+ </tr>
+ <tr>
+ <td class="smallText" colspan="2"> </td>
+ </tr>
+ <tr>
+ <td class="main"><?php echo TEXT_PRODUCTS_DATE_AVAILABLE; ?><br><small>(YYYY-MM-DD)</small></td>
+ <td class="main"><?php echo osc_draw_input_field('products_date_available', (isset($pInfo) ? $pInfo->products_date_available : ''), 'id="calendarValue"'); ?><input type="button" value="..." id="calendarTrigger" class="operationButton"><script type="text/javascript">Calendar.setup( { inputField: "calendarValue", ifFormat: "%Y-%m-%d", button: "calendarTrigger" } );</script></td>
+ </tr>
+ <tr>
+ <td class="smallText" colspan="2"> </td>
+ </tr>
+ <tr>
+ <td class="main"><?php echo TEXT_PRODUCTS_MANUFACTURER; ?></td>
+ <td class="main"><?php echo osc_draw_pull_down_menu('manufacturers_id', $manufacturers_array, (isset($pInfo) ? $pInfo->manufacturers_id : '')); ?></td>
+ </tr>
+ <tr>
+ <td class="smallText" colspan="2"> </td>
+ </tr>
+ <tr bgcolor="#fff3e7">
+ <td class="main"> </td>
+ <td>
+<?php
+ foreach ($languages as $l_entry) {
+ echo '<span id="lang_' . $l_entry['code'] . '"' . (($l_entry['directory'] == $osC_Session->value('language')) ? ' class="highlight"' : '') . '><a href="javascript:toggleDivBlocks(\'pName_\', \'pName_' . $l_entry['code'] . '\'); toggleDivBlocks(\'pDesc_\', \'pDesc_' . $l_entry['code'] . '\'); toggleDivBlocks(\'pURL_\', \'pURL_' . $l_entry['code'] . '\'); toggleClass(\'lang_\', \'lang_' . $l_entry['code'] . '\', \'highlight\', \'span\');">' . tep_image(DIR_WS_CATALOG_LANGUAGES . $l_entry['directory'] . '/images/' . $l_entry['image'], $l_entry['name']) . '</a></span> ';
+ }
+?>
+ </td>
+ </tr>
+ <tr bgcolor="#fff3e7">
+ <td class="main"><?php echo TEXT_PRODUCTS_NAME; ?></td>
+ <td>
+<?php
+ foreach ($languages as $l_entry) {
+ echo '<div id="pName_' . $l_entry['code'] . '"' . (($l_entry['directory'] != $osC_Session->value('language')) ? ' style="display: none;"' : '') . '>' . osc_draw_input_field('products_name[' . $l_entry['id'] . ']', (isset($pInfo) && is_array($pInfo->products_name) && isset($pInfo->products_name[$l_entry['id']]) ? $pInfo->products_name[$l_entry['id']] : '')) . '</div>';
+ }
+?>
+ </td>
+ </tr>
+ <tr bgcolor="#fff3e7">
+ <td class="main" valign="top"><?php echo TEXT_PRODUCTS_DESCRIPTION; ?></td>
+ <td>
+<?php
+ foreach ($languages as $l_entry) {
+ echo '<div id="pDesc_' . $l_entry['code'] . '"' . (($l_entry['directory'] != $osC_Session->value('language')) ? ' style="display: none;"' : '') . '>' . tep_draw_textarea_field('products_description[' . $l_entry['id'] . ']', 'soft', '70', '15', (isset($pInfo) && is_array($pInfo->products_description) && isset($pInfo->products_description[$l_entry['id']]) ? $pInfo->products_description[$l_entry['id']] : ''), 'id="fckpd_' . $l_entry['code'] . '" style="width: 100%;"') . '</div>';
+
+ echo '<script type="text/javascript">' . "\n" .
+ ' var fckpd_' . $l_entry['code'] . ' = new FCKeditor(\'fckpd_' . $l_entry['code'] . '\');' . "\n" .
+ ' fckpd_' . $l_entry['code'] . '.BasePath = "' . DIR_WS_ADMIN . 'external/FCKeditor/2.0b1/";' . "\n" .
+ ' fckpd_' . $l_entry['code'] . '.Height = "400";' . "\n" .
+ ' fckpd_' . $l_entry['code'] . '.ReplaceTextarea();' . "\n" .
+ '</script>';
+ }
+?>
+ </td>
+ </tr>
+ <tr bgcolor="#fff3e7">
+ <td class="main"><?php echo TEXT_PRODUCTS_URL . '<br><small>' . TEXT_PRODUCTS_URL_WITHOUT_HTTP . '</small>'; ?></td>
+ <td>
+<?php
+ foreach ($languages as $l_entry) {
+ echo '<div id="pURL_' . $l_entry['code'] . '"' . (($l_entry['directory'] != $osC_Session->value('language')) ? ' style="display: none;"' : '') . '>' . osc_draw_input_field('products_url[' . $l_entry['id'] . ']', (isset($pInfo) && is_array($pInfo->products_url) && isset($pInfo->products_url[$l_entry['id']]) ? $pInfo->products_url[$l_entry['id']] : '')) . '</div>';
+ }
+?>
+ </td>
+ </tr>
+ <tr>
+ <td class="smallText" colspan="2"> </td>
+ </tr>
+ <tr bgcolor="#ebebff">
+ <td class="main"><?php echo TEXT_PRODUCTS_TAX_CLASS; ?></td>
+ <td class="main"><?php echo osc_draw_pull_down_menu('products_tax_class_id', $tax_class_array, (isset($pInfo) ? $pInfo->products_tax_class_id : ''), 'onchange="updateGross()"'); ?></td>
+ </tr>
+ <tr bgcolor="#ebebff">
+ <td class="main"><?php echo TEXT_PRODUCTS_PRICE_NET; ?></td>
+ <td class="main"><?php echo osc_draw_input_field('products_price', (isset($pInfo) ? $pInfo->products_price : ''), 'onKeyUp="updateGross()"'); ?></td>
+ </tr>
+ <tr bgcolor="#ebebff">
+ <td class="main"><?php echo TEXT_PRODUCTS_PRICE_GROSS; ?></td>
+ <td class="main"><?php echo osc_draw_input_field('products_price_gross', (isset($pInfo) ? $pInfo->products_price : ''), 'OnKeyUp="updateNet()"'); ?></td>
+ </tr>
+<script language="javascript"><!--
+updateGross();
+//--></script>
+ <tr>
+ <td class="smallText" colspan="2"> </td>
+ </tr>
+ <tr>
+ <td class="main"><?php echo TEXT_PRODUCTS_QUANTITY; ?></td>
+ <td class="main"><?php echo osc_draw_input_field('products_quantity', (isset($pInfo) ? $pInfo->products_quantity : '')); ?></td>
+ </tr>
+ <tr>
+ <td class="smallText" colspan="2"> </td>
+ </tr>
+ <tr>
+ <td class="main"><?php echo TEXT_PRODUCTS_MODEL; ?></td>
+ <td class="main"><?php echo osc_draw_input_field('products_model', (isset($pInfo) ? $pInfo->products_model : '')); ?></td>
+ </tr>
+ <tr>
+ <td class="smallText" colspan="2"> </td>
+ </tr>
+ <tr>
+ <td class="main"><?php echo TEXT_PRODUCTS_IMAGE; ?></td>
+ <td class="main"><?php echo tep_draw_file_field('products_image') . '<br>' . (isset($pInfo) ? $pInfo->products_image . tep_draw_hidden_field('products_previous_image', $pInfo->products_image) : ''); ?></td>
+ </tr>
+ <tr>
+ <td class="smallText" colspan="2"> </td>
+ </tr>
+ <tr>
+ <td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td>
+ <td class="main"><?php echo osc_draw_input_field('products_weight', (isset($pInfo) ? $pInfo->products_weight : '')). ' ' . osc_draw_pull_down_menu('products_weight_class', $weight_class_array, (isset($pInfo) ? $pInfo->products_weight_class : SHIPPING_WEIGHT_UNIT)); ?></td>
+ </tr>
+ <tr>
+ <td class="smallText" colspan="2"> </td>
+ </tr>
+ <tr>
+ <td class="main" colspan="2" align="right"><?php echo osc_draw_hidden_field('products_date_added', (isset($pInfo) && isset($pInfo->products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))) . '<input type="submit" value="' . IMAGE_PREVIEW . '" class="operationButton"> <input type="button" value="' . IMAGE_CANCEL . '" onClick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '')) . '\';" class="operationButton">'; ?></td>
+ </tr>
+</table>
+
+</form>
----------
admin /admin /templates /pages
categories_new_product_preview.php added at 1.1
diff -N categories_new_product_preview.php
--- /dev/null Fri Jul 23 01:26:52 2004
+++ /tmp/cvsAAA7yay3c Fri Jul 23 01:26:52 2004
@@ -0,0 +1,122 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2004 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ if (isset($_GET['pID']) && empty($_POST)) {
+ $Qp = $osC_Database->query('select products_id, products_quantity, products_model, products_image, products_price, products_weight, products_weight_class, products_date_added, products_last_modified, date_format(products_date_available, "%Y-%m-%d") as products_date_available, products_status, products_tax_class_id, manufacturers_id from :table_products where products_id = :products_id');
+ $Qp->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qp->bindInt(':products_id', $_GET['pID']);
+ $Qp->execute();
+
+ $Qpd = $osC_Database->query('select products_name, products_description, products_url, language_id from :table_products_description where products_id = :products_id');
+ $Qpd->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
+ $Qpd->bindInt(':products_id', $_GET['pID']);
+ $Qpd->execute();
+
+ $pd_extra = array();
+ while ($Qpd->next()) {
+ $pd_extra['products_name'][$Qpd->valueInt('language_id')] = $Qpd->value('products_name');
+ $pd_extra['products_description'][$Qpd->valueInt('language_id')] = $Qpd->value('products_description');
+ $pd_extra['products_url'][$Qpd->valueInt('language_id')] = $Qpd->value('products_url');
+ }
+
+ $pInfo = new objectInfo(array_merge($Qp->toArray(), $pd_extra));
+
+ $products_image_name = $pInfo->products_image;
+ } else {
+ $pInfo = new objectInfo($_POST);
+
+ if (!isset($_GET['read'])) {
+// copy image only if modified
+ if ($products_image = new upload('products_image', DIR_FS_CATALOG_IMAGES)) {
+ $products_image_name = $products_image->filename;
+ } else {
+ $products_image_name = (isset($_POST['products_previous_image']) ? $_POST['products_previous_image'] : '');
+ }
+ }
+ }
+
+ $languages = tep_get_languages();
+
+ echo tep_draw_form('save_product', FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '') . '&action=save_product', 'post', 'enctype="multipart/form-data"');
+?>
+
+<table border="0" width="100%" cellspacing="0" cellpadding="2">
+ <tr bgcolor="#fff3e7">
+ <td>
+<?php
+ foreach ($languages as $l_entry) {
+ echo '<span id="lang_' . $l_entry['code'] . '"' . (($l_entry['directory'] == $osC_Session->value('language')) ? ' class="highlight"' : '') . '><a href="javascript:toggleDivBlocks(\'pName_\', \'pName_' . $l_entry['code'] . '\'); toggleClass(\'lang_\', \'lang_' . $l_entry['code'] . '\', \'highlight\', \'span\');">' . tep_image(DIR_WS_CATALOG_LANGUAGES . $l_entry['directory'] . '/images/' . $l_entry['image'], $l_entry['name']) . '</a></span> ';
+ }
+?>
+ </td>
+ </tr>
+</table>
+
+<?php
+ foreach ($languages as $l_entry) {
+?>
+
+<div id="pName_<?php echo $l_entry['code']; ?>" <?php echo (($l_entry['directory'] != $osC_Session->value('language')) ? ' style="display: none;"' : ''); ?>>
+ <table border="0" width="100%" cellspacing="0" cellpadding="2">
+ <tr>
+ <td><h1><?php echo $pInfo->products_name[$l_entry['id']]; ?></h1></td>
+ <td align="right"><h1><?php echo $osC_Currencies->format($pInfo->products_price); ?></h1></td>
+ </tr>
+ </table>
+
+ <p class="main"><?php echo tep_image(DIR_WS_CATALOG_IMAGES . $products_image_name, $pInfo->products_name[$l_entry['id']], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') . $pInfo->products_description[$l_entry['id']]; ?></p>
+
+<?php
+ if (!empty($pInfo->products_url[$l_entry['id']])) {
+ echo '<p class="main">' . sprintf(TEXT_PRODUCT_MORE_INFORMATION, $pInfo->products_url[$l_entry['id']]) . '</p>';
+ }
+?>
+
+<?php
+ if ($pInfo->products_date_available > date('Y-m-d')) {
+ echo '<p class="smallText" align="center">' . sprintf(TEXT_PRODUCT_DATE_AVAILABLE, tep_date_long($pInfo->products_date_available)) . '</p>';
+ } else {
+ echo '<p class="smallText" align="center">' . sprintf(TEXT_PRODUCT_DATE_ADDED, tep_date_long($pInfo->products_date_added)) . '</p>';
+ }
+?>
+
+</div>
+
+<?php
+ }
+
+ if (isset($_GET['read']) && ($_GET['read'] == 'only')) {
+ echo '<p align="right"><input type="button" value="' . IMAGE_BACK . '" onClick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id) . '\';" class="operationButton"></p>';
+ } else {
+ echo '<p align="right">';
+
+ foreach ($_POST as $key => $value) {
+ if (!is_array($_POST[$key])) {
+ echo osc_draw_hidden_field($key, $value);
+ }
+ }
+
+ foreach ($languages as $l_entry) {
+ echo osc_draw_hidden_field('products_name[' . $l_entry['id'] . ']', $pInfo->products_name[$l_entry['id']]) .
+ osc_draw_hidden_field('products_description[' . $l_entry['id'] . ']', $pInfo->products_description[$l_entry['id']]) .
+ osc_draw_hidden_field('products_url[' . $l_entry['id'] . ']', $pInfo->products_url[$l_entry['id']]);
+ }
+
+ echo osc_draw_hidden_field('products_image', $products_image_name);
+
+ echo '<input type="submit" value="' . IMAGE_BACK . '" name="product_edit" class="operationButton"> <input type="submit" value="' . (isset($_GET['pID']) ? IMAGE_UPDATE : IMAGE_INSERT) . '" class="operationButton"> <input type="button" value="' . IMAGE_CANCEL . '" onClick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '')) . '\';" class="operationButton">';
+
+ echo '</p>';
+ }
+?>
+
+</form>
----------
admin /admin /templates /pages
categories.php added at 1.1
diff -N categories.php
--- /dev/null Fri Jul 23 01:26:52 2004
+++ /tmp/cvsAAAnAaO3c Fri Jul 23 01:26:53 2004
@@ -0,0 +1,328 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2004 osCommerce
+
+ Released under the GNU General Public License
+*/
+?>
+
+<table border="0" width="100%" cellspacing="0" cellpadding="2">
+ <tr>
+ <td><h1><?php echo HEADING_TITLE; ?></h1></td>
+ <td class="smallText" align="right">
+<?php
+ echo tep_draw_form('search', FILENAME_CATEGORIES, '', 'get') .
+ HEADING_TITLE_SEARCH . ' ' . osc_draw_input_field('search') .
+ '<input type="submit" value="GO" class="operationButton"></form><br>' .
+ tep_draw_form('goto', FILENAME_CATEGORIES, '', 'get') .
+ HEADING_TITLE_GOTO . ' ' . osc_draw_pull_down_menu('cPath', tep_get_category_tree(), $current_category_id, 'onChange="this.form.submit();"') .
+ '</form>';
+?>
+ </td>
+ </tr>
+</table>
+
+<div id="infoBox_cDefault" <?php if (!empty($action)) { echo 'style="display: none;"'; } ?>>
+ <table border="0" width="100%" cellspacing="0" cellpadding="2" class="dataTable">
+ <thead>
+ <tr>
+ <th><?php echo TABLE_HEADING_CATEGORIES_PRODUCTS; ?></th>
+ <th><?php echo TABLE_HEADING_STATUS; ?></th>
+ <th><?php echo TABLE_HEADING_ACTION; ?></th>
+ </tr>
+ </thead>
+ <tbody>
+<?php
+ if (isset($_GET['search']) && !empty($_GET['search'])) {
+ $Qcategories = $osC_Database->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 = :language_id and cd.categories_name like :categories_name order by c.sort_order, cd.categories_name');
+ $Qcategories->bindValue(':categories_name', '%' . $_GET['search'] . '%');
+ } else {
+ $Qcategories = $osC_Database->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 = :parent_id and c.categories_id = cd.categories_id and cd.language_id = :language_id order by c.sort_order, cd.categories_name');
+ $Qcategories->bindInt(':parent_id', $current_category_id);
+ }
+ $Qcategories->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qcategories->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
+ $Qcategories->bindInt(':language_id', $osC_Session->value('languages_id'));
+ $Qcategories->execute();
+
+ while ($Qcategories->next()) {
+ if (isset($_GET['search']) && !empty($_GET['search'])) {
+ $cPath = $Qcategories->valueInt('parent_id');
+ }
+
+ if (!isset($cInfo) && (!isset($_GET['cID']) && !isset($_GET['pID']) || (isset($_GET['cID']) && ($_GET['cID'] == $Qcategories->valueInt('categories_id')))) && ($action != 'cNew')) {
+ $cInfo_extra = array('childs_count' => tep_childs_in_category_count($Qcategories->valueInt('categories_id')),
+ 'products_count' => tep_products_in_category_count($Qcategories->valueInt('categories_id')));
+
+ $cInfo = new objectInfo(array_merge($Qcategories->toArray(), $cInfo_extra));
+ }
+
+ if (isset($cInfo) && ($Qcategories->valueInt('categories_id') == $cInfo->categories_id)) {
+ echo ' <tr class="selected">' . "\n";
+ } else {
+ echo ' <tr onMouseOver="rowOverEffect(this);" onMouseOut="rowOutEffect(this);" onClick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $Qcategories->valueInt('categories_id')) . '\';">' . "\n";
+ }
+?>
+ <td><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, tep_get_path($Qcategories->valueInt('categories_id'))) . '">' . tep_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . ' <b>' . $Qcategories->value('categories_name') . '</b></a>'; ?></td>
+ <td align="center"><?php echo tep_image('templates/' . $template . '/images/icons/checkbox_ticked.gif'); ?></td>
+ <td align="right">
+<?php
+ if (isset($cInfo) && ($Qcategories->valueInt('categories_id') == $cInfo->categories_id)) {
+ echo '<a href="#" onClick="toggleInfoBox(\'cEdit\');">' . tep_image('templates/' . $template . '/images/icons/16x16/configure.png', IMAGE_EDIT, '16', '16') . '</a> ' .
+ '<a href="#" onClick="toggleInfoBox(\'cMove\');">' . tep_image('templates/' . $template . '/images/icons/16x16/move.png', IMAGE_MOVE, '16', '16') . '</a> ' .
+ '<a href="#" onClick="toggleInfoBox(\'cDelete\');">' . tep_image('templates/' . $template . '/images/icons/16x16/trash.png', IMAGE_DELETE, '16', '16') . '</a>';
+ } else {
+ echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $Qcategories->valueInt('categories_id') . '&action=cEdit') . '">' . tep_image('templates/' . $template . '/images/icons/16x16/configure.png', IMAGE_EDIT, '16', '16') . '</a> ' .
+ '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $Qcategories->valueInt('categories_id') . '&action=cMove') . '">' . tep_image('templates/' . $template . '/images/icons/16x16/move.png', IMAGE_MOVE, '16', '16') . ' </a>' .
+ '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $Qcategories->valueInt('categories_id') . '&action=cDelete') . '">' . tep_image('templates/' . $template . '/images/icons/16x16/trash.png', IMAGE_DELETE, '16', '16') . '</a>';
+ }
+?>
+ </td>
+ </tr>
+<?php
+ }
+
+ if (isset($_GET['search']) && !empty($_GET['search'])) {
+ $Qproducts = $osC_Database->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 = :language_id and p.products_id = p2c.products_id and pd.products_name like :products_name order by pd.products_name');
+ $Qproducts->bindValue(':products_name', '%' . $_GET['search'] . '%');
+ } else {
+ $Qproducts = $osC_Database->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 = :language_id and p.products_id = p2c.products_id and p2c.categories_id = :categories_id order by pd.products_name');
+ $Qproducts->bindInt(':categories_id', $current_category_id);
+ }
+ $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
+ $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qproducts->bindInt(':language_id', $osC_Session->value('languages_id'));
+ $Qproducts->execute();
+
+ while ($Qproducts->next()) {
+ if (isset($_GET['search']) && !empty($_GET['search'])) {
+ $cPath = $Qproducts->valueInt('categories_id');
+ }
+
+ if (!isset($pInfo) && !isset($cInfo) && (!isset($_GET['pID']) && !isset($_GET['cID']) || (isset($_GET['pID']) && ($_GET['pID'] == $Qproducts->valueInt('products_id')))) && ($action != 'cNew')) {
+ $Qreviews = $osC_Database->query('select (avg(reviews_rating) / 5 * 100) as average_rating from :table_reviews where products_id = :products_id');
+ $Qreviews->bindTable(':table_reviews', TABLE_REVIEWS);
+ $Qreviews->bindInt(':products_id', $Qproducts->valueInt('products_id'));
+ $Qreviews->execute();
+
+ $pInfo = new objectInfo(array_merge($Qproducts->toArray(), $Qreviews->toArray()));
+ }
+
+ if (isset($pInfo) && ($Qproducts->valueInt('products_id') == $pInfo->products_id)) {
+ echo ' <tr class="selected">' . "\n";
+ } else {
+ echo ' <tr onMouseOver="rowOverEffect(this);" onMouseOut="rowOutEffect(this);" onClick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $Qproducts->valueInt('products_id')) . '\';">' . "\n";
+ }
+?>
+ <td><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $Qproducts->valueInt('products_id') . '&action=new_product_preview&read=only') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . ' ' . $Qproducts->value('products_name') . '</a>'; ?></td>
+ <td align="center"><?php echo tep_image('templates/' . $template . '/images/icons/' . (($Qproducts->valueInt('products_status') === 1) ? 'checkbox_ticked.gif' : 'checkbox_crossed.gif')); ?></td>
+ <td align="right">
+<?php
+ echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $Qproducts->valueInt('products_id') . '&action=new_product') . '">' . tep_image('templates/' . $template . '/images/icons/16x16/configure.png', IMAGE_EDIT, '16', '16') . '</a>';
+
+ if (isset($pInfo) && ($Qproducts->valueInt('products_id') == $pInfo->products_id)) {
+ echo '<a href="#" onClick="toggleInfoBox(\'pMove\');">' . tep_image('templates/' . $template . '/images/icons/16x16/move.png', IMAGE_MOVE, '16', '16') . '</a> ' .
+ '<a href="#" onClick="toggleInfoBox(\'pCopyTo\');">' . tep_image('templates/' . $template . '/images/icons/16x16/copy.png', IMAGE_COPY_TO, '16', '16') . '</a> ' .
+ '<a href="#" onClick="toggleInfoBox(\'pDelete\');">' . tep_image('templates/' . $template . '/images/icons/16x16/trash.png', IMAGE_DELETE, '16', '16') . '</a>';
+ } else {
+ echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $Qproducts->valueInt('products_id') . '&action=pMove') . '">' . tep_image('templates/' . $template . '/images/icons/16x16/move.png', IMAGE_MOVE, '16', '16') . '</a> ' .
+ '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $Qproducts->valueInt('products_id') . '&action=pCopyTo') . '">' . tep_image('templates/' . $template . '/images/icons/16x16/copy.png', IMAGE_COPY_TO, '16', '16') . '</a> ' .
+ '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $Qproducts->valueInt('products_id') . '&action=pDelete') . '">' . tep_image('templates/' . $template . '/images/icons/16x16/trash.png', IMAGE_DELETE, '16', '16') . '</a>';
+ }
+?>
+ </td>
+ </tr>
+<?php
+ }
+?>
+ </tbody>
+ </table>
+
+ <p align="right">
+<?php
+ if (sizeof($cPath_array) > 0) {
+ echo '<input type="button" value="' . IMAGE_BACK . '" onClick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . implode('_', array_slice($cPath_array, 0, -1)) . '&cID=' . $current_category_id) . '\';" class="infoBoxButton"> ';
+ }
+
+ if (!isset($_GET['search'])) {
+ if ($action != 'cNew') {
+ echo '<input type="button" value="' . IMAGE_NEW_CATEGORY . '" onClick="toggleInfoBox(\'cNew\');" class="infoBoxButton"> ';
+ }
+
+ echo '<input type="button" value="' . IMAGE_NEW_PRODUCT . '" onClick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&action=new_product') . '\';" class="infoBoxButton">';
+ }
+?>
+ </p>
+</div>
+
+<div id="infoBox_cNew" <?php if ($action != 'cNew') { echo 'style="display: none;"'; } ?>>
+ <div class="infoBoxHeading"><?php echo tep_image('templates/' . $template . '/images/icons/16x16/new.png', IMAGE_INSERT, '16', '16') . ' ' . TEXT_INFO_HEADING_NEW_CATEGORY; ?></div>
+ <div class="infoBoxContent">
+ <?php echo tep_draw_form('cNew', FILENAME_CATEGORIES, 'cPath=' . $cPath . '&action=save_category', 'post', 'enctype="multipart/form-data"'); ?>
+
+ <p><?php echo TEXT_NEW_CATEGORY_INTRO; ?></p>
+ <p>
+<?php
+ echo TEXT_CATEGORIES_NAME;
+
+ $languages = tep_get_languages();
+ foreach ($languages as $l_entry) {
+ echo '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $l_entry['directory'] . '/images/' . $l_entry['image'], $l_entry['name']) . ' ' . osc_draw_input_field('categories_name[' . $l_entry['id'] . ']');
+ }
+?>
+ </p>
+ <p><?php echo TEXT_CATEGORIES_IMAGE . '<br>' . tep_draw_file_field('categories_image'); ?></p>
+ <p><?php echo TEXT_EDIT_SORT_ORDER . '<br>' . osc_draw_input_field('sort_order'); ?></p>
+
+ <p align="center"><?php echo '<input type="submit" value="' . IMAGE_SAVE . '" class="operationButton"> <input type="button" value="' . IMAGE_CANCEL . '" onClick="toggleInfoBox(\'cDefault\');" class="operationButton">'; ?></p>
+
+ </form>
+ </div>
+</div>
+
+<?php
+ if (isset($cInfo)) {
+?>
+<div id="infoBox_cMove" <?php if ($action != 'cMove') { echo 'style="display: none;"'; } ?>>
+ <div class="infoBoxHeading"><?php echo tep_image('templates/' . $template . '/images/icons/16x16/move.png', IMAGE_MOVE, '16', '16') . ' ' . $cInfo->categories_name; ?></div>
+ <div class="infoBoxContent">
+ <?php echo tep_draw_form('cMove', FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=move_category_confirm'); ?>
+
+ <p><?php echo sprintf(TEXT_MOVE_CATEGORIES_INTRO, $cInfo->categories_name); ?></p>
+ <p><?php echo sprintf(TEXT_MOVE, $cInfo->categories_name) . '<br>' . osc_draw_pull_down_menu('move_to_category_id', tep_get_category_tree(), $current_category_id); ?></p>
+
+ <p align="center"><?php echo '<input type="submit" value="' . IMAGE_MOVE . '" class="operationButton"> <input type="button" value="' . IMAGE_CANCEL . '" onClick="toggleInfoBox(\'cDefault\');" class="operationButton">'; ?></p>
+
+ </form>
+ </div>
+</div>
+
+<div id="infoBox_cDelete" <?php if ($action != 'cDelete') { echo 'style="display: none;"'; } ?>>
+ <div class="infoBoxHeading"><?php echo tep_image('templates/' . $template . '/images/icons/16x16/trash.png', IMAGE_DELETE, '16', '16') . ' ' . $cInfo->categories_name; ?></div>
+ <div class="infoBoxContent">
+ <p><?php echo TEXT_DELETE_CATEGORY_INTRO; ?></p>
+ <p><?php echo '<b>' . $cInfo->categories_name . '</b>'; ?></p>
+<?php
+ if ($cInfo->childs_count > 0) {
+ echo ' <p>' . sprintf(TEXT_DELETE_WARNING_CHILDS, $cInfo->childs_count) . '</p>';
+ }
+
+ if ($cInfo->products_count > 0) {
+ echo ' <p>' . sprintf(TEXT_DELETE_WARNING_PRODUCTS, $cInfo->products_count) . '</p>';
+ }
+?>
+ <p align="center"><?php echo '<input type="button" value="' . IMAGE_DELETE . '" onClick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=delete_category_confirm') . '\'" class="operationButton"> <input type="button" value="' . IMAGE_CANCEL . '" onClick="toggleInfoBox(\'cDefault\');" class="operationButton">'; ?></p>
+ </div>
+</div>
+
+<div id="infoBox_cEdit" <?php if ($action != 'cEdit') { echo 'style="display: none;"'; } ?>>
+ <div class="infoBoxHeading"><?php echo tep_image('templates/' . $template . '/images/icons/16x16/configure.png', IMAGE_EDIT, '16', '16') . ' ' . $cInfo->categories_name; ?></div>
+ <div class="infoBoxContent">
+ <?php echo tep_draw_form('cEdit', FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id . '&action=save_category', 'post', 'enctype="multipart/form-data"'); ?>
+
+ <p><?php echo TEXT_EDIT_INTRO; ?></p>
+ <p>
+<?php
+ echo TEXT_EDIT_CATEGORIES_NAME;
+
+ $Qcd = $osC_Database->query('select language_id, categories_name from :table_categories_description where categories_id = :categories_id');
+ $Qcd->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
+ $Qcd->bindInt(':categories_id', $cInfo->categories_id);
+ $Qcd->execute();
+
+ $categories_name = array();
+ while ($Qcd->next()) {
+ $categories_name[$Qcd->valueInt('language_id')] = $Qcd->value('categories_name');
+ }
+
+ $languages = tep_get_languages();
+ foreach ($languages as $l_entry) {
+ echo '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $l_entry['directory'] . '/images/' . $l_entry['image'], $l_entry['name']) . ' ' . osc_draw_input_field('categories_name[' . $l_entry['id'] . ']', (isset($categories_name[$l_entry['id']]) ? $categories_name[$l_entry['id']] : ''));
+ }
+?>
+ </p>
+ <p><?php echo tep_image(DIR_WS_CATALOG_IMAGES . $cInfo->categories_image, $cInfo->categories_name, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT) . '<br>' . DIR_WS_CATALOG_IMAGES . '<br><b>' . $cInfo->categories_image . '</b>'; ?></p>
+ <p><?php echo TEXT_EDIT_CATEGORIES_IMAGE . '<br>' . tep_draw_file_field('categories_image'); ?></p>
+ <p><?php echo TEXT_EDIT_SORT_ORDER . '<br>' . osc_draw_input_field('sort_order', $cInfo->sort_order); ?></p>
+
+ <p align="center"><?php echo '<input type="submit" value="' . IMAGE_UPDATE . '" class="operationButton"> <input type="button" value="' . IMAGE_CANCEL . '" onClick="toggleInfoBox(\'cDefault\');" class="operationButton">'; ?></p>
+
+ </form>
+ </div>
+</div>
+
+<?php
+ } elseif (isset($pInfo)) {
+?>
+
+<div id="infoBox_pCopyTo" <?php if ($action != 'pCopyTo') { echo 'style="display: none;"'; } ?>>
+ <div class="infoBoxHeading"><?php echo tep_image('templates/' . $template . '/images/icons/16x16/copy.png', IMAGE_COPY_TO, '16', '16') . ' ' . $pInfo->products_name; ?></div>
+ <div class="infoBoxContent">
+ <?php echo tep_draw_form('pCopyTo', FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=copy_to_confirm'); ?>
+
+ <p><?php echo TEXT_INFO_COPY_TO_INTRO; ?></p>
+ <p><?php echo TEXT_INFO_CURRENT_CATEGORIES . '<br>' . tep_output_generated_category_path($pInfo->products_id, 'product'); ?></p>
+ <p><?php echo TEXT_CATEGORIES . '<br>' . osc_draw_pull_down_menu('categories_id', tep_get_category_tree(), $current_category_id); ?></p>
+ <p><?php echo TEXT_HOW_TO_COPY . '<br>' . osc_draw_radio_field('copy_as', array(array('id' => 'link', 'text' => TEXT_COPY_AS_LINK), array('id' => 'duplicate', 'text' => TEXT_COPY_AS_DUPLICATE)), 'link', '', false, '<br>'); ?></p>
+
+ <p align="center"><?php echo '<input type="submit" value="' . IMAGE_COPY . '" class="operationButton"> <input type="button" value="' . IMAGE_CANCEL . '" onClick="toggleInfoBox(\'cDefault\');" class="operationButton">'; ?></p>
+
+ </form>
+ </div>
+</div>
+
+<div id="infoBox_pMove" <?php if ($action != 'pMove') { echo 'style="display: none;"'; } ?>>
+ <div class="infoBoxHeading"><?php echo tep_image('templates/' . $template . '/images/icons/16x16/move.png', IMAGE_MOVE, '16', '16') . ' ' . $pInfo->products_name; ?></div>
+ <div class="infoBoxContent">
+ <?php echo tep_draw_form('pMove', FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=move_product_confirm'); ?>
+
+ <p><?php echo sprintf(TEXT_MOVE_PRODUCTS_INTRO, $pInfo->products_name); ?></p>
+ <p><?php echo TEXT_INFO_CURRENT_CATEGORIES . '<br>' . tep_output_generated_category_path($pInfo->products_id, 'product'); ?></p>
+ <p><?php echo sprintf(TEXT_MOVE, $pInfo->products_name) . '<br>' . osc_draw_pull_down_menu('move_to_category_id', tep_get_category_tree(), $current_category_id); ?></p>
+
+ <p align="center"><?php echo '<input type="submit" value="' . IMAGE_MOVE . '" class="operationButton"> <input type="button" value="' . IMAGE_CANCEL . '" onClick="toggleInfoBox(\'cDefault\');" class="operationButton">'; ?></p>
+
+ </form>
+ </div>
+</div>
+
+<div id="infoBox_pDelete" <?php if ($action != 'pDelete') { echo 'style="display: none;"'; } ?>>
+ <div class="infoBoxHeading"><?php echo tep_image('templates/' . $template . '/images/icons/16x16/trash.png', IMAGE_DELETE, '16', '16') . ' ' . $pInfo->products_name; ?></div>
+ <div class="infoBoxContent">
+ <?php echo tep_draw_form('pDelete', FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=delete_product_confirm'); ?>
+
+ <p><?php echo TEXT_DELETE_PRODUCT_INTRO; ?></p>
+ <p><?php echo $pInfo->products_name; ?></p>
+ <p>
+<?php
+ $product_categories_array = array();
+ $product_categories = tep_generate_category_path($pInfo->products_id, 'product');
+ for ($i=0, $n=sizeof($product_categories); $i<$n; $i++) {
+ $category_path = '';
+ for ($j=0, $k=sizeof($product_categories[$i]); $j<$k; $j++) {
+ $category_path .= $product_categories[$i][$j]['text'] . ' > ';
+ }
+ $category_path = substr($category_path, 0, -16);
+
+ $product_categories_array[] = array('id' => $product_categories[$i][sizeof($product_categories[$i])-1]['id'], 'text' => $category_path);
+ }
+
+ echo osc_draw_checkbox_field('product_categories[]', $product_categories_array, true, '', false, '<br>');
+?>
+ </p>
+
+ <p align="center"><?php echo '<input type="submit" value="' . IMAGE_DELETE . '" class="operationButton"> <input type="button" value="' . IMAGE_CANCEL . '" onClick="toggleInfoBox(\'cDefault\');" class="operationButton">'; ?></p>
+
+ </form>
+ </div>
+</div>
+
+<?php
+ }
+?>
CVSspam 0.2.8
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click