Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Shop Owner Product Cost Contribution


homewetbar

Recommended Posts

This contribution allows the shop keeper to store the product's cost (what the shop keeper paid for the item) in the database and allows you to easily modify it. The customer will not see the cost, the cost is only visible in admin.

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

You can get the contribution here:

 

http://www.oscommerce.com/community/contributions,2508

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

Yes you can view the selling price along side the cost price as this mod shows up on your product page in admin (page when you update or add a product).

 

I would like to add a function to show the cost/price margin later when I have time or if someone else wanted to I don't think it would be too hard...

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

What would it take to get the cost to show up in the summary box on the right so you don't have to enter "edit" mode to see the cost number? The box currently displays Date Added, Last Modified, Picture, Price, Quantity, and Average Rating.

Link to comment
Share on other sites

To answer my own question:

 

In catalog/admin/categories.php (at line 993 in my file)

 

FIND:

$contents[] = array('text' => '<br>' . TEXT_PRODUCTS_PRICE_INFO . ' ' . $currencies->format($pInfo->products_price) . '<br>' . TEXT_PRODUCTS_QUANTITY_INFO . ' ' . $pInfo->products_quantity);

 

ADD (AFTER ABOVE):

$contents[] = array('text' => '<br>' . TEXT_PRODUCTS_COST_INFO . ' ' . $currencies->format($pInfo->products_cost));

 

In catalog/admin/includes/language/english/categories/php (line 26 in my file)

 

FIND:

define('TEXT_PRODUCTS_PRICE_INFO', 'Price:');

 

ADD (AFTER ABOVE):

define('TEXT_PRODUCTS_COST_INFO', 'Cost:');

Edited by baddog
Link to comment
Share on other sites

Some errors;

 

line 692 and 694 must be 892 and 894. Both need to mention after, add and not before add (first one) ... Not that makes much difference, just for the sake of logic.

 

Add on line 391 also: 'products_price' => '',

 

(search for line 383: $parameters = array('products_name' => '',)

 

line 378 is 402 by me... :huh: (403 with above addition).

545-549 instead of 515-519

634 instead of 608 (with all of the above changes already made)

662 instead of 636

 

And most importantly... I have no input field yet, when I want to add a new product for example! Going to sort that one out.

 

This feature is also available in the order processing module, but that is a really poor contrubition release and virtually unsupported nowadays... ;)

 

Nevertheless, great effort :thumbsup:

Link to comment
Share on other sites

And most importantly... I have no input field yet, when I want to add a new product for example! Going to sort that one out.

 

Allright, there was an input field but outside my viewable area ;)

 

Anyway there is another error in the section of lines you need to add;

 

ADD THESE LINES:

<tr bgcolor="#ebebff">

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

<td class="main"><?php echo TEXT_PRODUCTS_COST; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_cost', $pInfo->products_cost); ?></td>

</tr>

 

must be:

 

ADD THESE LINES:

<tr bgcolor="#ebebff">

<td class="main"><?php echo TEXT_PRODUCTS_COST; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_cost', $pInfo->products_cost); ?></td>

</tr>

 

(notice that I removed a line)

Link to comment
Share on other sites

supra_dave

In your first question the error you encountered the line # is different is probably because you have other mods you have installed as I have also. Thats why you should search for the string and not the specific line #

 

In your second question

Allright, there was an input field but outside my viewable area ;)

 

Anyway there is another error in the section of lines you need to add;

must be:

(notice that I removed a line)

 

Yes, you can do it either way I just felt it was easier to read with that extra line for me.

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

  • 1 month later...

hi, this is the feature i've been looking for a long time...thanks for this, btw, is the product cost is only for viewing? does this also compute your profit like 'Our Cost' minus the 'Product Price'?

 

thanks!

Link to comment
Share on other sites

I'm happy with this mod so far, if I could figure out math in php I'd make it more useful. Considering I've been using php for 3 days total (all with oscommerce) I'm pretty pleased with my progress. Hopefully I'll be adding to this contribution soon.

bloom,

php geek wannabe

