SQL Stuff:
Code:
ALTER TABLE `xcart_products` ADD `categoryid4` INT DEFAULT '0' NOT NULL AFTER `categoryid3`,
ADD `categoryid5` INT DEFAULT '0' NOT NULL AFTER `categoryid4`,
ADD `categoryid6` INT DEFAULT '0' NOT NULL AFTER `categoryid5`,
ADD `categoryid7` INT DEFAULT '0' NOT NULL AFTER `categoryid6`,
ADD `categoryid8` INT DEFAULT '0' NOT NULL AFTER `categoryid7`,
ADD `categoryid9` INT DEFAULT '0' NOT NULL AFTER `categoryid8`,
ADD `categoryid10` INT DEFAULT '0' NOT NULL AFTER `categoryid9`,
ADD `categoryid11` INT DEFAULT '0' NOT NULL AFTER `categoryid10`,
ADD `categoryid12` INT DEFAULT '0' NOT NULL AFTER `categoryid11`,
ADD `categoryid13` INT DEFAULT '0' NOT NULL AFTER `categoryid12`,
ADD `categoryid14` INT DEFAULT '0' NOT NULL AFTER `categoryid13`,
ADD `categoryid15` INT DEFAULT '0' NOT NULL AFTER `categoryid14`,
ADD `categoryid16` INT DEFAULT '0' NOT NULL AFTER `categoryid15`,
ADD `categoryid17` INT DEFAULT '0' NOT NULL AFTER `categoryid16`,
ADD `categoryid18` INT DEFAULT '0' NOT NULL AFTER `categoryid17`,
ADD `categoryid19` INT DEFAULT '0' NOT NULL AFTER `categoryid18`,
ADD `categoryid20` INT DEFAULT '0' NOT NULL AFTER `categoryid19`,
ADD `categoryid21` INT DEFAULT '0' NOT NULL AFTER `categoryid20`,
ADD `categoryid22` INT DEFAULT '0' NOT NULL AFTER `categoryid21`,
ADD `categoryid23` INT DEFAULT '0' NOT NULL AFTER `categoryid22`,
ADD `categoryid24` INT DEFAULT '0' NOT NULL AFTER `categoryid23`,
ADD `categoryid25` INT DEFAULT '0' NOT NULL AFTER `categoryid24`,
ADD `categoryid26` INT DEFAULT '0' NOT NULL AFTER `categoryid25`,
ADD `categoryid27` INT DEFAULT '0' NOT NULL AFTER `categoryid26`,
ADD `categoryid28` INT DEFAULT '0' NOT NULL AFTER `categoryid27`,
ADD `categoryid29` INT DEFAULT '0' NOT NULL AFTER `categoryid28`;
------------------------------------
include/categories.php
------------------------------------
Code:
<?
#for increase speed
$enable_subcategories_count = $config["General"]["count_products"]=="Y"?1:0;
if ($current_area == "C") {
$membership_condition = " AND ($sql_tbl[categories].membership='$user_account[membership]' OR $sql_tbl[categories].membership='') ";
} else {
$membership_condition = "";
}
$categories_data = func_query("select $sql_tbl[categories].*, 0 as product_count from $sql_tbl[categories] ".($current_area=="C"?"where $sql_tbl[categories].avail='Y' $membership_condition ":"")." group by $sql_tbl[categories].categoryid order by ".($current_area=="C" ? "order_by" : "category"));
#
# Put all categories into $all_categories array and find current_category
# by categoryid stored in $cat
#
if(!$categories_data) $categories_data = array();
$all_categories = $categories_data;
foreach($categories_data as $category_data) {
if ($category_data["categoryid"]==$cat) {
$current_category = $category_data;
$current_category["product_count"] = array_pop(func_query_first("
SELECT COUNT(*) FROM $sql_tbl[products] WHERE (
categoryid=$category_data[categoryid]
OR categoryid1=$category_data[categoryid]
OR categoryid2=$category_data[categoryid]
OR categoryid3=$category_data[categoryid]
OR categoryid4=$category_data[categoryid]
OR categoryid5=$category_data[categoryid]
OR categoryid6=$category_data[categoryid]
OR categoryid7=$category_data[categoryid]
OR categoryid8=$category_data[categoryid]
OR categoryid9=$category_data[categoryid]
OR categoryid10=$category_data[categoryid]
OR categoryid11=$category_data[categoryid]
OR categoryid12=$category_data[categoryid]
OR categoryid13=$category_data[categoryid]
OR categoryid14=$category_data[categoryid]
OR categoryid15=$category_data[categoryid]
OR categoryid16=$category_data[categoryid]
OR categoryid17=$category_data[categoryid]
OR categoryid18=$category_data[categoryid]
OR categoryid19=$category_data[categoryid]
OR categoryid20=$category_data[categoryid]
OR categoryid21=$category_data[categoryid]
OR categoryid22=$category_data[categoryid]
OR categoryid23=$category_data[categoryid]
OR categoryid24=$category_data[categoryid]
OR categoryid25=$category_data[categoryid]
OR categoryid26=$category_data[categoryid]
OR categoryid27=$category_data[categoryid]
OR categoryid28=$category_data[categoryid]
OR categoryid29=$category_data[categoryid]
) and $sql_tbl[products].forsale='Y'"));
}
}
#
# Put all root categories to $categories array
# Put all subcategories of current_category to $categories array
#
foreach($all_categories as $all_category) {
$category=$all_category["category"];
$cur_dir_len = strlen($current_category["category"]);
if(!strstr($category,"/")) {
$categories[]=$all_category;
if(empty($current_category)) {
if($enable_subcategories_count)
$all_category["product_count"]=array_pop(func_query_first("
SELECT COUNT(*) FROM $sql_tbl[products] WHERE $sql_tbl[products].forsale='Y' and (
categoryid='$all_category[categoryid]'
OR categoryid1='$all_category[categoryid]'
OR categoryid2='$all_category[categoryid]'
OR categoryid3='$all_category[categoryid]'
OR categoryid4='$all_category[categoryid]'
OR categoryid5='$all_category[categoryid]'
OR categoryid6='$all_category[categoryid]'
OR categoryid7='$all_category[categoryid]'
OR categoryid8='$all_category[categoryid]'
OR categoryid9='$all_category[categoryid]'
OR categoryid10='$all_category[categoryid]'
OR categoryid11='$all_category[categoryid]'
OR categoryid12='$all_category[categoryid]'
OR categoryid13='$all_category[categoryid]'
OR categoryid14='$all_category[categoryid]'
OR categoryid15='$all_category[categoryid]'
OR categoryid16='$all_category[categoryid]'
OR categoryid17='$all_category[categoryid]'
OR categoryid18='$all_category[categoryid]'
OR categoryid19='$all_category[categoryid]'
OR categoryid20='$all_category[categoryid]'
OR categoryid21='$all_category[categoryid]'
OR categoryid22='$all_category[categoryid]'
OR categoryid23='$all_category[categoryid]'
OR categoryid24='$all_category[categoryid]'
OR categoryid25='$all_category[categoryid]'
OR categoryid26='$all_category[categoryid]'
OR categoryid27='$all_category[categoryid]'
OR categoryid28='$all_category[categoryid]'
OR categoryid29='$all_category[categoryid]'
)
"));
$subcategories[]=$all_category;
}
}
if(substr($category,0,$cur_dir_len+1) == $current_category["category"]."/" and $category!=$current_category["category"])
if(!strstr(substr($category,$cur_dir_len+1),"/")) {
if($enable_subcategories_count)
$all_category["product_count"]=array_pop(func_query_first("
select count(*) from $sql_tbl[products] where $sql_tbl[products].forsale='Y' and (
categoryid='$all_category[categoryid]'
OR categoryid1='$all_category[categoryid]'
OR categoryid2='$all_category[categoryid]'
OR categoryid3='$all_category[categoryid]'
OR categoryid4='$all_category[categoryid]'
OR categoryid5='$all_category[categoryid]'
OR categoryid6='$all_category[categoryid]'
OR categoryid7='$all_category[categoryid]'
OR categoryid8='$all_category[categoryid]'
OR categoryid9='$all_category[categoryid]'
OR categoryid10='$all_category[categoryid]'
OR categoryid11='$all_category[categoryid]'
OR categoryid12='$all_category[categoryid]'
OR categoryid13='$all_category[categoryid]'
OR categoryid14='$all_category[categoryid]'
OR categoryid15='$all_category[categoryid]'
OR categoryid16='$all_category[categoryid]'
OR categoryid17='$all_category[categoryid]'
OR categoryid18='$all_category[categoryid]'
OR categoryid19='$all_category[categoryid]'
OR categoryid20='$all_category[categoryid]'
OR categoryid21='$all_category[categoryid]'
OR categoryid22='$all_category[categoryid]'
OR categoryid23='$all_category[categoryid]'
OR categoryid24='$all_category[categoryid]'
OR categoryid25='$all_category[categoryid]'
OR categoryid26='$all_category[categoryid]'
OR categoryid27='$all_category[categoryid]'
OR categoryid28='$all_category[categoryid]'
OR categoryid29='$all_category[categoryid]'
)
"));
$all_category["category"]=ereg_replace("^.*/","",$all_category["category"]);
$subcategories[]=$all_category;
}
}
#
# Put subcategory_count to $subcategories array
#
if ($subcategories)
foreach($subcategories as $key =>$subcategory) {
$subcategory["subcategory_count"]=0;
foreach($all_categories as $all_category) {
if ($all_category["categoryid"]==$subcategory["categoryid"]) {
$cur_dir_len = strlen($all_category["category"]);
$current_subcategory=$all_category["category"];
}
}
foreach($all_categories as $all_category) {
$category=$all_category["category"];
if(substr($category,0,$cur_dir_len+1) == $current_subcategory."/" and $category!=$current_subcategory)
if(!strstr(substr($category,$cur_dir_len+1),"/"))
$subcategory["subcategory_count"]++;
}
$subcategories[$key]["subcategory_count"]=$subcategory["subcategory_count"];
}
#
# Generate category sequence, i.e.
# Books, Books/Poetry, Books/Poetry/Philosophy ...
#
$current_category_array = explode("/",$current_category["category"]);
$prev = $current_category_array[0];
list($key,$val)=each($current_category_array);
$new_array = array($val);
while(list($key,$val)=each($current_category_array)) {
$new_array[] = $prev."/".$val;
$prev = $prev."/".$val;
}
unset($current_category_array);
#
# Generate array for displaying categories sequence in location
#
$category_location=array();
reset($all_categories);
$my_cats = array ();
foreach($all_categories as $all_category) {
$categoryid=$all_category["categoryid"];
$category=$all_category["category"];
$my_cats [$categoryid] = $category;
}
asort ($my_cats);
foreach ($my_cats as $categoryid => $category) {
reset ($new_array);
while(list($key,$val)=each($new_array))
if ($val==$category) $category_location[]=array(ereg_replace(".*/","",$val),"home.php?cat=".$categoryid);
}
#
# Assign Smarty variables
#
$smarty->assign("allcategories",$all_categories);
$smarty->assign("categories",$categories);
$smarty->assign("subcategories",$subcategories);
$smarty->assign("current_category",$current_category);
$smarty->assign("enable_subcategories_count",$enable_subcategories_count);
$smarty->assign("cat",$cat);
?>
------------------------------
\skin1\main\product_modify.tpl
------------------------------
Code:
{* $Id: product_modify.tpl,v 1.60.2.1 2003/02/18 09:19:54 svowl Exp $ *}
{if $product.productid ne ""}
{assign var="last_location" value=$lng.lbl_product_modify}
{else}
{assign var="last_location" value=$lng.lbl_add_product}
{/if}
{ include file="location.tpl" last_location=$last_location }
{capture name=dialog}
<form name="modifyform" action="product_modify.php?productid={$product.productid}" method=post enctype="multipart/form-data">
<table border=0 cellpadding="0">
<tr>
<td valign="top" class="ProductDetailsTitle">{$lng.lbl_classification}</td>
<td></td>
</tr>
<tr>
<td class=Line height="1" colspan=2>[img]{$ImagesDir}/orangespacer.gif[/img]</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td class=ProductDetails>{$lng.lbl_main_category}</td>
<td class=ProductDetails>
<select name="categoryid">
{section name=cat_num loop=$allcategories}
<option value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid}selected{/if}>{ $allcategories[cat_num].category }</option>
{/section}
</select>
{if $fillerror ne "" and $product.categoryid eq ""}<font class=Star><<</font>{/if}
</td>
<!--</tr>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #1</TD>
<TD class=ProductDetails>
<SELECT name="categoryid1">
<OPTION value=0 {if $product.categoryid1 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<option value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid1}selected{/if}>{ $allcategories[cat_num].category }</option>
{/section}
</SELECT></TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #2</TD>
<TD class=ProductDetails>
<SELECT name="categoryid2">
<OPTION value=0 {if $product.categoryid2 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid2}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT></TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #3</TD>
<TD class=ProductDetails>
<SELECT name="categoryid3">
<OPTION value=0 {if $product.categoryid3 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid3}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #4</TD>
<TD class=ProductDetails>
<SELECT name="categoryid4">
<OPTION value=0 {if $product.categoryid4 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid4}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #5</TD>
<TD class=ProductDetails>
<SELECT name="categoryid5">
<OPTION value=0 {if $product.categoryid5 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid5}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #6</TD>
<TD class=ProductDetails>
<SELECT name="categoryid6">
<OPTION value=0 {if $product.categoryid6 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid6}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #7</TD>
<TD class=ProductDetails>
<SELECT name="categoryid7">
<OPTION value=0 {if $product.categoryid7 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid7}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #8</TD>
<TD class=ProductDetails>
<SELECT name="categoryid8">
<OPTION value=0 {if $product.categoryid8 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid8}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #9</TD>
<TD class=ProductDetails>
<SELECT name="categoryid9">
<OPTION value=0 {if $product.categoryid9 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid9}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #10</TD>
<TD class=ProductDetails>
<SELECT name="categoryid10">
<OPTION value=0 {if $product.categoryid10 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid10}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #11</TD>
<TD class=ProductDetails>
<SELECT name="categoryid11">
<OPTION value=0 {if $product.categoryid11 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid11}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #12</TD>
<TD class=ProductDetails>
<SELECT name="categoryid12">
<OPTION value=0 {if $product.categoryid12 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid12}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #13</TD>
<TD class=ProductDetails>
<SELECT name="categoryid13">
<OPTION value=0 {if $product.categoryid13 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid13}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #14</TD>
<TD class=ProductDetails>
<SELECT name="categoryid14">
<OPTION value=0 {if $product.categoryid14 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid14}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #15</TD>
<TD class=ProductDetails>
<SELECT name="categoryid15">
<OPTION value=0 {if $product.categoryid15 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid15}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #16</TD>
<TD class=ProductDetails>
<SELECT name="categoryid16">
<OPTION value=0 {if $product.categoryid16 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid16}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #17</TD>
<TD class=ProductDetails>
<SELECT name="categoryid17">
<OPTION value=0 {if $product.categoryid17 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid17}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #18</TD>
<TD class=ProductDetails>
<SELECT name="categoryid18">
<OPTION value=0 {if $product.categoryid18 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid18}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #19</TD>
<TD class=ProductDetails>
<SELECT name="categoryid19">
<OPTION value=0 {if $product.categoryid19 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid19}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #20</TD>
<TD class=ProductDetails>
<SELECT name="categoryid20">
<OPTION value=0 {if $product.categoryid20 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid20}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #21</TD>
<TD class=ProductDetails>
<SELECT name="categoryid21">
<OPTION value=0 {if $product.categoryid21 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid21}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #22</TD>
<TD class=ProductDetails>
<SELECT name="categoryid22">
<OPTION value=0 {if $product.categoryid22 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid22}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #23</TD>
<TD class=ProductDetails>
<SELECT name="categoryid23">
<OPTION value=0 {if $product.categoryid23 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid23}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #24</TD>
<TD class=ProductDetails>
<SELECT name="categoryid24">
<OPTION value=0 {if $product.categoryid24 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid24}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #25</TD>
<TD class=ProductDetails>
<SELECT name="categoryid25">
<OPTION value=0 {if $product.categoryid25 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid25}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #26</TD>
<TD class=ProductDetails>
<SELECT name="categoryid26">
<OPTION value=0 {if $product.categoryid26 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid26}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #27</TD>
<TD class=ProductDetails>
<SELECT name="categoryid27">
<OPTION value=0 {if $product.categoryid27 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid27}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<TR>
<TD class=ProductDetails>{$lng.lbl_category} #28</TD>
<TD class=ProductDetails>
<SELECT name="categoryid28">
<OPTION value=0 {if $product.categoryid28 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid28}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
<!--</TR>
<TR>-->
<TD class=ProductDetails>{$lng.lbl_category} #29</TD>
<TD class=ProductDetails>
<SELECT name="categoryid29">
<OPTION value=0 {if $product.categoryid29 eq "0"}selected{/if}></OPTION>
{section name=cat_num loop=$allcategories}
<OPTION value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid29}selected{/if}>{ $allcategories[cat_num].category }</OPTION>
{/section}
</SELECT>
</TD>
</TR>
<tr>
<td class=ProductDetails height=11>{$lng.lbl_availability}</td>
<td class=ProductDetails height=11>
<select name="forsale">
<option value="Y" {if $product.forsale eq "Y"}selected{/if}>{$lng.lbl_avail_for_sale}</option>
<option value="N" {if $product.forsale eq "N"}selected{/if}>{$lng.lbl_disabled}</option>
</select>
</td>
<td></td>
<td></td>
</tr>
</table>
<table border="0" cellpadding="0">
<tr>
<td valign="top" class="ProductDetailsTitle">{$lng.lbl_details}</td>
<td></td>
</tr>
<tr>
<td class=Line height="1" colspan=2>[img]{$ImagesDir}/orangespacer.gif[/img]</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td class=ProductDetails nowrap>{$lng.lbl_sku}</td>
<td class=ProductDetails>
<input type="text" name="productcode" size="20" value="{ $product.productcode }">
</td>
</tr>
<tr>
<td class=ProductDetails nowrap>{$lng.lbl_product_name}</td>
<td class=ProductDetails>
<input type="text" name="product" size="45" value="{ $product.product|escape }">
{if $fillerror ne "" and $product.product eq ""}<font class=Star><<</font>{/if}
</td>
</tr>
{if $active_modules.Egoods ne ""}
{include file="modules/Egoods/egoods.tpl"}
{/if}
<tr>
<td valign="top" class=ProductDetails>{$lng.lbl_description}</td>
<td valign="top" class=ProductDetails>
<textarea name="descr" cols="45" rows="6">{ $product.descr|replace:"
":"\n"|escape:"html"}</textarea>
{if $fillerror ne "" and $product.descr eq ""}<font class=Star><<</font>{/if}
</td>
</tr>
<tr>
<td valign="top" class=ProductDetails>{$lng.lbl_det_description}</td>
<td valign="top" class=ProductDetails>
<textarea name="fulldescr" cols="45" rows="10">
{ $product.fulldescr|replace:"
":"\n"|escape:"html"}</textarea>
</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
{if $config.General.show_thumbnails eq "Y"}
<tr>
<td class=ProductDetails valign=top height="15">{$lng.lbl_thumbnail_msg}</td>
<td class=ProductDetails valign="middle">
{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product}
<input type="file" name="userfile">
</td>
</tr>
{/if}
<tr>
<td valign=middle class=Text>{$lng.lbl_price} ({$config.General.currency_symbol})</td>
<td valign="middle">
<input type="text" name="price" size="18" value="{if $product.productid eq ""}0.00{else}{ $product.price }{/if}">
{if $fillerror ne "" and $product.price eq ""}<font class=Star><<</font>{/if}
</td>
</tr>
<tr>
{if $config.General.use_vat eq "Y"}
<tr>
<td valign=middle class=Text>Including VAT (%)</td>
<td valign="middle">
<input type="text" name="vat" size="18" value="{if $product.productid eq ""}0{else}{ $product.vat }{/if}">
</td>
</tr>
{/if}
<tr>
<td valign="middle" class=Text>{$lng.lbl_adv_discount} <span class=Text>
(%)</span></td>
<td valign="middle">
<input type="text" name="discount" size="18" value="{if $product.productid eq ""}0{else}{$product.discount}{/if}">
</td>
</tr>
<tr>
<td valign="middle" class=ProductDetails>{$lng.lbl_quantity_in_stock}</td>
<td valign="middle" class=ProductDetails>
<input type="text" name="avail" size="18" value="{if $product.productid eq ""}1000{else}{ $product.avail }{/if}">
{if $fillerror ne "" and $product.avail eq ""}<font class=Star><<</font>{/if}
</td>
</tr>
<tr>
<td valign="middle" class=ProductDetails>{$lng.lbl_lowlimit_in_stock}</td>
<td valign="middle" class=ProductDetails>
<input type="text" name="low_avail_limit" size="18" value="{if $product.productid eq ""}10{else}{ $product.low_avail_limit }{/if}">
{if $fillerror ne "" and $product.low_avail_limit le 0}<font class=Star><<</font>{/if}
</td>
</tr>
<TR>
<TD valign=middle class=ProductDetails>{$lng.lbl_min_order_amount}</TD>
<TD valign=middle class=ProductDetails>
<INPUT type=text name=min_amount size=18 value="{if $product.productid eq ""}1{else}{$product.min_amount}{/if}">
</TD>
</TR>
<tr>
<td valign="middle" class=ProductDetails>{$lng.lbl_weight} ({$config.General.weight_symbol})</td>
<td valign="middle" class=ProductDetails>
<input type="text" name="weight" size="18" value="{if $product.productid eq ""}0.00{else}{ $product.weight }{/if}">
</td>
</tr>
<tr>
<td class=ProductDetails height="11">{$lng.lbl_free_shipping}</td>
<td class=ProductDetails height="11">
<select name=free_shipping>
<option value='N' {if ($product.free_shipping eq 'N')} selected {/if}>{$lng.lbl_no}</option>
<option value='Y' {if ($product.free_shipping eq 'Y')} selected {/if}>{$lng.lbl_yes}</option>
</select>
</td>
</tr>
<TR>
<TD class=ProductDetails height="11">{$lng.lbl_shipping_freight} ({$config.General.currency_symbol})</TD>
<TD class=ProductDetails height="11">
<INPUT type=text name=shipping_freight size="18" value="{if $product.shipping_freight eq ""}0.00{else}{$product.shipping_freight}{/if}">
</TD>
</TR>
<TR>
<TD class=ProductDetails height="11">{$lng.lbl_apply_global_discounts}</TD>
<TD class=ProductDetails height="11">
<INPUT type=checkbox name=discount_avail value="Y" {if $product.productid eq ""}checked{elseif $product.discount_avail eq "Y"}checked{/if}>
</TD>
</TR>
{if $active_modules.Extra_Fields ne ""}
{include file="modules/Extra_Fields/product_modify.tpl"}
{/if}
<tr>
<td colspan=2 align=center>
<input type=submit value="{$lng.lbl_submit_changes}">
</td>
</tr>
</table>
<input type=hidden name=productid value="{$product.productid}">
<input type=hidden name=mode value=product_modify>
</form>
{/capture}
{include file="dialog.tpl" title=$product.producttitle content=$smarty.capture.dialog extra="width=100%"}
{if $product.productid ne ""}
{if $product_languages ne "" or $other_languages}
{include file="main/products_lng.tpl"}
{/if}
{if $active_modules.Subscriptions ne ""}
{include file="modules/Subscriptions/subscription_plans.tpl"}
{/if}
{if $active_modules.Product_Options ne ""}
{include file="modules/Product_Options/product_options.tpl"}
{/if}
{if $active_modules.Wholesale_Trading ne ""}
{include file="modules/Wholesale_Trading/product_wholesale.tpl"}
{/if}
{if $active_modules.Upselling_Products ne ""}
{include file="modules/Upselling_Products/product_links.tpl"}
{/if}
{if $active_modules.Detailed_Product_Images ne ""}
{include file="modules/Detailed_Product_Images/product_images_modify.tpl"}
{/if}
{if $active_modules.Tax_Zones ne ""}
{include file="modules/Tax_Zones/product_taxes.tpl"}
{/if}
{if $active_modules.Customer_Reviews ne ""}
{include file="modules/Customer_Reviews/admin_reviews.tpl"}
{/if}
{/if}
---------------------
\customer\products.php
---------------------
Code:
<?
/*****************************************************************************\
+-----------------------------------------------------------------------------+
| X-Cart |
| Copyright (c) 2001-2002 Ruslan R. Fazliev. All rights reserved. |
+-----------------------------------------------------------------------------+
| The Ruslan R. Fazliev forbids, under any circumstances, the unauthorized |
| reproduction of software or use of illegally obtained software. Making |
| illegal copies of software is prohibited. Individuals who violate copyright |
| law and software licensing agreements may be subject to criminal or civil |
| action by the owner of the copyright. |
| |
| 1. It is illegal to copy a software, and install that single program for |
| simultaneous use on multiple machines. |
| |
| 2. Unauthorized copies of software may not be used in any way. This applies |
| even though you yourself may not have made the illegal copy. |
| |
| 3. Purchase of the appropriate number of copies of a software is necessary |
| for maintaining legal status. |
| |
| DISCLAIMER |
| |
| THIS SOFTWARE IS PROVIDED BY Ruslan R. Fazliev ``AS IS'' AND ANY |
| EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| DISCLAIMED. IN NO EVENT SHALL Ruslan R. Fazliev OR ITS |
| CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| |
| The Initial Developer of the Original Code is Ruslan R. Fazliev. |
| Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2002 |
| Ruslan R. Fazliev. All Rights Reserved. |
+-----------------------------------------------------------------------------+
\*****************************************************************************/
#
# $Id: products.php,v 1.30 2002/11/19 12:06:10 alfiya Exp $
#
# Navigation code
#
$objects_per_page = $config["General"]["products_per_page"];
$total_nav_pages = ceil($current_category["product_count"]/$config["General"]["products_per_page"])+1;
require "../include/navigation.php";
if($active_modules["Advanced_Statistics"])
include "../modules/Advanced_Statistics/cat_viewed.php";
#
# Get products data for current category and store it into $products array
#
$search_query = "(
$sql_tbl[products].categoryid='$cat'
or $sql_tbl[products].categoryid1='$cat'
or $sql_tbl[products].categoryid2='$cat'
or $sql_tbl[products].categoryid3='$cat'
or $sql_tbl[products].categoryid4='$cat'
or $sql_tbl[products].categoryid5='$cat'
or $sql_tbl[products].categoryid6='$cat'
or $sql_tbl[products].categoryid7='$cat'
or $sql_tbl[products].categoryid8='$cat'
or $sql_tbl[products].categoryid9='$cat'
or $sql_tbl[products].categoryid10='$cat'
or $sql_tbl[products].categoryid11='$cat'
or $sql_tbl[products].categoryid12='$cat'
or $sql_tbl[products].categoryid13='$cat'
or $sql_tbl[products].categoryid14='$cat'
or $sql_tbl[products].categoryid15='$cat'
or $sql_tbl[products].categoryid16='$cat'
or $sql_tbl[products].categoryid17='$cat'
or $sql_tbl[products].categoryid18='$cat'
or $sql_tbl[products].categoryid19='$cat'
or $sql_tbl[products].categoryid20='$cat'
or $sql_tbl[products].categoryid21='$cat'
or $sql_tbl[products].categoryid22='$cat'
or $sql_tbl[products].categoryid23='$cat'
or $sql_tbl[products].categoryid24='$cat'
or $sql_tbl[products].categoryid25='$cat'
or $sql_tbl[products].categoryid26='$cat'
or $sql_tbl[products].categoryid27='$cat'
or $sql_tbl[products].categoryid28='$cat'
or $sql_tbl[products].categoryid29='$cat'
) and $sql_tbl[products].forsale='Y'";
$products = func_search_products($search_query, $user_account['membership'], $first_page,$current_category["product_count"]);
if (count($products) ==0) $products="";
if($active_modules["Subscriptions"]) {
include "../modules/Subscriptions/subscription.php";
}
$smarty->assign("products",$products);
$smarty->assign("navigation_script","home.php?cat=$cat");
?>
------------------------
\include\product_modify.php
------------------------
Code:
<?
#
# $Id: product_modify.php,v 1.61.2.1 2003/01/22 13:45:01 svowl Exp $
#
# Add, modify product
# Get product information
#
if ($productid != "") {
$product_info = func_select_product($productid, $user_account['membership']);
$product_languages = func_query ("SELECT $sql_tbl[products_lng].*, $sql_tbl[countries].country, $sql_tbl[countries].language FROM $sql_tbl[products_lng], $sql_tbl[countries] WHERE $sql_tbl[products_lng].productid='$productid' AND $sql_tbl[products_lng].code=$sql_tbl[countries].code");
}
$int_languages = func_query ("SELECT DISTINCT($sql_tbl[languages].code), $sql_tbl[countries].country, $sql_tbl[countries].language FROM $sql_tbl[languages], $sql_tbl[countries] WHERE $sql_tbl[languages].code=$sql_tbl[countries].code AND $sql_tbl[languages].code!='$config[default_admin_language]'");
$other_languages = array ();
if ($int_languages) {
foreach ($int_languages as $key=>$value) {
$found = false;
if ($product_languages) {
foreach ($product_languages as $key1 => $lng) {
$product_languages[$key1]["descr"] = stripslashes($lng["descr"]);
$product_languages[$key1]["full_descr"] = stripslashes($lng["full_descr"]);
if ($lng["code"] == $value["code"])
$found = true;
}
}
if (!$found)
$other_languages[] = $value;
}
}
$smarty->assign("int_languages", $int_languages);
$smarty->assign("other_languages", $other_languages);
$smarty->assign("product_languages", $product_languages);
if (($REQUEST_METHOD == "POST") && ($mode == "product_modify")) {
$fillerror = (($categoryid == "") || empty($product) || empty($descr) || ($price == "") || ($avail == "") || empty($low_avail_limit));
if (func_is_image_userfile($userfile, $userfile_size, $userfile_type)) {
move_uploaded_file($userfile, "$file_temp_dir/$userfile_name");
$userfile = "$file_temp_dir/$userfile_name";
list($image_size, $image_x, $image_y) = func_get_image_size($userfile);
$fd = fopen($userfile, "rb");
$image = addslashes(fread($fd, $image_size));
fclose($fd);
unlink($userfile);
}
#
# Replace newlines by
's in description fields
#
$descr = str_replace("\n", "
", $descr);
$fulldescr = str_replace("\n", "
", $fulldescr);
if (!$fillerror) {
if ($productid == "") {
#
# New product
#
#
# Get the last pos in products' category
#
$orderby = 1 + array_pop(func_query_first("select max(orderby) from $sql_tbl[products] where categoryid='$categoryid'"));
db_query("insert into $sql_tbl[products] (provider, add_date, orderby) values ('$login', '".time()."', '$orderby')");
$productid = db_insert_id();
#
# Insert pricing and image
#
db_query("insert into $sql_tbl[pricing] (productid, quantity, price) values ('$productid', '1', '$price')");
if (func_is_image_userfile($userfile, $userfile_size, $userfile_type))
db_query("insert into $sql_tbl[thumbnails] (productid, image, image_type) values ('$productid', '$image', '$userfile_type')");
$smarty->assign("main", "product_add_message");
} else {
#
# Update existing product
# For security reasons check if provider owners the
# product and then update pricing
#
db_query("update $sql_tbl[pricing] set price='$price' where productid='$productid' and quantity='1' and membership=''");
if (func_is_image_userfile($userfile, $userfile_size, $userfile_type)) {
db_query("delete from $sql_tbl[thumbnails] where productid='$productid'");
db_query("insert into $sql_tbl[thumbnails] (productid, image, image_type) values ('$productid', '$image', '$userfile_type')");
db_query("update $sql_tbl[products] set image_x='$image_x', image_y='$image_y' where productid='$productid'");
}
$smarty->assign("main","product_modify_message");
}
#
# Update product data
#
db_query(
"update $sql_tbl[products] set product='$product', "
. "categoryid='$categoryid', "
. "categoryid1='$categoryid1', "
. "categoryid2='$categoryid2', "
. "categoryid3='$categoryid3', "
. "categoryid4='$categoryid4', "
. "categoryid5='$categoryid5', "
. "categoryid6='$categoryid6', "
. "categoryid7='$categoryid7', "
. "categoryid8='$categoryid8', "
. "categoryid9='$categoryid9', "
. "categoryid10='$categoryid10', "
. "categoryid11='$categoryid11', "
. "categoryid12='$categoryid12', "
. "categoryid13='$categoryid13', "
. "categoryid14='$categoryid14', "
. "categoryid15='$categoryid15', "
. "categoryid16='$categoryid16', "
. "categoryid17='$categoryid17', "
. "categoryid18='$categoryid18', "
. "categoryid19='$categoryid19', "
. "categoryid20='$categoryid20', "
. "categoryid21='$categoryid21', "
. "categoryid22='$categoryid22', "
. "categoryid23='$categoryid23', "
. "categoryid24='$categoryid24', "
. "categoryid25='$categoryid25', "
. "categoryid26='$categoryid26', "
. "categoryid27='$categoryid27', "
. "categoryid28='$categoryid28', "
. "categoryid29='$categoryid29', "
. "brand='$brand', model='$model', descr='$descr', fulldescr='$fulldescr', "
. "avail='$avail', discount='$discount', weight='$weight', productcode='$productcode', "
. "forsale='$forsale', distribution='$distribution', free_shipping='$free_shipping', "
. "shipping_freight='$shipping_freight', discount_avail='$discount_avail', "
. "min_amount='$min_amount', param00='$param00', param01='$param01', param02='$param02', "
. "param03='$param03', param04='$param04', param05='$param05', param06='$param06', "
. "param07='$param07', param08='$param08', param09='$param09', low_avail_limit='$low_avail_limit', "
. "vat='$vat' where productid='$productid'"
);
} else {
#
# Form filled with errors
#
$product_info = $HTTP_POST_VARS;
$product_info["productid"] = $productid;
$smarty->assign("main", "product_modify");
}
} else {
#
# GET request
#
$smarty->assign("main", "product_modify");
}
#
# International descriptions
#
if ($mode == "update_lng") {
if ($product_lng_code) {
foreach ($product_lng_code as $value) {
db_query ("UPDATE $sql_tbl[products_lng] SET descr='".$product_lng_descr[$value]."', full_descr='".$product_lng_full_descr[$value]."' WHERE code='$value' AND productid='$productid'");
}
}
if ($product_new_descr or $product_new_full_descr) {
db_query ("INSERT INTO $sql_tbl[products_lng] (code, productid, descr, full_descr) VALUES ('$product_new_language','$productid','$product_new_descr','$product_new_full_descr')");
}
header ("Location: product_modify.php?productid=$productid&lng_updated");
exit;
}
if ($mode == "del_lang") {
db_query ("DELETE FROM $sql_tbl[products_lng] WHERE productid='$productid' AND code='$code'");
header ("Location: product_modify.php?productid=$productid&lng_deleted");
exit;
}
#
# Detailed__Product_Images module
#
if ($active_modules["Detailed_Product_Images"]) {
include "../modules/Detailed_Product_Images/product_images_modify.php";
include "../modules/Detailed_Product_Images/product_images.php";
}
#
# Subscription module
#
if ($active_modules["Subscriptions"])
include "../modules/Subscriptions/subscription_modify.php";
#
# Wholesale trading module
#
if ($active_modules["Wholesale_Trading"])
include "../modules/Wholesale_Trading/product_wholesale.php";
#
# Product options module
#
if ($active_modules["Product_Options"])
include "../modules/Product_Options/product_options.php";
#
# Extra fields module
#
if ($active_modules["Extra_Fields"]) {
$extra_fields_provider = $login;
include "../modules/Extra_Fields/extra_fields.php";
}
#include "../modules/Product_Shipping/product_shipping.php";
#
# Upselling products module
#
if ($active_modules["Upselling_Products"])
include "../modules/Upselling_Products/edit_upsales.php";
#
# Tax Zones module
#
if ($active_modules["Tax_Zones"])
include "../modules/Tax_Zones/edit_product.php";
#
# Customer Reviews module
#
include "../include/reviews.php";
if (($productid != "") && !$fillerror)
$product_info = func_select_product($productid, $user_account['membership']);
$smarty->assign("product", $product_info);
$smarty->assign("fillerror", $fillerror);
?>
|