Need Help Please

Locked
Results 1 to 20 of 26
This thread is locked. New replies are disabled.
25 May 2007, 13:38
#1
eagle75au avatar

eagle75au

New Zenner

Join Date:
May 2007
Posts:
64
Plugin Contributions:
0

Need Help Please

Hey ,

Need help porting a mod into Zen from osC...

This module in osC is far better then the current 'Easy Populate' mod..

i have tried going through the porting guidlines but im well stuck..

2 Parts -

The PhP file 'Quick_Add_Products'

and

The SQL File..

here is both:

<?php

require('includes/application_top.php');
//// Tax Row
$tax_class_array = array();
$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']);
}

////Info Row
$manufacturers_array = array(array('id' => '0', 'text' => NO_MANUFACTURER));
$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']);
}

##// Update database
switch ($HTTP_GET_VARS['action']) {
case 'add' :
$products_added = 0;

for ($i = 1; $i <= MAX_PRODUCTS; $i++) {
$valid = false; $product_exist = false;
if($HTTP_POST_VARS['product_name'][$i]){
foreach($HTTP_POST_VARS['product_name'][$i] as $id => $product_language_name){
if($product_language_name != ''){
if(!$product_exist){
if(strrchr($HTTP_POST_VARS['product_image'][$i], '\\'))$image = substr(strrchr(trim(stripslashes($HTTP_POST_VARS['product_image'][$i])), '\\'), 1);else $image = substr(strrchr(trim(stripslashes($HTTP_POST_VARS['product_image'][$i])), '/'), 1);
tep_db_query("INSERT INTO " . TABLE_PRODUCTS . " (products_quantity, products_model, products_image, products_price, products_weight, products_status, products_tax_class_id, manufacturers_id) VALUES (" . $HTTP_POST_VARS['product_quantity'][$i] . ", '" . $HTTP_POST_VARS['product_model'][$i] . "', '" . $image . "', " . $HTTP_POST_VARS['product_price'][$i] . ", " . $HTTP_POST_VARS['product_weight'][$i] . ", ". $HTTP_POST_VARS['product_status'][$i] . ", " . $HTTP_POST_VARS['product_tax'][$i] . ", " . $HTTP_POST_VARS['product_manufacturer'][$i] . ");");
$products_id_query = tep_db_query("SELECT products_id from " . TABLE_PRODUCTS . " WHERE products_quantity=" . $HTTP_POST_VARS['product_quantity'][$i] ." and products_model='" . $HTTP_POST_VARS['product_model'][$i] ."' and products_price=" . $HTTP_POST_VARS['product_price'][$i] . " and products_weight=" . $HTTP_POST_VARS['product_weight'][$i] . " and products_image='" . $image . "' and products_status=" . $HTTP_POST_VARS['product_status'][$i] . " and products_tax_class_id=" . $HTTP_POST_VARS['product_tax'][$i] . " and manufacturers_id=" . $HTTP_POST_VARS['product_manufacturer'][$i] . ";");
$products_id = tep_db_fetch_array($products_id_query);
tep_db_query("INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . " VALUES ('" . $products_id['products_id'] . "', '" . $HTTP_POST_VARS['product_categories'][$i] . "');");
}
tep_db_query("INSERT INTO " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description) VALUES ('" . $products_id['products_id'] . "', '" . $HTTP_POST_VARS['languages'][$i][$id] . "', '" . $product_language_name . "', '" . $HTTP_POST_VARS['product_description'][$i][$id] . "');");

$product_exist = true;
$valid = true;
}
}
}
if($valid)$products_added++;
}
$messageStack->add($products_added . ' ' . TEXT_PRODUCTS_ADDED , 'success');
break;
}
##// Let's start displaying page with forms
?>
<!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">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<script language="javascript">
<!--
var browser_family;
var up = 1;
if (document.all && !document.getElementById)
browser_family = "dom2";
else if (document.layers)
browser_family = "ns4";
else if (document.getElementById)
browser_family = "dom2";
else
browser_family = "other";
function display_ttc(action, prix, taxe, up){
if(action == 'display'){
if(up != 1)
valeur = Math.round((prix + (taxe / 100) * prix) * 100) / 100;
}else{
if(action == 'keyup'){
valeur = Math.round((parseFloat(prix) + (taxe / 100) * parseFloat(prix)) * 100) / 100;
}else{
valeur = '0';
}
}
switch (browser_family){
case 'dom2':
document.getElementById('descDiv').innerHTML = 'TTC : '+valeur;
break;
case 'ie4':
document.all.descDiv.innerHTML = 'TTC : '+valeur;
break;
case 'ns4':
document.descDiv.document.descDiv_sub.document.write(valeur);
document.descDiv.document.descDiv_sub.document.close();
break;
case 'other':
break;
}
}
-->
</script>
<!-- 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">
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading" colspan="3" valign="top"><?php echo HEADING_TITLE . "<br><br>"; ?></td>
</tr>
</table></td></tr>
<tr><td align="center">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr align="center">
<form name="add" method="POST" action="<?php echo "$PHP_SELF?action=add"; ?>">
<td class="smalltext" align="middle"><?php echo WARNING_MESSAGE; ?> </td>
<?php echo "<td class=\"pageHeading\" align=\"right\">" . '<script language="javascript"><!--
switch (browser_family)
{
case "dom2":
case "ie4":
document.write(\'<div id="descDiv">\');
break;
default:
document.write(\'<ilayer id="descDiv"><layer id="descDiv_sub">\');
break;
}
-->
</script>' . "</td>\n";
?>
<td align="right" valign="middle"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE, "action=add");?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent" align="left" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_MODEL ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="middle" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_PRODUCTS ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_STATUS ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_WEIGHT ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_QUANTITY ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_IMAGE ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_MANUFACTURERS ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_CATEGORIES ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_PRICE ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_TAX ."</td>"; ?>
</tr>
</table>
</td>
</tr>
<tr class="datatableRow">
<?php
for ($i = 1; $i <= MAX_PRODUCTS; $i++) {
echo '<tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="'; if(DISPLAY_TVA_OVER == 'true'){echo 'display_ttc(\'delete\');';} echo 'this.className=\'dataTableRow\'">';
echo "<td class=\"smallText\" align=\"center\"><input type=\"text\" size=\"10\" name=\"product_model[".$i."]\"></td>\n";
// The name in all languages.
echo "<td class=\"smallText\" align=\"center\">";
echo '<table border="0" cellspacing="0" cellpadding="0">';
$languages_query = tep_db_query("select languages_id, name, image, directory from " . TABLE_LANGUAGES . " order by sort_order ASC");
while($languages = tep_db_fetch_array($languages_query)){
echo '<tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'"><td class="smallText" align="center">';
echo "<input type=\"text\" size=\"25\" name=\"product_name[".$i."][".$languages['languages_id']."]\">" . ' ' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages['directory'] . '/images/' . $languages['image'], $languages['name']) . " <input type=\"text\" size=\"25\" name=\"product_description[".$i."][".$languages['languages_id']."]\">" . ' ' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages['directory'] . '/images/' . $languages['image'], $languages['name']);
echo tep_draw_hidden_field('languages['.$i.']['.$languages['languages_id'] . ']',$languages['languages_id']);
echo '</td></tr>';
}
echo "</table></td>\n";

echo "<td class=\"smallText\" align=\"center\"><input type=\"radio\" name=\"product_status[".$i."]\" value=\"0\" ><input type=\"radio\" name=\"product_status[".$i."]\" value=\"1\" checked ></td>\n";
echo "<td class=\"smallText\" align=\"center\"><input type=\"text\" size=\"4\" name=\"product_weight[".$i."]\" value=0.00></td>\n";
echo "<td class=\"smallText\" align=\"center\"><input type=\"text\" size=\"2\" name=\"product_quantity[".$i."]\" value=0></td>\n";
echo "<td class=\"smallText\" align=\"center\">" . tep_draw_file_field('product_image['.$i.']') . " </td>\n";
echo "<td class=\"smallText\" align=\"center\">" . tep_draw_pull_down_menu("product_manufacturer[".$i."]", $manufacturers_array, $products['manufacturers_id'])."</td>\n";
echo "<td class=\"smallText\" align=\"center\">" . tep_draw_pull_down_menu("product_categories[".$i."]", tep_get_category_tree());
echo "<td class=\"smallText\" align=\"center\"> <input type=\"text\" size=\"6\" name=\"product_price[".$i."]\" value=0.0000 "; if(DISPLAY_TVA_UP == 'true'){ echo "onKeyUp=\"display_ttc('keyup', this.value" . ", " . ALL_INCLUDED_TAX_VALUE . ", 1);\"";} echo "></td>\n";
echo "<td class=\"smallText\" align=\"center\">" . tep_draw_pull_down_menu("product_tax[".$i."]", $tax_class_array, $products['products_tax_class_id'])."</td>\n";
}
echo "</table>\n";
?>
</td>
</tr>
<tr>
<td align="right">
<?php
echo tep_image_submit('button_update.gif', IMAGE_UPDATE);
echo ' <a href="' . tep_href_link(FILENAME_QUICK_ADD_PRODUCTS) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';
?>
</td>
</tr>
</form>
</table>
</tr>
</table></td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->
</tr>
</table>
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>