"The difference between genius and stupidity is that genius has its limits." -Einstein

 

My Contributions

In-Stock Quantity Display

Link to comment
Share on other sites

  • 9 months later...
To answer my own question:

 

In catalog/admin/categories.php (at line 993 in my file)

 

FIND:

$contents[] = array('text' => '<br>' . TEXT_PRODUCTS_PRICE_INFO . ' ' . $currencies->format($pInfo->products_price) . '<br>' .  TEXT_PRODUCTS_QUANTITY_INFO . ' ' . $pInfo->products_quantity);

 

ADD (AFTER ABOVE):

$contents[] = array('text' => '<br>' . TEXT_PRODUCTS_COST_INFO . ' ' . $currencies->format($pInfo->products_cost));

 

In catalog/admin/includes/language/english/categories/php (line 26 in my file)

 

FIND:

define('TEXT_PRODUCTS_PRICE_INFO', 'Price:');

 

ADD (AFTER ABOVE):

define('TEXT_PRODUCTS_COST_INFO', 'Cost:');

 

 

Regarding the Product Cost appearing in the box under Catalog/Products...

I used the lines listed above. It works. But, the box shows TEXT_PRODUCTS_COST_INFO instead of simply showing Cost:

 

What is wrong? Any help is appreciated.

 

Kym

Link to comment
Share on other sites

Regarding the Product Cost appearing in the box under Catalog/Products...

I used the lines listed above.  It works.  But, the box shows TEXT_PRODUCTS_COST_INFO instead of simply showing Cost:

 

What is wrong?  Any help is appreciated.

 

Kym

 

Add TEXT_PRODUCTS_COST_INFO to your languages file and define it. I think there is a step you missed that does this, if not then just view the english.php file in the languages directory and you'll see what I mean, just follow the examples.

Most Valuable OsCommerce Contributions:

Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294

FedEx Automated Labels -- Contribution 2244

RMA Returns system -- Contribution 1136

Sort Products By Dropdown -- Contribution 4312

Ultimate SEO URLs -- Contribution 2823

Credit Class & Gift Voucher -- Contribution 282

Cross-Sell -- Contribution 5347

Link to comment
Share on other sites

  • 4 weeks later...
Add TEXT_PRODUCTS_COST_INFO to your languages file and define it. I think there is a step you missed that does this, if not then just view the english.php file in the languages directory and you'll see what I mean, just follow the examples.

 

 

Is there a snippet of code we can add so that when you are in admin looking at the product in the right column under categories where the product is listed with a pic and the retail price add the cost price?

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

 

I use this contrib for some time and the only problem I have is: on my admin/categories.php in the summary box in the right column I have Cost: $0.00. The value doesn't change when I enter Our Cost: in admin/categories.php Edit. Here is a code in my admin/categories.php:

<?php

 

require('includes/application_top.php');

// PRODUCT ATTRIBUTES CONTRIB

if (file_exists(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCTS_ATTRIBUTES)) {

include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCTS_ATTRIBUTES);

}

// PRODUCT ATTRIBUTES CONTRIB

 

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

 

$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

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()');

 

$sql_data_array = array_merge($sql_data_array, $update_sql_data);

 

tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'");

}

 

$languages = tep_get_languages();

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

$categories_name_array = $HTTP_POST_VARS['categories_name'];

 

$language_id = $languages[$i]['id'];

 

$sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]));

 

if ($action == 'insert_category') {

$insert_sql_data = array('categories_id' => $categories_id,

'language_id' => $languages[$i]['id']);

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

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 ($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 . "'");

}

 

// RJW Begin Meta Tags Code

$meta_title = tep_db_prepare_input($HTTP_POST_VARS['meta_title']);

$meta_description = tep_db_prepare_input($HTTP_POST_VARS['meta_description']);

$meta_keywords = tep_db_prepare_input($HTTP_POST_VARS['meta_keywords']);

 

$sql_data_array = array('title' => $meta_title,

'description' => $meta_description,

'keywords' => $meta_keywords);

 

