<?php
// =======================================================================
// Module name: Products
// File name: products.inc
// Version: 1.0
// Description: This script contains php code for product management. The
// products module allows users to add, edit, view, search, and delete
// products, categories, inventory, manufactures, and vendors. Comments
// are included to explain the functions of each section of code and to
// document any changes that are made to the code.
//
// Comments are included within this script to document changes made to
// the code with each new version of the script. Each comment also lists
// the author's initials to document who made the changes to the code.
//
// Copyright (C) 2006-2010 Dustin Cowell Enterprises
//
// License: GNU General Public License, Version 2
//
// Link: http://www.gnu.org/licenses/gpl-2.0.txt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to:
//
// Free Software Foundation, Inc.
// 51 Franklin Street, Fifth Floor
// Boston, MA 02110-1301 USA
// =======================================================================
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($request == "install" and $admin_rights == "Admin") {
echo("<b>Products - Install Module</b><p>");
$db_lookup_admin_modules = @mysql_query("SELECT id FROM admin_modules WHERE module_name='Products'");
$db_admin_modules = @mysql_fetch_array($db_lookup_admin_modules);
if ($db_admin_modules) {
echo("This module is already installed. The current installation must be uninstalled before a new installation can be created");
} else {
echo("Click the link below to install this module.<p>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?include=$include&request=run_install'>" . $link_color . "Install</font></a>]");
}
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($request == "run_install" and $admin_rights == "Admin") {
if ($install_type != "express") {
echo("<b>Products - Install Module</b><p>");
}
$db_create_categories = "CREATE TABLE products_categories (" .
"id int not null auto_increment primary key, " .
"master_category_id int, " .
"name text, " .
"meta_title text, " .
"meta_description text, " .
"meta_keywords text" .
")";
$db_create_products = "CREATE TABLE products (" .
"id int not null auto_increment primary key, " .
"rss_date text, " .
"mode text, " .
"code text, " .
"name text, " .
"cost text, " .
"price text, " .
"payment_type text, " .
"sub_time text, " .
"sub_unit text, " .
"inventory text, " .
"weight text, " .
"width text, " .
"depth text, " .
"height text, " .
"short_description text, " .
"long_description text, " .
"option_groups_id int, " .
"shipping_type text, " .
"shipping_cost text, " .
"tax_type text, " .
"tax_cost text, " .
"category_id int, " .
"manufacture_id int, " .
"vendor_id int, " .
"meta_title text, " .
"meta_description text, " .
"meta_keywords text" .
")";
$db_create_products_images = "CREATE TABLE products_images (" .
"id int not null auto_increment primary key, " .
"products_id text, " .
"main_image text, " .
"small_image_path text, " .
"large_image_path text, " .
"small_image_name text, " .
"large_image_name text" .
")";
$db_create_manufactures = "CREATE TABLE products_manufactures (" .
"id int not null auto_increment primary key, " .
"name text, " .
"address text, " .
"address_2 text, " .
"city text, " .
"state text, " .
"zip_code text, " .
"country text, " .
"phone text, " .
"cell text, " .
"fax text, " .
"email text, " .
"website text" .
")";
$db_create_option_groups = "CREATE TABLE products_option_groups (" .
"id int not null auto_increment primary key, " .
"name text" .
")";
$db_create_options = "CREATE TABLE products_options (" .
"id int not null auto_increment primary key, " .
"group_id int, " .
"name text, " .
"plus_minus text, " .
"price_difference text" .
")";
$db_create_vendors = "CREATE TABLE products_vendors (" .
"id int not null auto_increment primary key, " .
"name text, " .
"address text, " .
"address_2 text, " .
"city text, " .
"state text, " .
"zip_code text, " .
"country text, " .
"phone text, " .
"fax text, " .
"cell text, " .
"email text, " .
"website text" .
")";
$db_insert_admin_modules_products = "INSERT INTO admin_modules SET " .
"module_name = 'Products', " .
"file_path = 'products.inc', " .
"rights = ' ', " .
"install_date = '$date', " .
"install_time = '$time'";
if ($install_type != "express") {
echo("Products Module Installation Status:<p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
}
echo("<tr>");
echo("<td>" . $font_body . "Categories Table Setup</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_create_categories)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Products Table Setup</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_create_products)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Products Images Table Setup</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_create_products_images)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Manufactures Table Setup</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_create_manufactures)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Option Groups Table Setup</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_create_option_groups)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Options Table Setup</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_create_options)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Vendors Table Setup</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_create_vendors)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Products Module Registration</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_admin_modules_products)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
$db_lookup_admin_menu_categories = @mysql_query("SELECT id FROM admin_menu_categories WHERE name='Shop'");
$db_admin_menu_categories = @mysql_fetch_array($db_lookup_admin_menu_categories);
$db_admin_menu_categories_id = $db_admin_menu_categories['id'];
if (!$db_admin_menu_categories_id) {
$db_insert_admin_menu_categories_osmc = "INSERT INTO admin_menu_categories SET " .
"name = 'Shop'";
echo("<tr>");
echo("<td>" . $font_body . "Insert Admin Menu Categories Master</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_admin_menu_categories_osmc)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
}
$db_lookup_admin_menu_categories = @mysql_query("SELECT id FROM admin_menu_categories WHERE name='Shop'");
$db_admin_menu_categories = @mysql_fetch_array($db_lookup_admin_menu_categories);
$db_admin_menu_categories_id = $db_admin_menu_categories['id'];
$db_insert_admin_menu_categories = "INSERT INTO admin_menu SET " .
"menu_categories_id = '$db_admin_menu_categories_id', " .
"name = 'Categories', " .
"include_file = 'products.inc', " .
"page = 'product_categories'";
$db_insert_admin_menu_products = "INSERT INTO admin_menu SET " .
"menu_categories_id = '$db_admin_menu_categories_id', " .
"name = 'Products', " .
"include_file = 'products.inc', " .
"page = 'products'";
$db_insert_admin_menu_options = "INSERT INTO admin_menu SET " .
"menu_categories_id = '$db_admin_menu_categories_id', " .
"name = 'Options', " .
"include_file = 'products.inc', " .
"page = 'product_options'";
$db_insert_admin_menu_manufactures = "INSERT INTO admin_menu SET " .
"menu_categories_id = '$db_admin_menu_categories_id', " .
"name = 'Manufactures', " .
"include_file = 'products.inc', " .
"page = 'product_manufactures'";
$db_insert_admin_menu_vendors = "INSERT INTO admin_menu SET " .
"menu_categories_id = '$db_admin_menu_categories_id', " .
"name = 'Vendors', " .
"include_file = 'products.inc', " .
"page = 'product_vendors'";
echo("<tr>");
echo("<td>" . $font_body . "Insert Admin Menu Categories</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_admin_menu_categories)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Insert Admin Menu Products</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_admin_menu_products)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Insert Admin Menu Options</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_admin_menu_options)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Insert Admin Menu Manufactures</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_admin_menu_manufactures)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Insert Admin Menu Vendors</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_insert_admin_menu_vendors)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
if ($install_type != "express") {
echo("</table>");
echo("<p>");
}
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "products" and $request == "uninstall" and $admin_rights == "Admin") {
echo("<b>Products - Uninstall Module</b><p>");
echo("Click the link below to uninstall this module.<p>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=run_uninstall'>" . $link_color . "Uninstall</font></a>]");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "products" and $request == "run_uninstall" and $admin_rights == "Admin") {
echo("<b>Products - Uninstall Module</b><p>");
echo("This module will now be uninstalled...<p>");
$db_lookup_products_images = @mysql_query("SELECT small_image_name, large_image_name FROM products_images");
while ($db_products_images = @mysql_fetch_array($db_lookup_products_images)) {
$db_products_images_small_file_name = $db_products_images['small_file_name'];
$db_products_images_large_file_name = $db_products_images['large_file_name'];
unlink("./shop_images/" . $db_products_images_small_file_name);
unlink("./shop_images/" . $db_products_images_large_file_name);
}
rmdir("./shop_images");
$db_delete_categories = "DROP TABLE products_categories";
$db_delete_products = "DROP TABLE products";
$db_delete_products = "DROP TABLE products_images";
$db_delete_manufactures = "DROP TABLE products_manufactures";
$db_delete_option_groups = "DROP TABLE products_option_groups";
$db_delete_options = "DROP TABLE products_options";
$db_delete_vendors = "DROP TABLE products_vendors";
$db_delete_admin_modules_products = "DELETE FROM admin_modules WHERE module_name='Products'";
$db_delete_admin_menu_categories = "DELETE FROM admin_menu WHERE name='Categories'";
$db_delete_admin_menu_products = "DELETE FROM admin_menu WHERE name='Products'";
$db_delete_admin_menu_manufactures = "DELETE FROM admin_menu WHERE name='Manufactures'";
$db_delete_admin_menu_options = "DELETE FROM admin_menu WHERE name='Options'";
$db_delete_admin_menu_vendors = "DELETE FROM admin_menu WHERE name='Vendors'";
echo("Products Module Uninstallation Status:<p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Categories Table Deletion</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_delete_categories)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Products Table Deletion</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_delete_products)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Products Images Deletion</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_delete_products_images)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Manufactures Table Deletion</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_delete_manufactures)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Option Groups Table Deletion</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_delete_option_groups)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Options Table Deletion</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_delete_options)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Vendors Table Deletion</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_delete_vendors)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Products Module Unregistered</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_delete_admin_modules_products)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Categories Admin Menu Deletion</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_delete_admin_menu_categories)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Products Admin Menu Deletion</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_delete_admin_menu_products)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Manufactures Admin Menu Deletion</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_delete_admin_menu_manufactures)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Options Admin Menu Deletion</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_delete_admin_menu_options)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Vendors Admin Menu Deletion</td>");
echo("<td>" . $font_body . "");
if (@mysql_query($db_delete_admin_menu_vendors)) {
echo("Successful");
} else {
echo("Error");
}
echo("</font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "products" and !$request and $admin_rights) {
echo("<b>Products</b><p>");
$db_lookup_products = @mysql_query("SELECT id FROM products");
$db_products = @mysql_fetch_array($db_lookup_products);
$db_products_id = $db_products['id'];
if ($db_products_id) {
// ==================== START OF PAGE # HEADER ====================
if ($_POST["results_per_page"]) {
$results_per_page = $_POST["results_per_page"];
$_SESSION['results_per_page'] = $results_per_page;
} else {
if (!$_SESSION['results_per_page']) {
$results_per_page=10;
}
}
if ($_GET["start_page"]) {
$start_page = $_GET["start_page"];
} else {
$start_page=1;
}
$start_from = ($start_page-1) * $results_per_page;
echo("<p>");
echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
echo("<tr>");
echo("<td align='left' width='50%'>" . $font_body);
echo "<b>Pages: ";
$db_count_products = @mysql_query("SELECT COUNT(id) FROM products");
$row = @mysql_fetch_row($db_count_products);
$total_records = $row[0];
$total_start_pages = ceil($total_records / $results_per_page);
for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
if ($page_number == $start_page) {
echo "$page_number ";
} else {
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=products&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a> ";
}
}
echo "</b>";
echo("</td>");
echo("<td align='left' width='50%'>" . $font_body);
echo("<table border='0' cellpadding='2' cellspacing='0'>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=products&start_page=".$start_page."' method='post'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='results_per_page'>");
if ($results_per_page == 10) {
echo("<option value='10' selected>10</option>");
} else {
echo("<option value='10'>10</option>");
}
if ($results_per_page == 25) {
echo("<option value='25' selected>25</option>");
} else {
echo("<option value='25'>25</option>");
}
if ($results_per_page == 50) {
echo("<option value='50' selected>50</option>");
} else {
echo("<option value='50'>50</option>");
}
if ($results_per_page == 100) {
echo("<option value='100' selected>100</option>");
} else {
echo("<option value='100'>100</option>");
}
if ($results_per_page == 99999) {
echo("<option value='99999' selected>All</option>");
} else {
echo("<option value='99999'>All</option>");
}
echo("</select>");
echo("</font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
echo("</tr>");
echo("</form>");
echo("</table>");
echo("</td>");
echo("</tr>");
echo("</table>");
// ==================== END OF PAGE # HEADER ====================
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=new_product'>" . $link_color . "New</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=search_products'>" . $link_color . "Search</font></a>]<p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Image</b></td>");
echo("<td>" . $font_body . "<b>Model #</b></td>");
echo("<td>" . $font_body . "<b>Name</b></td>");
echo("<td>" . $font_body . "<b>Inventory</b></td>");
echo("<td>" . $font_body . "<b>Actions</b></td>");
echo("</tr>");
$db_lookup_products = @mysql_query("SELECT id, code, payment_type, inventory, name FROM products ORDER BY id DESC LIMIT $start_from, $results_per_page");
while ($db_products = @mysql_fetch_array($db_lookup_products)) {
$db_products_id = $db_products['id'];
$db_products_code = $db_products['code'];
$db_products_name = $db_products['name'];
$db_products_payment_type = $db_products['payment_type'];
$db_products_inventory = $db_products['inventory'];
$db_lookup_products_images = @mysql_query("SELECT small_image_name FROM products_images WHERE products_id='$db_products_id' and main_image='yes'");
$db_products_images = @mysql_fetch_array($db_lookup_products_images);
$db_products_small_image_name = $db_products_images['small_image_name'];
echo("<tr>");
echo("<td>" . $font_body);
if ($db_products_small_image_name) {
echo("<img border='0' src='./shop_images/" . $db_products_small_image_name . "'>");
}
echo("</td>");
echo("<td>" . $font_body . $db_products_code . "</td>");
echo("<td>" . $font_body . $db_products_name . " </td>");
if ($db_products_payment_type == "One Time") {
echo("<td>" . $font_body . $db_products_inventory . "</td>");
} else {
echo("<td>" . $font_body . "Unlimited</td>");
}
echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=view_product&product_id=" . $db_products_id . "'>" . $link_color . "View</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=edit_product&product_id=" . $db_products_id . "'>" . $link_color . "Edit</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=delete_product&product_id=" . $db_products_id . "'>" . $link_color . "Delete</font></a>]</td>");
echo("</tr>");
}
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=new_product'>" . $link_color . "New</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=search_products'>" . $link_color . "Search</font></a>]<p>");
// ==================== START OF PAGE # FOOTER ====================
echo("<p>");
echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
echo("<tr>");
echo("<td align='left' width='50%'>" . $font_body);
echo "<b>Pages: ";
$db_count_products = @mysql_query("SELECT COUNT(id) FROM products");
$row = @mysql_fetch_row($db_count_products);
$total_records = $row[0];
$total_start_pages = ceil($total_records / $results_per_page);
for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
if ($page_number == $start_page) {
echo "$page_number ";
} else {
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=products&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a> ";
}
}
echo "</b>";
echo("</td>");
echo("<td align='left' width='50%'>" . $font_body);
echo("<table border='0' cellpadding='2' cellspacing='0'>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=products&start_page=".$start_page."' method='post'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='results_per_page'>");
if ($results_per_page == 10) {
echo("<option value='10' selected>10</option>");
} else {
echo("<option value='10'>10</option>");
}
if ($results_per_page == 25) {
echo("<option value='25' selected>25</option>");
} else {
echo("<option value='25'>25</option>");
}
if ($results_per_page == 50) {
echo("<option value='50' selected>50</option>");
} else {
echo("<option value='50'>50</option>");
}
if ($results_per_page == 100) {
echo("<option value='100' selected>100</option>");
} else {
echo("<option value='100'>100</option>");
}
if ($results_per_page == 99999) {
echo("<option value='99999' selected>All</option>");
} else {
echo("<option value='99999'>All</option>");
}
echo("</select>");
echo("</font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
echo("</tr>");
echo("</form>");
echo("</table>");
echo("</td>");
echo("</tr>");
echo("</table>");
// ==================== END OF PAGE # FOOTER ====================
} else {
echo("No products were found in the database.");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=new_product'>" . $link_color . "New</font></a>]<p>");
}
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "products" and $request == "new_product" and $admin_rights) {
echo("<b>Products - New Product</b><p>");
echo("<form enctype='multipart/form-data' action='" . $_SERVER['PHP_SELF'] . "?page=products&request=new_product_submit' method='post'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Mode:</font></td>");
echo("<td>" . $font_body . "On: <input type='radio' name='mode' checked value='On'> Off: <input type='radio' name='mode' value='Off'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Model #:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='code'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='name'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Cost:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='cost'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Price:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='price'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Payment Type:</font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='payment_type'>");
echo("<option value='One Time' selected>One Time</option>");
echo("<option value='Subscription'>Subscription</option>");
echo("</select>");
echo("<br>");
echo("Subscription renews every: ");
echo("<select size='1' name='durration'>");
echo("<option value='None' selected>None</option>");
echo("<option value='Day'>Day</option>");
echo("<option value='Week'>Week</option>");
echo("<option value='Month'>Month</option>");
echo("<option value='3 Months'>3 Months</option>");
echo("<option value='6 Months'>6 Months</option>");
echo("<option value='Year'>Year</option>");
echo("<option value='2 Years'>2 Years</option>");
echo("<option value='3 Years'>3 Years</option>");
echo("<option value='4 Years'>4 Years</option>");
echo("<option value='5 Years'>5 Years</option>");
echo("</select>");
echo("</font></td>");
echo("</tr>");
// echo("<tr>");
// echo("<td>" . $font_body . "Shipping Type:</font></td>");
// echo("<td>" . $font_body . "");
// echo("<select size='1' name='shipping_type'>");
// echo("<option value='Free' selected>Free</option>");
// echo("<option value='Carrier'>Carrier</option>");
// echo("<option value='Other'>Other</option>");
// echo("</select>");
// echo("</font></td>");
// echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Shipping Cost:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='shipping_cost'></font></td>");
echo("</tr>");
// echo("<tr>");
// echo("<td>" . $font_body . "Tax Type:</font></td>");
// echo("<td>" . $font_body . "");
// echo("<select size='1' name='tax_type'>");
// echo("<option value='None' selected>None</option>");
// echo("<option value='State'>State</option>");
// echo("<option value='National'>National</option>");
// echo("<option value='Other'>Other</option>");
// echo("</select>");
// echo("</font></td>");
// echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Tax Cost:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='tax_cost'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Inventory:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='inventory'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Weight:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='weight'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Width:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='product_width'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Depth:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='product_depth'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Height:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='product_height'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Short<br>Description:</font></td>");
echo("<td>" . $font_body . "<textarea name='short_description' cols='40' rows='10'></textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Long<br>Description:</font></td>");
echo("<td>" . $font_body . "<textarea name='long_description' cols='40' rows='10'></textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Option Group:</font></td>");
echo("<td>" . $font_body . "<select size='1' name='option_groups_id'><option selected value='0'>None</option>");
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups");
while ($db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups)) {
$db_products_option_groups_id = $db_products_option_groups['id'];
$db_products_option_groups_name = $db_products_option_groups['name'];
echo("<option value='" . $db_products_option_groups_id . "'>" . $db_products_option_groups_name . "</option>");
}
echo("</select>");
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Category:</font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='category'><option selected value='0'>None</option>");
$db_lookup_products_categories = @mysql_query("SELECT id, name FROM products_categories");
while ($db_products_categories = @mysql_fetch_array($db_lookup_products_categories)) {
$db_products_categories_id = $db_products_categories['id'];
$db_products_categories_name = $db_products_categories['name'];
echo("<option value='" . $db_products_categories_id . "'>" . $db_products_categories_name . "</option>");
}
echo("</select> or new: <input type='text' name='new_category' size='20'>");
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Manufacture:</font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='manufacture'><option selected value='0'>None</option>");
$db_lookup_products_manufactures = @mysql_query("SELECT id, name FROM products_manufactures");
while ($db_products_manufactures = @mysql_fetch_array($db_lookup_products_manufactures)) {
$db_products_manufactures_id = $db_products_manufactures['id'];
$db_products_manufactures_name = $db_products_manufactures['name'];
echo("<option value='" . $db_products_manufactures_id . "'>" . $db_products_manufactures_name . "</option>");
}
echo("</select>");
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Vendor:</font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='vendor'><option selected value='0'>None</option>");
$db_lookup_products_vendors = @mysql_query("SELECT id, name FROM products_vendors");
while ($db_products_vendors = @mysql_fetch_array($db_lookup_products_vendors)) {
$db_products_vendors_id = $db_products_vendors['id'];
$db_products_vendors_name = $db_products_vendors['name'];
echo("<option value='" . $db_products_vendors_id . "'>" . $db_products_vendors_name . "</option>");
}
echo("</select>");
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image'></font></td>");
echo("</tr>");
echo("<tr>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<b>Search Engine Marketing:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Title:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='meta_title' size='40'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Description:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_description' cols='40' rows='5'></textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Keywords:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_keywords' cols='40' rows='5'></textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . " </font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Submit'></font></td>");
echo("</tr>");
echo("</table>");
echo("</form>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "products" and $request == "new_product_submit" and $admin_rights) {
echo("<b>Products - New Product</b><p>");
$mode = $_POST['mode'];
$code = $_POST['code'];
$name = $_POST['name'];
$cost = $_POST['cost'];
$price = $_POST['price'];
$payment_type = $_POST['payment_type'];
$durration = $_POST['durration'];
$inventory = $_POST['inventory'];
$weight = $_POST['weight'];
$product_width = $_POST['product_width'];
$product_depth = $_POST['product_depth'];
$product_height = $_POST['product_height'];
$short_description = $_POST['short_description'];
$long_description = $_POST['long_description'];
$option_groups_id = $_POST['option_groups_id'];
$shipping_type = $_POST['shipping_type'];
$shipping_cost = $_POST['shipping_cost'];
$tax_type = $_POST['tax_type'];
$tax_cost = $_POST['tax_cost'];
$category_id = $_POST['category'];
$new_category = $_POST['new_category'];
$manufacture_id = $_POST['manufacture'];
$vendor_id = $_POST['vendor'];
$meta_title = $_POST['meta_title'];
$meta_description = $_POST['meta_description'];
$meta_keywords = $_POST['meta_keywords'];
if (!$inventory) {
$inventory = "1";
}
if ($durration == "None") {
$sub_time = "None";
$sub_unit = "None";
}
if ($durration == "Day") {
$sub_time = "1";
$sub_unit = "D";
}
if ($durration == "Week") {
$sub_time = "1";
$sub_unit = "W";
}
if ($durration == "Month") {
$sub_time = "1";
$sub_unit = "M";
}
if ($durration == "3 Months") {
$sub_time = "3";
$sub_unit = "M";
}
if ($durration == "6 Months") {
$sub_time = "6";
$sub_unit = "M";
}
if ($durration == "Year") {
$sub_time = "1";
$sub_unit = "Y";
}
if ($durration == "2 Years") {
$sub_time = "2";
$sub_unit = "Y";
}
if ($durration == "3 Years") {
$sub_time = "3";
$sub_unit = "Y";
}
if ($durration == "4 Years") {
$sub_time = "4";
$sub_unit = "Y";
}
if ($durration == "5 Years") {
$sub_time = "5";
$sub_unit = "Y";
}
if ($payment_type == "Subscription") {
if ($sub_time == "None" and $sub_unit == "None") {
$payment_type = "One Time";
}
}
$original_db_themes_website_name = $db_themes_website_name;
$db_lookup_products = @mysql_query("SELECT id FROM products WHERE code='$code' and name='$name'");
$db_products = @mysql_fetch_array($db_lookup_products);
if ($db_products) {
echo("Product already exists in database, duplicates are not allowed.<p>");
} else {
if (!$meta_title) {
if ($name) {
$db_themes_website_name = addslashes($db_themes_website_name);
$meta_title = "$db_themes_website_name - $name";
$meta_title = substr($meta_title, 0, 60);
} else {
$db_themes_website_name = addslashes($db_themes_website_name);
$meta_title = "$db_themes_website_name - $code";
$meta_title = substr($meta_title, 0, 60);
}
}
if (!$meta_description) {
if ($long_description) {
$meta_description = "$long_description";
$meta_description = substr($meta_description, 0, 140);
} else {
$meta_description = "$short_description";
$meta_description = substr($meta_description, 0, 140);
}
}
if (!$meta_keywords) {
if ($long_description) {
$meta_keywords = strtolower($long_description);
$common_words = array ('a','able','about','above','abroad','according','accordingly','across','actually','adj','after','afterwards','again','against','ago','ahead','ain\'t','all','allow','allows','almost','alone','along','alongside','already','also','although','always','am','amid','amidst','among','amongst','an','and','another','any','anybody','anyhow','anyone','anything','anyway','anyways','anywhere','apart','appear','appreciate','appropriate','are','aren\'t','around','as','a\'s','aside','ask','asking','associated','at','available','away','awfully','b','back','backward','backwards','be','became','because','become','becomes','becoming','been','before','beforehand','begin','behind','being','believe','below','beside','besides','best','better','between','beyond','both','brief','but','by','c','came','can','cannot','cant','can\'t','caption','cause','causes','certain','certainly','changes','clearly','c\'mon','co','co.','com','come','comes','concerning','consequently','consider','considering','contain','containing','contains','corresponding','could','couldn\'t','course','c\'s','currently','d','dare','daren\'t','definitely','described','despite','did','didn\'t','different','directly','do','does','doesn\'t','doing','done','don\'t','down','downwards','during','e','each','edu','eg','eight','eighty','either','else','elsewhere','end','ending','enough','entirely','especially','et','etc','even','ever','evermore','every','everybody','everyone','everything','everywhere','ex','exactly','example','except','f','fairly','far','farther','few','fewer','fifth','first','five','followed','following','follows','for','forever','former','formerly','forth','forward','found','four','from','further','furthermore','g','get','gets','getting','given','gives','go','goes','going','gone','got','gotten','greetings','h','had','hadn\'t','half','happens','hardly','has','hasn\'t','have','haven\'t','having','he','he\'d','he\'ll','hello','help','hence','her','here','hereafter','hereby','herein','here\'s','hereupon','hers','herself','he\'s','hi','him','himself','his','hither','hopefully','how','howbeit','however','hundred','i','i\'d','ie','if','ignored','i\'ll','i\'m','immediate','in','inasmuch','inc','inc.','indeed','indicate','indicated','indicates','inner','inside','insofar','instead','into','inward','is','isn\'t','it','it\'d','it\'ll','its','it\'s','itself','i\'ve','j','just','k','keep','keeps','kept','know','known','knows','l','last','lately','later','latter','latterly','least','less','lest','let','let\'s','like','liked','likely','likewise','little','look','looking','looks','lot','low','lower','ltd','m','made','mainly','make','makes','many','may','maybe','mayn\'t','me','mean','meantime','meanwhile','merely','might','mightn\'t','mine','minus','miss','more','moreover','most','mostly','mr','mrs','much','must','mustn\'t','my','myself','n','name','namely','nd','near','nearly','necessary','need','needn\'t','needs','neither','never','neverf','neverless','nevertheless','new','next','nine','ninety','no','nobody','non','none','nonetheless','noone','no-one','nor','normally','not','nothing','notwithstanding','novel','now','nowhere','o','obviously','of','off','often','oh','ok','okay','old','on','once','one','ones','one\'s','only','onto','opposite','or','other','others','otherwise','ought','oughtn\'t','our','ours','ourselves','out','outside','over','overall','own','p','particular','particularly','past','per','perhaps','placed','please','plus','possible','presumably','probably','provided','provides','q','que','quite','qv','r','rather','rd','re','really','reasonably','recent','recently','regarding','regardless','regards','relatively','respectively','right','round','s','said','same','saw','say','saying','says','second','secondly','see','seeing','seem','seemed','seeming','seems','seen','self','selves','sensible','sent','serious','seriously','seven','several','shall','shan\'t','she','she\'d','she\'ll','she\'s','should','shouldn\'t','since','six','so','some','somebody','someday','somehow','someone','something','sometime','sometimes','somewhat','somewhere','soon','sorry','specified','specify','specifying','still','sub','such','sup','sure','t','take','taken','taking','tell','tends','th','than','thank','thanks','thanx','that','that\'ll','thats','that\'s','that\'ve','the','their','theirs','them','themselves','then','thence','there','thereafter','thereby','there\'d','therefore','therein','there\'ll','there\'re','theres','there\'s','thereupon','there\'ve','these','they','they\'d','they\'ll','they\'re','they\'ve','thing','things','think','third','thirty','this','thorough','thoroughly','those','though','three','through','throughout','thru','thus','till','to','together','too','took','toward','towards','tried','tries','truly','try','trying','t\'s','twice','two','u','un','under','underneath','undoing','unfortunately','unless','unlike','unlikely','until','unto','up','upon','upwards','us','use','used','useful','uses','using','usually','v','value','various','versus','very','via','viz','vs','w','want','wants','was','wasn\'t','way','we','we\'d','welcome','well','we\'ll','went','were','we\'re','weren\'t','we\'ve','what','whatever','what\'ll','what\'s','what\'ve','when','whence','whenever','where','whereafter','whereas','whereby','wherein','where\'s','whereupon','wherever','whether','which','whichever','while','whilst','whither','who','who\'d','whoever','whole','who\'ll','whom','whomever','who\'s','whose','why','will','willing','wish','with','within','without','wonder','won\'t','would','wouldn\'t','x','y','yes','yet','you','you\'d','you\'ll','your','you\'re','yours','yourself','yourselves','you\'ve','z','zero',' \'');
$meta_keywords = preg_replace('/\b('.implode('|',$common_words).')\b/','',$meta_keywords);
$meta_keywords = preg_replace('/\s\s+/', ' ', $meta_keywords);
$meta_keywords = trim($meta_keywords);
$meta_keywords = substr($meta_keywords, 0, 140);
$meta_keywords = str_replace(" ", ", ", $meta_keywords);
$meta_keywords = str_replace("., ", ", ", $meta_keywords);
$meta_keywords = str_replace(".", "", $meta_keywords);
$meta_keywords = str_replace("? ", ", ", $meta_keywords);
$meta_keywords = str_replace("?", "", $meta_keywords);
$meta_keywords = str_replace("! ", ", ", $meta_keywords);
$meta_keywords = str_replace("!", "", $meta_keywords);
$meta_keywords = str_replace(",,", ",", $meta_keywords);
$meta_keywords = str_replace(", , ", ", ", $meta_keywords);
} else {
$meta_keywords = strtolower($short_description);
$common_words = array ('a','able','about','above','abroad','according','accordingly','across','actually','adj','after','afterwards','again','against','ago','ahead','ain\'t','all','allow','allows','almost','alone','along','alongside','already','also','although','always','am','amid','amidst','among','amongst','an','and','another','any','anybody','anyhow','anyone','anything','anyway','anyways','anywhere','apart','appear','appreciate','appropriate','are','aren\'t','around','as','a\'s','aside','ask','asking','associated','at','available','away','awfully','b','back','backward','backwards','be','became','because','become','becomes','becoming','been','before','beforehand','begin','behind','being','believe','below','beside','besides','best','better','between','beyond','both','brief','but','by','c','came','can','cannot','cant','can\'t','caption','cause','causes','certain','certainly','changes','clearly','c\'mon','co','co.','com','come','comes','concerning','consequently','consider','considering','contain','containing','contains','corresponding','could','couldn\'t','course','c\'s','currently','d','dare','daren\'t','definitely','described','despite','did','didn\'t','different','directly','do','does','doesn\'t','doing','done','don\'t','down','downwards','during','e','each','edu','eg','eight','eighty','either','else','elsewhere','end','ending','enough','entirely','especially','et','etc','even','ever','evermore','every','everybody','everyone','everything','everywhere','ex','exactly','example','except','f','fairly','far','farther','few','fewer','fifth','first','five','followed','following','follows','for','forever','former','formerly','forth','forward','found','four','from','further','furthermore','g','get','gets','getting','given','gives','go','goes','going','gone','got','gotten','greetings','h','had','hadn\'t','half','happens','hardly','has','hasn\'t','have','haven\'t','having','he','he\'d','he\'ll','hello','help','hence','her','here','hereafter','hereby','herein','here\'s','hereupon','hers','herself','he\'s','hi','him','himself','his','hither','hopefully','how','howbeit','however','hundred','i','i\'d','ie','if','ignored','i\'ll','i\'m','immediate','in','inasmuch','inc','inc.','indeed','indicate','indicated','indicates','inner','inside','insofar','instead','into','inward','is','isn\'t','it','it\'d','it\'ll','its','it\'s','itself','i\'ve','j','just','k','keep','keeps','kept','know','known','knows','l','last','lately','later','latter','latterly','least','less','lest','let','let\'s','like','liked','likely','likewise','little','look','looking','looks','lot','low','lower','ltd','m','made','mainly','make','makes','many','may','maybe','mayn\'t','me','mean','meantime','meanwhile','merely','might','mightn\'t','mine','minus','miss','more','moreover','most','mostly','mr','mrs','much','must','mustn\'t','my','myself','n','name','namely','nd','near','nearly','necessary','need','needn\'t','needs','neither','never','neverf','neverless','nevertheless','new','next','nine','ninety','no','nobody','non','none','nonetheless','noone','no-one','nor','normally','not','nothing','notwithstanding','novel','now','nowhere','o','obviously','of','off','often','oh','ok','okay','old','on','once','one','ones','one\'s','only','onto','opposite','or','other','others','otherwise','ought','oughtn\'t','our','ours','ourselves','out','outside','over','overall','own','p','particular','particularly','past','per','perhaps','placed','please','plus','possible','presumably','probably','provided','provides','q','que','quite','qv','r','rather','rd','re','really','reasonably','recent','recently','regarding','regardless','regards','relatively','respectively','right','round','s','said','same','saw','say','saying','says','second','secondly','see','seeing','seem','seemed','seeming','seems','seen','self','selves','sensible','sent','serious','seriously','seven','several','shall','shan\'t','she','she\'d','she\'ll','she\'s','should','shouldn\'t','since','six','so','some','somebody','someday','somehow','someone','something','sometime','sometimes','somewhat','somewhere','soon','sorry','specified','specify','specifying','still','sub','such','sup','sure','t','take','taken','taking','tell','tends','th','than','thank','thanks','thanx','that','that\'ll','thats','that\'s','that\'ve','the','their','theirs','them','themselves','then','thence','there','thereafter','thereby','there\'d','therefore','therein','there\'ll','there\'re','theres','there\'s','thereupon','there\'ve','these','they','they\'d','they\'ll','they\'re','they\'ve','thing','things','think','third','thirty','this','thorough','thoroughly','those','though','three','through','throughout','thru','thus','till','to','together','too','took','toward','towards','tried','tries','truly','try','trying','t\'s','twice','two','u','un','under','underneath','undoing','unfortunately','unless','unlike','unlikely','until','unto','up','upon','upwards','us','use','used','useful','uses','using','usually','v','value','various','versus','very','via','viz','vs','w','want','wants','was','wasn\'t','way','we','we\'d','welcome','well','we\'ll','went','were','we\'re','weren\'t','we\'ve','what','whatever','what\'ll','what\'s','what\'ve','when','whence','whenever','where','whereafter','whereas','whereby','wherein','where\'s','whereupon','wherever','whether','which','whichever','while','whilst','whither','who','who\'d','whoever','whole','who\'ll','whom','whomever','who\'s','whose','why','will','willing','wish','with','within','without','wonder','won\'t','would','wouldn\'t','x','y','yes','yet','you','you\'d','you\'ll','your','you\'re','yours','yourself','yourselves','you\'ve','z','zero',' \'');
$meta_keywords = preg_replace('/\b('.implode('|',$common_words).')\b/','',$meta_keywords);
$meta_keywords = preg_replace('/\s\s+/', ' ', $meta_keywords);
$meta_keywords = trim($meta_keywords);
$meta_keywords = substr($meta_keywords, 0, 140);
$meta_keywords = str_replace(" ", ", ", $meta_keywords);
$meta_keywords = str_replace("., ", ", ", $meta_keywords);
$meta_keywords = str_replace(".", "", $meta_keywords);
$meta_keywords = str_replace("? ", ", ", $meta_keywords);
$meta_keywords = str_replace("?", "", $meta_keywords);
$meta_keywords = str_replace("! ", ", ", $meta_keywords);
$meta_keywords = str_replace("!", "", $meta_keywords);
$meta_keywords = str_replace(",,", ",", $meta_keywords);
$meta_keywords = str_replace(", , ", ", ", $meta_keywords);
}
}
$uploadedfile = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
if ($uploadedfile) {
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
$src = imagecreatefromjpeg($uploadedfile);
}
if ($file_type == "image/gif") {
$src = imagecreatefromgif($uploadedfile);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
$src = imagecreatefrompng($uploadedfile);
}
list($width,$height)=getimagesize($uploadedfile);
if ($width>$height) {
if ($width <= "100") {
$small_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$small_width=100;
$small_height=($height/$width)*100;
$small_tmp=imagecreatetruecolor($small_width,$small_height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$small_width,$small_height,$width,$height);
}
if ($width <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=500;
$large_height=($height/$width)*500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
if ($width<$height) {
if ($height <= "100") {
$small_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$small_width=($width/$height)*100;
$small_height=100;
$small_tmp=imagecreatetruecolor($small_width,$small_height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$small_width,$small_height,$width,$height);
}
if ($height <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=($width/$height)*500;
$large_height=500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
if ($width == $height) {
if ($height <= "100" || $width <= "100") {
$small_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$small_width=($width/$height)*100;
$small_height=100;
$small_tmp=imagecreatetruecolor($small_width,$small_height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$small_width,$small_height,$width,$height);
}
if ($height <= "500" || $width <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=($width/$height)*500;
$large_height=500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
$small_file = "./shop_images/[S]". $_FILES['image']['name'];
$large_file = "./shop_images/[L]". $_FILES['image']['name'];
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
imagejpeg($small_tmp,$small_file,80);
imagejpeg($large_tmp,$large_file,80);
}
if ($file_type == "image/gif") {
imagegif($small_tmp,$small_file);
imagegif($large_tmp,$large_file);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
imagepng($small_tmp,$small_file);
imagepng($large_tmp,$large_file);
}
$small_file_path = addslashes($small_file);
$large_file_path = addslashes($large_file);
$small_file_name = "[S]" . $_FILES['image']['name'];
$large_file_name = "[L]" . $_FILES['image']['name'];
imagedestroy($src);
imagedestroy($small_tmp);
imagedestroy($large_tmp);
}
$short_description = ereg_replace("\r", '', $short_description);
$short_description = ereg_replace("\n\n", "<p>", $short_description);
$short_description = ereg_replace("\n", "<br>", $short_description);
$long_description = ereg_replace("\r", '', $long_description);
$long_description = ereg_replace("\n\n", "<p>", $long_description);
$long_description = ereg_replace("\n", "<br>", $long_description);
$short_description = str_replace(array('[b]', '[B]'), '<b>', $short_description);
$short_description = str_replace(array('[eb]', '[EB]'), '</b>', $short_description);
$short_description = str_replace(array('[u]', '[U]'), '<u>', $short_description);
$short_description = str_replace(array('[eu]', '[EU]'), '</u>', $short_description);
$short_description = str_replace(array('[i]', '[I]'), '<i>', $short_description);
$short_description = str_replace(array('[ei]', '[EI]'), '</i>', $short_description);
$long_description = str_replace(array('[b]', '[B]'), '<b>', $long_description);
$long_description = str_replace(array('[eb]', '[EB]'), '</b>', $long_description);
$long_description = str_replace(array('[u]', '[U]'), '<u>', $long_description);
$long_description = str_replace(array('[eu]', '[EU]'), '</u>', $long_description);
$long_description = str_replace(array('[i]', '[I]'), '<i>', $long_description);
$long_description = str_replace(array('[ei]', '[EI]'), '</i>', $long_description);
if ($new_category) {
if ($db_products_categories_name) {
echo("Product category already exists in the database, duplicates are not allowed.<p>");
} else {
$db_themes_website_name = addslashes($db_themes_website_name);
$category_meta_title = "$db_themes_website_name - $new_category";
$category_meta_title = substr($category_meta_title, 0, 60);
$category_meta_description = "$new_category products from $db_themes_website_name.";
$category_meta_keywords = strtolower($new_category);
$category_meta_keywords = preg_replace('/\s\s+/', ' ', $category_meta_keywords);
$category_meta_keywords = trim($category_meta_keywords);
$category_meta_keywords = substr($category_meta_keywords, 0, 140);
$category_meta_keywords = str_replace(" ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace("., ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace(".", "", $category_meta_keywords);
$category_meta_keywords = str_replace("? ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace("?", "", $category_meta_keywords);
$category_meta_keywords = str_replace("! ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace("!", "", $category_meta_keywords);
$category_meta_keywords = str_replace(",,", ",", $category_meta_keywords);
$category_meta_keywords = str_replace(", , ", ", ", $category_meta_keywords);
$single_category_meta_keywords = $category_meta_keywords;
$category_meta_keywords .= ", $db_themes_website_name";
$category_meta_keywords .= ", $meta_keywords";
$category_meta_keywords = substr($category_meta_keywords, 0, 140);
$category_meta_keywords = str_replace(" ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace("., ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace(".", "", $category_meta_keywords);
$category_meta_keywords = str_replace("? ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace("?", "", $category_meta_keywords);
$category_meta_keywords = str_replace("! ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace("!", "", $category_meta_keywords);
$category_meta_keywords = str_replace(",,", ",", $category_meta_keywords);
$category_meta_keywords = str_replace(", , ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace(" ,", "", $category_meta_keywords);
$category_meta_keywords = str_replace(", $single_category_meta_keywords", "", $category_meta_keywords);
$db_insert_products_categories = "INSERT INTO products_categories SET " .
"name = '$new_category', " .
"meta_title = '$category_meta_title', " .
"meta_description = '$category_meta_description', " .
"meta_keywords = '$category_meta_keywords'";
if (@mysql_query($db_insert_products_categories)) {
echo("Product category creation successful.<p>");
} else {
echo("Product category creation error.<p>");
}
$db_lookup_products_categories = @mysql_query("SELECT name FROM products_categories WHERE name='$new_category'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_name = $db_products_categories['name'];
$db_lookup_menu_categories = @mysql_query("SELECT id FROM menu_categories WHERE name='Shop'");
$db_menu_categories = @mysql_fetch_array($db_lookup_menu_categories);
$db_menu_categories_id = $db_menu_categories['id'];
if (!$db_menu_categories_id) {
$db_insert_menu_categories = "INSERT INTO menu_categories SET " .
"name = 'Shop'";
if (@mysql_query($db_insert_menu_categories)) {
echo("Menu categories insert successful.<p>");
} else {
echo("Menu categories insert failed.<p>");
}
}
$db_lookup_products_categories = @mysql_query("SELECT id FROM products_categories WHERE name='$new_category'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_id = $db_products_categories['id'];
$db_lookup_menu = @mysql_query("SELECT id FROM menu WHERE request='$db_products_categories_id'");
$db_menu = @mysql_fetch_array($db_lookup_menu);
$db_menu_id = $db_menu['id'];
if (!$db_menu_id) {
$db_lookup_menu_categories = @mysql_query("SELECT id FROM menu_categories WHERE name='Shop'");
$db_menu_categories = @mysql_fetch_array($db_lookup_menu_categories);
$db_menu_categories_id = $db_menu_categories['id'];
$db_insert_menu = "INSERT INTO menu SET " .
"menu_categories_id = '$db_menu_categories_id', " .
"name = '$new_category', " .
"include_file = 'catalog.inc', " .
"page = 'view_category', " .
"request = '$db_products_categories_id'";
if (@mysql_query($db_insert_menu)) {
echo("Menu insert successful.<p>");
} else {
echo("Menu insert failed.<p>");
}
}
$db_lookup_products_categories = @mysql_query("SELECT id FROM products_categories WHERE name='$new_category'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_id = $db_products_categories['id'];
}
}
if ($db_products_categories_id) {
$db_insert_products = "INSERT INTO products SET " .
"rss_date = '$rss_date', " .
"mode = '$mode', " .
"code = '$code', " .
"name = '$name', " .
"cost = '$cost', " .
"price = '$price', " .
"payment_type = '$payment_type', " .
"sub_time = '$sub_time', " .
"sub_unit = '$sub_unit', " .
"inventory = '$inventory', " .
"weight = '$weight', " .
"width = '$product_width', " .
"depth = '$product_depth', " .
"height = '$product_height', " .
"short_description = '$short_description', " .
"long_description = '$long_description', " .
"option_groups_id = '$option_groups_id', " .
"shipping_type = '$shipping_type', " .
"shipping_cost = '$shipping_cost', " .
"tax_type = '$tax_type', " .
"tax_cost = '$tax_cost', " .
"category_id = '$db_products_categories_id', " .
"manufacture_id = '$manufacture_id', " .
"vendor_id = '$vendor_id', " .
"meta_title = '$meta_title', " .
"meta_description = '$meta_description', " .
"meta_keywords = '$meta_keywords'";
} else {
$db_insert_products = "INSERT INTO products SET " .
"rss_date = '$rss_date', " .
"mode = '$mode', " .
"code = '$code', " .
"name = '$name', " .
"cost = '$cost', " .
"price = '$price', " .
"payment_type = '$payment_type', " .
"sub_time = '$sub_time', " .
"sub_unit = '$sub_unit', " .
"inventory = '$inventory', " .
"weight = '$weight', " .
"width = '$product_width', " .
"depth = '$product_depth', " .
"height = '$product_height', " .
"short_description = '$short_description', " .
"long_description = '$long_description', " .
"option_groups_id = '$option_groups_id', " .
"shipping_type = '$shipping_type', " .
"shipping_cost = '$shipping_cost', " .
"tax_type = '$tax_type', " .
"tax_cost = '$tax_cost', " .
"category_id = '$category_id', " .
"manufacture_id = '$manufacture_id', " .
"vendor_id = '$vendor_id', " .
"meta_title = '$meta_title', " .
"meta_description = '$meta_description', " .
"meta_keywords = '$meta_keywords'";
}
if (@mysql_query($db_insert_products)) {
$db_lookup_products = @mysql_query("SELECT id FROM products WHERE code='$code' and name='$name' and cost='$cost' and price='$price' and inventory='$inventory' and weight='$weight' and width='$product_width' and depth='$product_depth' and height='$product_height' and short_description='$short_description' and long_description='$long_description' and option_groups_id='$option_groups_id' and shipping_cost='$shipping_cost' and tax_cost='$tax_cost' and manufacture_id='$manufacture_id' and vendor_id='$vendor_id' and meta_title='$meta_title' and meta_description='$meta_description' and meta_keywords='$meta_keywords'");
$db_products = @mysql_fetch_array($db_lookup_products);
$db_products_id = $db_products['id'];
$db_insert_products_images = "INSERT INTO products_images SET " .
"products_id = '$db_products_id', " .
"main_image = 'yes', " .
"small_image_path = '$small_file_path', " .
"large_image_path = '$large_file_path', " .
"small_image_name = '$small_file_name', " .
"large_image_name = '$large_file_name'";
if (@mysql_query($db_insert_products_images)) {
echo("Product creation successful.<p>");
$db_lookup_themes = @mysql_query("SELECT website_name FROM themes WHERE on_off='on'");
$db_themes = @mysql_fetch_array($db_lookup_themes);
$db_themes_website_name = $db_themes['website_name'];
$file = "shop_feed.xml";
$method = fopen($file, 'w');
$data = "<?xml version=\"1.0\"?>\r";
fwrite($method, $data);
$data = "<rss version=\"2.0\">\r";
fwrite($method, $data);
$data = "<channel>\r";
fwrite($method, $data);
$db_themes_website_name = str_replace("\\", "", $db_themes_website_name);
$db_themes_website_name = htmlspecialchars("$db_themes_website_name", ENT_QUOTES);
$data = "\r<title>$db_themes_website_name Shop Feed</title>\r";
fwrite($method, $data);
$data = "<link>http://" . $_SERVER['HTTP_HOST'] . "" . $_SERVER['PHP_SELF'] . "</link>\r";
fwrite($method, $data);
$data = "<description>Latest Products</description>\r";
fwrite($method, $data);
$data = "<lastBuildDate>$rss_date</lastBuildDate>\r";
fwrite($method, $data);
$data = "<language>en-us</language>\r\r";
fwrite($method, $data);
$db_lookup_products = @mysql_query("SELECT id, rss_date, code, name, price, width, depth, height, short_description, long_description, category_id FROM products WHERE mode='On' and inventory >= '1' ORDER BY id DESC LIMIT 0, 20");
while ($db_products = @mysql_fetch_array($db_lookup_products)) {
$db_products_id = $db_products['id'];
$db_products_rss_date = $db_products['rss_date'];
$db_products_code = $db_products['code'];
$db_products_name = $db_products['name'];
$db_products_price = $db_products['price'];
$db_products_width = $db_products['width'];
$db_products_depth = $db_products['depth'];
$db_products_height = $db_products['height'];
$db_products_short_description = $db_products['short_description'];
$db_products_long_description = $db_products['long_description'];
$db_products_category_id = $db_products['category_id'];
$db_products_short_description = str_replace("\r", '<br>', $db_products_short_description);
$db_products_short_description = str_replace("\n", "<p>", $db_products_short_description);
$db_products_short_description = str_replace("<br><p><br><p>", "<p>", $db_products_short_description);
$db_products_short_description = str_replace("<br><p>", "<br>", $db_products_short_description);
$db_products_short_description = str_replace("\\", "", $db_products_short_description);
$db_products_long_description = str_replace("\r", '<br>', $db_products_long_description);
$db_products_long_description = str_replace("\n", "<p>", $db_products_long_description);
$db_products_long_description = str_replace("<br><p><br><p>", "<p>", $db_products_long_description);
$db_products_long_description = str_replace("<br><p>", "<br>", $db_products_long_description);
$db_products_long_description = str_replace("\\", "", $db_products_long_description);
$db_lookup_product_categories = @mysql_query("SELECT name FROM products_categories WHERE id='$db_products_category_id'");
$db_product_categories = @mysql_fetch_array($db_lookup_product_categories);
$db_product_categories_name = $db_product_categories['name'];
$data = "<item>\r";
fwrite($method, $data);
$db_products_name = str_replace("\\", "", $db_products_name);
$db_products_code = str_replace("\\", "", $db_products_code);
$db_products_name = htmlspecialchars("$db_products_name", ENT_QUOTES);
$db_products_code = htmlspecialchars("$db_products_code", ENT_QUOTES);
if ($name) {
$data = "<title>$db_products_name</title>\r";
} else {
$data = "<title>$db_products_code</title>\r";
}
fwrite($method, $data);
$data = "<link>http://" . $_SERVER['HTTP_HOST'] . "" . $_SERVER['PHP_SELF'] . "?page=view_detail&request=$db_products_id&include=catalog.inc</link>\r";
fwrite($method, $data);
$data = "<guid>http://" . $_SERVER['HTTP_HOST'] . "" . $_SERVER['PHP_SELF'] . "?page=view_detail&request=$db_products_id&include=catalog.inc</guid>\r";
fwrite($method, $data);
$data = "<description><![CDATA[";
fwrite($method, $data);
$db_lookup_products_images = @mysql_query("SELECT small_image_name FROM products_images WHERE products_id='$db_products_id' and main_image='yes'");
$db_products_images = @mysql_fetch_array($db_lookup_products_images);
$db_products_images_small_image_name = $db_products_images['small_image_name'];
$file = "http://" . $_SERVER['HTTP_HOST'] . "" . $_SERVER['PHP_SELF'];
$find = '/';
$after_find = substr(strrchr($file, $find), 1);
$strlen_str = strlen($after_find);
$result = substr($file, 0, -$strlen_str);
if ($db_products_images_small_image_name) {
if ($db_products_long_description) {
$data = "<img src='" . $result . "shop_images/$db_products_images_small_image_name' border='0'><p> $db_products_long_description";
} else {
$data = "<img src='" . $result . "shop_images/$db_products_images_small_image_name' border='0'><p> $db_products_short_description";
}
} else {
if ($db_products_long_description) {
$data = "$db_products_long_description";
} else {
$data = "$db_products_short_description";
}
}
if ($db_products_width or $db_products_depth or $db_products_height) {
$data .= "<br>";
}
if ($db_products_height) {
$data .= "Height: $db_products_height ";
}
if ($db_products_width) {
$data .= "Width: $db_products_width ";
}
if ($db_products_depth) {
$data .= "Depth: $db_products_depth";
}
if ($db_products_price) {
$data .= "<br>Price: \$$db_products_price";
}
fwrite($method, $data);
$data = "]]></description>\r";
fwrite($method, $data);
if ($db_product_categories_name) {
$data = "<category>$db_product_categories_name</category>\r";
fwrite($method, $data);
}
$data = "<pubDate>$db_products_rss_date</pubDate>\r";
fwrite($method, $data);
$data = "</item>\r\r";
fwrite($method, $data);
}
$data = "</channel>\r";
fwrite($method, $data);
$data = "</rss>";
fwrite($method, $data);
fclose($method);
}
} else {
echo("Product creation failed.<p>");
}
}
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "products" and $request == "view_product" and $admin_rights) {
echo("<b>Products - View Product</b><p>");
$product_id = $_GET['product_id'];
$db_lookup_products = @mysql_query("SELECT id, mode, code, name, cost, price, payment_type, sub_time, sub_unit, inventory, weight, width, depth, height, short_description, long_description, option_groups_id, shipping_type, shipping_cost, tax_type, tax_cost, category_id, manufacture_id, vendor_id, meta_title, meta_description, meta_keywords FROM products WHERE id='$product_id'");
$db_products = @mysql_fetch_array($db_lookup_products);
$db_products_id = $db_products['id'];
$db_products_mode = $db_products['mode'];
$db_products_code = $db_products['code'];
$db_products_name = $db_products['name'];
$db_products_cost = $db_products['cost'];
$db_products_price = $db_products['price'];
$db_products_payment_type = $db_products['payment_type'];
$db_products_sub_time = $db_products['sub_time'];
$db_products_sub_unit = $db_products['sub_unit'];
$db_products_inventory = $db_products['inventory'];
$db_products_weight = $db_products['weight'];
$db_products_width = $db_products['width'];
$db_products_depth = $db_products['depth'];
$db_products_height = $db_products['height'];
$db_products_short_description = $db_products['short_description'];
$db_products_long_description = $db_products['long_description'];
$db_products_option_groups_id = $db_products['option_groups_id'];
$db_products_shipping_type = $db_products['shipping_type'];
$db_products_shipping_cost = $db_products['shipping_cost'];
$db_products_tax_type = $db_products['tax_type'];
$db_products_tax_cost = $db_products['tax_cost'];
$db_products_category_id = $db_products['category_id'];
$db_products_manufacture_id = $db_products['manufacture_id'];
$db_products_vendor_id = $db_products['vendor_id'];
$db_products_meta_title = $db_products['meta_title'];
$db_products_meta_description = $db_products['meta_description'];
$db_products_meta_keywords = $db_products['meta_keywords'];
$db_lookup_categories = @mysql_query("SELECT id, name FROM products_categories WHERE id='$db_products_category_id'");
$db_categories = @mysql_fetch_array($db_lookup_categories);
$db_categories_id = $db_categories['id'];
$db_categories_name = $db_categories['name'];
$db_lookup_manufactures = @mysql_query("SELECT id, name FROM products_manufactures WHERE id='$db_products_manufacture_id'");
$db_manufactures = @mysql_fetch_array($db_lookup_manufactures);
$db_manufactures_id = $db_manufactures['id'];
$db_manufactures_name = $db_manufactures['name'];
$db_lookup_vendors = @mysql_query("SELECT id, name FROM products_vendors WHERE id='$db_products_vendor_id'");
$db_vendors = @mysql_fetch_array($db_lookup_vendors);
$db_vendors_id = $db_vendors['id'];
$db_vendors_name = $db_vendors['name'];
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups WHERE id='$db_products_option_groups_id'");
$db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups);
$db_products_option_groups_id = $db_products_option_groups['id'];
$db_products_option_groups_name = $db_products_option_groups['name'];
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Mode:</td>");
echo("<td>" . $font_body . $db_products_mode . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Code:</td>");
echo("<td>" . $font_body . $db_products_code . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Name:</td>");
echo("<td>" . $font_body . $db_products_name . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Cost:</td>");
echo("<td>" . $font_body . $db_products_cost . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Price:</td>");
echo("<td>" . $font_body . $db_products_price . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Payment Type:</td>");
echo("<td>" . $font_body . $db_products_payment_type . " ");
if ($db_products_payment_type == "Subscription") {
$db_products_sub_unit = str_replace("D", "Days", $db_products_sub_unit);
$db_products_sub_unit = str_replace("W", "Weeks", $db_products_sub_unit);
$db_products_sub_unit = str_replace("M", "Months", $db_products_sub_unit);
$db_products_sub_unit = str_replace("Y", "Years", $db_products_sub_unit);
echo("(" . $db_products_sub_time . " " . $db_products_sub_unit . ")");
}
echo("</td>");
echo("</tr>");
// echo("<tr>");
// echo("<td>" . $font_body . "Shipping Type:</td>");
// echo("<td>" . $font_body . $db_products_shipping_type . " </td>");
// echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Shipping Cost:</td>");
echo("<td>" . $font_body . $db_products_shipping_cost . " </td>");
echo("</tr>");
// echo("<tr>");
// echo("<td>" . $font_body . "Tax Type:</td>");
// echo("<td>" . $font_body . $db_products_tax_type . " </td>");
// echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Tax Cost:</td>");
echo("<td>" . $font_body . $db_products_tax_cost . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Inventory:</td>");
echo("<td>" . $font_body . $db_products_inventory . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Weight:</td>");
echo("<td>" . $font_body . $db_products_weight . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Width:</td>");
echo("<td>" . $font_body . $db_products_width . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Depth:</td>");
echo("<td>" . $font_body . $db_products_depth . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Height:</td>");
echo("<td>" . $font_body . $db_products_height . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Short Description:</td>");
echo("<td>" . $font_body . $db_products_short_description . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Long Description:</td>");
echo("<td>" . $font_body . $db_products_long_description . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Options:</td>");
if ($db_products_option_groups_name) {
echo("<td>" . $font_body . "");
echo("Group name: " . $db_products_option_groups_name . "<p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Option Name</td>");
echo("<td>" . $font_body . "Price Difference</td>");
echo("</tr>");
$db_lookup_products_options = @mysql_query("SELECT name, plus_minus, price_difference FROM products_options WHERE group_id='$db_products_option_groups_id'");
while ($db_products_options = @mysql_fetch_array($db_lookup_products_options)) {
$db_products_options_name = $db_products_options['name'];
$db_products_options_plus_minus = $db_products_options['plus_minus'];
$db_products_options_price_difference = $db_products_options['price_difference'];
echo("<tr>");
echo("<td>" . $font_body . $db_products_options_name . " </td>");
echo("<td>" . $font_body . $db_products_options_plus_minus . " " . $db_products_options_price_difference . " </td>");
echo("</tr>");
}
echo("</table>");
echo(" </td>");
} else {
echo("<td>" . $font_body . " </td>");
}
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Category:</td>");
echo("<td>" . $font_body . $db_categories_name . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Manufacture:</td>");
echo("<td>" . $font_body . $db_manufactures_name . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Vendor:</td>");
echo("<td>" . $font_body . $db_vendors_name . " </td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<b>Search Engine Marketing:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Title:</td>");
echo("<td>" . $font_body . $db_products_meta_title . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Description:</td>");
echo("<td>" . $font_body . $db_products_meta_description . " </td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Keywords:</td>");
echo("<td>" . $font_body . $db_products_meta_keywords . " </td>");
echo("</tr>");
echo("</table>");
echo("<p><b>Images:</b><p>");
$db_select_count_products_images = "SELECT COUNT(id) FROM products_images WHERE products_id='$db_products_id'";
$db_count_products_images = mysql_query($db_select_count_products_images);
$db_count_products_images_rows = mysql_fetch_row($db_count_products_images);
$products_images_total_records = $db_count_products_images_rows[0];
$products_images_total_rows = ceil($products_images_total_records / 5);
echo("<table border='0' cellpadding='5' cellspacing='0'>");
$start_from = "0";
while ($products_images_total_rows > 0) {
echo("<tr>");
$db_lookup_products_images = @mysql_query("SELECT small_image_name FROM products_images WHERE products_id='$product_id' ORDER BY id ASC LIMIT $start_from, 5");
while ($db_products_images = @mysql_fetch_array($db_lookup_products_images)) {
$db_products_images_small_image_name = $db_products_images['small_image_name'];
echo("<td><img border='0' src='./shop_images/" . $db_products_images_small_image_name . "'></td>");
}
echo("</tr>");
echo("<tr>");
$db_lookup_products_images = @mysql_query("SELECT main_image, id FROM products_images WHERE products_id='$product_id' ORDER BY id ASC LIMIT $start_from, 5");
while ($db_products_images = @mysql_fetch_array($db_lookup_products_images)) {
$db_products_images_id = $db_products_images['id'];
$db_products_images_main_image = $db_products_images['main_image'];
echo("<td>" . $font_body);
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=view_products_images&product_images_id=$db_products_images_id'>" . $link_color . "View</font></a>]");
if ($db_products_images_main_image == "yes") {
echo("<br>(Main Image)");
} else {
echo("<br>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=delete_products_images&product_images_id=$db_products_images_id'>" . $link_color . "Delete</font></a>]");
}
echo ("</td>");
}
$products_images_total_rows = $products_images_total_rows - 1;
$start_from = $start_row + 5;
echo("</tr>");
}
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=new_products_images&product_id=$product_id'>" . $link_color . "Add Additional Images</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "products" and $request == "edit_product" and $admin_rights) {
echo("<b>Products - Edit Product</b><p>");
$product_id = $_GET['product_id'];
$db_lookup_products = @mysql_query("SELECT id, mode, code, name, cost, price, payment_type, sub_time, sub_unit, inventory, weight, width, depth, height, short_description, long_description, option_groups_id, shipping_type, shipping_cost, tax_type, tax_cost, category_id, manufacture_id, vendor_id, meta_title, meta_description, meta_keywords FROM products WHERE id='$product_id'");
$db_products = @mysql_fetch_array($db_lookup_products);
$db_products_id = $db_products['id'];
$db_products_mode = $db_products['mode'];
$db_products_code = $db_products['code'];
$db_products_name = $db_products['name'];
$db_products_cost = $db_products['cost'];
$db_products_price = $db_products['price'];
$db_products_payment_type = $db_products['payment_type'];
$db_products_sub_time = $db_products['sub_time'];
$db_products_sub_unit = $db_products['sub_unit'];
$db_products_inventory = $db_products['inventory'];
$db_products_weight = $db_products['weight'];
$db_products_width = $db_products['width'];
$db_products_depth = $db_products['depth'];
$db_products_height = $db_products['height'];
$db_products_short_description = $db_products['short_description'];
$db_products_long_description = $db_products['long_description'];
$db_products_option_groups_id = $db_products['option_groups_id'];
$db_products_shipping_type = $db_products['shipping_type'];
$db_products_shipping_cost = $db_products['shipping_cost'];
$db_products_tax_type = $db_products['tax_type'];
$db_products_tax_cost = $db_products['tax_cost'];
$db_products_category_id = $db_products['category_id'];
$db_products_manufacture_id = $db_products['manufacture_id'];
$db_products_vendor_id = $db_products['vendor_id'];
$db_products_meta_title = $db_products['meta_title'];
$db_products_meta_description = $db_products['meta_description'];
$db_products_meta_keywords = $db_products['meta_keywords'];
$db_lookup_categories = @mysql_query("SELECT id, name FROM categories WHERE id='$db_products_category_id'");
$db_categories = @mysql_fetch_array($db_lookup_categories);
$db_categories_id = $db_categories['id'];
$db_categories_name = $db_categories['name'];
$db_lookup_manufactures = @mysql_query("SELECT id, name FROM manufactures WHERE id='$db_products_manufacture_id'");
$db_manufactures = @mysql_fetch_array($db_lookup_manufactures);
$db_manufactures_id = $db_manufactures['id'];
$db_manufactures_name = $db_manufactures['name'];
$db_lookup_vendors = @mysql_query("SELECT id, name FROM vendors WHERE id='$db_products_vendor_id'");
$db_vendors = @mysql_fetch_array($db_lookup_vendors);
$db_vendors_id = $db_vendors['id'];
$db_vendors_name = $db_vendors['name'];
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups WHERE id='$db_products_option_groups_id'");
$db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups);
$db_products_option_groups_id = $db_products_option_groups['id'];
$db_products_option_groups_name = $db_products_option_groups['name'];
echo("<form enctype='multipart/form-data' action='" . $_SERVER['PHP_SELF'] . "?page=products&request=edit_product_submit' method='post'>");
echo("<input type='hidden' name='product_id' value='$product_id'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Mode:</font></td>");
if ($db_products_mode == "On") {
echo("<td>" . $font_body . "On: <input type='radio' name='mode' checked value='On'> Off: <input type='radio' name='mode' value='Off'></font></td>");
}
if ($db_products_mode == "Off") {
echo("<td>" . $font_body . "On: <input type='radio' name='mode' value='On'> Off: <input type='radio' name='mode' checked value='Off'></font></td>");
}
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Code:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='code' value='$db_products_code'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='name' value='$db_products_name'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Cost:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='cost' value='$db_products_cost'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Price:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='price' value='$db_products_price'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Payment Type:</font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='payment_type'>");
if ($db_products_payment_type == "One Time") {
echo("<option value='One Time' selected>One Time</option>");
} else {
echo("<option value='One Time'>One Time</option>");
}
if ($db_products_payment_type == "Subscription") {
echo("<option value='Subscription' selected>Subscription</option>");
} else {
echo("<option value='Subscription'>Subscription</option>");
}
echo("</select>");
echo("<br>");
$db_products_sub_unit = str_replace("D", "Days", $db_products_sub_unit);
$db_products_sub_unit = str_replace("W", "Weeks", $db_products_sub_unit);
$db_products_sub_unit = str_replace("M", "Months", $db_products_sub_unit);
$db_products_sub_unit = str_replace("Y", "Years", $db_products_sub_unit);
echo("Subscription renews every: ");
echo("<select size='1' name='durration'>");
if ($db_products_sub_unit == "None") {
echo("<option value='None' selected>None</option>");
} else {
echo("<option value='None'>None</option>");
}
if ($db_products_sub_unit == "Days") {
echo("<option value='Day' selected>Day</option>");
} else {
echo("<option value='Day'>Day</option>");
}
if ($db_products_sub_unit == "Weeks") {
echo("<option value='Week' selected>Week</option>");
} else {
echo("<option value='Week'>Week</option>");
}
if ($db_products_sub_unit == "Months" and $db_products_sub_time == "1") {
echo("<option value='Month' selected>Month</option>");
} else {
echo("<option value='Month'>Month</option>");
}
if ($db_products_sub_unit == "Months" and $db_products_sub_time == "3") {
echo("<option value='3 Months' selected>3 Months</option>");
} else {
echo("<option value='3 Months'>3 Months</option>");
}
if ($db_products_sub_unit == "Months" and $db_products_sub_time == "6") {
echo("<option value='6 Months' selected>6 Months</option>");
} else {
echo("<option value='6 Months'>6 Months</option>");
}
if ($db_products_sub_unit == "Years" and $db_products_sub_time == "1") {
echo("<option value='Year' selected>Year</option>");
} else {
echo("<option value='Year'>Year</option>");
}
if ($db_products_sub_unit == "Years" and $db_products_sub_time == "2") {
echo("<option value='2 Years' selected>2 Years</option>");
} else {
echo("<option value='2 Years'>2 Years</option>");
}
if ($db_products_sub_unit == "Years" and $db_products_sub_time == "3") {
echo("<option value='3 Years' selected>3 Years</option>");
} else {
echo("<option value='3 Years'>3 Years</option>");
}
if ($db_products_sub_unit == "Years" and $db_products_sub_time == "4") {
echo("<option value='4 Years' selected>4 Years</option>");
} else {
echo("<option value='4 Years'>4 Years</option>");
}
if ($db_products_sub_unit == "Years" and $db_products_sub_time == "5") {
echo("<option value='5 Years' selected>5 Years</option>");
} else {
echo("<option value='5 Years'>5 Years</option>");
}
echo("</select>");
echo("</font></td>");
echo("</tr>");
// echo("<tr>");
// echo("<td>" . $font_body . "Shipping Type:</font></td>");
// echo("<td>" . $font_body . "");
// echo("<select size='1' name='shipping_type'>");
// if ($db_products_shipping_type == "Free") {
// echo("<option value='Free' selected>Free</option>");
// } else {
// echo("<option value='Free'>Free</option>");
// }
// if ($db_products_shipping_type == "Carrier") {
// echo("<option selected value='Carrier'>Carrier</option>");
// } else {
// echo("<option value='Carrier'>Carrier</option>");
// }
// if ($db_products_shipping_type == "Other") {
// echo("<option selected value='Other'>Other</option>");
// } else {
// echo("<option value='Other'>Other</option>");
// }
// echo("</select>");
// echo("</font></td>");
// echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Shipping Cost:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='shipping_cost' value='$db_products_shipping_cost'></font></td>");
echo("</tr>");
// echo("<tr>");
// echo("<td>" . $font_body . "Tax Type:</font></td>");
// echo("<td>" . $font_body . "");
// echo("<select size='1' name='tax_type'>");
// if ($db_products_tax_type == "None") {
// echo("<option value='None' selected>None</option>");
// } else {
// echo("<option value='None'>None</option>");
// }
// if ($db_products_tax_type == "State") {
// echo("<option selected value='State'>State</option>");
// } else {
// echo("<option value='State'>State</option>");
// }
// if ($db_products_tax_type == "National") {
// echo("<option selected value='National'>National</option>");
// } else {
// echo("<option value='National'>National</option>");
// }
// if ($db_products_tax_type == "Other") {
// echo("<option selected value='Other'>Other</option>");
// } else {
// echo("<option value='Other'>Other</option>");
// }
// echo("</select>");
// echo("</font></td>");
// echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Tax Cost:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='tax_cost' value='$db_products_tax_cost'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Inventory:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='inventory' value='$db_products_inventory'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Weight:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='weight' value='$db_products_weight'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Width:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='product_width' value='$db_products_width'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Depth:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='product_depth' value='$db_products_depth'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Height:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='product_height' value='$db_products_height'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Short<br>Description:</font></td>");
echo("<td>" . $font_body . "<textarea name='short_description' cols='40' rows='10'>$db_products_short_description</textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Long<br>Description:</font></td>");
echo("<td>" . $font_body . "<textarea name='long_description' cols='40' rows='10'>$db_products_long_description</textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Option Group:</font></td>");
echo("<td>" . $font_body . "<select size='1' name='option_groups_id'>");
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups WHERE id='$db_products_option_groups_id'");
while ($db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups)) {
$db_products_option_groups_id_new = $db_products_option_groups['id'];
$db_products_option_groups_name_new = $db_products_option_groups['name'];
echo("<option selected value='" . $db_products_option_groups_id_new . "'>" . $db_products_option_groups_name_new . "</option>");
}
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups WHERE id != '$db_products_option_groups_id'");
while ($db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups)) {
$db_products_option_groups_id_new = $db_products_option_groups['id'];
$db_products_option_groups_name_new = $db_products_option_groups['name'];
echo("<option value='" . $db_products_option_groups_id_new . "'>" . $db_products_option_groups_name_new . "</option>");
}
if (!$db_products_option_groups_id) {
echo("<option selected value='0'>None</option>");
} else {
echo("<option value='0'>None</option>");
}
echo("</select>");
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Category:</font></td>");
echo("<td>" . $font_body . "<select size='1' name='category'>");
if (!$db_products_category_id) {
echo("<option selected value='0'>None</option>");
} else {
echo("<option value='0'>None</option>");
}
$db_lookup_products_categories = @mysql_query("SELECT id, name FROM products_categories WHERE id='$db_products_category_id'");
while ($db_products_categories = @mysql_fetch_array($db_lookup_products_categories)) {
$db_products_categories_id = $db_products_categories['id'];
$db_products_categories_name = $db_products_categories['name'];
echo("<option selected value='" . $db_products_categories_id . "'>" . $db_products_categories_name . "</option>");
}
$db_lookup_products_categories = @mysql_query("SELECT id, name FROM products_categories WHERE id != '$db_products_category_id'");
while ($db_products_categories = @mysql_fetch_array($db_lookup_products_categories)) {
$db_products_categories_id = $db_products_categories['id'];
$db_products_categories_name = $db_products_categories['name'];
echo("<option value='" . $db_products_categories_id . "'>" . $db_products_categories_name . "</option>");
}
echo("</select> or new: <input type='text' name='new_category' size='20'>");
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Manufacture:</font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='manufacture'>");
if (!$db_products_manufacture_id) {
echo("<option selected value='0'>None</option>");
} else {
echo("<option value='0'>None</option>");
}
$db_lookup_products_manufactures = @mysql_query("SELECT id, name FROM products_manufactures WHERE id='$db_products_manufacture_id'");
while ($db_products_manufactures = @mysql_fetch_array($db_lookup_products_manufactures)) {
$db_products_manufactures_id = $db_products_manufactures['id'];
$db_products_manufactures_name = $db_products_manufactures['name'];
echo("<option selected value='" . $db_products_manufactures_id . "'>" . $db_products_manufactures_name . "</option>");
}
$db_lookup_products_manufactures = @mysql_query("SELECT id, name FROM products_manufactures WHERE id != '$db_products_manufacture_id'");
while ($db_products_manufactures = @mysql_fetch_array($db_lookup_products_manufactures)) {
$db_products_manufactures_id = $db_products_manufactures['id'];
$db_products_manufactures_name = $db_products_manufactures['name'];
echo("<option value='" . $db_products_manufactures_id . "'>" . $db_products_manufactures_name . "</option>");
}
echo("</select>");
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Vendor:</font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='vendor'>");
if (!$db_products_vendor_id) {
echo("<option selected value='0'>None</option>");
} else {
echo("<option value='0'>None</option>");
}
$db_lookup_products_vendors = @mysql_query("SELECT id, name FROM products_vendors WHERE id='$db_products_vendor_id'");
while ($db_products_vendors = @mysql_fetch_array($db_lookup_products_vendors)) {
$db_products_vendors_id = $db_products_vendors['id'];
$db_products_vendors_name = $db_products_vendors['name'];
echo("<option selected value='" . $db_products_vendors_id . "'>" . $db_products_vendors_name . "</option>");
}
$db_lookup_products_vendors = @mysql_query("SELECT id, name FROM products_vendors WHERE id != '$db_products_vendors_id'");
while ($db_products_vendors = @mysql_fetch_array($db_lookup_products_vendors)) {
$db_products_vendors_id = $db_products_vendors['id'];
$db_products_vendors_name = $db_products_vendors['name'];
echo("<option value='" . $db_products_vendors_id . "'>" . $db_products_vendors_name . "</option>");
}
echo("</select>");
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Main Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image'></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<b>Search Engine Marketing:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
$db_products_meta_title = htmlspecialchars("$db_products_meta_title", ENT_QUOTES);
echo("<td>" . $font_body . "Meta Title:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='meta_title' value='$db_products_meta_title' size='40'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Description:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_description' cols='40' rows='5'>$db_products_meta_description</textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Keywords:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_keywords' cols='40' rows='5'>$db_products_meta_keywords</textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . " </font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Update'></font></td>");
echo("</tr>");
echo("</table>");
echo("</form>");
echo("<p><b>Images:</b><p>");
$db_select_count_products_images = "SELECT COUNT(id) FROM products_images WHERE products_id='$db_products_id'";
$db_count_products_images = mysql_query($db_select_count_products_images);
$db_count_products_images_rows = mysql_fetch_row($db_count_products_images);
$products_images_total_records = $db_count_products_images_rows[0];
$products_images_total_rows = ceil($products_images_total_records / 5);
echo("<table border='0' cellpadding='5' cellspacing='0'>");
$start_from = "0";
while ($products_images_total_rows > 0) {
echo("<tr>");
$db_lookup_products_images = @mysql_query("SELECT small_image_name FROM products_images WHERE products_id='$product_id' ORDER BY id ASC LIMIT $start_from, 5");
while ($db_products_images = @mysql_fetch_array($db_lookup_products_images)) {
$db_products_images_small_image_name = $db_products_images['small_image_name'];
echo("<td><img border='0' src='./shop_images/" . $db_products_images_small_image_name . "'></td>");
}
echo("</tr>");
echo("<tr>");
$db_lookup_products_images = @mysql_query("SELECT main_image, id FROM products_images WHERE products_id='$product_id' ORDER BY id ASC LIMIT $start_from, 5");
while ($db_products_images = @mysql_fetch_array($db_lookup_products_images)) {
$db_products_images_id = $db_products_images['id'];
$db_products_images_main_image = $db_products_images['main_image'];
echo("<td>" . $font_body);
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=view_products_images&product_images_id=$db_products_images_id'>" . $link_color . "View</font></a>]");
if ($db_products_images_main_image == "yes") {
echo("<br>(Main Image)");
} else {
echo("<br>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=delete_products_images&product_images_id=$db_products_images_id'>" . $link_color . "Delete</font></a>]");
}
echo ("</td>");
}
$products_images_total_rows = $products_images_total_rows - 1;
$start_from = $start_row + 5;
echo("</tr>");
}
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=new_products_images&product_id=$product_id'>" . $link_color . "Add Additional Images</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "products" and $request == "edit_product_submit" and $admin_rights) {
echo("<b>Products - Edit Product</b><p>");
$product_id = $_POST['product_id'];
$mode = $_POST['mode'];
$code = $_POST['code'];
$name = $_POST['name'];
$cost = $_POST['cost'];
$price = $_POST['price'];
$payment_type = $_POST['payment_type'];
$durration = $_POST['durration'];
$inventory = $_POST['inventory'];
$weight = $_POST['weight'];
$product_width = $_POST['product_width'];
$product_depth = $_POST['product_depth'];
$product_height = $_POST['product_height'];
$short_description = $_POST['short_description'];
$long_description = $_POST['long_description'];
$option_groups_id = $_POST['option_groups_id'];
$shipping_type = $_POST['shipping_type'];
$shipping_cost = $_POST['shipping_cost'];
$tax_type = $_POST['tax_type'];
$tax_cost = $_POST['tax_cost'];
$category_id = $_POST['category'];
$new_category = $_POST['new_category'];
$manufacture_id = $_POST['manufacture'];
$vendor_id = $_POST['vendor'];
$products_images_id = $_POST['products_images_id'];
$meta_title = $_POST['meta_title'];
$meta_description = $_POST['meta_description'];
$meta_keywords = $_POST['meta_keywords'];
if ($durration == "None") {
$sub_time = "None";
$sub_unit = "None";
}
if ($durration == "Day") {
$sub_time = "1";
$sub_unit = "D";
}
if ($durration == "Week") {
$sub_time = "1";
$sub_unit = "W";
}
if ($durration == "Month") {
$sub_time = "1";
$sub_unit = "M";
}
if ($durration == "3 Months") {
$sub_time = "3";
$sub_unit = "M";
}
if ($durration == "6 Months") {
$sub_time = "6";
$sub_unit = "M";
}
if ($durration == "Year") {
$sub_time = "1";
$sub_unit = "Y";
}
if ($durration == "2 Years") {
$sub_time = "2";
$sub_unit = "Y";
}
if ($durration == "3 Years") {
$sub_time = "3";
$sub_unit = "Y";
}
if ($durration == "4 Years") {
$sub_time = "4";
$sub_unit = "Y";
}
if ($durration == "5 Years") {
$sub_time = "5";
$sub_unit = "Y";
}
if ($payment_type == "Subscription") {
if ($sub_time == "None" and $sub_unit == "None") {
$payment_type = "One Time";
}
}
if (!$meta_title) {
if ($name) {
$db_themes_website_name = addslashes($db_themes_website_name);
$meta_title = "$db_themes_website_name - $name";
$meta_title = substr($meta_title, 0, 60);
} else {
$db_themes_website_name = addslashes($db_themes_website_name);
$meta_title = "$db_themes_website_name - $code";
$meta_title = substr($meta_title, 0, 60);
}
}
if (!$meta_description) {
if ($long_description) {
$meta_description = "$long_description";
$meta_description = substr($meta_description, 0, 140);
} else {
$meta_description = "$short_description";
$meta_description = substr($meta_description, 0, 140);
}
}
if (!$meta_keywords) {
if ($long_description) {
$meta_keywords = strtolower($long_description);
$common_words = array ('a','able','about','above','abroad','according','accordingly','across','actually','adj','after','afterwards','again','against','ago','ahead','ain\'t','all','allow','allows','almost','alone','along','alongside','already','also','although','always','am','amid','amidst','among','amongst','an','and','another','any','anybody','anyhow','anyone','anything','anyway','anyways','anywhere','apart','appear','appreciate','appropriate','are','aren\'t','around','as','a\'s','aside','ask','asking','associated','at','available','away','awfully','b','back','backward','backwards','be','became','because','become','becomes','becoming','been','before','beforehand','begin','behind','being','believe','below','beside','besides','best','better','between','beyond','both','brief','but','by','c','came','can','cannot','cant','can\'t','caption','cause','causes','certain','certainly','changes','clearly','c\'mon','co','co.','com','come','comes','concerning','consequently','consider','considering','contain','containing','contains','corresponding','could','couldn\'t','course','c\'s','currently','d','dare','daren\'t','definitely','described','despite','did','didn\'t','different','directly','do','does','doesn\'t','doing','done','don\'t','down','downwards','during','e','each','edu','eg','eight','eighty','either','else','elsewhere','end','ending','enough','entirely','especially','et','etc','even','ever','evermore','every','everybody','everyone','everything','everywhere','ex','exactly','example','except','f','fairly','far','farther','few','fewer','fifth','first','five','followed','following','follows','for','forever','former','formerly','forth','forward','found','four','from','further','furthermore','g','get','gets','getting','given','gives','go','goes','going','gone','got','gotten','greetings','h','had','hadn\'t','half','happens','hardly','has','hasn\'t','have','haven\'t','having','he','he\'d','he\'ll','hello','help','hence','her','here','hereafter','hereby','herein','here\'s','hereupon','hers','herself','he\'s','hi','him','himself','his','hither','hopefully','how','howbeit','however','hundred','i','i\'d','ie','if','ignored','i\'ll','i\'m','immediate','in','inasmuch','inc','inc.','indeed','indicate','indicated','indicates','inner','inside','insofar','instead','into','inward','is','isn\'t','it','it\'d','it\'ll','its','it\'s','itself','i\'ve','j','just','k','keep','keeps','kept','know','known','knows','l','last','lately','later','latter','latterly','least','less','lest','let','let\'s','like','liked','likely','likewise','little','look','looking','looks','lot','low','lower','ltd','m','made','mainly','make','makes','many','may','maybe','mayn\'t','me','mean','meantime','meanwhile','merely','might','mightn\'t','mine','minus','miss','more','moreover','most','mostly','mr','mrs','much','must','mustn\'t','my','myself','n','name','namely','nd','near','nearly','necessary','need','needn\'t','needs','neither','never','neverf','neverless','nevertheless','new','next','nine','ninety','no','nobody','non','none','nonetheless','noone','no-one','nor','normally','not','nothing','notwithstanding','novel','now','nowhere','o','obviously','of','off','often','oh','ok','okay','old','on','once','one','ones','one\'s','only','onto','opposite','or','other','others','otherwise','ought','oughtn\'t','our','ours','ourselves','out','outside','over','overall','own','p','particular','particularly','past','per','perhaps','placed','please','plus','possible','presumably','probably','provided','provides','q','que','quite','qv','r','rather','rd','re','really','reasonably','recent','recently','regarding','regardless','regards','relatively','respectively','right','round','s','said','same','saw','say','saying','says','second','secondly','see','seeing','seem','seemed','seeming','seems','seen','self','selves','sensible','sent','serious','seriously','seven','several','shall','shan\'t','she','she\'d','she\'ll','she\'s','should','shouldn\'t','since','six','so','some','somebody','someday','somehow','someone','something','sometime','sometimes','somewhat','somewhere','soon','sorry','specified','specify','specifying','still','sub','such','sup','sure','t','take','taken','taking','tell','tends','th','than','thank','thanks','thanx','that','that\'ll','thats','that\'s','that\'ve','the','their','theirs','them','themselves','then','thence','there','thereafter','thereby','there\'d','therefore','therein','there\'ll','there\'re','theres','there\'s','thereupon','there\'ve','these','they','they\'d','they\'ll','they\'re','they\'ve','thing','things','think','third','thirty','this','thorough','thoroughly','those','though','three','through','throughout','thru','thus','till','to','together','too','took','toward','towards','tried','tries','truly','try','trying','t\'s','twice','two','u','un','under','underneath','undoing','unfortunately','unless','unlike','unlikely','until','unto','up','upon','upwards','us','use','used','useful','uses','using','usually','v','value','various','versus','very','via','viz','vs','w','want','wants','was','wasn\'t','way','we','we\'d','welcome','well','we\'ll','went','were','we\'re','weren\'t','we\'ve','what','whatever','what\'ll','what\'s','what\'ve','when','whence','whenever','where','whereafter','whereas','whereby','wherein','where\'s','whereupon','wherever','whether','which','whichever','while','whilst','whither','who','who\'d','whoever','whole','who\'ll','whom','whomever','who\'s','whose','why','will','willing','wish','with','within','without','wonder','won\'t','would','wouldn\'t','x','y','yes','yet','you','you\'d','you\'ll','your','you\'re','yours','yourself','yourselves','you\'ve','z','zero',' \'');
$meta_keywords = preg_replace('/\b('.implode('|',$common_words).')\b/','',$meta_keywords);
$meta_keywords = preg_replace('/\s\s+/', ' ', $meta_keywords);
$meta_keywords = trim($meta_keywords);
$meta_keywords = substr($meta_keywords, 0, 140);
$meta_keywords = str_replace(" ", ", ", $meta_keywords);
$meta_keywords = str_replace("., ", ", ", $meta_keywords);
$meta_keywords = str_replace(".", "", $meta_keywords);
$meta_keywords = str_replace("? ", ", ", $meta_keywords);
$meta_keywords = str_replace("?", "", $meta_keywords);
$meta_keywords = str_replace("! ", ", ", $meta_keywords);
$meta_keywords = str_replace("!", "", $meta_keywords);
$meta_keywords = str_replace(",,", ",", $meta_keywords);
$meta_keywords = str_replace(", , ", ", ", $meta_keywords);
} else {
$meta_keywords = strtolower($short_description);
$common_words = array ('a','able','about','above','abroad','according','accordingly','across','actually','adj','after','afterwards','again','against','ago','ahead','ain\'t','all','allow','allows','almost','alone','along','alongside','already','also','although','always','am','amid','amidst','among','amongst','an','and','another','any','anybody','anyhow','anyone','anything','anyway','anyways','anywhere','apart','appear','appreciate','appropriate','are','aren\'t','around','as','a\'s','aside','ask','asking','associated','at','available','away','awfully','b','back','backward','backwards','be','became','because','become','becomes','becoming','been','before','beforehand','begin','behind','being','believe','below','beside','besides','best','better','between','beyond','both','brief','but','by','c','came','can','cannot','cant','can\'t','caption','cause','causes','certain','certainly','changes','clearly','c\'mon','co','co.','com','come','comes','concerning','consequently','consider','considering','contain','containing','contains','corresponding','could','couldn\'t','course','c\'s','currently','d','dare','daren\'t','definitely','described','despite','did','didn\'t','different','directly','do','does','doesn\'t','doing','done','don\'t','down','downwards','during','e','each','edu','eg','eight','eighty','either','else','elsewhere','end','ending','enough','entirely','especially','et','etc','even','ever','evermore','every','everybody','everyone','everything','everywhere','ex','exactly','example','except','f','fairly','far','farther','few','fewer','fifth','first','five','followed','following','follows','for','forever','former','formerly','forth','forward','found','four','from','further','furthermore','g','get','gets','getting','given','gives','go','goes','going','gone','got','gotten','greetings','h','had','hadn\'t','half','happens','hardly','has','hasn\'t','have','haven\'t','having','he','he\'d','he\'ll','hello','help','hence','her','here','hereafter','hereby','herein','here\'s','hereupon','hers','herself','he\'s','hi','him','himself','his','hither','hopefully','how','howbeit','however','hundred','i','i\'d','ie','if','ignored','i\'ll','i\'m','immediate','in','inasmuch','inc','inc.','indeed','indicate','indicated','indicates','inner','inside','insofar','instead','into','inward','is','isn\'t','it','it\'d','it\'ll','its','it\'s','itself','i\'ve','j','just','k','keep','keeps','kept','know','known','knows','l','last','lately','later','latter','latterly','least','less','lest','let','let\'s','like','liked','likely','likewise','little','look','looking','looks','lot','low','lower','ltd','m','made','mainly','make','makes','many','may','maybe','mayn\'t','me','mean','meantime','meanwhile','merely','might','mightn\'t','mine','minus','miss','more','moreover','most','mostly','mr','mrs','much','must','mustn\'t','my','myself','n','name','namely','nd','near','nearly','necessary','need','needn\'t','needs','neither','never','neverf','neverless','nevertheless','new','next','nine','ninety','no','nobody','non','none','nonetheless','noone','no-one','nor','normally','not','nothing','notwithstanding','novel','now','nowhere','o','obviously','of','off','often','oh','ok','okay','old','on','once','one','ones','one\'s','only','onto','opposite','or','other','others','otherwise','ought','oughtn\'t','our','ours','ourselves','out','outside','over','overall','own','p','particular','particularly','past','per','perhaps','placed','please','plus','possible','presumably','probably','provided','provides','q','que','quite','qv','r','rather','rd','re','really','reasonably','recent','recently','regarding','regardless','regards','relatively','respectively','right','round','s','said','same','saw','say','saying','says','second','secondly','see','seeing','seem','seemed','seeming','seems','seen','self','selves','sensible','sent','serious','seriously','seven','several','shall','shan\'t','she','she\'d','she\'ll','she\'s','should','shouldn\'t','since','six','so','some','somebody','someday','somehow','someone','something','sometime','sometimes','somewhat','somewhere','soon','sorry','specified','specify','specifying','still','sub','such','sup','sure','t','take','taken','taking','tell','tends','th','than','thank','thanks','thanx','that','that\'ll','thats','that\'s','that\'ve','the','their','theirs','them','themselves','then','thence','there','thereafter','thereby','there\'d','therefore','therein','there\'ll','there\'re','theres','there\'s','thereupon','there\'ve','these','they','they\'d','they\'ll','they\'re','they\'ve','thing','things','think','third','thirty','this','thorough','thoroughly','those','though','three','through','throughout','thru','thus','till','to','together','too','took','toward','towards','tried','tries','truly','try','trying','t\'s','twice','two','u','un','under','underneath','undoing','unfortunately','unless','unlike','unlikely','until','unto','up','upon','upwards','us','use','used','useful','uses','using','usually','v','value','various','versus','very','via','viz','vs','w','want','wants','was','wasn\'t','way','we','we\'d','welcome','well','we\'ll','went','were','we\'re','weren\'t','we\'ve','what','whatever','what\'ll','what\'s','what\'ve','when','whence','whenever','where','whereafter','whereas','whereby','wherein','where\'s','whereupon','wherever','whether','which','whichever','while','whilst','whither','who','who\'d','whoever','whole','who\'ll','whom','whomever','who\'s','whose','why','will','willing','wish','with','within','without','wonder','won\'t','would','wouldn\'t','x','y','yes','yet','you','you\'d','you\'ll','your','you\'re','yours','yourself','yourselves','you\'ve','z','zero',' \'');
$meta_keywords = preg_replace('/\b('.implode('|',$common_words).')\b/','',$meta_keywords);
$meta_keywords = preg_replace('/\s\s+/', ' ', $meta_keywords);
$meta_keywords = trim($meta_keywords);
$meta_keywords = substr($meta_keywords, 0, 140);
$meta_keywords = str_replace(" ", ", ", $meta_keywords);
$meta_keywords = str_replace("., ", ", ", $meta_keywords);
$meta_keywords = str_replace(".", "", $meta_keywords);
$meta_keywords = str_replace("? ", ", ", $meta_keywords);
$meta_keywords = str_replace("?", "", $meta_keywords);
$meta_keywords = str_replace("! ", ", ", $meta_keywords);
$meta_keywords = str_replace("!", "", $meta_keywords);
$meta_keywords = str_replace(",,", ",", $meta_keywords);
$meta_keywords = str_replace(", , ", ", ", $meta_keywords);
}
}
$uploadedfile = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
if ($uploadedfile) {
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
$src = imagecreatefromjpeg($uploadedfile);
}
if ($file_type == "image/gif") {
$src = imagecreatefromgif($uploadedfile);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
$src = imagecreatefrompng($uploadedfile);
}
list($width,$height)=getimagesize($uploadedfile);
if ($width>$height) {
if ($width <= "100") {
$small_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$small_width=100;
$small_height=($height/$width)*100;
$small_tmp=imagecreatetruecolor($small_width,$small_height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$small_width,$small_height,$width,$height);
}
if ($width <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=500;
$large_height=($height/$width)*500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
if ($width<$height) {
if ($height <= "100") {
$small_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$small_width=($width/$height)*100;
$small_height=100;
$small_tmp=imagecreatetruecolor($small_width,$small_height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$small_width,$small_height,$width,$height);
}
if ($height <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=($width/$height)*500;
$large_height=500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
if ($width == $height) {
if ($height <= "100" || $width <= "100") {
$small_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$small_width=($width/$height)*100;
$small_height=100;
$small_tmp=imagecreatetruecolor($small_width,$small_height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$small_width,$small_height,$width,$height);
}
if ($height <= "500" || $width <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=($width/$height)*500;
$large_height=500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
$small_file = "./shop_images/[S]". $_FILES['image']['name'];
$large_file = "./shop_images/[L]". $_FILES['image']['name'];
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
imagejpeg($small_tmp,$small_file,80);
imagejpeg($large_tmp,$large_file,80);
}
if ($file_type == "image/gif") {
imagegif($small_tmp,$small_file);
imagegif($large_tmp,$large_file);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
imagepng($small_tmp,$small_file);
imagepng($large_tmp,$large_file);
}
$small_file_path = addslashes($small_file);
$large_file_path = addslashes($large_file);
$small_file_name = "[S]" . $_FILES['image']['name'];
$large_file_name = "[L]" . $_FILES['image']['name'];
imagedestroy($src);
imagedestroy($small_tmp);
imagedestroy($large_tmp);
}
$short_description = ereg_replace("\r", '', $short_description);
$short_description = ereg_replace("\n\n", "<p>", $short_description);
$short_description = ereg_replace("\n", "<br>", $short_description);
$long_description = ereg_replace("\r", '', $long_description);
$long_description = ereg_replace("\n\n", "<p>", $long_description);
$long_description = ereg_replace("\n", "<br>", $long_description);
$short_description = str_replace(array('[b]', '[B]'), '<b>', $short_description);
$short_description = str_replace(array('[eb]', '[EB]'), '</b>', $short_description);
$short_description = str_replace(array('[u]', '[U]'), '<u>', $short_description);
$short_description = str_replace(array('[eu]', '[EU]'), '</u>', $short_description);
$short_description = str_replace(array('[i]', '[I]'), '<i>', $short_description);
$short_description = str_replace(array('[ei]', '[EI]'), '</i>', $short_description);
$long_description = str_replace(array('[b]', '[B]'), '<b>', $long_description);
$long_description = str_replace(array('[eb]', '[EB]'), '</b>', $long_description);
$long_description = str_replace(array('[u]', '[U]'), '<u>', $long_description);
$long_description = str_replace(array('[eu]', '[EU]'), '</u>', $long_description);
$long_description = str_replace(array('[i]', '[I]'), '<i>', $long_description);
$long_description = str_replace(array('[ei]', '[EI]'), '</i>', $long_description);
if ($new_category) {
$db_themes_website_name = addslashes($db_themes_website_name);
$category_meta_title = "$db_themes_website_name - $new_category";
$category_meta_title = substr($category_meta_title, 0, 60);
$category_meta_description = "$new_category products from $db_themes_website_name.";
$category_meta_keywords = strtolower($new_category);
$category_meta_keywords = preg_replace('/\s\s+/', ' ', $category_meta_keywords);
$category_meta_keywords = trim($category_meta_keywords);
$category_meta_keywords = substr($category_meta_keywords, 0, 140);
$category_meta_keywords = str_replace(" ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace("., ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace(".", "", $category_meta_keywords);
$category_meta_keywords = str_replace("? ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace("?", "", $category_meta_keywords);
$category_meta_keywords = str_replace("! ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace("!", "", $category_meta_keywords);
$category_meta_keywords = str_replace(",,", ",", $category_meta_keywords);
$category_meta_keywords = str_replace(", , ", ", ", $category_meta_keywords);
$single_category_meta_keywords = $category_meta_keywords;
$category_meta_keywords .= ", $db_themes_website_name";
$category_meta_keywords .= ", $meta_keywords";
$category_meta_keywords = substr($category_meta_keywords, 0, 140);
$category_meta_keywords = str_replace(" ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace("., ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace(".", "", $category_meta_keywords);
$category_meta_keywords = str_replace("? ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace("?", "", $category_meta_keywords);
$category_meta_keywords = str_replace("! ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace("!", "", $category_meta_keywords);
$category_meta_keywords = str_replace(",,", ",", $category_meta_keywords);
$category_meta_keywords = str_replace(", , ", ", ", $category_meta_keywords);
$category_meta_keywords = str_replace(" ,", "", $category_meta_keywords);
$category_meta_keywords = str_replace(", $single_category_meta_keywords", "", $category_meta_keywords);
$db_insert_products_categories = "INSERT INTO products_categories SET " .
"name = '$new_category', " .
"meta_title = '$category_meta_title', " .
"meta_description = '$category_meta_description', " .
"meta_keywords = '$category_meta_keywords'";
if (@mysql_query($db_insert_products_categories)) {
echo("Product category creation successful.<p>");
} else {
echo("Product category creation error.<p>");
}
$db_lookup_products_categories = @mysql_query("SELECT name FROM products_categories WHERE name='$new_category'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_name = $db_products_categories['name'];
if ($db_products_categories_name) {
echo("Product category already exists in the database, duplicates are not allowed.");
} else {
$db_lookup_menu_categories = @mysql_query("SELECT id FROM menu_categories WHERE name='Shop'");
$db_menu_categories = @mysql_fetch_array($db_lookup_menu_categories);
$db_menu_categories_id = $db_menu_categories['id'];
if (!$db_menu_categories_id) {
$db_insert_menu_categories = "INSERT INTO menu_categories SET " .
"name = 'Shop'";
if (@mysql_query($db_insert_menu_categories)) {
echo("Menu categories insert successful.<p>");
} else {
echo("Menu categories insert failed.<p>");
}
}
$db_lookup_products_categories = @mysql_query("SELECT id FROM products_categories WHERE name='$new_category'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_id = $db_products_categories['id'];
$db_lookup_menu = @mysql_query("SELECT id FROM menu WHERE request='$db_products_categories_id'");
$db_menu = @mysql_fetch_array($db_lookup_menu);
$db_menu_id = $db_menu['id'];
if (!$db_menu_id) {
$db_lookup_menu_categories = @mysql_query("SELECT id FROM menu_categories WHERE name='Shop'");
$db_menu_categories = @mysql_fetch_array($db_lookup_menu_categories);
$db_menu_categories_id = $db_menu_categories['id'];
$db_insert_menu = "INSERT INTO menu SET " .
"menu_categories_id = '$db_menu_categories_id', " .
"name = '$new_category', " .
"include_file = 'catalog.inc', " .
"page = 'view_category', " .
"request = '$db_products_categories_id'";
if (@mysql_query($db_insert_menu)) {
echo("Menu insert successful.<p>");
} else {
echo("Menu insert failed.<p>");
}
}
$db_lookup_products_categories = @mysql_query("SELECT id FROM products_categories WHERE name='$new_category'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_id = $db_products_categories['id'];
}
}
if ($db_products_categories_id) {
$db_update_products = "UPDATE products SET " .
"mode = '$mode', " .
"code = '$code', " .
"name = '$name', " .
"cost = '$cost', " .
"price = '$price', " .
"payment_type = '$payment_type', " .
"sub_time = '$sub_time', " .
"sub_unit = '$sub_unit', " .
"inventory = '$inventory', " .
"weight = '$weight', " .
"width = '$product_width', " .
"depth = '$product_depth', " .
"height = '$product_height', " .
"short_description = '$short_description', " .
"long_description = '$long_description', " .
"option_groups_id = '$option_groups_id', " .
"shipping_type = '$shipping_type', " .
"shipping_cost = '$shipping_cost', " .
"tax_type = '$tax_type', " .
"tax_cost = '$tax_cost', " .
"category_id = '$db_products_categories_id', " .
"manufacture_id = '$manufacture_id', " .
"vendor_id = '$vendor_id', " .
"meta_title = '$meta_title', " .
"meta_description = '$meta_description', " .
"meta_keywords = '$meta_keywords'" .
"WHERE id = '$product_id'";
} else {
$db_update_products = "UPDATE products SET " .
"mode = '$mode', " .
"code = '$code', " .
"name = '$name', " .
"cost = '$cost', " .
"price = '$price', " .
"payment_type = '$payment_type', " .
"sub_time = '$sub_time', " .
"sub_unit = '$sub_unit', " .
"inventory = '$inventory', " .
"weight = '$weight', " .
"width = '$product_width', " .
"depth = '$product_depth', " .
"height = '$product_height', " .
"short_description = '$short_description', " .
"long_description = '$long_description', " .
"option_groups_id = '$option_groups_id', " .
"shipping_type = '$shipping_type', " .
"shipping_cost = '$shipping_cost', " .
"tax_type = '$tax_type', " .
"tax_cost = '$tax_cost', " .
"category_id = '$category_id', " .
"manufacture_id = '$manufacture_id', " .
"vendor_id = '$vendor_id', " .
"meta_title = '$meta_title', " .
"meta_description = '$meta_description', " .
"meta_keywords = '$meta_keywords'" .
"WHERE id = '$product_id'";
}
if (@mysql_query($db_update_products)) {
if ($uploadedfile) {
$db_lookup_products_images = @mysql_query("SELECT small_image_path, large_image_path FROM products_images WHERE products_id='$product_id' and main_image='yes'");
$db_products_images = @mysql_fetch_array($db_lookup_products_images);
$db_products_images_small_image_path = $db_products_images['large_small_path'];
$db_products_images_large_image_path = $db_products_images['large_image_path'];
if ($db_products_images_small_image_path) {
unlink("$db_products_images_small_image_path");
}
if ($db_products_images_large_image_path) {
unlink("$db_products_images_large_image_path");
}
$db_update_products_images = "UPDATE products_images SET " .
"small_image_path = '$small_file_path', " .
"large_image_path = '$large_file_path', " .
"small_image_name = '$small_file_name', " .
"large_image_name = '$large_file_name'" .
"WHERE id = '$product_id' and main_image = 'yes'";
if (@mysql_query($db_update_products_images)) {
echo ("The product images have been updated.<p>");
} else {
echo ("Error updating product images.<p>");
}
}
echo("The product has been updated.");
$db_lookup_themes = @mysql_query("SELECT website_name FROM themes WHERE on_off='on'");
$db_themes = @mysql_fetch_array($db_lookup_themes);
$db_themes_website_name = $db_themes['website_name'];
$file = "shop_feed.xml";
$method = fopen($file, 'w');
$data = "<?xml version=\"1.0\"?>\r";
fwrite($method, $data);
$data = "<rss version=\"2.0\">\r";
fwrite($method, $data);
$data = "<channel>\r";
fwrite($method, $data);
$db_themes_website_name = str_replace("\\", "", $db_themes_website_name);
$db_themes_website_name = htmlspecialchars("$db_themes_website_name", ENT_QUOTES);
$data = "\r<title>$db_themes_website_name Shop Feed</title>\r";
fwrite($method, $data);
$data = "<link>http://" . $_SERVER['HTTP_HOST'] . "" . $_SERVER['PHP_SELF'] . "</link>\r";
fwrite($method, $data);
$data = "<description>Latest Products</description>\r";
fwrite($method, $data);
$data = "<lastBuildDate>$rss_date</lastBuildDate>\r";
fwrite($method, $data);
$data = "<language>en-us</language>\r\r";
fwrite($method, $data);
$db_lookup_products = @mysql_query("SELECT id, rss_date, code, name, price, width, depth, height, short_description, long_description, category_id FROM products WHERE mode='On' and inventory >= '1' ORDER BY id DESC LIMIT 0, 20");
while ($db_products = @mysql_fetch_array($db_lookup_products)) {
$db_products_id = $db_products['id'];
$db_products_rss_date = $db_products['rss_date'];
$db_products_code = $db_products['code'];
$db_products_name = $db_products['name'];
$db_products_price = $db_products['price'];
$db_products_width = $db_products['width'];
$db_products_depth = $db_products['depth'];
$db_products_height = $db_products['height'];
$db_products_short_description = $db_products['short_description'];
$db_products_long_description = $db_products['long_description'];
$db_products_category_id = $db_products['category_id'];
$db_products_short_description = str_replace("\r", '<br>', $db_products_short_description);
$db_products_short_description = str_replace("\n", "<p>", $db_products_short_description);
$db_products_short_description = str_replace("<br><p><br><p>", "<p>", $db_products_short_description);
$db_products_short_description = str_replace("<br><p>", "<br>", $db_products_short_description);
$db_products_short_description = str_replace("\\", "", $db_products_short_description);
$db_products_long_description = str_replace("\r", '<br>', $db_products_long_description);
$db_products_long_description = str_replace("\n", "<p>", $db_products_long_description);
$db_products_long_description = str_replace("<br><p><br><p>", "<p>", $db_products_long_description);
$db_products_long_description = str_replace("<br><p>", "<br>", $db_products_long_description);
$db_products_long_description = str_replace("\\", "", $db_products_long_description);
$db_lookup_product_categories = @mysql_query("SELECT name FROM products_categories WHERE id='$db_products_category_id'");
$db_product_categories = @mysql_fetch_array($db_lookup_product_categories);
$db_product_categories_name = $db_product_categories['name'];
$data = "<item>\r";
fwrite($method, $data);
$db_products_name = str_replace("\\", "", $db_products_name);
$db_products_code = str_replace("\\", "", $db_products_code);
$db_products_name = htmlspecialchars("$db_products_name", ENT_QUOTES);
$db_products_code = htmlspecialchars("$db_products_code", ENT_QUOTES);
if ($name) {
$data = "<title>$db_products_name</title>\r";
} else {
$data = "<title>$db_products_code</title>\r";
}
fwrite($method, $data);
$data = "<link>http://" . $_SERVER['HTTP_HOST'] . "" . $_SERVER['PHP_SELF'] . "?page=view_detail&request=$db_products_id</link>\r";
fwrite($method, $data);
$data = "<guid>http://" . $_SERVER['HTTP_HOST'] . "" . $_SERVER['PHP_SELF'] . "?page=view_detail&request=$db_products_id</guid>\r";
fwrite($method, $data);
$data = "<description><![CDATA[";
fwrite($method, $data);
$db_lookup_products_images = @mysql_query("SELECT small_image_name FROM products_images WHERE products_id='$db_products_id' and main_image='yes'");
$db_products_images = @mysql_fetch_array($db_lookup_products_images);
$db_products_images_small_image_name = $db_products_images['small_image_name'];
$file = "http://" . $_SERVER['HTTP_HOST'] . "" . $_SERVER['PHP_SELF'];
$find = '/';
$after_find = substr(strrchr($file, $find), 1);
$strlen_str = strlen($after_find);
$result = substr($file, 0, -$strlen_str);
if ($db_products_images_small_image_name) {
if ($db_products_long_description) {
$data = "<img src='" . $result . "shop_images/$db_products_images_small_image_name' border='0'><p> $db_products_long_description";
} else {
$data = "<img src='" . $result . "shop_images/$db_products_images_small_image_name' border='0'><p> $db_products_short_description";
}
} else {
if ($db_products_long_description) {
$data = "$db_products_long_description";
} else {
$data = "$db_products_short_description";
}
}
if ($db_products_width or $db_products_depth or $db_products_height) {
$data .= "<br>";
}
if ($db_products_height) {
$data .= "Height: $db_products_height ";
}
if ($db_products_width) {
$data .= "Width: $db_products_width ";
}
if ($db_products_depth) {
$data .= "Depth: $db_products_depth ";
}
if ($db_products_price) {
$data .= "<br>Price: \$$db_products_price";
}
fwrite($method, $data);
$data = "]]></description>\r";
fwrite($method, $data);
if ($db_product_categories_name) {
$data = "<category>$db_product_categories_name</category>\r";
fwrite($method, $data);
}
$data = "<pubDate>$db_products_rss_date</pubDate>\r";
fwrite($method, $data);
$data = "</item>\r\r";
fwrite($method, $data);
}
$data = "</channel>\r";
fwrite($method, $data);
$data = "</rss>";
fwrite($method, $data);
fclose($method);
} else {
echo("Error updating the product.");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "products" and $request == "delete_product" and $admin_rights == "Admin") {
echo("<b>Products - Delete Product</b><p>");
$product_id = $_GET['product_id'];
$db_lookup_products_images = @mysql_query("SELECT small_image_name FROM products_images WHERE products_id='$product_id'");
$db_products_images = @mysql_fetch_array($db_lookup_products_images);
$db_products_images_small_image_name = $db_products_images['small_image_name'];
$db_lookup_products = @mysql_query("SELECT id, code, name FROM products WHERE id='$product_id'");
$db_products = @mysql_fetch_array($db_lookup_products);
$db_products_id = $db_products['id'];
$db_products_code = $db_products['code'];
$db_products_name = $db_products['name'];
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . " </td>");
echo("<td>" . $font_body . "<img border='0' src='./shop_images/" . $db_products_images_small_image_name . "'></td>");
echo("</tr>");
if ($db_products_code) {
echo("<tr>");
echo("<td>" . $font_body . "Code:</td>");
echo("<td>" . $font_body . $db_products_code . "</td>");
echo("</tr>");
}
if ($db_products_name) {
echo("<tr>");
echo("<td>" . $font_body . "Name:</td>");
echo("<td>" . $font_body . "" . $db_products_name . "</td>");
echo("</tr>");
}
echo("</table>");
echo("<p>");
echo("Are you sure you want to delete this product?<p>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=delete_product_submit&product_id=$db_products_id'>" . $link_color . "Yes</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=delete_product_cancel&product_id=$db_products_id'>" . $link_color . "No</font></a>] ");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "products" and $request == "delete_product_submit" and $admin_rights == "Admin") {
echo("<b>Products - Delete Product</b><p>");
$product_id = $_GET['product_id'];
$db_lookup_products_images = @mysql_query("SELECT small_image_path, large_image_path FROM products_images WHERE products_id='$product_id'");
while ($db_products_images = @mysql_fetch_array($db_lookup_products_images)) {
$db_products_images_small_image_path = $db_products_images['small_image_path'];
$db_products_images_large_image_path = $db_products_images['large_image_path'];
unlink("$db_products_images_small_image_path");
unlink("$db_products_images_large_image_path");
}
$db_delete_products = @mysql_query("DELETE FROM products WHERE id='$product_id'");
$db_delete_products_images = @mysql_query("DELETE FROM products_images WHERE products_id='$product_id'");
$db_delete_menu = @mysql_query("DELETE FROM menu WHERE page='view_detail' and request='$db_products_id'");
if ($db_delete_products and $db_delete_products_images and $db_delete_menu) {
echo("The product has been deleted from the database.");
} else {
echo("Error deleting product.");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "products" and $request == "delete_product_cancel" and $admin_rights == "Admin") {
echo("<b>Products - Delete Product</b><p>");
$product_id = $_GET['product_id'];
$db_lookup_products = @mysql_query("SELECT id, code, name FROM products WHERE id='$product_id'");
$db_products = @mysql_fetch_array($db_lookup_products);
$db_products_id = $db_products['id'];
$db_products_code = $db_products['code'];
$db_products_name = $db_products['name'];
echo("The product has not been deleted from the database.");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "products" and $request == "new_products_images" and $admin_rights) {
echo("<b>Products - Add Additional Images</b><p>");
$product_id = $_GET['product_id'];
echo("<form enctype='multipart/form-data' action='" . $_SERVER['PHP_SELF'] . "?page=products&request=new_products_images_submit' method='post'>");
echo("<input type='hidden' name='product_id' value='$product_id'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_1'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_11'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_2'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_12'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_3'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_13'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_4'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_14'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_5'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_15'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_6'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_16'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_7'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_17'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_8'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_18'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_9'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_19'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_10'></font></td>");
echo("<td>" . $font_body . "Image:</font></td>");
echo("<td>" . $font_body . "<input type='file' name ='image_20'></font></td>");
echo("</tr>");
echo("</table>");
echo("<p><input type='submit' name ='submit' value ='Submit'>");
echo("</form>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=view_product&product_id=$product_id'>" . $link_color . "View Product</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "products" and $request == "new_products_images_submit" and $admin_rights) {
echo("<b>Products - Add Additional Images</b><p>");
$product_id = $_POST['product_id'];
$uploadedfile_1 = $_FILES['image_1']['tmp_name'];
$uploadedfile_2 = $_FILES['image_2']['tmp_name'];
$uploadedfile_3 = $_FILES['image_3']['tmp_name'];
$uploadedfile_4 = $_FILES['image_4']['tmp_name'];
$uploadedfile_5 = $_FILES['image_5']['tmp_name'];
$uploadedfile_6 = $_FILES['image_6']['tmp_name'];
$uploadedfile_7 = $_FILES['image_7']['tmp_name'];
$uploadedfile_8 = $_FILES['image_8']['tmp_name'];
$uploadedfile_9 = $_FILES['image_9']['tmp_name'];
$uploadedfile_10 = $_FILES['image_10']['tmp_name'];
$uploadedfile_11 = $_FILES['image_11']['tmp_name'];
$uploadedfile_12 = $_FILES['image_12']['tmp_name'];
$uploadedfile_13 = $_FILES['image_13']['tmp_name'];
$uploadedfile_14 = $_FILES['image_14']['tmp_name'];
$uploadedfile_15 = $_FILES['image_15']['tmp_name'];
$uploadedfile_16 = $_FILES['image_16']['tmp_name'];
$uploadedfile_17 = $_FILES['image_17']['tmp_name'];
$uploadedfile_18 = $_FILES['image_18']['tmp_name'];
$uploadedfile_19 = $_FILES['image_19']['tmp_name'];
$uploadedfile_20 = $_FILES['image_20']['tmp_name'];
if ($uploadedfile_1) {
$image_count = 1;
}
if ($uploadedfile_2) {
$image_count = 2;
}
if ($uploadedfile_3) {
$image_count = 3;
}
if ($uploadedfile_4) {
$image_count = 4;
}
if ($uploadedfile_5) {
$image_count = 5;
}
if ($uploadedfile_6) {
$image_count = 6;
}
if ($uploadedfile_7) {
$image_count = 7;
}
if ($uploadedfile_8) {
$image_count = 8;
}
if ($uploadedfile_9) {
$image_count = 9;
}
if ($uploadedfile_10) {
$image_count = 10;
}
if ($uploadedfile_11) {
$image_count = 11;
}
if ($uploadedfile_12) {
$image_count = 12;
}
if ($uploadedfile_13) {
$image_count = 13;
}
if ($uploadedfile_14) {
$image_count = 14;
}
if ($uploadedfile_15) {
$image_count = 15;
}
if ($uploadedfile_16) {
$image_count = 16;
}
if ($uploadedfile_17) {
$image_count = 17;
}
if ($uploadedfile_18) {
$image_count = 18;
}
if ($uploadedfile_19) {
$image_count = 19;
}
if ($uploadedfile_20) {
$image_count = 20;
}
while ($image_count > 0) {
$uploadedfile = $_FILES["image_" . $image_count]['tmp_name'];
$file_type = $_FILES["image_" . $image_count]['type'];
$file_name = $_FILES["image_" . $image_count]['name'];
if ($file_name) {
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
$src = imagecreatefromjpeg($uploadedfile);
}
if ($file_type == "image/gif") {
$src = imagecreatefromgif($uploadedfile);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
$src = imagecreatefrompng($uploadedfile);
}
list($width,$height)=getimagesize($uploadedfile);
if ($width>$height) {
if ($width <= "100") {
$small_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$small_width=100;
$small_height=($height/$width)*100;
$small_tmp=imagecreatetruecolor($small_width,$small_height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$small_width,$small_height,$width,$height);
}
if ($width <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=500;
$large_height=($height/$width)*500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
if ($width<$height) {
if ($height <= "100") {
$small_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$small_width=($width/$height)*100;
$small_height=100;
$small_tmp=imagecreatetruecolor($small_width,$small_height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$small_width,$small_height,$width,$height);
}
if ($height <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=($width/$height)*500;
$large_height=500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
if ($width == $height) {
if ($height <= "100" || $width <= "100") {
$small_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$small_width=($width/$height)*100;
$small_height=100;
$small_tmp=imagecreatetruecolor($small_width,$small_height);
imagecopyresampled($small_tmp,$src,0,0,0,0,$small_width,$small_height,$width,$height);
}
if ($height <= "500" || $width <= "500") {
$large_tmp=imagecreatetruecolor($width,$height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$width,$height,$width,$height);
} else {
$large_width=($width/$height)*500;
$large_height=500;
$large_tmp=imagecreatetruecolor($large_width,$large_height);
imagecopyresampled($large_tmp,$src,0,0,0,0,$large_width,$large_height,$width,$height);
}
}
$small_file = "./shop_images/[S]". $file_name;
$large_file = "./shop_images/[L]". $file_name;
if ($file_type == "image/pjpeg" || $file_type == "image/jpeg") {
imagejpeg($small_tmp,$small_file,80);
imagejpeg($large_tmp,$large_file,80);
}
if ($file_type == "image/gif") {
imagegif($small_tmp,$small_file);
imagegif($large_tmp,$large_file);
}
if ($file_type == "image/x-png" || $file_type == "image/png") {
imagepng($small_tmp,$small_file);
imagepng($large_tmp,$large_file);
}
$small_file_path = addslashes($small_file);
$large_file_path = addslashes($large_file);
$small_file_name = "[S]" . $file_name;
$large_file_name = "[L]" . $file_name;
imagedestroy($src);
imagedestroy($small_tmp);
imagedestroy($large_tmp);
$db_insert_products_images = "INSERT INTO products_images SET " .
"products_id = '$product_id', " .
"small_image_path = '$small_file_path', " .
"large_image_path = '$large_file_path', " .
"small_image_name = '$small_file_name', " .
"large_image_name = '$large_file_name'";
@mysql_query($db_insert_products_images);
}
if ($image_count == "1") {
echo "Product images were successfully uploaded.";
}
$image_count = $image_count - 1;
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=view_product&product_id=$product_id'>" . $link_color . "View Product</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "products" and $request == "view_products_images" and $admin_rights) {
echo("<b>Products - View Additional Images</b><p>");
$product_id = $_GET['product_id'];
$product_images_id = $_GET['product_images_id'];
if ($product_id) {
$db_lookup_products = @mysql_query("SELECT large_image_name FROM products WHERE id='$product_id'");
$db_products = @mysql_fetch_array($db_lookup_products);
$db_products_large_image_name = $db_products['large_image_name'];
echo("<img border='0' src='./shop_images/" . $db_products_large_image_name . "'>");
echo("<p>" . $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=view_product&product_id=$product_id'>" . $link_color . "View Product</font></a>]");
}
if ($product_images_id) {
$db_lookup_products_images = @mysql_query("SELECT products_id, large_image_name FROM products_images WHERE id='$product_images_id'");
$db_products_images = @mysql_fetch_array($db_lookup_products_images);
$db_products_images_products_id = $db_products_images['products_id'];
$db_products_images_large_image_name = $db_products_images['large_image_name'];
echo("<img border='0' src='./shop_images/" . $db_products_images_large_image_name . "'>");
echo("<p>" . $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=view_product&product_id=$db_products_images_products_id'>" . $link_color . "View Product</font></a>]");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "products" and $request == "delete_products_images" and $admin_rights) {
echo("<b>Products - Delete Additional Images</b><p>");
$product_images_id = $_GET['product_images_id'];
$db_lookup_products_images = @mysql_query("SELECT products_id, large_image_name FROM products_images WHERE id='$product_images_id'");
$db_products_images = @mysql_fetch_array($db_lookup_products_images);
$db_products_images_products_id = $db_products_images['products_id'];
$db_products_images_large_image_name = $db_products_images['large_image_name'];
echo("<img border='0' src='./shop_images/" . $db_products_images_large_image_name . "'>");
echo("<p>Are you sure you want to delete this product image?<p>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=delete_products_images_submit&product_id=$db_products_images_products_id&product_images_id=$product_images_id'>" . $link_color . "Yes</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=delete_products_images_cancel&product_id=$db_products_images_products_id&product_images_id=$product_images_id'>" . $link_color . "No</font></a>] ");
echo("<p>" . $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=view_product&product_id=$db_products_images_products_id'>" . $link_color . "View Product</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "products" and $request == "delete_products_images_submit" and $admin_rights) {
echo("<b>Products - Delete Additional Images</b><p>");
$product_id = $_GET['product_id'];
$product_images_id = $_GET['product_images_id'];
$db_lookup_products_images = @mysql_query("SELECT small_image_path, large_image_path FROM products_images WHERE id='$product_images_id'");
$db_products_images = @mysql_fetch_array($db_lookup_products_images);
$db_products_images_small_image_path = $db_products_images['small_image_path'];
$db_products_images_large_image_path = $db_products_images['large_image_path'];
$db_delete_products_images = @mysql_query("DELETE FROM products_images WHERE id='$product_images_id'");
$db_delete_products_images_small_image = unlink("$db_products_images_small_image_path");
$db_delete_products_images_large_image = unlink("$db_products_images_large_image_path");
if ($db_delete_products_images and $db_delete_products_images_small_image and $db_delete_products_images_large_image) {
echo("The product image has been deleted from the database.");
} else {
echo("Error deleting product image.");
}
echo("<p>" . $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=view_product&product_id=$product_id'>" . $link_color . "View Product</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]<p>");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "products" and $request == "delete_products_images_cancel" and $admin_rights) {
echo("<b>Products - Delete Additional Images</b><p>");
$product_id = $_GET['product_id'];
$product_images_id = $_GET['product_images_id'];
echo("The product image has not been deleted from the database.");
echo("<p>" . $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=products&request=view_product&product_id=$product_id'>" . $link_color . "View Product</font></a>]");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=products'>" . $link_color . "Products</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_options" and !$request and $admin_rights) {
echo("<b>Product Options</b><p>");
$db_lookup_products_option_groups = @mysql_query("SELECT id FROM products_option_groups");
$db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups);
$db_products_option_groups_id = $db_products_option_groups['id'];
if ($db_products_option_groups) {
// ==================== START OF PAGE # HEADER ====================
if ($_POST["results_per_page"]) {
$results_per_page = $_POST["results_per_page"];
$_SESSION['results_per_page'] = $results_per_page;
} else {
if (!$_SESSION['results_per_page']) {
$results_per_page=10;
}
}
if ($_GET["start_page"]) {
$start_page = $_GET["start_page"];
} else {
$start_page=1;
}
$start_from = ($start_page-1) * $results_per_page;
echo("<p>");
echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
echo("<tr>");
echo("<td align='left' width='50%'>" . $font_body);
echo "<b>Pages: ";
$db_count_products = @mysql_query("SELECT COUNT(id) FROM products_option_groups");
$row = @mysql_fetch_row($db_count_products);
$total_records = $row[0];
$total_start_pages = ceil($total_records / $results_per_page);
for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
if ($page_number == $start_page) {
echo "$page_number ";
} else {
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a> ";
}
}
echo "</b>";
echo("</td>");
echo("<td align='left' width='50%'>" . $font_body);
echo("<table border='0' cellpadding='2' cellspacing='0'>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_options&start_page=".$start_page."' method='post'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='results_per_page'>");
if ($results_per_page == 10) {
echo("<option value='10' selected>10</option>");
} else {
echo("<option value='10'>10</option>");
}
if ($results_per_page == 25) {
echo("<option value='25' selected>25</option>");
} else {
echo("<option value='25'>25</option>");
}
if ($results_per_page == 50) {
echo("<option value='50' selected>50</option>");
} else {
echo("<option value='50'>50</option>");
}
if ($results_per_page == 100) {
echo("<option value='100' selected>100</option>");
} else {
echo("<option value='100'>100</option>");
}
if ($results_per_page == 99999) {
echo("<option value='99999' selected>All</option>");
} else {
echo("<option value='99999'>All</option>");
}
echo("</select>");
echo("</font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
echo("</tr>");
echo("</form>");
echo("</table>");
echo("</td>");
echo("</tr>");
echo("</table>");
// ==================== END OF PAGE # HEADER ====================
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=new_group'>" . $link_color . "New</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=search_groups'>" . $link_color . "Search</font></a>]<p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Option Groups</b></td>");
echo("<td>" . $font_body . "<b>Actions</b></td>");
echo("</tr>");
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups ORDER BY name ASC LIMIT $start_from, $results_per_page");
while ($db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups)) {
$db_products_option_groups_id = $db_products_option_groups['id'];
$db_products_option_groups_name = $db_products_option_groups['name'];
echo("<tr>");
echo("<td>" . $font_body . $db_products_option_groups_name . "</td>");
echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=view_group&group_id=" . $db_products_option_groups_id . "'>" . $link_color . "View</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=edit_group&group_id=" . $db_products_option_groups_id . "'>" . $link_color . "Edit</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=delete_group&group_id=" . $db_products_option_groups_id . "'>" . $link_color . "Delete</font></a>]</td>");
echo("</tr>");
}
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=new_group'>" . $link_color . "New</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=search_groups'>" . $link_color . "Search</font></a>]<p>");
// ==================== START OF PAGE # FOOTER ====================
echo("<p>");
echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
echo("<tr>");
echo("<td align='left' width='50%'>" . $font_body);
echo "<b>Pages: ";
$db_count_products = @mysql_query("SELECT COUNT(id) FROM products_option_groups");
$row = @mysql_fetch_row($db_count_products);
$total_records = $row[0];
$total_start_pages = ceil($total_records / $results_per_page);
for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
if ($page_number == $start_page) {
echo "$page_number ";
} else {
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a> ";
}
}
echo "</b>";
echo("</td>");
echo("<td align='left' width='50%'>" . $font_body);
echo("<table border='0' cellpadding='2' cellspacing='0'>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_options&start_page=".$start_page."' method='post'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='results_per_page'>");
if ($results_per_page == 10) {
echo("<option value='10' selected>10</option>");
} else {
echo("<option value='10'>10</option>");
}
if ($results_per_page == 25) {
echo("<option value='25' selected>25</option>");
} else {
echo("<option value='25'>25</option>");
}
if ($results_per_page == 50) {
echo("<option value='50' selected>50</option>");
} else {
echo("<option value='50'>50</option>");
}
if ($results_per_page == 100) {
echo("<option value='100' selected>100</option>");
} else {
echo("<option value='100'>100</option>");
}
if ($results_per_page == 99999) {
echo("<option value='99999' selected>All</option>");
} else {
echo("<option value='99999'>All</option>");
}
echo("</select>");
echo("</font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
echo("</tr>");
echo("</form>");
echo("</table>");
echo("</td>");
echo("</tr>");
echo("</table>");
// ==================== END OF PAGE # FOOTER ====================
} else {
echo("No product option groups were found in the database.");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=new_group'>" . $link_color . "New</font></a>]<p>");
}
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "new_group" and $admin_rights) {
echo("<b>Product Options - New Group</b><p>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=new_group_submit' method='post'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Group name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='name'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . " </font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Submit'></font></td>");
echo("</tr>");
echo("</table>");
echo("</form>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "new_group_submit" and $admin_rights) {
echo("<b>Product Options - New Group</b><p>");
$name = $_POST['name'];
$db_insert_products_option_groups = "INSERT INTO products_option_groups SET " .
"name = '$name'";
if (@mysql_query($db_insert_products_option_groups)) {
echo("The product option group has been added to the database.");
} else {
echo("Error adding product option group to the database.");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "view_group" and $admin_rights) {
echo("<b>Product Options - View Group</b><p>");
$group_id = $_GET['group_id'];
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups WHERE id='$group_id'");
$db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups);
$db_products_option_groups_id = $db_products_option_groups['id'];
$db_products_option_groups_name = $db_products_option_groups['name'];
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Group Name:</b></td>");
echo("<td>" . $font_body . $db_products_option_groups_name . "</td>");
echo("</tr>");
echo("</table>");
echo("<p>");
$db_lookup_product_options = @mysql_query("SELECT id, name, plus_minus, price_difference FROM products_options WHERE group_id='$db_products_option_groups_id'");
$db_product_options = @mysql_fetch_array($db_lookup_product_options);
$db_product_options_id = $db_product_options['id'];
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=new_option&group_id=$db_products_option_groups_id'>" . $link_color . "New</font></a>] <p>");
if ($db_product_options_id) {
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Option Name</b></td>");
echo("<td>" . $font_body . "<b>+/-</b></td>");
echo("<td>" . $font_body . "<b>Price Diff.</b></td>");
echo("<td>" . $font_body . "<b>Actions</b></td>");
echo("</tr>");
$db_lookup_product_options = @mysql_query("SELECT id, name, plus_minus, price_difference FROM products_options WHERE group_id='$db_products_option_groups_id'");
while ($db_product_options = @mysql_fetch_array($db_lookup_product_options)) {
$db_product_options_id = $db_product_options['id'];
$db_product_options_name = $db_product_options['name'];
$db_product_options_plus_minus = $db_product_options['plus_minus'];
$db_product_options_price_difference = $db_product_options['price_difference'];
echo("<tr>");
echo("<td>" . $font_body . $db_product_options_name . "</td>");
echo("<td>" . $font_body . $db_product_options_plus_minus . "</td>");
echo("<td>" . $font_body . $db_product_options_price_difference . "</td>");
echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=view_option&group_id=$db_products_option_groups_id&option_id=$db_product_options_id'>" . $link_color . "View</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=edit_option&group_id=$db_products_option_groups_id&option_id=$db_product_options_id'>" . $link_color . "Edit</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=delete_option&group_id=$db_products_option_groups_id&option_id=$db_product_options_id'>" . $link_color . "Delete</font></a>]</td>");
echo("</tr>");
}
echo("</table>");
} else {
echo("No product options were found in the database.");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=new_option&group_id=$db_products_option_groups_id'>" . $link_color . "New</font></a>] ");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "edit_group" and $admin_rights) {
echo("<b>Product Options - Edit Group</b><p>");
$group_id = $_GET['group_id'];
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups WHERE id='$group_id'");
$db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups);
$db_products_option_groups_id = $db_products_option_groups['id'];
$db_products_option_groups_name = $db_products_option_groups['name'];
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=edit_group_submit' method='post'>");
echo("<input type='hidden' name='group_id' value='$group_id'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Group Name:</b></td>");
echo("<td>" . $font_body . "<input type='text' name='name' value='$db_products_option_groups_name'></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . " </font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Update'></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "edit_group_submit" and $admin_rights) {
echo("<b>Product Options - Edit Group</b><p>");
$group_id = $_POST['group_id'];
$name = $_POST['name'];
$db_insert_products_option_groups = "UPDATE products_option_groups SET " .
"name = '$name'" .
"WHERE id = '$group_id'";
if (@mysql_query($db_insert_products_option_groups)) {
echo("The group has been updated.");
} else {
echo("Error updating the group.");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "delete_group" and $admin_rights == "Admin") {
echo("<b>Products - Delete Group</b><p>");
$group_id = $_GET['group_id'];
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups WHERE id='$group_id'");
$db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups);
$db_products_option_groups_id = $db_products_option_groups['id'];
$db_products_option_groups_name = $db_products_option_groups['name'];
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Group Name:</b></td>");
echo("<td>" . $font_body . $db_products_option_groups_name . "</td>");
echo("</tr>");
echo("</table>");
echo("<p>");
$db_lookup_product_options = @mysql_query("SELECT id, name, plus_minus, price_difference FROM products_options WHERE group_id='$db_products_option_groups_id'");
$db_product_options = @mysql_fetch_array($db_lookup_product_options);
$db_product_options_id = $db_product_options['id'];
if ($db_product_options_id) {
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Option Name</b></td>");
echo("<td>" . $font_body . "<b>+/-</b></td>");
echo("<td>" . $font_body . "<b>Price Diff.</b></td>");
echo("</tr>");
$db_lookup_product_options = @mysql_query("SELECT id, name, plus_minus, price_difference FROM products_options WHERE group_id='$db_products_option_groups_id'");
while ($db_product_options = @mysql_fetch_array($db_lookup_product_options)) {
$db_product_options_id = $db_product_options['id'];
$db_product_options_name = $db_product_options['name'];
$db_product_options_plus_minus = $db_product_options['plus_minus'];
$db_product_options_price_difference = $db_product_options['price_difference'];
echo("<tr>");
echo("<td>" . $font_body . $db_product_options_name . "</td>");
echo("<td>" . $font_body . $db_product_options_plus_minus . "</td>");
echo("<td>" . $font_body . $db_product_options_price_difference . "</td>");
echo("</tr>");
}
echo("</table>");
} else {
echo("No product options were found in the database.");
}
echo("<p>Are you sure you want to delete this option group and all of the group's options?<p>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=delete_group_submit&group_id=$group_id'>" . $link_color . "Yes</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=delete_group_cancel&group_id=$group_id'>" . $link_color . "No</font></a>] ");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "delete_group_submit" and $admin_rights == "Admin") {
echo("<b>Products - Delete Group</b><p>");
$group_id = $_GET['group_id'];
$db_delete_product_option_groups = @mysql_query("DELETE FROM products_option_groups WHERE id='$group_id'");
$db_delete_product_options = @mysql_query("DELETE FROM products_options WHERE group_id='$group_id'");
if ($db_delete_product_option_groups and $db_delete_product_options) {
echo("The option group and the group's options have been deleted from the database.");
} else {
echo("Error deleting the option group and the group's options from the database.");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "delete_group_cancel" and $admin_rights == "Admin") {
echo("<b>Products - Delete Grup</b><p>");
echo("The option group and the group's options have not been deleted from the database.");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "new_option" and $admin_rights) {
echo("<b>Products - New Option</b><p>");
$group_id = $_GET['group_id'];
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups WHERE id='$group_id'");
$db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups);
$db_products_option_groups_id = $db_products_option_groups['id'];
$db_products_option_groups_name = $db_products_option_groups['name'];
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Group Name:</b></td>");
echo("<td>" . $font_body . $db_products_option_groups_name . "</td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=new_option_submit' method='post'>");
echo("<input type='hidden' name='group_id' value='" . $group_id . "'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Option Name:</b></font></td>");
echo("<td>" . $font_body . "<input type='text' name='name'></textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "<b>+ or -:</b></font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='plus_minus'>");
echo("<option value='+' selected>+</option>");
echo("<option value='-'>-</option>");
echo("</select>");
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Price Difference:</b></font></td>");
echo("<td>" . $font_body . "<input type='text' name='price_difference'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . " </font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Submit'></font></td>");
echo("</tr>");
echo("</table>");
echo("</form>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=view_group&group_id=$group_id'>" . $link_color . "Return to group</a>] ");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "new_option_submit" and $admin_rights) {
echo("<b>Products - New Option</b><p>");
$group_id = $_POST['group_id'];
$name = $_POST['name'];
$plus_minus = $_POST['plus_minus'];
$price_difference = $_POST['price_difference'];
$db_insert_product_options = "INSERT INTO products_options SET " .
"group_id = '$group_id', " .
"name = '$name', " .
"plus_minus = '$plus_minus', " .
"price_difference = '$price_difference'";
if (@mysql_query($db_insert_product_options)) {
echo("The product option has been added to the database.");
} else {
echo("Error adding product option to the database.");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=view_group&group_id=$group_id'>" . $link_color . "Return to group</font></a>] ");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "view_option" and $admin_rights) {
echo("<b>Product Options - View Option</b><p>");
$option_id = $_GET['option_id'];
$group_id = $_GET['group_id'];
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups WHERE id='$group_id'");
$db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups);
$db_products_option_groups_id = $db_products_option_groups['id'];
$db_products_option_groups_name = $db_products_option_groups['name'];
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Group Name:</b></td>");
echo("<td>" . $font_body . $db_products_option_groups_name . "</td>");
echo("</tr>");
echo("</table>");
echo("<p>");
$db_lookup_product_options = @mysql_query("SELECT id, name, plus_minus, price_difference FROM products_options WHERE id='$option_id'");
$db_product_options = @mysql_fetch_array($db_lookup_product_options);
$db_product_options_id = $db_product_options['id'];
$db_product_options_name = $db_product_options['name'];
$db_product_options_plus_minus = $db_product_options['plus_minus'];
$db_product_options_price_difference = $db_product_options['price_difference'];
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Option Name:</b></td>");
echo("<td>" . $font_body . $db_product_options_name . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "<b>+/-:</b></td>");
echo("<td>" . $font_body . $db_product_options_plus_minus . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Price Difference:</b></td>");
echo("<td>" . $font_body . $db_product_options_price_difference . "</td>");
echo("</tr>");
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=view_group&group_id=$group_id'>" . $link_color . "Return to group</font></a>] ");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "edit_option" and $admin_rights) {
echo("<b>Product Options - Edit Option</b><p>");
$option_id = $_GET['option_id'];
$group_id = $_GET['group_id'];
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups WHERE id='$group_id'");
$db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups);
$db_products_option_groups_id = $db_products_option_groups['id'];
$db_products_option_groups_name = $db_products_option_groups['name'];
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Group Name:</b></td>");
echo("<td>" . $font_body . $db_products_option_groups_name . "</td>");
echo("</tr>");
echo("</table>");
echo("<p>");
$db_lookup_product_options = @mysql_query("SELECT id, name, plus_minus, price_difference FROM products_options WHERE id='$option_id'");
$db_product_options = @mysql_fetch_array($db_lookup_product_options);
$db_product_options_id = $db_product_options['id'];
$db_product_options_name = $db_product_options['name'];
$db_product_options_plus_minus = $db_product_options['plus_minus'];
$db_product_options_price_difference = $db_product_options['price_difference'];
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=edit_option_submit' method='post'>");
echo("<input type='hidden' name='option_id' value='$option_id'>");
echo("<input type='hidden' name='group_id' value='$group_id'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Option Name:</b></td>");
echo("<td>" . $font_body . "<input type='text' name='name' value='$db_product_options_name'></td>");
echo("</tr>");
echo("<td>" . $font_body . "<b>+ or -:</b></font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='plus_minus'>");
if ($db_product_options_plus_minus == "+") {
echo("<option value='+' selected>+</option>");
} else {
echo("<option value='+'>+</option>");
}
if ($db_product_options_plus_minus == "-") {
echo("<option selected value='-'>-</option>");
} else {
echo("<option value='-'>-</option>");
}
echo("</select>");
echo("</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Price Difference:</b></td>");
echo("<td>" . $font_body . "<input type='text' name='price_difference' value='$db_product_options_price_difference'></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . " </font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Update'></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=view_group&group_id=$group_id'>" . $link_color . "Return to group</font></a>] ");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "edit_option_submit" and $admin_rights) {
echo("<b>Product Options - Edit Option</b><p>");
$option_id = $_POST['option_id'];
$group_id = $_POST['group_id'];
$name = $_POST['name'];
$plus_minus = $_POST['plus_minus'];
$price_difference = $_POST['price_difference'];
$dbinsert = "UPDATE products_options SET " .
"name = '$name', " .
"plus_minus = '$plus_minus', " .
"price_difference = '$price_difference'" .
"WHERE id = '$option_id'";
if (@mysql_query($dbinsert)) {
echo("The option has been updated.");
} else {
echo("Error updating the option.");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=view_group&group_id=$group_id'>" . $link_color . "Return to group</font></a>] ");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "delete_option" and $admin_rights == "Admin") {
echo("<b>Products - Delete Option</b><p>");
$option_id = $_GET['option_id'];
$group_id = $_GET['group_id'];
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups WHERE id='$group_id'");
$db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups);
$db_products_option_groups_id = $db_products_option_groups['id'];
$db_products_option_groups_name = $db_products_option_groups['name'];
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Group Name:</b></td>");
echo("<td>" . $font_body . $db_products_option_groups_name . "</td>");
echo("</tr>");
echo("</table>");
echo("<p>");
$db_lookup_product_options = @mysql_query("SELECT id, name, plus_minus, price_difference FROM products_options WHERE id='$option_id'");
$db_product_options = @mysql_fetch_array($db_lookup_product_options);
$db_product_options_id = $db_product_options['id'];
$db_product_options_name = $db_product_options['name'];
$db_product_options_plus_minus = $db_product_options['plus_minus'];
$db_product_options_price_difference = $db_product_options['price_difference'];
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Option Name:</b></td>");
echo("<td>" . $font_body . $db_product_options_name . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "<b>+/-:</b></td>");
echo("<td>" . $font_body . $db_product_options_plus_minus . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Price Difference:</b></td>");
echo("<td>" . $font_body . $db_product_options_price_difference . "</td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("Are you sure you want to delete this option?<p>");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=delete_option_submit&group_id=$group_id&option_id=$option_id'>" . $link_color . "Yes</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=delete_option_cancel&group_id=$group_id&option_id=$option_id'>" . $link_color . "No</font></a>] ");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=view_group&group_id=$group_id'>" . $link_color . "Return to group</font></a>] ");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "delete_option_submit" and $admin_rights == "Admin") {
echo("<b>Products - Delete Option</b><p>");
$option_id = $_GET['option_id'];
$group_id = $_GET['group_id'];
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups WHERE id='$group_id'");
$db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups);
$db_products_option_groups_id = $db_products_option_groups['id'];
$db_products_option_groups_name = $db_products_option_groups['name'];
$db_lookup_product_options = @mysql_query("SELECT id, name, plus_minus, price_difference FROM products_options WHERE id='$option_id'");
$db_product_options = @mysql_fetch_array($db_lookup_product_options);
$db_product_options_id = $db_product_options['id'];
$db_product_options_name = $db_product_options['name'];
$db_product_options_plus_minus = $db_product_options['plus_minus'];
$db_product_options_price_difference = $db_product_options['price_difference'];
$db_delete_option = @mysql_query("DELETE FROM products_options WHERE id='$option_id'");
if ($db_delete_option) {
echo("The option has been deleted from the database.");
} else {
echo("Error deleting option.");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=view_group&group_id=$group_id'>" . $link_color . "Return to group</font></a>] ");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "delete_option_cancel" and $admin_rights == "Admin") {
echo("<b>Products - Delete Option</b><p>");
$option_id = $_GET['option_id'];
$group_id = $_GET['group_id'];
echo("The option has not been deleted from the database.");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=view_group&group_id=$group_id'>" . $link_color . "Return to group</font></a>] ");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_options" and $request == "search_groups" and $admin_rights) {
echo("<b>Product Options - Search Groups</b><p>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=search_groups_submit' method='post'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Group name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='group_name'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . " </font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Submit'></font></td>");
echo("</tr>");
echo("</table>");
echo("</form>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - Version 1.0 - DC
// =======================================================================
if ($page == "product_options" and $request == "search_groups_submit" and $admin_rights) {
echo("<b>Product Options - Search Groups</b><p>");
$group_name = $_POST['group_name'];
$db_lookup_products_option_groups = @mysql_query("SELECT id, name FROM products_option_groups WHERE name='$group_name'");
$db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups);
$db_products_option_groups_id = $db_products_option_groups['id'];
echo("group id: " . $db_products_option_groups_id . "<p>");
if ($db_products_option_groups_id) {
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Group Name</b></td>");
echo("<td>" . $font_body . "<b>Actions</b></td>");
echo("</tr>");
while ($db_products_option_groups = @mysql_fetch_array($db_lookup_products_option_groups)) {
$db_products_option_groups_id = $db_products_option_groups['id'];
$db_products_option_groups_name = $db_products_option_groups['name'];
echo("<tr>");
echo("<td>" . $font_body . $db_products_option_groups_name . "</td>");
echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=view_group&group_id=$db_products_option_groups_id'>" . $link_color . "View</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=edit_group&group_id=$db_products_option_groups_id'>" . $link_color . "Edit</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options&request=delete_group&group_id=$db_products_option_groups_id'>" . $link_color . "Delete</font></a>]</td>");
echo("</tr>");
}
echo("</table>");
} else {
echo("Sorry, there were no results found matching \"" . $group_name . "\".");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_options'>" . $link_color . "Options</font></a>] ");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_categories" and !$request and $admin_rights) {
echo("<b>Categories</b><p>");
$db_lookup_products_categories = @mysql_query("SELECT id FROM products_categories");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_id = $db_products_categories['id'];
if ($db_products_categories_id) {
// ==================== START OF PAGE # HEADER ====================
if ($_POST["results_per_page"]) {
$results_per_page = $_POST["results_per_page"];
$_SESSION['results_per_page'] = $results_per_page;
} else {
if (!$_SESSION['results_per_page']) {
$results_per_page=10;
}
}
if ($_GET["start_page"]) {
$start_page = $_GET["start_page"];
} else {
$start_page=1;
}
$start_from = ($start_page-1) * $results_per_page;
echo("<p>");
echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
echo("<tr>");
echo("<td align='left' width='50%'>" . $font_body);
echo "<b>Pages: ";
$db_count_products = @mysql_query("SELECT COUNT(id) FROM products_categories");
$row = @mysql_fetch_row($db_count_products);
$total_records = $row[0];
$total_start_pages = ceil($total_records / $results_per_page);
for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
if ($page_number == $start_page) {
echo "$page_number ";
} else {
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a> ";
}
}
echo "</b>";
echo("</td>");
echo("<td align='left' width='50%'>" . $font_body);
echo("<table border='0' cellpadding='2' cellspacing='0'>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_categories&start_page=".$start_page."' method='post'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='results_per_page'>");
if ($results_per_page == 10) {
echo("<option value='10' selected>10</option>");
} else {
echo("<option value='10'>10</option>");
}
if ($results_per_page == 25) {
echo("<option value='25' selected>25</option>");
} else {
echo("<option value='25'>25</option>");
}
if ($results_per_page == 50) {
echo("<option value='50' selected>50</option>");
} else {
echo("<option value='50'>50</option>");
}
if ($results_per_page == 100) {
echo("<option value='100' selected>100</option>");
} else {
echo("<option value='100'>100</option>");
}
if ($results_per_page == 99999) {
echo("<option value='99999' selected>All</option>");
} else {
echo("<option value='99999'>All</option>");
}
echo("</select>");
echo("</font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
echo("</tr>");
echo("</form>");
echo("</table>");
echo("</td>");
echo("</tr>");
echo("</table>");
// ==================== END OF PAGE # HEADER ====================
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=new_product_category'>" . $link_color . "New</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=search_product_categories'>" . $link_color . "Search</font></a>]<p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Master Categories</b></td>");
echo("<td>" . $font_body . "<b>Subcategories</b></td>");
echo("<td>" . $font_body . "<b>Actions</b></td>");
echo("</tr>");
$db_lookup_products_categories_master = @mysql_query("SELECT id, name FROM products_categories WHERE master_category_id is null ORDER BY name ASC LIMIT $start_from, $results_per_page");
while ($db_products_categories_master = @mysql_fetch_array($db_lookup_products_categories_master)) {
$db_products_categories_master_id = $db_products_categories_master['id'];
$db_products_categories_master_name = $db_products_categories_master['name'];
echo("<tr>");
echo("<td>" . $font_body . $db_products_categories_master_name . "</td>");
echo("<td>" . $font_body . " </td>");
echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=view_product_category&category_id=" . $db_products_categories_master_id . "'>" . $link_color . "View</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=edit_product_category&category_id=" . $db_products_categories_master_id . "'>" . $link_color . "Edit</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=delete_product_category&category_id=" . $db_products_categories_master_id . "'>" . $link_color . "Delete</font></a>]</td>");
echo("</tr>");
$db_lookup_products_categories_sub = @mysql_query("SELECT id, name FROM products_categories WHERE master_category_id='$db_products_categories_master_id'");
while ($db_products_categories_sub = @mysql_fetch_array($db_lookup_products_categories_sub)) {
$db_products_categories_sub_id = $db_products_categories_sub['id'];
$db_products_categories_sub_name = $db_products_categories_sub['name'];
echo("<tr>");
echo("<td>". $font_body . " </td>");
echo("<td>" . $font_body . $db_products_categories_sub_name . "</td>");
echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=view_product_category&category_id=" . $db_products_categories_sub_id . "'>" . $link_color . "View</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=edit_product_category&category_id=" . $db_products_categories_sub_id . "'>" . $link_color . "Edit</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=delete_product_category&category_id=" . $db_products_categories_sub_id . "'>" . $link_color . "Delete</font></a>]</td>");
echo("</tr>");
}
}
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=new_product_category'>" . $link_color . "New</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=search_product_categories'>" . $link_color . "Search</font></a>]");
// ==================== START OF PAGE # FOOTER ====================
echo("<p>");
echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
echo("<tr>");
echo("<td align='left' width='50%'>" . $font_body);
echo "<b>Pages: ";
$db_count_products = @mysql_query("SELECT COUNT(id) FROM products_categories");
$row = @mysql_fetch_row($db_count_products);
$total_records = $row[0];
$total_start_pages = ceil($total_records / $results_per_page);
for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
if ($page_number == $start_page) {
echo "$page_number ";
} else {
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a> ";
}
}
echo "</b>";
echo("</td>");
echo("<td align='left' width='50%'>" . $font_body);
echo("<table border='0' cellpadding='2' cellspacing='0'>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_categories&start_page=".$start_page."' method='post'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='results_per_page'>");
if ($results_per_page == 10) {
echo("<option value='10' selected>10</option>");
} else {
echo("<option value='10'>10</option>");
}
if ($results_per_page == 25) {
echo("<option value='25' selected>25</option>");
} else {
echo("<option value='25'>25</option>");
}
if ($results_per_page == 50) {
echo("<option value='50' selected>50</option>");
} else {
echo("<option value='50'>50</option>");
}
if ($results_per_page == 100) {
echo("<option value='100' selected>100</option>");
} else {
echo("<option value='100'>100</option>");
}
if ($results_per_page == 99999) {
echo("<option value='99999' selected>All</option>");
} else {
echo("<option value='99999'>All</option>");
}
echo("</select>");
echo("</font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
echo("</tr>");
echo("</form>");
echo("</table>");
echo("</td>");
echo("</tr>");
echo("</table>");
// ==================== END OF PAGE # FOOTER ====================
} else {
echo("No product categories were found in the database.");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=new_product_category'>" . $link_color . "New</font></a>]<p>");
}
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_categories" and $request == "new_product_category" and $admin_rights) {
echo("<b>Categories - New Category</b><p>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=new_product_category_submit' method='post'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Master Category:</font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='master_category_id'>");
echo("<option value='none'>None</option>");
$db_lookup_products_categories = @mysql_query("SELECT id, name FROM products_categories WHERE master_category_id is null");
while ($db_products_categories = @mysql_fetch_array($db_lookup_products_categories)) {
$db_products_categories_id = $db_products_categories['id'];
$db_products_categories_name = $db_products_categories['name'];
echo("<option value='" . $db_products_categories_id . "'>" . $db_products_categories_name . "</option>");
}
echo("</select>");
echo("</font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='new_category_name'></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<b>Search Engine Marketing:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Title:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='meta_title' size='40'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Description:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_description' cols='40' rows='5'></textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Keywords:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_keywords' cols='40' rows='5'></textarea></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo($font_body . "<input type='submit' name ='submit' value ='Submit'></font>");
echo("</form>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories'>" . $link_color . "Categories</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_categories" and $request == "new_product_category_submit" and $admin_rights) {
echo("<b>Categories - New Category</b><p>");
$master_category_id = $_POST['master_category_id'];
$new_category_name = $_POST['new_category_name'];
$meta_title = $_POST['meta_title'];
$meta_description = $_POST['meta_description'];
$meta_keywords = $_POST['meta_keywords'];
if (!$meta_title) {
$db_themes_website_name = addslashes($db_themes_website_name);
$meta_title = "$db_themes_website_name - $new_category_name";
$meta_title = substr($meta_title, 0, 60);
}
if (!$meta_description) {
$meta_description = "$new_category_name products from $db_themes_website_name.";
}
if (!$meta_keywords) {
$meta_keywords = strtolower($new_category_name);
$meta_keywords = preg_replace('/\s\s+/', ' ', $meta_keywords);
$meta_keywords = trim($meta_keywords);
$meta_keywords = substr($meta_keywords, 0, 140);
$meta_keywords = str_replace(" ", ", ", $meta_keywords);
$meta_keywords = str_replace("., ", ", ", $meta_keywords);
$meta_keywords = str_replace(".", "", $meta_keywords);
$meta_keywords = str_replace("? ", ", ", $meta_keywords);
$meta_keywords = str_replace("?", "", $meta_keywords);
$meta_keywords = str_replace("! ", ", ", $meta_keywords);
$meta_keywords = str_replace("!", "", $meta_keywords);
$meta_keywords = str_replace(",,", ",", $meta_keywords);
$meta_keywords = str_replace(", , ", ", ", $meta_keywords);
$meta_keywords .= ", $db_themes_website_name";
}
$db_lookup_products_categories = @mysql_query("SELECT name FROM products_categories WHERE name='$new_category_name'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_name = $db_products_categories['name'];
if ($db_products_categories_name) {
echo("Product category already exists in the database, duplicates are not allowed.");
} else {
if ($master_category_id == "none") {
$db_insert_products_categories = "INSERT INTO products_categories SET " .
"name = '$new_category_name', " .
"meta_title = '$meta_title', " .
"meta_description = '$meta_description', " .
"meta_keywords = '$meta_keywords'";
} else {
$db_insert_products_categories = "INSERT INTO products_categories SET " .
"name = '$new_category_name', " .
"master_category_id = '$master_category_id', " .
"meta_title = '$meta_title', " .
"meta_description = '$meta_description', " .
"meta_keywords = '$meta_keywords'";
}
if (@mysql_query($db_insert_products_categories)) {
echo("Category creation successful.<p>");
$insert_products_categories = "successful";
} else {
echo("Error creating product category.");
}
$db_lookup_menu_categories = @mysql_query("SELECT id FROM menu_categories WHERE name='Shop'");
$db_menu_categories = @mysql_fetch_array($db_lookup_menu_categories);
$db_menu_categories_id = $db_menu_categories['id'];
if (!$db_menu_categories_id) {
$db_insert_menu_categories = "INSERT INTO menu_categories SET " .
"name = 'Shop'";
if (@mysql_query($db_insert_menu_categories)) {
echo("Menu categories insert successful.<p>");
} else {
echo("Menu categories insert failed.<p>");
}
}
$db_lookup_products_categories = @mysql_query("SELECT id FROM products_categories WHERE name='$new_category_name'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_id = $db_products_categories['id'];
$db_lookup_menu = @mysql_query("SELECT id FROM menu WHERE request='$db_products_categories_id'");
$db_menu = @mysql_fetch_array($db_lookup_menu);
$db_menu_id = $db_menu['id'];
if (!$db_menu_id) {
$db_lookup_menu_categories = @mysql_query("SELECT id FROM menu_categories WHERE name='Shop'");
$db_menu_categories = @mysql_fetch_array($db_lookup_menu_categories);
$db_menu_categories_id = $db_menu_categories['id'];
$db_insert_menu = "INSERT INTO menu SET " .
"menu_categories_id = '$db_menu_categories_id', " .
"name = '$new_category_name', " .
"include_file = 'catalog.inc', " .
"page = 'view_category', " .
"request = '$db_products_categories_id'";
if (@mysql_query($db_insert_menu)) {
echo("Menu insert successful.<p>");
} else {
echo("Menu insert failed.<p>");
}
}
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories'>" . $link_color . "Categories</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_categories" and $request == "view_product_category" and $admin_rights) {
echo("<b>Categories - View Category</b><p>");
$product_category_id = $_GET['category_id'];
$db_lookup_products_categories = @mysql_query("SELECT id, name, master_category_id, meta_title, meta_description, meta_keywords FROM products_categories WHERE id='$product_category_id'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_name = $db_products_categories['name'];
$db_products_categories_master_category_id = $db_products_categories['master_category_id'];
$db_products_categories_meta_title = $db_products_categories['meta_title'];
$db_products_categories_meta_description = $db_products_categories['meta_description'];
$db_products_categories_meta_keywords = $db_products_categories['meta_keywords'];
$db_lookup_products_categories = @mysql_query("SELECT name FROM products_categories WHERE id='$db_products_categories_master_category_id'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_master_category_name = $db_products_categories['name'];
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Category Name:</td>");
echo("<td>" . $font_body . $db_products_categories_name . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Master Category:</td>");
if ($db_products_categories_master_category_name) {
echo("<td>" . $font_body . $db_products_categories_master_category_name . "</td>");
} else {
echo("<td><i>" . $font_body . "None</i></td>");
}
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<b>Search Engine Marketing:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Title:</td>");
echo("<td>" . $font_body . $db_products_categories_meta_title . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Description:</td>");
echo("<td>" . $font_body . $db_products_categories_meta_description . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Keywords:</td>");
echo("<td>" . $font_body . $db_products_categories_meta_keywords . "</td>");
echo("</tr>");
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories'>" . $link_color . "Categories</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_categories" and $request == "edit_product_category" and $admin_rights) {
echo("<b>Categories - Edit Category</b><p><p>");
$product_category_id = $_GET['category_id'];
$db_lookup_products_categories = @mysql_query("SELECT id, name, master_category_id, meta_title, meta_description, meta_keywords FROM products_categories WHERE id='$product_category_id'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_id = $db_products_categories['id'];
$db_products_categories_name = $db_products_categories['name'];
$db_products_categories_master_category_id = $db_products_categories['master_category_id'];
$db_products_categories_meta_title = $db_products_categories['meta_title'];
$db_products_categories_meta_description = $db_products_categories['meta_description'];
$db_products_categories_meta_keywords = $db_products_categories['meta_keywords'];
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=edit_product_category_submit' method='post'>");
echo("<input type='hidden' name='category_id' value='$product_category_id'>");
echo("<input type='hidden' name='category_name' value='$db_products_categories_name'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Category Name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='edit_category' value='$db_products_categories_name'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Master Category:</font></td>");
echo("<td><select name='edit_master_category'>");
$db_lookup_products_categories_master_category_selected = @mysql_query("SELECT id, name FROM products_categories WHERE id='$db_products_categories_master_category_id'");
$db_products_categories_master_category_selected = @mysql_fetch_array($db_lookup_products_categories_master_category_selected);
$db_products_categories_master_category_selected_id = $db_products_categories_master_category_selected['id'];
$db_products_categories_master_category_selected_name = $db_products_categories_master_category_selected['name'];
echo("<option value='". $db_products_categories_master_category_selected_id . "' selected>" . $db_products_categories_master_category_selected_name . "</option>");
$db_lookup_products_categories_master_categories = @mysql_query("SELECT id, name FROM products_categories WHERE id != '$db_products_categories_master_category_id'");
while ($db_products_categories_master_categories = @mysql_fetch_array($db_lookup_products_categories_master_categories)) {
$db_products_categories_master_categories_id = $db_products_categories_master_categories['id'];
$db_products_categories_master_categories_name = $db_products_categories_master_categories['name'];
echo("<option value='" . $db_products_categories_master_categories_id . "'> " . $db_products_categories_master_categories_name . "</option>");
}
echo("</select>");
echo("</font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo("<b>Search Engine Marketing:</b><p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Title:</font></td>");
$db_products_categories_meta_title = htmlspecialchars("$db_products_categories_meta_title", ENT_QUOTES);
echo("<td>" . $font_body . "<input type='text' name='meta_title' value='$db_products_categories_meta_title' size='40'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Description:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_description' cols='40' rows='5'>$db_products_categories_meta_description</textarea></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Meta Keywords:</font></td>");
echo("<td>" . $font_body . "<textarea name='meta_keywords' cols='40' rows='5'>$db_products_categories_meta_keywords</textarea></font></td>");
echo("</tr>");
echo("</table>");
echo("<p>");
echo($font_body . "<input type='submit' name ='submit' value ='Update'></font>");
echo("</form>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories'>" . $link_color . "Categories</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_categories" and $request == "edit_product_category_submit" and $admin_rights) {
echo("<b>Categories - Edit Category</b><p>");
$product_category_id = $_POST['category_id'];
$master_category_id = $_POST['edit_master_category'];
$old_category_name = $_POST['category_name'];
$new_category_name = $_POST['edit_category'];
$meta_title = $_POST['meta_title'];
$meta_description = $_POST['meta_description'];
$meta_keywords = $_POST['meta_keywords'];
if (!$meta_title) {
$db_themes_website_name = addslashes($db_themes_website_name);
$meta_title = "$db_themes_website_name - $new_category_name";
$meta_title = substr($meta_title, 0, 60);
}
if (!$meta_description) {
$meta_description = "$new_category_name products from $db_themes_website_name.";
}
if (!$meta_keywords) {
$meta_keywords = strtolower($new_category_name);
$meta_keywords = preg_replace('/\s\s+/', ' ', $meta_keywords);
$meta_keywords = trim($meta_keywords);
$meta_keywords = substr($meta_keywords, 0, 140);
$meta_keywords = str_replace(" ", ", ", $meta_keywords);
$meta_keywords = str_replace("., ", ", ", $meta_keywords);
$meta_keywords = str_replace(".", "", $meta_keywords);
$meta_keywords = str_replace("? ", ", ", $meta_keywords);
$meta_keywords = str_replace("?", "", $meta_keywords);
$meta_keywords = str_replace("! ", ", ", $meta_keywords);
$meta_keywords = str_replace("!", "", $meta_keywords);
$meta_keywords = str_replace(",,", ",", $meta_keywords);
$meta_keywords = str_replace(", , ", ", ", $meta_keywords);
$meta_keywords .= ", $db_themes_website_name";
}
if ($master_category_id) {
$db_update_products_categories = "UPDATE products_categories SET " .
"name = '$new_category_name', " .
"master_category_id = '$master_category_id', " .
"meta_title = '$meta_title', " .
"meta_description = '$meta_description', " .
"meta_keywords = '$meta_keywords' " .
"WHERE id = '$product_category_id'";
} else {
$db_update_products_categories = "UPDATE products_categories SET " .
"name = '$new_category_name', " .
"meta_title = '$meta_title', " .
"meta_description = '$meta_description', " .
"meta_keywords = '$meta_keywords' " .
"WHERE id = '$product_category_id'";
}
if (@mysql_query($db_update_products_categories)) {
echo("Category update successful.<p>");
} else {
echo("Error updating product category.<p>");
}
$db_lookup_menu = @mysql_query("SELECT id FROM menu WHERE name='$old_category_name'");
$db_menu = @mysql_fetch_array($db_lookup_menu);
$db_menu_id = $db_menu['id'];
$db_update_menu = "UPDATE menu SET " .
"name = '$new_category_name' " .
"WHERE id = '$db_menu_id'";
if (@mysql_query($db_update_menu)) {
echo("Menu update successful.<p>");
} else {
echo("Error updating product menu.<p>");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories'>" . $link_color . "Categories</font></a>]");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_categories" and $request == "delete_product_category" and $admin_rights == "Admin") {
echo("<b>Categories - Delete Category</b><p><p>");
$product_category_id = $_GET['category_id'];
$db_lookup_products_categories = @mysql_query("SELECT id, name FROM products_categories WHERE id='$product_category_id'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_id = $db_products_categories['id'];
$db_products_categories_name = $db_products_categories['name'];
echo("Are you sure you want to delete the category \"" . $db_products_categories_name . "\"?<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=delete_product_category_submit&category_id=" . $db_products_categories_id . "'>" . $link_color . "Yes</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=delete_product_category_cancel&category_id=" . $db_products_categories_id . "'>" . $link_color . "No</font></a>]<p>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories'>" . $link_color . "Categories</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_categories" and $request == "delete_product_category_submit" and $admin_rights == "Admin") {
echo("<b>Categories - Delete Category</b><p><p>");
$product_category_id = $_GET['category_id'];
$db_lookup_products_categories = @mysql_query("SELECT id, name FROM products_categories WHERE id='$product_category_id'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_id = $db_products_categories['id'];
$db_products_categories_name = $db_products_categories['name'];
$db_delete_products_categories = "DELETE FROM products_categories WHERE id='$db_products_categories_id'";
if (@mysql_query($db_delete_products_categories)) {
echo("Category deletion successfull.<p>");
} else {
echo("Error deleting category.<p>");
}
$db_delete_menu = "DELETE FROM menu WHERE name='$db_products_categories_name'";
if (@mysql_query($db_delete_menu)) {
echo("Menu entry deletion successfull.<p>");
} else {
echo("Error deleting menu entry.<p>");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories'>" . $link_color . "Categories</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_categories" and $request == "delete_product_category_cancel" and $admin_rights == "Admin") {
echo("<b>Categories - Delete Category</b><p><p>");
$product_category_id = $_GET['category_id'];
$db_lookup_products_categories = @mysql_query("SELECT id, name FROM products_categories WHERE id='$product_category_id'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_id = $db_products_categories['id'];
$db_products_categories_name = $db_products_categories['name'];
echo("The product category \"$db_products_categories_name\" has not been deleted.<p>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories'>" . $link_color . "Categories</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_categories" and $request == "search_product_categories" and $admin_rights) {
echo("<b>Categories - Search Categories</b><p><p>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=search_product_categories_submit' method='post'>");
echo("<table border='0' cellpadding='5' cellspacing='0'");
echo("<tr>");
echo("<td valign='top' align='left'>" . $font_body . "Categoery name: </td></font>");
echo("<td>" . $font_body . " ");
echo("<input type='text' name='category_name'> ");
echo("<input type='submit' name ='submit' value ='Search'>");
echo("</form></td>");
echo("</tr>");
echo("</table>");
echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories'>" . $link_color . "Categories</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_categories" and $request == "search_product_categories_submit" and $admin_rights) {
echo("<b>Categories - Search Categories</b><p><p>");
$product_category_name = $_POST['category_name'];
$db_lookup_products_categories = @mysql_query("SELECT id FROM products_categories WHERE name='$product_category_name'");
$db_products_categories = @mysql_fetch_array($db_lookup_products_categories);
$db_products_categories_id = $db_products_categories['id'];
if ($db_products_categories_id) {
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Categories</b></td>");
echo("<td>" . $font_body . "<b>Actions</b></td>");
echo("</tr>");
$db_lookup_products_categories = @mysql_query("SELECT id, name FROM products_categories WHERE name='$product_category_name'");
while ($db_products_categories = @mysql_fetch_array($db_lookup_products_categories)) {
$db_products_categories_id = $db_products_categories['id'];
$db_products_categories_name = $db_products_categories['name'];
echo("<tr>");
echo("<td>" . $font_body . $db_products_categories_name . "</td>");
echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=view_product_category&category_id=" . $db_products_categories_id . "'>" . $link_color . "View</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=edit_product_category&category_id=" . $db_products_categories_id . "'>" . $link_color . "Edit</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=delete_product_category&category_id=" . $db_products_categories_id . "'>" . $link_color . "Delete</font></a>]</td>");
echo("</tr>");
}
echo("</table>");
} else {
echo("Sorry, there were no results found matching \"$product_category_name\".");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories&request=search_product_categories'>" . $link_color . "Search</font></a>]<p>");
echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_categories'>" . $link_color . "Categories</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_vendors" and !$request and $admin_rights) {
echo("<b>Vendors</b><p>");
$db_lookup_products_vendors = @mysql_query("SELECT id FROM products_vendors");
$db_products_vendors = @mysql_fetch_array($db_lookup_products_vendors);
$db_products_vendors_id = $db_products_vendors['id'];
if ($db_products_vendors_id) {
// ==================== START OF PAGE # HEADER ====================
if ($_POST["results_per_page"]) {
$results_per_page = $_POST["results_per_page"];
$_SESSION['results_per_page'] = $results_per_page;
} else {
if (!$_SESSION['results_per_page']) {
$results_per_page=10;
}
}
if ($_GET["start_page"]) {
$start_page = $_GET["start_page"];
} else {
$start_page=1;
}
$start_from = ($start_page-1) * $results_per_page;
echo("<p>");
echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
echo("<tr>");
echo("<td align='left' width='50%'>" . $font_body);
echo "<b>Pages: ";
$db_count_products = @mysql_query("SELECT COUNT(id) FROM products_vendors");
$row = @mysql_fetch_row($db_count_products);
$total_records = $row[0];
$total_start_pages = ceil($total_records / $results_per_page);
for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
if ($page_number == $start_page) {
echo "$page_number ";
} else {
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a> ";
}
}
echo "</b>";
echo("</td>");
echo("<td align='left' width='50%'>" . $font_body);
echo("<table border='0' cellpadding='2' cellspacing='0'>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&start_page=".$start_page."' method='post'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='results_per_page'>");
if ($results_per_page == 10) {
echo("<option value='10' selected>10</option>");
} else {
echo("<option value='10'>10</option>");
}
if ($results_per_page == 25) {
echo("<option value='25' selected>25</option>");
} else {
echo("<option value='25'>25</option>");
}
if ($results_per_page == 50) {
echo("<option value='50' selected>50</option>");
} else {
echo("<option value='50'>50</option>");
}
if ($results_per_page == 100) {
echo("<option value='100' selected>100</option>");
} else {
echo("<option value='100'>100</option>");
}
if ($results_per_page == 99999) {
echo("<option value='99999' selected>All</option>");
} else {
echo("<option value='99999'>All</option>");
}
echo("</select>");
echo("</font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
echo("</tr>");
echo("</form>");
echo("</table>");
echo("</td>");
echo("</tr>");
echo("</table>");
// ==================== END OF PAGE # HEADER ====================
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=new_vendor'>" . $link_color . "New</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=search_vendors'>" . $link_color . "Search</font></a>]<p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Name</b></td>");
echo("<td>" . $font_body . "<b>Actions</b></td>");
echo("</tr>");
$db_lookup_products_vendors = @mysql_query("SELECT id, name FROM products_vendors ORDER BY name ASC LIMIT $start_from, $results_per_page");
while ($db_products_vendors = @mysql_fetch_array($db_lookup_products_vendors)) {
$db_products_vendors_id = $db_products_vendors['id'];
$db_products_vendors_name = $db_products_vendors['name'];
echo("<tr>");
echo("<td>" . $font_body . $db_products_vendors_name . "</td>");
echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=view_product_vendor&vendor_id=" . $db_products_vendors_id . "'>" . $link_color . "View</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=edit_product_vendor&vendor_id=" . $db_products_vendors_id . "'>" . $link_color . "Edit</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=delete_product_vendor&vendor_id=" . $db_products_vendors_id . "'>" . $link_color . "Delete</font></a>]</td>");
echo("</tr>");
}
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=new_vendor'>" . $link_color . "New</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=search_vendors'>" . $link_color . "Search</font></a>]");
// ==================== START OF PAGE # FOOTER ====================
echo("<p>");
echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
echo("<tr>");
echo("<td align='left' width='50%'>" . $font_body);
echo "<b>Pages: ";
$db_count_products = @mysql_query("SELECT COUNT(id) FROM products_vendors");
$row = @mysql_fetch_row($db_count_products);
$total_records = $row[0];
$total_start_pages = ceil($total_records / $results_per_page);
for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
if ($page_number == $start_page) {
echo "$page_number ";
} else {
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a> ";
}
}
echo "</b>";
echo("</td>");
echo("<td align='left' width='50%'>" . $font_body);
echo("<table border='0' cellpadding='2' cellspacing='0'>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&start_page=".$start_page."' method='post'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='results_per_page'>");
if ($results_per_page == 10) {
echo("<option value='10' selected>10</option>");
} else {
echo("<option value='10'>10</option>");
}
if ($results_per_page == 25) {
echo("<option value='25' selected>25</option>");
} else {
echo("<option value='25'>25</option>");
}
if ($results_per_page == 50) {
echo("<option value='50' selected>50</option>");
} else {
echo("<option value='50'>50</option>");
}
if ($results_per_page == 100) {
echo("<option value='100' selected>100</option>");
} else {
echo("<option value='100'>100</option>");
}
if ($results_per_page == 99999) {
echo("<option value='99999' selected>All</option>");
} else {
echo("<option value='99999'>All</option>");
}
echo("</select>");
echo("</font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
echo("</tr>");
echo("</form>");
echo("</table>");
echo("</td>");
echo("</tr>");
echo("</table>");
// ==================== END OF PAGE # FOOTER ====================
} else {
echo("No product vendors were found in the database.");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=new_vendor'>" . $link_color . "New</font></a>]<p>");
}
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_vendors" and $request == "new_vendor" and $admin_rights) {
echo("<b>Vendors - New Vendor</b><p><p>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=new_vendor_submit' method='post'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_name'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Address:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_address'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Address 2:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_address_2'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "City/Municipality:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_city'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "State/Province:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_state'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "ZIP/Postal Code:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_zip_code'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Country:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_country'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Phone:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_phone'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Fax:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_fax'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Cell:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_cell'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Email:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_email'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Website:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_website'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . " </font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Submit'></font></td>");
echo("</tr>");
echo("</table>");
echo("</form>");
echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors'>" . $link_color . "Vendors</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_vendors" and $request == "new_vendor_submit" and $admin_rights) {
echo("<b>Vendors - New Vendor</b><p><p>");
$vendor_name = $_POST['vendor_name'];
$vendor_address = $_POST['vendor_address'];
$vendor_address_2 = $_POST['vendor_address_2'];
$vendor_city = $_POST['vendor_city'];
$vendor_state = $_POST['vendor_state'];
$vendor_zip_code = $_POST['vendor_zip_code'];
$vendor_country = $_POST['vendor_country'];
$vendor_phone = $_POST['vendor_phone'];
$vendor_fax = $_POST['vendor_fax'];
$vendor_cell = $_POST['vendor_cell'];
$vendor_email = $_POST['vendor_email'];
$vendor_website = $_POST['vendor_website'];
$db_lookup_products_vendors = @mysql_query("SELECT name FROM products_vendors WHERE name='$vendor_name'");
$db_products_vendors = @mysql_fetch_array($db_lookup_products_vendors);
$db_products_vendors_name = $db_products_vendors['name'];
if ($db_products_vendors_name) {
echo("Product vendor already exists in the database, duplicates are not allowed.");
} else {
$db_insert_products_vendors = "INSERT INTO products_vendors SET " .
"name = '$vendor_name', " .
"address = '$vendor_address', " .
"address_2 = '$vendor_address_2', " .
"city = '$vendor_city', " .
"state = '$vendor_state', " .
"zip_code = '$vendor_zip_code', " .
"country = '$vendor_country', " .
"phone = '$vendor_phone', " .
"fax = '$vendor_fax', " .
"cell = '$vendor_cell', " .
"email = '$vendor_email', " .
"website = '$vendor_website'";
if (@mysql_query($db_insert_products_vendors)) {
echo("Product vendor created successfully.<p>");
} else {
echo("Error creating product vendor<p>");
}
}
echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors'>" . $link_color . "Vendors</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_vendors" and $request == "view_product_vendor" and $admin_rights) {
echo("<b>Vendors - View Vendor</b><p>");
$vendor_id = $_GET['vendor_id'];
$db_lookup_products_vendors = @mysql_query("SELECT name, address, address_2, city, state, zip_code, country, phone, fax, cell, email, website FROM products_vendors WHERE id='$vendor_id'");
$db_products_vendors = @mysql_fetch_array($db_lookup_products_vendors);
$db_products_vendors_name = $db_products_vendors['name'];
$db_products_vendors_address = $db_products_vendors['address'];
$db_products_vendors_address_2 = $db_products_vendors['address_2'];
$db_products_vendors_city = $db_products_vendors['city'];
$db_products_vendors_state = $db_products_vendors['state'];
$db_products_vendors_zip_code = $db_products_vendors['zip_code'];
$db_products_vendors_country = $db_products_vendors['country'];
$db_products_vendors_phone = $db_products_vendors['phone'];
$db_products_vendors_fax = $db_products_vendors['fax'];
$db_products_vendors_cell = $db_products_vendors['cell'];
$db_products_vendors_email = $db_products_vendors['email'];
$db_products_vendors_website = $db_products_vendors['website'];
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Name:</td>");
echo("<td>" . $font_body . $db_products_vendors_name . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Address:</td>");
echo("<td>" . $font_body . $db_products_vendors_address . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Address 2:</td>");
echo("<td>" . $font_body . $db_products_vendors_address_2 . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "City:</td>");
echo("<td>" . $font_body . $db_products_vendors_city . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "State:</td>");
echo("<td>" . $font_body . $db_products_vendors_state . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Zip Code:</td>");
echo("<td>" . $font_body . $db_products_vendors_zip_code . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Country:</td>");
echo("<td>" . $font_body . $db_products_vendors_country . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Phone:</td>");
echo("<td>" . $font_body . $db_products_vendors_phone . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Fax:</td>");
echo("<td>" . $font_body . $db_products_vendors_fax . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Cell:</td>");
echo("<td>" . $font_body . $db_products_vendors_cell . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Email:</td>");
echo("<td>" . $font_body . $db_products_vendors_email . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Website:</td>");
echo("<td>" . $font_body . $db_products_vendors_website . "</td>");
echo("</tr>");
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors'>" . $link_color . "Vendors</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_vendors" and $request == "edit_product_vendor" and $admin_rights) {
echo("<b>Vendors - Edit Vendor</b><p><p>");
$vendor_id = $_GET['vendor_id'];
$db_lookup_products_vendors = @mysql_query("SELECT name, address, address_2, city, state, zip_code, country, phone, fax, cell, email, website FROM products_vendors WHERE id='$vendor_id'");
$db_products_vendors = @mysql_fetch_array($db_lookup_products_vendors);
$db_products_vendors_name = $db_products_vendors['name'];
$db_products_vendors_address = $db_products_vendors['address'];
$db_products_vendors_address_2 = $db_products_vendors['address_2'];
$db_products_vendors_city = $db_products_vendors['city'];
$db_products_vendors_state = $db_products_vendors['state'];
$db_products_vendors_zip_code = $db_products_vendors['zip_code'];
$db_products_vendors_country = $db_products_vendors['country'];
$db_products_vendors_phone = $db_products_vendors['phone'];
$db_products_vendors_fax = $db_products_vendors['fax'];
$db_products_vendors_cell = $db_products_vendors['cell'];
$db_products_vendors_email = $db_products_vendors['email'];
$db_products_vendors_website = $db_products_vendors['website'];
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=edit_product_vendor_submit' method='post'>");
echo("<input type='hidden' name='vendor_id' value='$vendor_id'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_name' value='$db_products_vendors_name'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Address:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_address' value='$db_products_vendors_address'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Address 2:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_address_2' value='$db_products_vendors_address_2'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "City:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_city' value='$db_products_vendors_city'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "State:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_state' value='$db_products_vendors_state'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Zip Code:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_zip_code' value='$db_products_vendors_zip_code'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Country:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_country' value='$db_products_vendors_country'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Phone:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_phone' value='$db_products_vendors_phone'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Fax:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_fax' value='$db_products_vendors_fax'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Cell:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_cell' value='$db_products_vendors_cell'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Email:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_email' value='$db_products_vendors_email'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Website:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='vendor_website' value='$db_products_vendors_website'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . " </font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Update'></font></td>");
echo("</tr>");
echo("</table>");
echo("</form>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors'>" . $link_color . "Vendors</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_vendors" and $request == "edit_product_vendor_submit" and $admin_rights) {
echo("<b>Vendors - Edit Vendor</b><p>");
$vendor_id = $_POST['vendor_id'];
$vendor_name = $_POST['vendor_name'];
$vendor_address = $_POST['vendor_address'];
$vendor_address_2 = $_POST['vendor_address_2'];
$vendor_city = $_POST['vendor_city'];
$vendor_state = $_POST['vendor_state'];
$vendor_zip_code = $_POST['vendor_zip_code'];
$vendor_country = $_POST['vendor_country'];
$vendor_phone = $_POST['vendor_phone'];
$vendor_fax = $_POST['vendor_fax'];
$vendor_cell = $_POST['vendor_cell'];
$vendor_email = $_POST['vendor_email'];
$vendor_website = $_POST['vendor_website'];
$db_update_products_vendors = "UPDATE products_vendors SET " .
"name = '$vendor_name', " .
"address = '$vendor_address', " .
"address_2 = '$vendor_address_2', " .
"city = '$vendor_city', " .
"state = '$vendor_state', " .
"zip_code = '$vendor_zip_code', " .
"country = '$vendor_country', " .
"phone = '$vendor_phone', " .
"fax = '$vendor_fax', " .
"cell = '$vendor_cell', " .
"email = '$vendor_email', " .
"website = '$vendor_website' " .
"WHERE id = '$vendor_id'";
if (@mysql_query($db_update_products_vendors)) {
echo("Product vendor successfully updated.<p>");
} else {
echo("Error updating product vendor<p>");
}
echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors'>" . $link_color . "Vendors</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_vendors" and $request == "delete_product_vendor" and $admin_rights == "Admin") {
echo("<b>Vendors - Delete Vendor</b><p>");
$vendor_id = $_GET['vendor_id'];
$db_lookup_products_vendors = @mysql_query("SELECT id, name FROM products_vendors WHERE id='$vendor_id'");
$db_products_vendors = @mysql_fetch_array($db_lookup_products_vendors);
$db_products_vendors_id = $db_products_vendors['id'];
$db_products_vendors_name = $db_products_vendors['name'];
echo("Are you sure you want to delete the vendor \"" . $db_products_vendors_name . "\"?<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=delete_product_vendor_submit&vendor_id=" . $vendor_id . "'>" . $link_color . "Yes</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=delete_product_vendor_cancel'>" . $link_color . "No</font></a>]<p>");
echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors'>" . $link_color . "Vendors</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_vendors" and $request == "delete_product_vendor_submit" and $admin_rights == "Admin") {
echo("<b>Vendors - Delete Vendor</b><p><p>");
$vendor_id = $_GET['vendor_id'];
$db_lookup_products_vendors = @mysql_query("SELECT id, name FROM products_vendors WHERE id='$vendor_id'");
$db_products_vendors = @mysql_fetch_array($db_lookup_products_vendors);
$db_products_vendors_id = $db_products_vendors['id'];
$db_products_vendors_name = $db_products_vendors['name'];
$db_delete_products_vendors = "DELETE FROM products_vendors WHERE id='$db_products_vendors_id'";
if (@mysql_query($db_delete_products_vendors)) {
echo("Product vendor deleted successfully.<p>");
} else {
echo("Error deleting product vendor.<p>");
}
echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors'>" . $link_color . "Vendors</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_vendors" and $request == "delete_product_vendor_cancel" and $admin_rights == "Admin") {
echo("<b>Vendors - Delete Vendor</b><p><p>");
echo("Product vendor has not been deleted.");
echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors'>" . $link_color . "Vendors</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_vendors" and $request == "search_vendors" and $admin_rights) {
echo("<b>Vendors - Search Vendors</b><p><p>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=search_vendors_submit' method='post'>");
echo("<table border='0' cellpadding='5' cellspacing='0'");
echo("<tr>");
echo("<td valign='top' align='left'>" . $font_body . "Vendor name: </td></font>");
echo("<td>" . $font_body . " ");
echo("<input type='text' name='vendor_name'> ");
echo("<input type='submit' name ='submit' value ='Search'>");
echo("</form></td>");
echo("</tr>");
echo("</table>");
echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors'>" . $link_color . "Vendors</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_vendors" and $request == "search_vendors_submit" and $admin_rights) {
echo("<b>Vendors - Search Vendors</b><p><p>");
$vendor_name = $_POST['vendor_name'];
$db_lookup_products_vendors = @mysql_query("SELECT id FROM products_vendors WHERE name='$vendor_name'");
$db_products_vendors = @mysql_fetch_array($db_lookup_products_vendors);
$db_products_vendors_id = $db_products_vendors['id'];
if ($db_products_vendors_id) {
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Vendors</b></td>");
echo("<td>" . $font_body . "<b>Actions</b></td>");
echo("</tr>");
$db_lookup_products_vendors = @mysql_query("SELECT id, name FROM products_vendors WHERE name='$vendor_name'");
while ($db_products_vendors = @mysql_fetch_array($db_lookup_products_vendors)) {
$db_products_vendors_id = $db_products_vendors['id'];
$db_products_vendors_name = $db_products_vendors['name'];
echo("<tr>");
echo("<td>" . $font_body . $db_products_vendors_name . "</td>");
echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=view_product_vendor&vendor_id=" . $db_products_vendors_id . "'>" . $link_color . "View</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=edit_product_vendor&vendor_id=" . $db_products_vendors_id . "'>" . $link_color . "Edit</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=delete_product_vendor&vendor_id=" . $db_products_vendors_id . "'>" . $link_color . "Delete</font></a>]</td>");
echo("</tr>");
}
echo("</table>");
} else {
echo("Sorry, there were no results found matching \"$vendor_name\".");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors&request=search_vendors'>" . $link_color . "Search</font></a>]<p>");
echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_vendors'>" . $link_color . "Vendors</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_manufactures" and !$request and $admin_rights) {
echo("<b>Manufactures</b><p>");
$db_lookup_products_manufactures = @mysql_query("SELECT id FROM products_manufactures");
$db_products_manufactures = @mysql_fetch_array($db_lookup_products_manufactures);
$db_products_manufactures_id = $db_products_manufactures['id'];
if ($db_products_manufactures_id) {
// ==================== START OF PAGE # HEADER ====================
if ($_POST["results_per_page"]) {
$results_per_page = $_POST["results_per_page"];
$_SESSION['results_per_page'] = $results_per_page;
} else {
if (!$_SESSION['results_per_page']) {
$results_per_page=10;
}
}
if ($_GET["start_page"]) {
$start_page = $_GET["start_page"];
} else {
$start_page=1;
}
$start_from = ($start_page-1) * $results_per_page;
echo("<p>");
echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
echo("<tr>");
echo("<td align='left' width='50%'>" . $font_body);
echo "<b>Pages: ";
$db_count_products = @mysql_query("SELECT COUNT(id) FROM products_manufactures");
$row = @mysql_fetch_row($db_count_products);
$total_records = $row[0];
$total_start_pages = ceil($total_records / $results_per_page);
for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
if ($page_number == $start_page) {
echo "$page_number ";
} else {
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a> ";
}
}
echo "</b>";
echo("</td>");
echo("<td align='left' width='50%'>" . $font_body);
echo("<table border='0' cellpadding='2' cellspacing='0'>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&start_page=".$start_page."' method='post'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='results_per_page'>");
if ($results_per_page == 10) {
echo("<option value='10' selected>10</option>");
} else {
echo("<option value='10'>10</option>");
}
if ($results_per_page == 25) {
echo("<option value='25' selected>25</option>");
} else {
echo("<option value='25'>25</option>");
}
if ($results_per_page == 50) {
echo("<option value='50' selected>50</option>");
} else {
echo("<option value='50'>50</option>");
}
if ($results_per_page == 100) {
echo("<option value='100' selected>100</option>");
} else {
echo("<option value='100'>100</option>");
}
if ($results_per_page == 99999) {
echo("<option value='99999' selected>All</option>");
} else {
echo("<option value='99999'>All</option>");
}
echo("</select>");
echo("</font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
echo("</tr>");
echo("</form>");
echo("</table>");
echo("</td>");
echo("</tr>");
echo("</table>");
// ==================== END OF PAGE # HEADER ====================
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=new_manufacture'>" . $link_color . "New</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=search_manufactures'>" . $link_color . "Search</font></a>]<p>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Name</b></td>");
echo("<td>" . $font_body . "<b>Actions</b></td>");
echo("</tr>");
$db_lookup_products_manufactures = @mysql_query("SELECT id, name FROM products_manufactures ORDER BY name ASC LIMIT $start_from, $results_per_page");
while ($db_products_manufactures = @mysql_fetch_array($db_lookup_products_manufactures)) {
$db_products_manufactures_id = $db_products_manufactures['id'];
$db_products_manufactures_name = $db_products_manufactures['name'];
echo("<tr>");
echo("<td>" . $font_body . $db_products_manufactures_name . "</td>");
echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=view_product_manufacture&manufacture_id=" . $db_products_manufactures_id . "'>" . $link_color . "View</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=edit_product_manufacture&manufacture_id=" . $db_products_manufactures_id . "'>" . $link_color . "Edit</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=delete_product_manufacture&manufacture_id=" . $db_products_manufactures_id . "'>" . $link_color . "Delete</font></a>]</td>");
echo("</tr>");
}
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=new_manufacture'>" . $link_color . "New</font></a>] ");
echo("[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=search_manufactures'>" . $link_color . "Search</font></a>]<p>");
// ==================== START OF PAGE # FOOTER ====================
echo("<p>");
echo("<table border='0' cellpadding='0' cellspacing='0' bordercolor='#000000' width='100%'>");
echo("<tr>");
echo("<td align='left' width='50%'>" . $font_body);
echo "<b>Pages: ";
$db_count_products = @mysql_query("SELECT COUNT(id) FROM products_manufactures");
$row = @mysql_fetch_row($db_count_products);
$total_records = $row[0];
$total_start_pages = ceil($total_records / $results_per_page);
for ($page_number=1; $page_number<=$total_start_pages; $page_number++) {
if ($page_number == $start_page) {
echo "$page_number ";
} else {
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&results_per_page=$results_per_page&start_page=".$page_number."'>".$page_number."</a> ";
}
}
echo "</b>";
echo("</td>");
echo("<td align='left' width='50%'>" . $font_body);
echo("<table border='0' cellpadding='2' cellspacing='0'>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&start_page=".$start_page."' method='post'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Items per page:</b> </font></td>");
echo("<td>" . $font_body . "");
echo("<select size='1' name='results_per_page'>");
if ($results_per_page == 10) {
echo("<option value='10' selected>10</option>");
} else {
echo("<option value='10'>10</option>");
}
if ($results_per_page == 25) {
echo("<option value='25' selected>25</option>");
} else {
echo("<option value='25'>25</option>");
}
if ($results_per_page == 50) {
echo("<option value='50' selected>50</option>");
} else {
echo("<option value='50'>50</option>");
}
if ($results_per_page == 100) {
echo("<option value='100' selected>100</option>");
} else {
echo("<option value='100'>100</option>");
}
if ($results_per_page == 99999) {
echo("<option value='99999' selected>All</option>");
} else {
echo("<option value='99999'>All</option>");
}
echo("</select>");
echo("</font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Change'></font></td>");
echo("</tr>");
echo("</form>");
echo("</table>");
echo("</td>");
echo("</tr>");
echo("</table>");
// ==================== END OF PAGE # FOOTER ====================
} else {
echo("No product manufactures were found in the database.");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=new_manufacture'>" . $link_color . "New</font></a>]<p>");
}
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_manufactures" and $request == "new_manufacture" and $admin_rights) {
echo("<b>Manufactures - New Manufacture</b><p><p>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=new_manufacture_submit' method='post'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_name'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Address:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_address'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Address 2:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_address_2'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "City/Municipality:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_city'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "State/Province:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_state'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "ZIP/Postal Code:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_zip_code'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Country:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_country'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Phone:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_phone'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Fax:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_fax'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Cell:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_cell'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Email:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_email'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Website:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_website'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . " </font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Submit'></font></td>");
echo("</tr>");
echo("</table>");
echo("</form>");
echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures'>" . $link_color . "Manufactures</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_manufactures" and $request == "new_manufacture_submit" and $admin_rights) {
echo("<b>Manufactures - New Manufacture</b><p><p>");
$manufacture_name = $_POST['manufacture_name'];
$manufacture_address = $_POST['manufacture_address'];
$manufacture_address_2 = $_POST['manufacture_address_2'];
$manufacture_city = $_POST['manufacture_city'];
$manufacture_state = $_POST['manufacture_state'];
$manufacture_zip_code = $_POST['manufacture_zip_code'];
$manufacture_country = $_POST['manufacture_country'];
$manufacture_phone = $_POST['manufacture_phone'];
$manufacture_fax = $_POST['manufacture_fax'];
$manufacture_cell = $_POST['manufacture_cell'];
$manufacture_email = $_POST['manufacture_email'];
$manufacture_website = $_POST['manufacture_website'];
$db_lookup_products_manufactures = @mysql_query("SELECT name FROM products_manufactures WHERE name='$manufacture_name'");
$db_products_manufactures = @mysql_fetch_array($db_lookup_products_manufactures);
$db_products_manufactures_name = $db_products_manufactures['name'];
if ($db_products_manufactures_name) {
echo("Product manufacture already exists in the database, duplicates are not allowed.");
} else {
$db_insert_products_manufactures = "INSERT INTO products_manufactures SET " .
"name = '$manufacture_name', " .
"address = '$manufacture_address', " .
"address_2 = '$manufacture_address_2', " .
"city = '$manufacture_city', " .
"state = '$manufacture_state', " .
"zip_code = '$manufacture_zip_code', " .
"country = '$manufacture_country', " .
"phone = '$manufacture_phone', " .
"fax = '$manufacture_fax', " .
"cell = '$manufacture_cell', " .
"email = '$manufacture_email', " .
"website = '$manufacture_website'";
if (@mysql_query($db_insert_products_manufactures)) {
echo("Product manufacture creation successfull.<p>");
} else {
echo("Error creating product manufacture.<p>");
}
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures'>" . $link_color . "Manufactures</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_manufactures" and $request == "view_product_manufacture" and $admin_rights) {
echo("<b>Manufactures - View Manufacture</b><p>");
$manufacture_id = $_GET['manufacture_id'];
$db_lookup_products_manufactures = @mysql_query("SELECT name, address, address_2, city, state, zip_code, country, phone, fax, cell, email, website FROM products_manufactures WHERE id='$manufacture_id'");
$db_products_manufactures = @mysql_fetch_array($db_lookup_products_manufactures);
$db_products_manufactures_name = $db_products_manufactures['name'];
$db_products_manufactures_address = $db_products_manufactures['address'];
$db_products_manufactures_address_2 = $db_products_manufactures['address_2'];
$db_products_manufactures_city = $db_products_manufactures['city'];
$db_products_manufactures_state = $db_products_manufactures['state'];
$db_products_manufactures_zip_code = $db_products_manufactures['zip_code'];
$db_products_manufactures_country = $db_products_manufactures['country'];
$db_products_manufactures_phone = $db_products_manufactures['phone'];
$db_products_manufactures_fax = $db_products_manufactures['fax'];
$db_products_manufactures_cell = $db_products_manufactures['cell'];
$db_products_manufactures_email = $db_products_manufactures['email'];
$db_products_manufactures_website = $db_products_manufactures['website'];
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Name:</td>");
echo("<td>" . $font_body . $db_products_manufactures_name . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Address:</td>");
echo("<td>" . $font_body . $db_products_manufactures_address . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Address 2:</td>");
echo("<td>" . $font_body . $db_products_manufactures_address_2 . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "City:</td>");
echo("<td>" . $font_body . $db_products_manufactures_city . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "State:</td>");
echo("<td>" . $font_body . $db_products_manufactures_state . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Zip Code:</td>");
echo("<td>" . $font_body . $db_products_manufactures_zip_code . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Country:</td>");
echo("<td>" . $font_body . $db_products_manufactures_country . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Phone:</td>");
echo("<td>" . $font_body . $db_products_manufactures_phone . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Fax:</td>");
echo("<td>" . $font_body . $db_products_manufactures_fax . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Cell:</td>");
echo("<td>" . $font_body . $db_products_manufactures_cell . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Email:</td>");
echo("<td>" . $font_body . $db_products_manufactures_email . "</td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Website:</td>");
echo("<td>" . $font_body . $db_products_manufactures_website . "</td>");
echo("</tr>");
echo("</table>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures'>" . $link_color . "Manufactures</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_manufactures" and $request == "edit_product_manufacture" and $admin_rights) {
echo("<b>Manufactures - Edit Manufacture</b><p><p>");
$manufacture_id = $_GET['manufacture_id'];
$db_lookup_products_manufactures = @mysql_query("SELECT name, address, address_2, city, state, zip_code, country, phone, fax, cell, email, website FROM products_manufactures WHERE id='$manufacture_id'");
$db_products_manufactures = @mysql_fetch_array($db_lookup_products_manufactures);
$db_products_manufactures_name = $db_products_manufactures['name'];
$db_products_manufactures_address = $db_products_manufactures['address'];
$db_products_manufactures_address_2 = $db_product_manufactures['address_2'];
$db_products_manufactures_city = $db_products_manufactures['city'];
$db_products_manufactures_state = $db_products_manufactures['state'];
$db_products_manufactures_zip_code = $db_products_manufactures['zip_code'];
$db_products_manufactures_country = $db_products_manufactures['country'];
$db_products_manufactures_phone = $db_products_manufactures['phone'];
$db_products_manufactures_fax = $db_products_manufactures['fax'];
$db_products_manufactures_cell = $db_products_manufactures['cell'];
$db_products_manufactures_email = $db_products_manufactures['email'];
$db_products_manufactures_website = $db_products_manufactures['website'];
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=edit_product_manufacture_submit' method='post'>");
echo("<input type='hidden' name='manufacture_id' value='$manufacture_id'>");
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "Name:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_name' value='$db_products_manufactures_name'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Address:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_address' value='$db_products_manufactures_address'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Address 2:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_address_2' value='$db_products_manufactures_address_2'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "City:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_city' value='$db_products_manufactures_city'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "State:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_state' value='$db_products_manufactures_state'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Zip Code:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_zip_code' value='$db_products_manufactures_zip_code'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Country:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_country' value='$db_products_manufactures_country'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Phone:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_phone' value='$db_products_manufactures_phone'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Fax:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_fax' value='$db_products_manufactures_fax'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Cell:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_cell' value='$db_products_manufactures_cell'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Email:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_email' value='$db_products_manufactures_email'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . "Website:</font></td>");
echo("<td>" . $font_body . "<input type='text' name='manufacture_website' value='$db_products_manufactures_website'></font></td>");
echo("</tr>");
echo("<tr>");
echo("<td>" . $font_body . " </font></td>");
echo("<td>" . $font_body . "<input type='submit' name ='submit' value ='Update'></font></td>");
echo("</tr>");
echo("</table>");
echo("</form>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures'>" . $link_color . "Manufactures</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_manufactures" and $request == "edit_product_manufacture_submit" and $admin_rights) {
echo("<b>Manufactures - Edit Manufacture</b><p>");
$manufacture_id = $_POST['manufacture_id'];
$manufacture_name = $_POST['manufacture_name'];
$manufacture_address = $_POST['manufacture_address'];
$manufacture_address_2 = $_POST['manufacture_address_2'];
$manufacture_city = $_POST['manufacture_city'];
$manufacture_state = $_POST['manufacture_state'];
$manufacture_zip_code = $_POST['manufacture_zip_code'];
$manufacture_country = $_POST['manufacture_country'];
$manufacture_phone = $_POST['manufacture_phone'];
$manufacture_fax = $_POST['manufacture_fax'];
$manufacture_cell = $_POST['manufacture_cell'];
$manufacture_email = $_POST['manufacture_email'];
$manufacture_website = $_POST['manufacture_website'];
$db_update_products_manufactures = "UPDATE products_manufactures SET " .
"name = '$manufacture_name', " .
"address = '$manufacture_address', " .
"address_2 = '$manufacture_address_2', " .
"city = '$manufacture_city', " .
"state = '$manufacture_state', " .
"zip_code = '$manufacture_zip_code', " .
"country = '$manufacture_country', " .
"phone = '$manufacture_phone', " .
"fax = '$manufacture_fax', " .
"cell = '$manufacture_cell', " .
"email = '$manufacture_email', " .
"website = '$manufacture_website' " .
"WHERE id = '$manufacture_id'";
if (@mysql_query($db_update_products_manufactures)) {
echo("Product manufacture has been updated successfully.<p>");
} else {
echo("Error updating product manufacture.<p>");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures'>" . $link_color . "Manufactures</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_manufactures" and $request == "delete_product_manufacture" and $admin_rights == "Admin") {
echo("<b>Manufactures - Delete Manufacture</b><p>");
$manufacture_id = $_GET['manufacture_id'];
$db_lookup_products_manufactures = @mysql_query("SELECT id, name FROM products_manufactures WHERE id='$manufacture_id'");
$db_products_manufactures = @mysql_fetch_array($db_lookup_products_manufactures);
$db_products_manufactures_id = $db_products_manufactures['id'];
$db_products_manufactures_name = $db_products_manufactures['name'];
echo("Are you sure you want to delete the manufacture \"" . $db_products_manufactures_name . "\"?<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=delete_product_manufacture_submit&manufacture_id=" . $manufacture_id . "'>" . $link_color . "Yes</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=delete_product_manufacture_cancel'>" . $link_color . "No</font></a>]<p>");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures'>" . $link_color . "Manufactures</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_manufactures" and $request == "delete_product_manufacture_submit" and $admin_rights == "Admin") {
echo("<b>Manufactures - Delete Manufacture</b><p><p>");
$manufacture_id = $_GET['manufacture_id'];
$db_lookup_products_manufactures = @mysql_query("SELECT id, name FROM products_manufactures WHERE id='$manufacture_id'");
$db_products_manufactures = @mysql_fetch_array($db_lookup_products_manufactures);
$db_products_manufactures_id = $db_products_manufactures['id'];
$db_products_manufactures_name = $db_products_manufactures['name'];
$db_delete_products_manufactures = "DELETE FROM products_manufactures WHERE id='$db_products_manufactures_id'";
if (@mysql_query($db_delete_products_manufactures)) {
echo("Product manufacture successfully deleted.<p>");
} else {
echo("Error deleting product manufacture.<p>");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures'>" . $link_color . "Manufactures</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_manufactures" and $request == "delete_product_manufacture_cancel" and $admin_rights == "Admin") {
echo("<b>Manufactures - Delete Manufacture</b><p><p>");
echo("Product manufacture has not been deleted.");
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures'>" . $link_color . "Manufactures</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_manufactures" and $request == "search_manufactures" and $admin_rights) {
echo("<b>Manufactures - Search Manufactures</b><p><p>");
echo("<form action='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=search_manufactures_submit' method='post'>");
echo("<table border='0' cellpadding='5' cellspacing='0'");
echo("<tr>");
echo("<td valign='top' align='left'>" . $font_body . "Manufacture name: </td></font>");
echo("<td>" . $font_body . " ");
echo("<input type='text' name='manufacture_name'> ");
echo("<input type='submit' name ='submit' value ='Search'>");
echo("</form></td>");
echo("</tr>");
echo("</table>");
echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures'>" . $link_color . "Manufactures</font></a>]<p>");
}
// =======================================================================
// Comment - DC - Version 1.0
// =======================================================================
if ($page == "product_manufactures" and $request == "search_manufactures_submit" and $admin_rights) {
echo("<b>Manufactures - Search Manufactures</b><p><p>");
$manufacture_name = $_POST['manufacture_name'];
$db_lookup_products_manufactures = @mysql_query("SELECT id FROM products_manufactures WHERE name='$manufacture_name'");
$db_products_manufactures = @mysql_fetch_array($db_lookup_products_manufactures);
$db_products_manufactures_id = $db_products_manufactures['id'];
if ($db_products_manufactures_id) {
echo("<table border='0' cellpadding='5' cellspacing='0'>");
echo("<tr>");
echo("<td>" . $font_body . "<b>Manufactures</b></td>");
echo("<td>" . $font_body . "<b>Actions</b></td>");
echo("</tr>");
$db_lookup_products_manufactures = @mysql_query("SELECT id, name FROM products_manufactures WHERE name='$manufacture_name'");
while ($db_products_manufactures = @mysql_fetch_array($db_lookup_products_manufactures)) {
$db_products_manufactures_id = $db_products_manufactures['id'];
$db_products_manufactures_name = $db_products_manufactures['name'];
echo("<tr>");
echo("<td>" . $font_body . $db_products_manufactures_name . "</td>");
echo("<td>". $font_body . "[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=view_product_manufacture&manufacture_id=" . $db_products_manufactures_id . "'>" . $link_color . "View</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=edit_product_manufacture&manufacture_id=" . $db_products_manufactures_id . "'>" . $link_color . "Edit</font></a>] [<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=delete_product_manufacture&manufacture_id=" . $db_products_manufactures_id . "'>" . $link_color . "Delete</font></a>]</td>");
echo("</tr>");
}
echo("</table>");
} else {
echo("Sorry, there were no results found matching \"$manufacture_name\".");
}
echo("<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures&request=search_manufactures'>" . $link_color . "Search</font></a>]<p>");
echo($font_body . "<p>[<a href='" . $_SERVER['PHP_SELF'] . "?page=product_manufactures'>" . $link_color . "Manufactures</font></a>]<p>");
}
?>