The SQL

INSERT INTO `configuration_group` (`configuration_group_id`, `configuration_group_title`, `configuration_group_description`, `sort_order`, `visible`) VALUES ('400', 'Quick Add Product', 'You can for example choose haw many products will be added in one time.', '400', '1');
INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) VALUES (2000, 'Number of products.', 'MAX_PRODUCTS', '5', 'Number of products you can add in one time.', '400', '0', '2003-06-04 08:49:27', '2003-06-04 08:49:27', NULL, NULL),
(2001, 'Display price with all included tax.', 'DISPLAY_TVA_UP_ADD', 'true', 'Do you want that the price with all included tax be displayed?', 3400, 11, '2003-06-04 05:07:06', '2003-06-04 04:40:12', NULL, 'tep_cfg_select_option(array(\'true\', \'false\'),'),
(2002, 'Taxe rate.', 'ALL_INCLUDED_TAX_VALUE', 19.6, 'You have to choose the tax rate you want to use to calculate the price with all included tax.', 3400, 11, '2003-06-04 05:07:06', '2003-06-04 04:40:12', NULL, NULL);



I have Attached a Screen Shot of it from osC..

Anyone please help, this mod is an awesome help to anyone who has a huge amount of products.
26 May 2007, 09:17
#2
chuckl avatar