$meta_query = tep_db_query ("select title, keywords, description from " . TABLE_META_TAGS . " where categories_id = '" . (int)$categories_id . "'");

 

if (!tep_db_num_rows($meta_query)) {

$insert_sql_data = array('categories_id' => $categories_id);

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_META_TAGS, $sql_data_array);

} else {

tep_db_perform(TABLE_META_TAGS, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'");

}

// RJW End Meta Tags Code

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_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);

$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'] . "'");

 

while ($product_ids = tep_db_fetch_array($product_ids_query)) {

$products[$product_ids['products_id']]['categories'][] = $categories[$i]['id'];

}

}

 

reset($products);

while (list($key, $value) = each($products)) {

$category_ids = '';

 

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') {

$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']);

 

// RJW Begin Meta Tags Code

tep_db_query ("delete from " . TABLE_META_TAGS . " where categories_id = '" . $categories[$i]['id'] . "'");

// RJW End Meta Tags Code

 

}

 

reset($products_delete);

while (list($key) = each($products_delete)) {

tep_remove_product($key);

}

}

 

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 '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'];

 

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] . "'");

}

 

$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);

 

if ($product_categories['total'] == '0') {

tep_remove_product($product_id);

// X-SELL by Kavita Begin

tep_db_query("DELETE FROM " . TABLE_PRODUCTS_XSELL . " WHERE products_id = '".$product_id."'");

// X-SELL by Kavita End

}

}

 

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']);

 

$path = explode('_', tep_get_generated_category_path_ids($new_parent_id));

 

if (in_array($categories_id, $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 . "'");

 

if (USE_CACHE == 'true') {

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));

}

}

 

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']);

 

$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 (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&pID=' . $products_id));

break;

case 'insert_product':

case 'update_product':

if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) {

$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']);

 

$products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';

 

$sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),

'products_bundle' => tep_db_prepare_input($HTTP_POST_VARS['products_bundle']),

'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']),

'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']),

'products_cost' => tep_db_prepare_input($HTTP_POST_VARS['products_cost']),

'products_date_available' => $products_date_available,

'products_weight' => tep_db_prepare_input($HTTP_POST_VARS['products_weight']),

'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($HTTP_POST_VARS['products_pdfupload']) && tep_not_null($HTTP_POST_VARS['products_pdfupload']) && ($HTTP_POST_VARS['products_pdfupload'] != 'none')) {

$sql_data_array['products_pdfupload'] = tep_db_prepare_input($HTTP_POST_VARS['products_pdfupload']);

}

 

if ($action == 'insert_product') {

$insert_sql_data = array('products_date_added' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_PRODUCTS, $sql_data_array);

$products_id = tep_db_insert_id();

// X-SELL by Kavita Begin

$selected_xsellids = $HTTP_POST_VARS['products_xsell_ids'];

if ($selected_xsellids)

{

$s = 0;

$selected_xsellids = array_reverse($selected_xsellids);

foreach ($selected_xsellids as $xsell_product_id)

{

$s += 1;

tep_db_query("insert into " . TABLE_PRODUCTS_XSELL . " (products_id, xsell_id, sort_order) values ('" . $products_id . "', '" . $xsell_product_id . "','" . $s . "')");

}

}

// X-SELL by Kavita End

 

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()');

 

$sql_data_array = array_merge($sql_data_array, $update_sql_data);

 

tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");

}

// update bundle contents

