#############################################################
# File name: index.php
# Author: Plamen Jelezov
# Date:04.11.2003
#############################################################
# NO LINE BELOW IS TO BE MODIFIED
#############################################################
require_once("logo_fns.php");
//***********************************************************
$upld_dir = HOST.APP_DOC_ROOT.IMG_DIR;
//###########################################################################
//Starting with product's categories
while($cat) {
//###########################################################################
print_header("Продукти", $sid);
make_table("Продукти по категория");
db_connect();
$s_cat = "select prID, MainTypes_mtypID, MainCategories_mcatID, prName, prPrice, prInfo, ";
$s_cat .= "mcatID, mcatName, mtypID, mtypName, imgID, Images.Products_prID, imgName, imgPosition, ";
$s_cat .= "statID, statName, Products_has_prodStatus.Products_prID, Products_has_prodStatus.prodStatus_statID ";
$s_cat .= "from Products, MainCategories, MainTypes, Images, prodStatus, Products_has_prodStatus ";
$s_cat .= "where Products.MainCategories_mcatID = '$cat' and ";
$s_cat .= "Products.MainCategories_mcatID = MainCategories.mcatID and ";
$s_cat .= "Products.MainTypes_mtypID = MainTypes.mtypID and ";
$s_cat .= "Products.prID = Products_has_prodStatus.Products_prID and ";
$s_cat .= "Products_has_prodStatus.prodStatus_statID = prodStatus.statID and ";
$s_cat .= "Products.prID = Images.Products_prID and Images.imgPosition = '1' ";
$s_cat .= "group by Products.prID ";
$s_cat .= "order by prodStatus.statID";
$q_cat = mysql_query($s_cat)
or die("Can't make the select: ".mysql_error());
$num_cat = mysql_num_rows($q_cat);
if($num_cat == 0) {
print BR.NL;
make_warn("съжаляваме, но за момента няма продукт от тази категория!");
make_link("javascript:history.back();", "", "назад", "right");
close_table();
print_footer($sid);
exit;
}
$s_br = "select count(*) as br from Products where MainCategories_mcatID = '$cat'";
$q_br = mysql_query($s_br);
$r_br = mysql_fetch_object($q_br);
print TAB."
".NL;
$max_cols = MAX_COLS;
$br = $r_br->br;
$rows = ($br / $max_cols);
$rows = round($rows);
$upld_dir = HOST.APP_DOC_ROOT.IMG_DIR;
for($i = 0; $i <= $rows; $i ++) {
print TAB."".NL;
for($j = 0; $j <= $max_cols - 1; $j ++) {
$br --;
//Printing products
if($br >= 0) {
$r_cat = mysql_fetch_object($q_cat);
print TAB."".NL;
print TAB."".NL;
print TAB."".NL;
print TAB."".NL;
print TAB."prID\"> imgName\" border=\"0\" width=\"70\", height=\"100\">".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB.$r_cat->prName."".NL;
if($r_cat->statID < 4) {
print " - ".$r_cat->statName;
}
print "".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB." Цвят - ".NL;
print TAB."".NL;
print "".NL;
//Query for colors
$s_clr = "select Products_prID, Colors_colID, prID, colID, colName, colHexColor ";
$s_clr .= "from Products_has_Colors, Products, Colors ";
$s_clr .= "where Products.prID = Products_has_Colors.Products_prID and ";
$s_clr .= "Products_has_Colors.Colors_colID = Colors.colID and ";
$s_clr .= "Products.prID = '$r_cat->prID'";
$q_clr = mysql_query($s_clr) or die("Can't make the select: ".mysql_error());
while($r_clr = mysql_fetch_object($q_clr)) {
print "| colHexColor\" width=\"20\" height=\"10\"> | ".NL;
}
print TAB." ".NL;
print TAB." ";
print TAB." | ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB."$r_cat->mtypName $r_cat->mcatName".BR.NL;
print TAB.nl2br($r_cat->prInfo).NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ";
if($usr_lgn && $usr_lvl < 4) {
print TAB."Цена: ".$r_cat->prPrice." лв.".NL;
}
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB."prID\">повече ...".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB." ".NL;
print TAB." | ".NL;
}
}
print TAB."
".NL;
}
print TAB."
".NL;
close_table();
print_footer($sid);
exit;
}
//__END__ of All
//###########################################################################
//Starting with product's status
while($pstat) {
switch ($pstat) {
case "new":
$pstat = 1;
break;
case "promo":
$pstat = 2;
break;
case "sale":
$pstat = 3;
break;
}
print_header("Продукти", $sid);
make_table("Продукти по статус");
db_connect();
$s_stat = "select prID, MainTypes_mtypID, MainCategories_mcatID, prName, prPrice, prInfo, ";
$s_stat .= "mcatID, mcatName, mtypID, mtypName, imgID, Images.Products_prID, imgName, imgPosition, ";
$s_stat .= "statID, statName, Products_has_prodStatus.Products_prID, Products_has_prodStatus.prodStatus_statID ";
$s_stat .= "from Products, MainCategories, MainTypes, Images, prodStatus, Products_has_prodStatus ";
$s_stat .= "where prodStatus.statID = '$pstat' and ";
$s_stat .= "Products.MainCategories_mcatID = MainCategories.mcatID and ";
$s_stat .= "Products.MainTypes_mtypID = MainTypes.mtypID and ";
$s_stat .= "Products.prID = Products_has_prodStatus.Products_prID and ";
$s_stat .= "Products_has_prodStatus.prodStatus_statID = prodStatus.statID and ";
$s_stat .= "Products.prID = Images.Products_prID and Images.imgPosition = '1' ";
$s_stat .= "group by Products.prID ";
$s_stat .= "order by prodStatus.statID";
$q_stat = mysql_query($s_stat)
or die("Can't make the select: ".mysql_error());
$num_stat = mysql_num_rows($q_stat);
if($num_stat == 0) {
print BR.NL;
make_warn("съжаляваме, но за момента няма продукт от тази категория!");
make_link("javascript:history.back();", "", "назад", "right");
close_table();
print_footer($sid);
exit;
}
$s_br = "select count(*) as br from Products_has_prodStatus where prodStatus_statID = '$pstat'";
$q_br = mysql_query($s_br);
$r_br = mysql_fetch_object($q_br);
print TAB."".NL;
$max_cols = MAX_COLS;
$br = $r_br->br;
$rows = ($br / $max_cols);
$rows = round($rows);
$upld_dir = HOST.APP_DOC_ROOT.IMG_DIR;
for($i = 0; $i <= $rows; $i ++) {
print TAB."".NL;
for($j = 0; $j <= $max_cols - 1; $j ++) {
$br --;
//Printing products
if($br >= 0) {
$r_stat = mysql_fetch_object($q_stat);
print TAB."".NL;
print TAB."".NL;
print TAB."".NL;
print TAB."".NL;
print TAB."prID\"> imgName\" border=\"0\" width=\"70\", height=\"100\">".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB.$r_stat->prName."";
if($r_stat->statID < 4) {
print " - ".$r_stat->statName;
}
print "".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB." Цвят - ".NL;
print TAB."".NL;
print "".NL;
//Query for colors
$s_clr = "select Products_prID, Colors_colID, prID, colID, colName, colHexColor ";
$s_clr .= "from Products_has_Colors, Products, Colors ";
$s_clr .= "where Products.prID = Products_has_Colors.Products_prID and ";
$s_clr .= "Products_has_Colors.Colors_colID = Colors.colID and ";
$s_clr .= "Products.prID = '$r_stat->prID'";
$q_clr = mysql_query($s_clr) or die("Can't make the select: ".mysql_error());
while($r_clr = mysql_fetch_object($q_clr)) {
print "| colHexColor\" width=\"20\" height=\"10\"> | ".NL;
}
print TAB." ".NL;
print TAB." ";
print TAB." | ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB."$r_stat->mtypName $r_stat->mcatName".BR.NL;
print TAB.nl2br($r_stat->prInfo).NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ".NL;
if($usr_lgn && $usr_lvl < 4) {
print TAB."Цена: ".$r_stat->prPrice." лв.".NL;
}
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB."prID\">повече ...".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB." ".NL;
print TAB." | ".NL;
}
}
print TAB."
".NL;
}
print TAB."
".NL;
close_table();
print_footer($sid);
exit;
}
//__END__ of status
//###########################################################################
//Starting with product's type
while($mtyp) {
print_header("Продукти", $sid);
make_table("Продукти по тип");
db_connect();
$s_typ = "select prID, MainTypes_mtypID, MainCategories_mcatID, prName, prPrice, prInfo, ";
$s_typ .= "mcatID, mcatName, mtypID, mtypName, imgID, Images.Products_prID, imgName, imgPosition, ";
$s_typ .= "statID, statName, Products_has_prodStatus.Products_prID, Products_has_prodStatus.prodStatus_statID ";
$s_typ .= "from Products, MainCategories, MainTypes, Images, prodStatus, Products_has_prodStatus ";
$s_typ .= "where Products.MainTypes_mtypID = '$mtyp' and ";
$s_typ .= "Products.MainCategories_mcatID = MainCategories.mcatID and ";
$s_typ .= "Products.MainTypes_mtypID = MainTypes.mtypID and ";
$s_typ .= "Products.prID = Products_has_prodStatus.Products_prID and ";
$s_typ .= "Products_has_prodStatus.prodStatus_statID = prodStatus.statID and ";
$s_typ .= "Products.prID = Images.Products_prID and Images.imgPosition = '1' ";
$s_typ .= "group by Products.prID ";
$s_typ .= "order by prodStatus.statID";
$q_typ = mysql_query($s_typ)
or die("Can't make the select: ".mysql_error());
$num_typ = mysql_num_rows($q_typ);
if($num_typ == 0) {
print BR.NL;
make_warn("съжаляваме, но за момента няма продукт от тази категория!");
make_link("javascript:history.back();", "", "назад", "right");
close_table();
print_footer($sid);
exit;
}
$s_br = "select count(*) as br from Products where MainTypes_mtypID = '$mtyp'";
$q_br = mysql_query($s_br);
$r_br = mysql_fetch_object($q_br);
print TAB."".NL;
$max_cols = MAX_COLS;
$br = $r_br->br;
$rows = ($br / $max_cols);
$rows = round($rows);
$upld_dir = HOST.APP_DOC_ROOT.IMG_DIR;
for($i = 0; $i <= $rows; $i ++) {
print TAB."".NL;
for($j = 0; $j <= $max_cols - 1; $j ++) {
$br --;
//Printing products
if($br >= 0) {
$r_typ = mysql_fetch_object($q_typ);
print TAB."".NL;
print TAB."".NL;
print TAB."".NL;
print TAB."".NL;
print TAB."prID\"> imgName\" border=\"0\" width=\"70\", height=\"100\">".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB.$r_typ->prName."";
if($r_typ->statID < 4) {
print " - ".$r_typ->statName;
}
print "".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB." Цвят - ".NL;
print TAB."".NL;
print "".NL;
//Query for colors
$s_clr = "select Products_prID, Colors_colID, prID, colID, colName, colHexColor ";
$s_clr .= "from Products_has_Colors, Products, Colors ";
$s_clr .= "where Products.prID = Products_has_Colors.Products_prID and ";
$s_clr .= "Products_has_Colors.Colors_colID = Colors.colID and ";
$s_clr .= "Products.prID = '$r_typ->prID'";
$q_clr = mysql_query($s_clr) or die("Can't make the select: ".mysql_error());
while($r_clr = mysql_fetch_object($q_clr)) {
print "| colHexColor\" width=\"20\" height=\"10\"> | ".NL;
}
print TAB." ".NL;
print TAB." ";
print TAB." | ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB."$r_typ->mtypName $r_typ->mcatName".BR.NL;
print TAB.nl2br($r_typ->prInfo).NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ".NL;
if($usr_lgn && $usr_lvl < 4) {
print TAB."Цена: ".$r_typ->prPrice." лв.".NL;
}
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB."prID\">повече ...".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB." ".NL;
print TAB." | ".NL;
}
}
print TAB."
".NL;
}
print TAB."
".NL;
close_table();
print_footer($sid);
exit;
}
while($act == "v") {
print_header("Продукти", $sid);
make_table("Продукти по тип и категория");
db_connect();
$s_typ = "select prID, MainTypes_mtypID, MainCategories_mcatID, prName, prPrice, prInfo, ";
$s_typ .= "mcatID, mcatName, mtypID, mtypName, imgID, Images.Products_prID, imgName, imgPosition, ";
$s_typ .= "statID, statName, Products_has_prodStatus.Products_prID, Products_has_prodStatus.prodStatus_statID ";
$s_typ .= "from Products, MainCategories, MainTypes, Images, prodStatus, Products_has_prodStatus ";
$s_typ .= "where Products.MainTypes_mtypID = '$mt' and ";
$s_typ .= "Products.MainCategories_mcatID = '$mc' and ";
$s_typ .= "Products.MainCategories_mcatID = MainCategories.mcatID and ";
$s_typ .= "Products.MainTypes_mtypID = MainTypes.mtypID and ";
$s_typ .= "Products.prID = Products_has_prodStatus.Products_prID and ";
$s_typ .= "Products_has_prodStatus.prodStatus_statID = prodStatus.statID and ";
$s_typ .= "Products.prID = Images.Products_prID ";
$s_typ .= "group by Products.prID ";
$s_typ .= "order by prodStatus.statID";
$q_typ = mysql_query($s_typ)
or die("Can't make the select: ".mysql_error());
$num_typ = mysql_num_rows($q_typ);
if($num_typ == 0) {
print BR.NL;
make_warn("съжаляваме, но за момента няма продукт от тази категория!");
make_link("javascript:history.back();", "", "назад", "right");
close_table();
print_footer($sid);
exit;
}
$s_br = "select count(*) as br from Products where MainTypes_mtypID = '$mt' and ";
$s_br .= "MainCategories_mcatID = '$mc'";
$q_br = mysql_query($s_br);
$r_br = mysql_fetch_object($q_br);
print TAB."".NL;
$max_cols = MAX_COLS;
$br = $r_br->br;
$rows = ($br / $max_cols);
$rows = round($rows);
$upld_dir = HOST.APP_DOC_ROOT.IMG_DIR;
for($i = 0; $i <= $rows; $i ++) {
print TAB."".NL;
for($j = 0; $j <= $max_cols - 1; $j ++) {
$br --;
//Printing products
if($br >= 0) {
$r_typ = mysql_fetch_object($q_typ);
print TAB."".NL;
print TAB."".NL;
print TAB."".NL;
print TAB."".NL;
print TAB."prID\"> imgName\" border=\"0\" width=\"70\", height=\"100\">".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB.$r_typ->prName."";
if($r_typ->statID < 4) {
print " - ".$r_typ->statName;
}
print "".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB." Цвят - ".NL;
print TAB."".NL;
print "".NL;
//Query for colors
$s_clr = "select Products_prID, Colors_colID, prID, colID, colName, colHexColor ";
$s_clr .= "from Products_has_Colors, Products, Colors ";
$s_clr .= "where Products.prID = Products_has_Colors.Products_prID and ";
$s_clr .= "Products_has_Colors.Colors_colID = Colors.colID and ";
$s_clr .= "Products.prID = '$r_typ->prID'";
$q_clr = mysql_query($s_clr) or die("Can't make the select: ".mysql_error());
while($r_clr = mysql_fetch_object($q_clr)) {
print "| colHexColor\" width=\"20\" height=\"10\"> | ".NL;
}
print TAB." ".NL;
print TAB." ";
print TAB." | ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB." $r_typ->mtypName $r_typ->mcatName".BR.NL;
print TAB." ".$r_typ->prInfo.NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ";
if($usr_lgn && $usr_lvl < 4) {
print TAB."Цена: ".$r_typ->prPrice." лв.".NL;
}
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB."prID\">повече ...".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB." ".NL;
print TAB." | ".NL;
}
}
print TAB."
".NL;
}
print TAB."
".NL;
close_table();
print_footer($sid);
exit;
}
//__END__of type
//###########################################################################
//Starting with product's all
if(!$pstat || !$cat || !$mtyp || !$act || $act != "show") {
print_header("Продукти", $sid);
make_table("Всички Продукти");
$s = "select prID, prName, prInfo, prPrice, prMinQty, MainTypes_mtypID, MainCategories_mcatID, ";
$s .= "statID, statName, imgID, Images.Products_prID, imgName, imgPosition, ";
$s .= "Products_has_prodStatus.Products_prID, prodStatus_statID, ";
$s .= "mtypID, mtypName, mcatID, mcatName ";
$s .= "from Products, Products_has_prodStatus, prodStatus, Images, ";
$s .= "MainTypes, MainCategories ";
$s .= "where Products_has_prodStatus.prodStatus_statID < 10 ";
$s .= "and Products_has_prodStatus.Products_prID = Products.prID and ";
$s .= "Products_has_prodStatus.prodStatus_statID = prodStatus.statID and ";
$s .= "Products.prID = Images.Products_prID and Images.imgPosition = '1' and ";
$s .= "Products.MainTypes_mtypID = MainTypes.mtypID and ";
$s .= "Products.MainCategories_mcatID = MainCategories.mcatID ";
$s .= "group by Products.prID ";
$s .= "order by Products.MainCategories_mcatID, Products.MainTypes_mtypID, prodStatus.statID";
$q = mysql_query($s) or die("Can't make the select : ".mysql_error());
$num_r = mysql_num_rows($q);
if($num_r == 0) {
make_error("базата данни не върна резултат!$r_br->br");
close_table();
print_footer($sid);
exit;
}
$s_br = "select count(*) as br from Products_has_prodStatus where prodStatus_statID < 10";
$q_br = mysql_query($s_br);
$r_br = mysql_fetch_object($q_br);
print TAB."".NL;
$max_cols = MAX_COLS;
$br = $r_br->br;
$rows = ($br / $max_cols);
$rows = round($rows);
$upld_dir = HOST.APP_DOC_ROOT.IMG_DIR;
for($i = 0; $i <= $rows; $i ++) {
print TAB."| |
".NL;
print TAB."".NL;
for($j = 0; $j <= $max_cols - 1; $j ++) {
$br --;
//Printing products
if($br >= 0) {
$r = mysql_fetch_object($q);
print TAB."".NL;
print TAB."".NL;
print TAB."".NL;
print TAB."";
print TAB."prID\"> imgName\" border=\"0\" width=\"70\", height=\"100\">".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB.$r->prName."".NL;
if($r->statID < 4) {
print " - ".$r->statName."".NL;
}
print TAB." | ".NL;
print TAB." ".NL;
print TAB." Цвят - ".NL;
print TAB."".NL;
print "".NL;
//Query for colors
$s_clr = "select Products_prID, Colors_colID, prID, colID, colName, colHexColor ";
$s_clr .= "from Products_has_Colors, Products, Colors ";
$s_clr .= "where Products.prID = Products_has_Colors.Products_prID and ";
$s_clr .= "Products_has_Colors.Colors_colID = Colors.colID and ";
$s_clr .= "Products.prID = '$r->prID'";
$q_clr = mysql_query($s_clr) or die("Can't make the select: ".mysql_error());
while($r_clr = mysql_fetch_object($q_clr)) {
print "| colHexColor\" width=\"20\" height=\"10\"> | ".NL;
}
print TAB." ".NL;
print TAB." ";
print TAB." | ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB."$r->mtypName $r->mcatName".BR.NL;
print TAB.nl2br($r->prInfo).NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ";
if($usr_lgn && $usr_lvl < 4) {
print TAB."Цена: ".$r->prPrice." лв.".NL;
}
print TAB." | ".NL;
print TAB." ".NL;
print TAB."".NL;
print TAB."| ".NL;
print TAB."prID\">повече ...".NL;
print TAB." | ".NL;
print TAB." ".NL;
print TAB." ".NL;
print TAB." | ".NL;
}
}
print TAB."
".NL;
}
print TAB."
".NL;
close_table();
print_footer($sid);
exit;
}
?>