Thank you for this addon , is very helpfull for me . Though , i have some problems . I managed install it , i have run an alternate mysql command and I replaced
pd.short_desc with
p.short_desc to get it work . Now , when i search for a product , it displays duplicates . For example , i have only
one product and it display
three. (doesn't matter which is the product) Here are my files :
product_quickedit.phpCODE
<?php
/*
$Id: categories.php,v 1.146 2003/07/11 14:40:27 hpdl Exp $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com Copyright © 2003 osCommerce
Released under the GNU General Public License
*/
require('includes/application_top.php');
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
$pID = 0;
if (isset($HTTP_GET_VARS['pID'])) $pID = $HTTP_GET_VARS['pID'];
$short=false; // set this to true if you have the short description mod
$prod_search = "";
//$prod_search = $_REQUEST['prod_search'];
//if($prod_search=="")
//{
if(isset($HTTP_GET_VARS['pSearch'])) {
$prod_search = $HTTP_GET_VARS['pSearch'];
}
//}
if($_REQUEST['prod_search']!="" || $prod_search !="")
{
if ($prod_search == "") $prod_search = $_REQUEST['prod_search'];
$product_query = tep_db_query("select pd.products_name, " . ($short ? 'p.short_desc, ' : '') . "p.products_id, p.products_status, p.products_quantity, p.products_price, p.products_model, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and (pd.products_name like '%".$prod_search."%' or p.products_model like '%".$prod_search."%' or p.products_id like '%".$prod_search."%' or p.short_desc like '%".$prod_search."%') order by pd.products_name");
}
else{ }
?>
<!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 onload="SetFocus();">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<!-- body_text //-->
<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>
<td width="100%" valign="top" >
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading">Quick Edit Products</td>
<form name="search_products" method="POST" action="product_quickedit.php"><!-- product_quickedit.php -->
<td class="smallText" align="right" valign="top"> (search by Name or SKU/ID)
<input type="text" name="prod_search" value="%">
<input type="submit" name="search" value="Search"> Just Click to list all
<?php echo tep_draw_separator('pixel_trans.gif', '1', '1'); ?>
</td>
</form>
</tr>
<?php
if($_REQUEST['Update']=="Success")
{
?>
<tr><td><font color="#FF3333">Record has been updated successfully</font></td></tr>
<?php
}
?>
<tr>
<td valign="top" colspan="2">
<form name="form1" method="POST" action="product_quickedit.php">
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent" width="8%">Model</td>
<td class="dataTableHeadingContent" width="5%">ID</td>
<td class="dataTableHeadingContent" width="45%">Name</td>
<td class="dataTableHeadingContent" width="8%"></td>
<td class="dataTableHeadingContent" width="8%">Price</td>
<td class="dataTableHeadingContent" width="8%">Stock</td>
<td class="dataTableHeadingContent" width="8%">Edit</td>
</tr>
<?php
if (!$product_query) {
} else {
$i=0;while($product = tep_db_fetch_array($product_query))
{$i++;
echo '<tr valign="top"' . ($pID == $product['products_id'] ? 'bgcolor="#9999ff"' : (((int)($i/2)*2) == $i ? 'bgcolor="#DFE4F4"' : '')) . '>';
?>
<td valign="top" class="dataTableContent"><?php echo $product['products_model'];?></td>
<td width="5%" valign="top" class="dataTableContent"><?php echo $product['products_id'];?></td>
<?php echo '<td width="45%" valign="top" class="dataTableContent">' .
'<b>' . $product['products_name'] . '</b>' . ($short ? '<br>' . $product['short_desc'] : '');
?>
</td>
<td width="10%" valign="top" class="dataTableContent"></td>
<td width="10%" valign="top" class="dataTableContent"><?php echo $currencies->display_price($product['products_price'], tep_get_tax_rate($product['products_tax_class_id'])); ?></td>
<td width="10%" valign="top" class="dataTableContent"><?php echo $product['products_quantity']; ?></td>
<td width="10%" valign="top" class="dataTableContent"><a href="product_quickedit_info.php?pID=<?php echo $product['products_id'] . "&prod_search=" . $prod_search; ?>">Edit</a></td>
</tr>
<?php
}
}
?>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- body_text_eof //-->
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
product_quickedit_info.phpCODE
<?php
require('includes/application_top.php');
require(DIR_WS_INCLUDES . '/languages/english/categories.php');
$edit_quantity=true; // set this to false to prevent quantity edit otherwise true
$short=false; // set this to true if you have the short description mod
$pID = 0;$prod_search = $_GET['prod_search'];
if (isset($_GET['pID']) && tep_not_null($_GET['pID'])) $pID = $_GET['pID']; else tep_redirect(tep_href_link('product_quickedit.php', '&pSearch=' . $prod_search));
$product_query = tep_db_query("select p.products_id, p.products_model, pd.products_name, pd.products_description, " . ($short ? 'p.short_desc, ' : '') . "p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . $pID . "' and p.products_id = pd.products_id");
if(isset($_POST["submit"])) {
$sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),
'products_tax_class_id' => tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']),
'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']),
'products_image' => tep_db_prepare_input($HTTP_POST_VARS['products_image']),
'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']),
'products_last_modified' => date("Y-m-d H:i:s"),
'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']));
tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . $pID . "'");
$sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name']),
'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description']));
if ($short) {$insert_sql_data = array('short_desc' => tep_db_prepare_input($HTTP_POST_VARS['short_desc']));
$sql_data_array = array_merge($sql_data_array, $insert_sql_data); }
tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . $pID . "'");
$messageStack->add_session('', 'none');$name=$_POST['products_name'];
$messageStack->add_session("Product $pID $name updated.", 'success');
tep_redirect(tep_href_link('product_quickedit.php', 'pID=' . $pID . '&pSearch=' . $prod_search . ''));
}
?>
<!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 onLoad="SetFocus();">
<!-- 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" id="left"><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>
<form name="product_update" method="POST" action="product_quickedit_info.php?pID=<?php echo $pID; ?>&prod_search=<?php echo $prod_search; ?>">
<?php while($product = tep_db_fetch_array($product_query)) {
$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']);
}
?>
<td width="100%" valign="top" id="main">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="pageHeading">Edit Product (<?php echo $pID;?>)</td>
</tr>
<tr>
<td class="main"><a href="product_quickedit.php?pID=<?php echo $pID . '&pSearch=' . $prod_search; ?>"><b>Return to Quick Edit</b></a></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<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["product_update"].products_tax_class_id.selectedIndex;
var parameterVal = document.forms["product_update"].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["product_update"].products_price.value;
if (taxRate > 0) {
grossValue = grossValue * ((taxRate / 100) + 1);
}
document.forms["product_update"].products_price_gross.value = doRound(grossValue, 4);
}
function updateNet() {
var taxRate = getTaxRate();
var netValue = document.forms["product_update"].products_price_gross.value;
if (taxRate > 0) {
netValue = netValue / ((taxRate / 100) + 1);
}
document.forms["product_update"].products_price.value = doRound(netValue, 4);
}
function flagUpload() {
document.forms["product_update"].cx_image.value = 'upload';
}
//--></script>
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_STATUS; ?></td>
<td class="main">
<?php
if ($product['products_status'] == '1') {
?>
<input type="radio" name="products_status" id="products_status" value="1" checked><?php echo TEXT_PRODUCT_AVAILABLE; ?>
<input type="radio" name="products_status" id="products_status" value="0"><?php echo TEXT_PRODUCT_NOT_AVAILABLE; ?><br>
<?php
} else {
?>
<input type="radio" name="products_status" id="products_status" value="1"><?php echo TEXT_PRODUCT_AVAILABLE; ?>
<input type="radio" name="products_status" id="products_status" value="0" checked><?php echo TEXT_PRODUCT_NOT_AVAILABLE; ?><br>
<?php
}
?>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_NAME; ?></td>
<td class="main"><?php echo tep_draw_input_field('products_name', $product['products_name'], 'size="38" maxlength="38"', true); ?></td>
</tr>
<?php if ($short) { ?> <tr>
<td class="main"><?php echo TEXT_PRODUCTS_SHORT_DESC; ?></td>
<td class="main"><?php echo tep_draw_input_field('short_desc', $product['short_desc'], 'size="80" maxlength="80"');?></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" colspan="3"><?php echo tep_draw_pull_down_menu('products_tax_class_id', $tax_class_array, $product['products_tax_class_id'], 'onchange="updateGross()"'); ?></td>
</tr>
<tr bgcolor="#ebebff">
<td class="main"><?php echo TEXT_PRODUCTS_PRICE_NET; ?></td>
<td class="main" colspan="3"><?php echo tep_draw_input_field('products_price', $product['products_price'], 'size="10" onKeyUp="updateGross()"'); ?> Enter '0' here and Put Stock Quantity of '1' to display P.O.A </td>
</tr>
<tr bgcolor="#ebebff">
<td class="main"><?php echo TEXT_PRODUCTS_PRICE_GROSS; ?></td>
<td class="main" colspan="3"><?php echo tep_draw_input_field('products_price_gross', $product['products_price'], 'size="10" OnKeyUp="updateNet()"'); ?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main" valign="top"><?php echo TEXT_PRODUCTS_DESCRIPTION; ?></td>
<?php global $languages_id;
if (empty($language)) $language = $languages_id;
$products_query = tep_db_query("select p.products_id, p.products_model, pd.products_name, pd.products_description, " . ($short ? 'p.short_desc, ' : '') . "p.products_image, 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 where p.products_id = '" . $pID . "' and p.products_id = pd.products_id");
$product_fetch = tep_db_fetch_array($products_query);
$products_descript = $product_fetch['products_description'];
?>
<td><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="mainedit"><?php if (function_exists(tep_draw_fckeditor)) echo tep_draw_fckeditor('products_description','620','800',(isset($products_description[$language]) ? ($products_description[$language]) : $products_descript)); else echo tep_draw_textarea_field('products_description', 'soft', '100', '20', (isset($products_description[$language]) ? ($products_description[$language]) : $products_descript)); ?></td>
</tr>
</table></td>
</tr>
</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_QUANTITY; ?></td><td class="main"><?php echo ($edit_quantity ? tep_draw_input_field('products_quantity', $product['products_quantity'], 'size="10"') : $product['products_quantity'] . tep_draw_hidden_field('products_quantity', $product['products_quantity'])); ?></td>
</tr>
<!-- <tr>
<td class="main">Products Condition:</td>
<td class="main"><input type="text" name="products_condition" id="products_condition" value="<?php echo $product['products_condition'];?>" size="10"></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_input_field('products_model', $product['products_model'], 'size="16" maxlength="16"', true); ?></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" width="100%"><?php echo tep_info_image($product['products_image'], $product['products_name'], '150', '') . '<br />'; echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . $product['products_image'] . '<br /><br />'; //echo tep_draw_file_field('products_image');
$text = 'Select large image for zoom function if required. Image Normally Displayed at: ' . SMALL_IMAGE_WIDTH . 'px wide';
if (tep_not_null(SMALL_IMAGE_HEIGHT)) {$text .= ', ' . SMALL_IMAGE_HEIGHT . ' high.';}
if (function_exists(tep_display_block)) echo tep_display_block ($text);
echo '<br />' . tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_hidden_field('products_previous_image', $product['products_image']); ?><br /></td>
</tr><tr>
<td></td><td class="main"><input type="text" name="products_image" id="products_image" value="<?php echo $product['products_image'];?>" size="50"><br /><br /></td>
</td>
</tr>
<tr>
<td></td>
<td class="main" colspan="2" align="left"><?php echo 'Product Was Last Modified on: ' . date('D d M Y',strtotime($product['products_last_modified'])) .' at: '. date('H:i',strtotime($product['products_last_modified'])); ?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<script language="javascript"><!--
updateGross();
//--></script>
<tr>
<td ><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td><td><?php
if (isset($_GET['pID'])) {
?><input type="submit" name="submit" value="Update Product"><?php;
echo tep_draw_separator('pixel_trans.gif', '80', '1') ?><INPUT TYPE=BUTTON OnClick="location.href='product_quickedit.php?pID=<?php echo $pID . '&pSearch=' . $prod_search; ?>'" value=" Cancel "> <?php
} else {
echo 'Product ID missing.'; }?></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
?>
<!-- body_text //-->
<?php
if (isset($HTTP_GET_VARS['pID']))
{ ?>
<!-- <tr>
<td width="80%" class="dataTableContent" >
<p align="right"><input type="submit" name="submit" value="Update Product"></p>
</td>
</tr> -->
<?php
} else {
echo 'Product ID missing.';
}
?>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- body_text_eof //-->
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>