if ($HTTP_POST_VARS['products_bundle'] == "yes") {

tep_db_query("DELETE FROM products_bundles WHERE bundle_id = '" . $products_id . "'");

for ($i=0, $n=6; $i<$n; $i++) {

if (isset($HTTP_POST_VARS['subproduct_' . $i . '_qty']) && $HTTP_POST_VARS['subproduct_' . $i . '_qty'] > 0) {

tep_db_query("INSERT INTO products_bundles (bundle_id, subproduct_id, subproduct_qty) VALUES ('" . $products_id . "', '" . $HTTP_POST_VARS['subproduct_' . $i . '_id'] . "', '" . $HTTP_POST_VARS['subproduct_' . $i . '_qty'] . "')");

}

}

// X-SELL by Kavita Begin

$selected_xsellids = $HTTP_POST_VARS['products_xsell_ids'];

if ($selected_xsellids)

{

tep_db_query("DELETE FROM " . TABLE_PRODUCTS_XSELL . " WHERE products_id = '".(int)$products_id . "'");

$selected_xsellids = array_reverse($selected_xsellids);

$s = 0;

foreach ($selected_xsellids as $xsell_product_id)

{

$s += 1;

tep_db_query("insert into " . TABLE_PRODUCTS_XSELL . " (products_id, xsell_id, sort_order) values ('" . $products_id . "', '" . $xsell_product_id . "','" . $s . "')");

}

}

// X-SELL by Kavita End

}

 

$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 (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

// commented and replaced for product attributes contrib

// tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id . '&action=new_product'));

// end replacement

}

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 . "')");

}

} 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_pdfupload, products_price, products_cost, products_date_available, products_weight, products_tax_class_id, manufacturers_id, products_bundle 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_pdfupload, products_price, products_cost, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_bundle) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_pdfupload']) . "', '". tep_db_input($product['products_price']) . "', '" . tep_db_input($product['products_bundle']) . "', '" . tep_db_input($product['products_cost']) . "', 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')");

}

 

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 (USE_CACHE == 'true') {

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':

// 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'] : '');

}

 

$products_pdfupload = new upload('products_pdfupload');

$products_pdfupload->set_destination(DIR_FS_CATALOG_IMAGES);

 

if ($products_pdfupload->parse() && $products_pdfupload->save()) {

$products_pdfupload_name = $products_pdfupload->filename;

} else {

$products_pdfupload_name = (isset($HTTP_POST_VARS['products_previous_pdfupload']) ? $HTTP_POST_VARS['products_previous_pdfupload'] : '');

}

########################################

 

break;

}

}

 

// 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>

<script language="javascript" src="includes/javascript/description_toolbar.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_date_added' => '',

'products_last_modified' => '',

'products_date_available' => '',

'products_status' => '',

'products_tax_class_id' => '',

'manufacturers_id' => '',

'products_bundle' => '');

 

$pInfo = new objectInfo($parameters);

 

// commented and replaced for product attributes contrib

// if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) {

if (isset($HTTP_GET_VARS['pID']) && ( empty($HTTP_POST_VARS) || $HTTP_GET_VARS['action_att']) ) {

// end replacement

$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_pdfupload, p.products_price, p.products_cost, 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, p.products_bundle 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 (isset($pInfo->products_bundle) && $pInfo->products_bundle == "yes") {

// this product is a bundle so get contents data

$bundle_query = tep_db_query("SELECT pb.subproduct_id, pb.subproduct_qty, pd.products_name FROM " . TABLE_PRODUCTS_DESCRIPTION . " pd INNER JOIN " . TABLE_PRODUCTS_BUNDLES . " pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id = '" . $HTTP_GET_VARS['pID'] . "' and language_id = '" . (int)$languages_id . "'");

while ($bundle_contents = tep_db_fetch_array($bundle_query)) {

$bundle_array[] = array('id' => $bundle_contents['subproduct_id'],

'qty' => $bundle_contents['subproduct_qty'],

'name' => $bundle_contents['products_name']);

}

}

$default_tax_class_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'DEFAULT_PRODUCT_TAX_CLASS'");

if (($pInfo->products_tax_class_id == '') && ($default_tax_class = tep_db_fetch_array($default_tax_class_query)))

$pInfo->products_tax_class_id = $default_tax_class['configuration_value'];

 

$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;

}

?>

<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);

}

 

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>

<?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 bgcolor="#ebebff">

<td class="main"><?php echo TEXT_PRODUCTS_COST; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_input_field('products_cost', $pInfo->products_cost); ?></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">

<? include("description_toolbar.php"); ?>

<?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>

<?php

// X-SELL by Kavita Begin

$products_query_selected = tep_db_query("select xsell_id from " . TABLE_PRODUCTS_XSELL . " where products_id = '" . $HTTP_GET_VARS['pID'] . "'");