chuckl

Totally Zenned

Join Date:
Nov 2006
Posts:
717
Plugin Contributions:
0

Re: Need Help Please

What is the question?
26 May 2007, 11:33
#3
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Need Help Please

Here's some hint. However, I'm not convinced with the languages since Zen-Cart already uses their own classes languages object in order to be used internationally. :wink2:

<?php

<?php

require('includes/application_top.php');

if (isset($_GET['action']) || isset($_POST['action'])) {
    $action = (isset($_POST['action'])) ? zen_db_prepare_input($_POST['action']) : zen_db_prepare_input($_GET['action']);
    $action = preg_replace("/[^a-z0-9\-\_]+/i", "", $action);
} else {
    $action = "";
} // End of if statement.

//// Tax Row
$tax_class_array = array();
$tax_class_query = $db->Execute("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
$tax_class = new objectInfo($tax_class_query->fields);
while ($tax_class->EOF) {
$tax_class_array[] = array('id' => $tax_class->tax_class_id, 'text' => $tax_class->tax_class_title);
$tax_class->MoveNext();
}

////Info Row
$manufacturers_array = array(array('id' => '0', 'text' => NO_MANUFACTURER));
$manufacturers_query = $db->Execute("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
$nanufacturers = new objectInfo($manufacturers_query->fields);
$manufacturers_array[] = array('id' => $manufacturers->manufacturers_id, 'text' => $manufacturers->manufacturers_name);
}

##// Update database
switch ($action) {
case 'add' :
$products_added = 0;

$product_name = (isset($_POST['product_name'])) ? zen_db_prepare_input($_POST['product_name']) : '';
$product_image = (isset($_POST['product_image'])) ? zen_db_prepare_input($_POST['product_image']) : '';
$product_quantity = (isset($_POST['product_quantity'])) ? zen_db_prepare_input($_POST['product_quantity']) : 0;
$product_model = (isset($_POST['product_model'])) ? zen_db_prepare_input($_POST['product_model']) : '';
$product_price = (isset($_POST['product_price'])) ? zen_db_prepare_input($_POST['product_price']) : '';
$product_weight = (isset($_POST['product_weight'])) ? zen_db_prepare_input($_POST['product_weight']) : '';
$product_status = (isset($_POST['product_status'])) ? zen_db_prepare_input($_POST['product_status']) : '';
$product_tax = (isset($_POST['product_tax'])) ? zen_db_prepare_input($_POST['product_tax']) : '';
$product_manufacturer = (isset($_POST['product_manufacturer'])) ? zen_db_prepare_input($_POST['product_manufacturer']) : '';
$product_categories = (isset($_POST['product_categories'])) ? zen_db_prepare_input($_POST['product_categories']) : '';
$product_description = (isset($_POST['product_description'])) ? zen_db_prepare_input($_POST['product_description']) : '';


for ($i = 1; $i <= MAX_PRODUCTS; $i++) {
$valid = false; $product_exist = false;
if(isset($product_name) && $product_name[$i]){
foreach($product_name[$i] as $id => $product_language_name){
if($product_language_name != ''){
if(!$product_exist){
if(strrchr($product_name][$i], '\\'))$image = substr(strrchr($product_image][$i])), '\\', 1;else $image = substr(strrchr($product_image][$i])), '/', 1;
$db->Execute("INSERT INTO " . TABLE_PRODUCTS . " (products_quantity, products_model, products_image, products_price, products_weight, products_status, products_tax_class_id, manufacturers_id) VALUES (" . $product_quantity[$i] . ", '" . $product_model[$i] . "', '" . $image . "', " . $product_price[$i] . ", " . $product_weight[$i] . ", ". $product_status[$i] . ", " . $product_tax[$i] . ", " . $product_manufacturer[$i] . ");");
$products_id_query = $db->Execute("SELECT products_id from " . TABLE_PRODUCTS . " WHERE products_quantity=" . $product_quantity[$i] ." and products_model='" . $product_model[$i] ."' and products_price=" . $product_price[$i] . " and products_weight=" . $product_weight[$i] . " and products_image='" . $image . "' and products_status=" . $product_status[$i] . " and products_tax_class_id=" . $product_tax[$i] . " and manufacturers_id=" . $product_manufacturer[$i] . ";");
$products_id = new objectInfo($products_id_query->fields);
$db->Execute("INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . " VALUES ('" . $products_id->products_id . "', '" . $product_categories[$i] . "');");
}
$db->Execute("INSERT INTO " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description) VALUES ('" . $products_id->products_id . "', '" . $languages[$i][$id] . "', '" . $product_language_name . "', '" . $product_description[$i][$id] . "');");

$product_exist = true;
$valid = true;
}
}
}
if($valid)$products_added++;
}
$messageStack->add($products_added . ' ' . TEXT_PRODUCTS_ADDED , 'success');
break;
}
##// Let's start displaying page with forms
?>
<!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">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<script language="javascript">
<!--
var browser_family;
var up = 1;
if (document.all && !document.getElementById)
browser_family = "dom2";
else if (document.layers)
browser_family = "ns4";
else if (document.getElementById)
browser_family = "dom2";
else
browser_family = "other";
function display_ttc(action, prix, taxe, up){
if(action == 'display'){
if(up != 1)
valeur = Math.round((prix + (taxe / 100) * prix) * 100) / 100;
}else{
if(action == 'keyup'){
valeur = Math.round((parseFloat(prix) + (taxe / 100) * parseFloat(prix)) * 100) / 100;
}else{
valeur = '0';
}
}
switch (browser_family){
case 'dom2':
document.getElementById('descDiv').innerHTML = 'TTC : '+valeur;
break;
case 'ie4':
document.all.descDiv.innerHTML = 'TTC : '+valeur;
break;
case 'ns4':
document.descDiv.document.descDiv_sub.document.wri te(valeur);
document.descDiv.document.descDiv_sub.document.clo se();
break;
case 'other':
break;
}
}
-->
</script>
<!-- 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">
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading" colspan="3" valign="top"><?php echo HEADING_TITLE . "<br><br>"; ?></td>
</tr>
</table></td></tr>
<tr><td align="center">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr align="center">
<form name="add" method="POST" action="<?php echo "$PHP_SELF?action=add"; ?>">
<td class="smalltext" align="middle"><?php echo WARNING_MESSAGE; ?> </td>
<?php echo "<td class=\"pageHeading\" align=\"right\">" . '<script language="javascript"><!--
switch (browser_family)
{
case "dom2":
case "ie4":
document.write(\'<div id="descDiv">\');
break;
default:
document.write(\'<ilayer id="descDiv"><layer id="descDiv_sub">\');
break;
}
-->
</script>' . "</td>\n";
?>
<td align="right" valign="middle"><?php echo zen_draw_image_submit('button_update.gif', IMAGE_UPDATE, "action=add");?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent" align="left" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_MODEL ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="middle" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_PRODUCTS ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_STATUS ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_WEIGHT ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_QUANTITY ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_IMAGE ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_MANUFACTURERS ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_CATEGORIES ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_PRICE ."</td>"; ?>
</tr>
</table>
</td>
<td class="dataTableHeadingContent" align="center" valign="middle">
<table border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<?php echo "<td class=\"dataTableHeadingContent\" align=\"center\" valign=\"middle\">" .TABLE_HEADING_TAX ."</td>"; ?>
</tr>
</table>
</td>
</tr>
<tr class="datatableRow">
<?php
for ($i = 1; $i <= MAX_PRODUCTS; $i++) {
echo '<tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';t his.style.cursor=\'hand\'" onmouseout="'; if(DISPLAY_TVA_OVER == 'true'){echo 'display_ttc(\'delete\');';} echo 'this.className=\'dataTableRow\'">';
echo "<td class=\"smallText\" align=\"center\"><input type=\"text\" size=\"10\" name=\"product_model[".$i."]\"></td>\n";
// The name in all languages.
echo "<td class=\"smallText\" align=\"center\">";
echo '<table border="0" cellspacing="0" cellpadding="0">';
$languages_query = $db->Execute("select languages_id, name, image, directory from " . TABLE_LANGUAGES . " order by sort_order ASC");
$languages = new objectInfo($languages_query->fields);
while($languages->EOF){
echo '<tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';t his.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'"><td class="smallText" align="center">';
echo "<input type=\"text\" size=\"25\" name=\"product_name[".$i."][".$languages->languages_id."]\">" . ' ' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages->directory . '/images/' . $languages->image, $languages->name) . " <input type=\"text\" size=\"25\" name=\"product_description[".$i."][".$languages->languages_id."]\">" . ' ' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages->directory . '/images/' . $languages->image, $languages->name);
echo zen_draw_hidden_field('languages['.$i.']['.$languages->languages_id . ']',$languages->languages_id);
echo '</td></tr>';
$languages->MoveNext();
}
echo "</table></td>\n";

echo "<td class=\"smallText\" align=\"center\"><input type=\"radio\" name=\"product_status[".$i."]\" value=\"0\" ><input type=\"radio\" name=\"product_status[".$i."]\" value=\"1\" checked ></td>\n";
echo "<td class=\"smallText\" align=\"center\"><input type=\"text\" size=\"4\" name=\"product_weight[".$i."]\" value=0.00></td>\n";
echo "<td class=\"smallText\" align=\"center\"><input type=\"text\" size=\"2\" name=\"product_quantity[".$i."]\" value=0></td>\n";
echo "<td class=\"smallText\" align=\"center\">" . zen_draw_input_field('product_image['.$i.']') . " </td>\n";
echo "<td class=\"smallText\" align=\"center\">" . zen_draw_pull_down_menu("product_manufacturer[".$i."]", $manufacturers_array, $products_id->manufacturers_id)."</td>\n";
echo "<td class=\"smallText\" align=\"center\">" . zen_draw_pull_down_menu("product_categories[".$i."]", zen_get_category_tree());
echo "<td class=\"smallText\" align=\"center\"> <input type=\"text\" size=\"6\" name=\"product_price[".$i."]\" value=0.0000 "; if(DISPLAY_TVA_UP == 'true'){ echo "onKeyUp=\"display_ttc('keyup', this.value" . ", " . ALL_INCLUDED_TAX_VALUE . ", 1);\"";} echo "></td>\n";
echo "<td class=\"smallText\" align=\"center\">" . zen_draw_pull_down_menu("product_tax[".$i."]", $tax_class_array, $products_id->products_tax_class_id)."</td>\n";
}
echo "</table>\n";
?>
</td>
</tr>
<tr>
<td align="right">
<?php
echo zen_image_submit('button_update.gif', IMAGE_UPDATE);
echo ' <a href="' . zen_href_link(FILENAME_QUICK_ADD_PRODUCTS) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';
?>
</td>
</tr>
</form>
</table>
</tr>
</table></td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->
</tr>
</table>
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
26 May 2007, 11:49
#4
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Need Help Please