$products_array_selected = array(array('id' => ''));

while ($products = tep_db_fetch_array($products_query_selected)) {

$products_array_selected[] = array('id' => $products['xsell_id']);

}

 

if ($HTTP_GET_VARS['pID']) {

$products_query = tep_db_query("select products_id, products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where language_id = '". $languages_id ."' and products_id != '" . (int)$HTTP_GET_VARS['pID'] . "' order by products_name");

} else {

$products_query = tep_db_query("select products_id, products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where language_id = ". $languages_id ." order by products_name");

}

while ($products = tep_db_fetch_array($products_query)) {

$products_array[] = array('id' => $products['products_id'],

'text' => $products['products_name']);

}

?>

 

<tr>

<td class="main"><?php echo 'Cross Sell Products'; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_mselect_menu('products_xsell_ids[]', $products_array, $products_array_selected, 'size=10'); ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<?php // X-SELL by Kavita End ?>

<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>

<?php

 

?>

<tr>

<td class="main"><?php echo TEXT_PRODUCTS_PDFUPLOAD; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . tep_draw_file_field('products_pdfupload') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . '?' . $pInfo->products_pdfupload . tep_draw_hidden_field('products_previous_pdfupload', $pInfo->products_pdfupload); ?></td>

</tr>

<?php

 

?>

<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); ?></td>

</tr>

<!-- start bundle mod -->

<tr bgcolor="#EEEEEE">

<td class="main" valign="top">

<?php echo TEXT_PRODUCTS_BUNDLE; ?>

</td>

<td class="main" valign="top">

<table>

<tr>

<td class="main" valign="top">

<?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . tep_draw_input_field('products_bundle', $pInfo->products_bundle) . '<br>("yes" or blank)'; ?>

</td>

<td class="main" valign="top">

<script language="javascript"><!--

function fillCodes() {

for (var n=0;n<6;n++) {

var this_subproduct_id = eval("document.new_product.subproduct_" + n + "_id")

var this_subproduct_name = eval("document.new_product.subproduct_" + n + "_name")

var this_subproduct_qty = eval("document.new_product.subproduct_" + n + "_qty")

if (this_subproduct_id.value == "") {

this_subproduct_id.value = document.new_product.subproduct_selector.value

this_subproduct_qty.value = "1"

var name = document.new_product.subproduct_selector[document.new_product.subproduct_selecto

r.selectedIndex].name

this_subproduct_name.value = name

document.returnValue = true;

return true;

}

}

}

 

function clearSubproduct(n) {

var this_subproduct_id = eval("document.new_product.subproduct_" + n + "_id");

var this_subproduct_name = eval("document.new_product.subproduct_" + n + "_name");

var this_subproduct_qty = eval("document.new_product.subproduct_" + n + "_qty");

this_subproduct_id.value = "";

this_subproduct_name.value = "";

this_subproduct_qty.value = "";

}

//--></script>

<?php

for ($i=0, $n=6; $i<$n; $i++) {

echo "\n" . '<input type="text" size="30" name="subproduct_' . $i . '_name" value="' . $bundle_array[$i]['name'] . '">';

echo "\n" . '<input type="text" size="3" name="subproduct_' . $i . '_id" value="' . $bundle_array[$i]['id'] . '">';

echo "\n" . '<input type="text" size="2" name="subproduct_' . $i . '_qty" value="' . $bundle_array[$i]['qty'] . '">';

echo "\n" . '<a href="java script:clearSubproduct(' . $i . ')">[x]</a><br>';

}

echo 'add : <select name="subproduct_selector" onChange="fillCodes()">';

echo '<option name="null" value="" SELECTED></option>';

$products = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' and p.products_id <> '" . $HTTP_GET_VARS['pID'] . "' order by pd.products_name");

 

while($products_values = tep_db_fetch_array($products)) {

echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $products_values['products_name'] . " (" . $products_values['products_id'] . ')</option>';

}

echo '</select>';

?>

</td>

</tr>

</table>

</td>

</tr>

<!-- end bundle mod -->

</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_pdfupload, p.products_price, p.products_cost, 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>

<td class="pageHeading" align="right"><?php echo $currencies->format($pInfo->products_cost); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10

Link to comment
Share on other sites

  • 6 months later...

My main reason for looking at this contribution was to to have an instant online inventory including the wholesale value of the inventory. I found this to be a necessity after my first run with a business tax return this year.

 

This contribution paired with a contribution called "StockView" will get the job done. Once "Product Cost" is installed and working properly you need to install "StockView" with some modifications. StockView is not an difficult install, it's just a single stand alone file. Below is the code. Save it as stockview.php and put it in your admin directory. At this initial phase I just added "Wholesale Costs", many more additions are possible. What is most excellent is that you can copy/past Stockview directly into Excel and do caculations.

 

<?php
/*
 $Id: stockview.php,v 1.00 2005/03/07

 osCommerce Simple StockViewer

 Contribution based on:

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 - 2005 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

?>
<!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; ?>">
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<head>
<body>
<table width="700" class="infoBoxContents">
<tr>
<td colspan="2" class="infoBoxHeading" align="center">osCommerce StockView Version 1.0. </td>
</tr>
<?
echo "<tr><td><b>". 'Products ID' . "</b></td><td><b>" . 'Products Name' . "</b></td> <td><b>" . 'Products Model' . "</b></td> <td><b>" . 'Products Status' . "</b></td><td><b>". 'Stock Quantity ' . "</b></td><td><b>". 'Wholesale Cost ' ."</b></td> </tr><tr>";
$result = mysql_query("SELECT * FROM products, products_description WHERE products.products_id = products_description.products_id and products_description.language_id = '" . $languages_id . "' ORDER BY products_description.products_name");
if ($row = mysql_fetch_array($result)) {
	do {
		echo "<td class='infoBoxContents'> ".$row["products_id"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_name"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_model"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_status"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_quantity"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_cost"]."</td>\n";
		echo "</tr>\n";
	}
	while($row = mysql_fetch_array($result));
}
echo "</table>\n";
?>
<p class="smallText" align="right"><?php echo '<a href="javascript:window.close()">' . TEXT_CLOSE_WINDOW . '</a>'; ?>   </p>
<br>
</body>
</html>
<?php require('includes/application_bottom.php'); ?>

Link to comment
Share on other sites

I also added Product price. With that info I was able to make a spreadsheet and with a simple copy/paste I was able to see my inventory value, my profit margin per product and my potential gross margin.

 

I'm so proud of myself! Now to add the product cost for another hundred or so products... :P

Link to comment
Share on other sites

  • 2 weeks later...
My main reason for looking at this contribution was to to have an instant online inventory including the wholesale value of the inventory. I found this to be a necessity after my first run with a business tax return this year.

 

This contribution paired with a contribution called "StockView" will get the job done. Once "Product Cost" is installed and working properly you need to install "StockView" with some modifications. StockView is not an difficult install, it's just a single stand alone file. Below is the code. Save it as stockview.php and put it in your admin directory. At this initial phase I just added "Wholesale Costs", many more additions are possible. What is most excellent is that you can copy/past Stockview directly into Excel and do caculations.

 

<?php
/*
 $Id: stockview.php,v 1.00 2005/03/07

 osCommerce Simple StockViewer

 Contribution based on:

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 - 2005 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

?>
<!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; ?>">
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<head>
<body>
<table width="700" class="infoBoxContents">
<tr>
<td colspan="2" class="infoBoxHeading" align="center">osCommerce StockView Version 1.0. </td>
</tr>
<?
echo "<tr><td><b>". 'Products ID' . "</b></td><td><b>" . 'Products Name' . "</b></td> <td><b>" . 'Products Model' . "</b></td> <td><b>" . 'Products Status' . "</b></td><td><b>". 'Stock Quantity ' . "</b></td><td><b>". 'Wholesale Cost ' ."</b></td> </tr><tr>";
$result = mysql_query("SELECT * FROM products, products_description WHERE products.products_id = products_description.products_id and products_description.language_id = '" . $languages_id . "' ORDER BY products_description.products_name");
if ($row = mysql_fetch_array($result)) {
	do {
		echo "<td class='infoBoxContents'> ".$row["products_id"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_name"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_model"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_status"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_quantity"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_cost"]."</td>\n";
		echo "</tr>\n";
	}
	while($row = mysql_fetch_array($result));
}
echo "</table>\n";
?>
<p class="smallText" align="right"><?php echo '<a href="java script:window.close()">' . TEXT_CLOSE_WINDOW . '</a>'; ?>   </p>
<br>
</body>
</html>
<?php require('includes/application_bottom.php'); ?>

 

thanks for the combined contrib but how do i get the stockview listing added to my admin panel so i can click from there to see my stock list

 

tia

 

Rob

Link to comment
Share on other sites

  • 7 months later...
thanks for the combined contrib but how do i get the stockview listing added to my admin panel so i can click from there to see my stock list

 

tia

 

Rob

 

Above File was slightly modified. Save as /admin/inventory_cost.php :

<?php
/*
 $Id: stockview.php,v 1.00 2005/03/07

 osCommerce Simple StockViewer

 Contribution based on:

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 - 2005 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

?>
<!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; ?>">
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<head>
<body>
<table width="700" class="infoBoxContents">
<tr>
<td colspan="2" class="infoBoxHeading" align="center">osCommerce StockView Version 1.0. </td>
</tr>
<?
echo "<tr><td><b>". 'Products ID' . "</b></td><td><b>" . 'Products Name' . "</b></td> <td><b>" . 'Products Status' . "</b></td><td><b>". 'Stock Quantity ' . "</b></td><td><b>". 'Wholesale Cost ' . "</b></td><td><b>". 'Retail Price ' ."</b></td> </tr><tr>";
$result = mysql_query("SELECT * FROM products, products_description WHERE products.products_id = products_description.products_id and products_description.language_id = '" . $languages_id . "' ORDER BY products_description.products_name");
if ($row = mysql_fetch_array($result)) {
	do {
		echo "<td class='infoBoxContents'> ".$row["products_id"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_name"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_status"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_quantity"]."</td>\n";
		echo "<td class='infoBoxContents'>".$row["products_cost"]."</td>\n";
	echo "<td class='infoBoxContents'>".$row["products_price"]."</td>\n";
		echo "</tr>\n";
	}
	while($row = mysql_fetch_array($result));
}
echo "</table>\n";
?>
<p class="smallText" align="right"><?php echo '<a href="java script:history.back()">' . TEXT_BACK_WINDOW . '</a>'; ?>   </p>
<br>
</body>
</html>
<?php require('includes/application_bottom.php'); ?>

 

In admin/includes/filenames.php add:

  define('FILENAME_INVENTORY_COST', 'inventory_cost.php');

 

In admin/includes/boxes/tools.php add:

'<a href="' . tep_href_link(FILENAME_INVENTORY_COST) . '" class="menuBoxContentLink">' . BOX_TOOLS_INVENTORY_COST . '</a><br>' .

 

In admin/includes/languages/english.php add

define('BOX_TOOLS_INVENTORY_COST', 'Inventory');

and

define('TEXT_BACK_WINDOW', 'Return to Administration');

 

 

That should do it. You will now have an inventory link in your administration tools box. It will open full screen to cut/paste into a spreadsheet, and will return to the admin using the "back " at the bottom of the page.

Link to comment
Share on other sites

  • 2 weeks later...

Has anyone written a piece of code so that :

 

1. The orders_total table is updated to reflect not only the total price of the products ordered, but also the total costs of the products ordered? [with an appropriate additional field?]

Link to comment
Share on other sites

  • 2 weeks later...

Is there anyone that has made an efford to include calculation into this usefull contrib?

 

I think it would be great if it will just let you insert price and profit and that automaticly the retail price is presented in store.

 

Tnx in advance,

 

Greetz,

 

Peter

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...