Additionally to the above,

replace all instances of:

[php]
while($
[/php]

with:

[php]
while(!$
[/php]

Forgot to do it while I was coding.
26 May 2007, 11:56
#5
eagle75au avatar

eagle75au

New Zenner

Join Date:
May 2007
Posts:
64
Plugin Contributions:
0

Re: Need Help Please

thx for the help, i shall give it a try...

does the SQL seem fine to work with Zen?

sorry to be a pest but, i dont wanna insert these commands only to have the whole store come down...

im guessing that Zen was based on osC and that the relevant queries would suit the database.
26 May 2007, 12:08
#6
chuckl avatar

chuckl

Totally Zenned

Join Date:
Nov 2006
Posts:
717
Plugin Contributions:
0

Re: Need Help Please

I would say the only contentious area in the SQl is that it hard codes ID's in fields that are auto increment.
The usual technique is followed, a variation of the C programmers disease, as the id is set to a random 'large' number, in the hope that the auto increment will never get that far.
This could come back and bite in the future.
26 May 2007, 12:11
#7
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Need Help Please

[php]
INSERT INTO configuration_group (configuration_group_id, configuration_group_title, configuration_group_description, sort_order, visible) VALUES ('400', 'Quick Add Product', 'You can for example choose haw many products will be added in one time.', '400', '1');
INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES (2000, 'Number of products.', 'MAX_PRODUCTS', '5', 'Number of products you can add in one time.', '400', '0', '2003-06-04 08:49:27', '2003-06-04 08:49:27', NULL, NULL),
(2001, 'Display price with all included tax.', 'DISPLAY_TVA_UP_ADD', 'true', 'Do you want that the price with all included tax be displayed?', 3400, 11, '2003-06-04 05:07:06', '2003-06-04 04:40:12', NULL, 'tep_cfg_select_option(array(\'true\', \'false\'),'),
(2002, 'Taxe rate.', 'ALL_INCLUDED_TAX_VALUE', 19.6, 'You have to choose the tax rate you want to use to calculate the price with all included tax.', 3400, 11, '2003-06-04 05:07:06', '2003-06-04 04:40:12', NULL, NULL);
[/php]

Perhaps this one will return better results. :cool:
26 May 2007, 13:45
#8
eagle75au avatar

eagle75au

New Zenner

Join Date:
May 2007
Posts:
64
Plugin Contributions:
0

Re: Need Help Please

ok i gave it a try and got this error...

Parse error: syntax error, unexpected ',' in /home/tower/public_html/admin/quick_add_products.php on line 54

i also tried the original line with the zen mods

if(strrchr($_POST['product_image'][$i], '\\'))$image = substr(strrchr(trim(stripslashes($_POST['product_image'][$i])), '\\'), 1);else $image = substr(strrchr(trim(stripslashes($_POST['product_image'][$i])), '/'), 1);


but got these errors

Warning: main(includes/boxes/configuration.php) [function.main]: failed to open stream: No such file or directory in /home/tower/public_html/admin/includes/column_left.php on line 13

Warning: main(includes/boxes/configuration.php) [function.main]: failed to open stream: No such file or directory in /home/tower/public_html/admin/includes/column_left.php on line 13

Warning: main(includes/boxes/configuration.php) [function.main]: failed to open stream: No such file or directory in /home/tower/public_html/admin/includes/column_left.php on line 13

Fatal error: main() [function.require]: Failed opening required 'includes/boxes/configuration.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/tower/public_html/admin/includes/column_left.php on line 13
26 May 2007, 15:18
#9
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Need Help Please

Replace all instances of:

[php]
;");
[/php]

with:

[php]
");
[/php]

(by keeping the modified codes)
27 May 2007, 12:08
#10
eagle75au avatar

eagle75au

New Zenner

Join Date:
May 2007
Posts:
64
Plugin Contributions:
0

Re: Need Help Please

if(strrchr([$product_name][$i], '\\'))$image = substr(strrchr([$product_image][$i])), '\\', 1;else $image = substr(strrchr([$product_image][$i])), '/', 1;


if(strrchr($_POST['product_image'][$i], '\\'))$image = substr(strrchr(trim(stripslashes($_POST['product_image'][$i])), '\\'), 1);else $image = substr(strrchr(trim(stripslashes($_POST['product_image'][$i])), '/'), 1);



the 1st line of code i tried came up with this error:
Parse error: syntax error, unexpected '[', expecting ')' in /home/tower/public_html/admin/quick_add_products.php on line 54


the 2nd line which i had a go at comes up with another error:
Parse error: syntax error, unexpected T_STRING in /home/tower/public_html/admin/quick_add_products.php on line 57


this is line 57
$products_id_query = $db->Execute("SELECT products_id from " . TABLE_PRODUCTS . " WHERE products_quantity=" . $product_quantity[$i] ." and products_model=" . $product_model[$i] ." and products_price=" . $product_price[$i] . " and products_weight=" . $product_weight[$i] . " and products_image=" . $image . " and products_status=" . $product_status[$i] . " and products_tax_class_id=" . $product_tax[$i] . " and manufacturers_id=" . $product_manufacturer[$i] . ";


i also fixed the last instances that were only in line 54
27 May 2007, 12:13
#11
eagle75au avatar

eagle75au

New Zenner

Join Date:
May 2007
Posts:
64
Plugin Contributions:
0

Re: Need Help Please

another strange thing is that if i comment out line 57 it still shows the same error in line 57
27 May 2007, 12:20
#12
chuckl avatar

chuckl

Totally Zenned

Join Date:
Nov 2006
Posts:
717
Plugin Contributions:
0

Re: Need Help Please

Server or Browser caching?
27 May 2007, 12:51
#13
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Need Help Please

[php]
(strrchr([$product_name][$i]
[/php]

All these instances should look like these:

[php]
(strrchr($product_name[$i]
[/php]

:wink2:
27 May 2007, 13:04
#14
eagle75au avatar

eagle75au

New Zenner

Join Date:
May 2007
Posts:
64
Plugin Contributions:
0

Re: Need Help Please

if(strrchr($product_name[$i], '\\'))$image = substr(strrchr($product_image[$i])), '\\', 1;else $image = substr(strrchr($product_image[$i])), '/', 1;


Parse error: syntax error, unexpected ',' in /home/tower/public_html/admin/quick_add_products.php on line 54
27 May 2007, 13:11
#15
chuckl avatar

chuckl

Totally Zenned

Join Date:
Nov 2006
Posts:
717
Plugin Contributions:
0

Re: Need Help Please

else $image = substr(strrchr($product_image[$i])), '/', 1;

If you put the closing brackets in the right place, it might work better?
Perhaps you mean

else $image = substr(strrchr($product_image[$i], '/'), 1);
27 May 2007, 21:28
#16
eagle75au avatar

eagle75au

New Zenner

Join Date:
May 2007
Posts:
64
Plugin Contributions:
0

Re: Need Help Please

returns the same error
27 May 2007, 23:26
#17
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Need Help Please

Make a backup of the file.

On the error block you mentionned, if you replace it with this one:

[php]
if (eregi('\\', $product_name[$i])) {
$image = substr($product_image[$i], 1);
} else {
$image = str_replace('\\', '/', $image);
$image = substr($image, 1);
}
[/php]

Will it still return the same error message ?
28 May 2007, 09:11
#18
eagle75au avatar

eagle75au

New Zenner

Join Date:
May 2007
Posts:
64
Plugin Contributions:
0

Re: Need Help Please

thx oracle that code seems to have worked ...

next error lol

Parse error: syntax error, unexpected T_STRING in /home/tower/public_html/admin/quick_add_products.php on line 66

$db->Execute("INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . " VALUES ('" . $products_id->products_id . "', '" . $product_categories[$i] . "'));


note there is only a few lines left of code before it starts to display the page... hopefully this will be all that faults...
28 May 2007, 19:28
#19
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Need Help Please

[php]
$db->Execute("INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . " VALUES ('" . $products_id->products_id . "', '" . $product_categories[$i] . "'));
[/php]

to:

[php]
$db->Execute("INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . " VALUES ('" . (int)$products_id->products_id . "', '" . $product_categories[$i] . "')");
[/php]
28 May 2007, 21:28
#20
eagle75au avatar

eagle75au

New Zenner

Join Date:
May 2007
Posts:
64
Plugin Contributions:
0

Re: Need Help Please

still same error