<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Programmer<programmer@armia.com>        		              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com � 2005                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
?>
<?php
include "../includes/config.php";
include "../includes/session.php";
include "../includes/functions.php";
if (get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}

if(isset( $_SESSION["sess_adminname"]) and $_SESSION["sess_adminname"]!= ""){
	$adminname = $_SESSION["sess_adminname"];
}else{
	header("Location:login.php");
	exit;
}

if (isset($_GET["productid"]) and $_GET["productid"] != "") {
    $productid = $_GET["productid"];
} else if (isset($_POST["productid"]) and $_POST["productid"] != "") {
    $productid = $_POST["productid"];
} else{
	header("Location:catalog.php");
	exit;
}

$txtProductName = $_POST["txtProductName"];
$txtProductCode = $_POST["txtProductCode"];
$txtDescription = $_POST["txtDescription"];
$txtPrice = $_POST["txtPrice"];
$ddlCategory = $_POST["ddlCategory"];
$ddlArtist = $_POST["ddlArtist"];

$txtStock = $_POST["txtStock"];
$txtReorderLevel = $_POST["txtReorderLevel"];
$txtShippingWeight = $_POST["txtShippingWeight"];

$txtDiscount = (int)$_POST["txtDiscount"];
$txtDiscountDesc = $_POST["txtDiscountDesc"];
$txtlength=$_POST['txtlength'];
$txtheight=$_POST['txtheight'];
$txtwidth=$_POST['txtwidth'];
$oldcategory= $_POST["oldcategory"];
$prodimagedir = "../products/";

$sql = "SELECT * FROM ".$tableprefix."settings ";
		$result = mysql_query($sql);
		if(mysql_num_rows($result)>0)
		{
			$row = mysql_fetch_array($result);
			$chkcanship =$row["enable_canadapost"];
		}	
$sql_digital="SELECT * FROM ".$tableprefix."products WHERE product_id= '".addslashes($productid)."' and product_artist_id = '".addslashes($artistid)."'  ";
$result_digital= mysql_query($sql_digital);
if(mysql_num_rows($result_digital) != 0)
{
$rr=mysql_fetch_array($result_digital);
$txtDigitalproduct=$rr['vdigital_product'];
}
if($txtDigitalproduct=="Y")
{
$canshipblock="none";
}
else
{
$canshipblock="";
}
if ($_POST["btnSaveChanges"] == "Save Changes") {
    $message = "" ;
	$checkleafcategory=" select *  FROM  " . $tableprefix . "categories where parent_id='$ddlCategory'";
	if (mysql_num_rows(mysql_query($checkleafcategory)) > 0) {
            $message .= "* There is a subcategory under the category you have selected.Please select a subcategory!<br>";
    }
    if (!isNotNull($txtProductName)) {
        $message .= "* Product Name cannot be empty! <br>";
    } else {
        $qry = "SELECT  product_name FROM  " . $tableprefix . "products WHERE product_name='" . addslashes($txtProductName) . "' 
		and product_artist_id='".$ddlArtist."' and product_category = '".$ddlCategory."' and product_id <> '".addslashes($productid)."'  ";
        if (mysql_num_rows(mysql_query($qry)) > 0) {
            $message .= "* Product with the same name already exists under the same category!<br>";
        }
    }

	if (!isNotNull($txtProductCode)) {
        $message .= "* Product Code cannot be empty! <br>";
    } else {
        $qry = "SELECT  product_code FROM  " . $tableprefix . "products WHERE product_code='" . addslashes($txtProductCode) . "' 
		 and product_artist_id='".$ddlArtist."' and product_category = '".$ddlCategory."' and product_id <> '".addslashes($productid)."'  ";
        if (mysql_num_rows(mysql_query($qry)) > 0) {
            $message .= "* Product with the same code already exists! Please select a unique code!<br>";
        }
    }
	if (!isNotNull($ddlCategory)) {
        $message .= "* Product Category cannot be empty! <br>";
    }
	if (!isNotNull($ddlArtist)) {
        $message .= "* Product Seller cannot be empty! <br>";
    }
    $txtPrice = doubleval($txtPrice);
    if (!isNotNull($txtPrice)) {
        $message .= "* Product Price cannot be empty! <br>";
    } else {
        if($txtPrice <= 0 ){
			$message .= "* Product Price should be a positive value! <br>";
		}
    }
	if($chkcanship=="Y")
	{
	if (!isNotNull($txtlength)) {
        $message .= "* Product Length cannot be empty! <br>";
    }
	if (!isNotNull($txtwidth)) {
        $message .= "* Product Width cannot be empty! <br>";
    }
	if (!isNotNull($txtheight)) {
        $message .= "* Product Height cannot be empty! <br>";
    }
	}	

	$txtShippingWeight = doubleval($txtShippingWeight);
	if($txtShippingWeight < 0 ){
			$message .= "* Product shipping weight should be a positive value! <br>";
	}
	
	
    $txtStock = doubleval($txtStock);
	if (isNotNull($txtStock)) {
        if($txtStock < 0 ){
			$message .= "* Product Stock should be a positive value! <br>";
		}
    }
	$txtReorderLevel= doubleval($txtReorderLevel);
	if (isNotNull($txtReorderLevel)) {
        if($txtReorderLevel < 0 ){
			$message .= "* Product Reorder Level should be a positive value! <br>";
		}
    }
    $picsmall = $_FILES['userfile'][0];
    $picbig = $_FILES['userfile'][1];

    $picsmallname = $_FILES['userfile']['name'][0];
    $picbigname = $_FILES['userfile']['name'][1];

    $picsmalltype = $_FILES['userfile']['type'][0];
    $picbigtype = $_FILES['userfile']['type'][1];

	$picsmallfilename 	= 	$_FILES['userfile']['name'][0];
	$picsmalltempname 	=	$_FILES['userfile']['tmp_name'][0];
	$picbigfilename 	= 	$_FILES['userfile']['name'][1];
	$picbigtempname		=	$_FILES['userfile']['tmp_name'][1];

	if($picbigname != "")
	{
		$final_image_big = "productlarge_".time().$picbigname;
	}
	else
	{
		$final_image_big = "";
	}
	
	if($picsmallname != "")
	{
		$final_image_small = "productsmall_".time().$picsmallname;
	}
	else
	{
		$final_image_small = "";
	}

	$picsmalldest = $prodimagedir . $picsmallname;
	$picbigdest = $prodimagedir . $picbigname;

	if (!is_readable($prodimagedir) || !is_writable($prodimagedir) || !is_executable($prodimagedir)) {
        $error = true;
        $message .= " * Change the permission of 'products' folder in the root to 777 <br>";
    }
	if ($picsmalltype != "") {
        if (!isValidWebImageType($picsmalltype,$picsmallfilename,$picsmalltempname)) {
            $message .= " * Invalid product picture (small)! Upload an image (jpg/gif/png)" . "<br>";
            $error = true;
        } else {
            if (file_exists($picsmalldest)) {
                $message .= " * Product picture (small) with the same name exists! Please rename the product picture (small) and upload! " . "<br>";
                $error = true;
            }
        }
    }
	if ($picbigtype != "") {
        if (!isValidWebImageType($picbigtype,$picbigfilename,$picbigtempname)) {
            $message .= " * Invalid product picture (big)! Upload an image (jpg/gif/png)" . "<br>";
            $error = true;
        } else {
            if (file_exists($picbigdest)) {
                $message .= " * Product picture (big) with the same name exists! Please rename the product picture (big) and upload! " . "<br>";
                $error = true;
            }
        }
    }
	
/*----Digital Product Block Starts-------*/

		
	if(isNotNull($_FILES['txtProductZip']['name']))
	{
	$uploadfile =ReplaceArrayImage($_FILES['txtProductZip']['name']); 
		$types=array('zip','pdf','rar','psd','opf','azw','lit','pdb','pkg','mp3','mpeg','mp4','avi');
		preg_match('/\.([a-zA-Z]+?)$/', $uploadfile, $matches);
		if(!in_array(strtolower($matches[1]),$types))
					{ // check file format is valid or not 
						$message .= "* Invalid file format for Digital Product! <br>";
					} // end format check 		
	
	}
	
	
/*----Digital Product Block Ends-------*/	

    if ($message != "") { // error
        $message = "<br>Please correct the following errors to continue!<br>" . $message;
    } else { // no error so insert user details
		if($picsmallname != "")
		{
			//checking extension and replace
			$replaceArray=array('jpg','jpeg','gif');
			$findArray=array('JPG','JPEG','GIF');
			
			@list($piName,$ext)=@split("[.]",$final_image_small);
			$final_image_small=$piName.'.'.str_replace($findArray,$replaceArray,$ext);
			//checking extension and replace
		

			move_uploaded_file($_FILES['userfile']['tmp_name'][0], "../products/".$final_image_small);
			
			if($_FILES['userfile']['tmp_name'][0] != "")
			{
				chmod("../products/$final_image_small", 0777);
				
				generateThumbNail("../products/".$final_image_small,"../products/".$final_image_small,120,150);
			}	
			
		}
		if($picbigname != "")
		{
			//checking extension and replace
			$replaceArray=array('jpg','jpeg','gif');
			$findArray=array('JPG','JPEG','GIF');
			
			@list($piName,$ext)=@split("[.]",$final_image_big);
			$final_image_big=$piName.'.'.str_replace($findArray,$replaceArray,$ext);
			//checking extension and replace
		

			move_uploaded_file($_FILES['userfile']['tmp_name'][1], "../products/".$final_image_big);
											
			if($_FILES['userfile']['tmp_name'][1] != "")
			{
				chmod("../products/$final_image_big", 0777);
				
				generateThumbNail("../products/".$final_image_big,"../products/".$final_image_big,400,400);
			}	
			
		}
		$sql = "UPDATE  ".$tableprefix."products SET
			product_name = '".addslashes($txtProductName)."',
			product_code = '".addslashes($txtProductCode)."',
			product_description = '".addslashes($txtDescription)."',
			product_price = '".addslashes($txtPrice)."',
			product_category = '".addslashes($ddlCategory)."',";
			if($picsmallname != ""){
				$sql .= "product_image_small = '".addslashes($final_image_small)."',";
			}
			if($picbigname != ""){
				$sql .= "product_image_big = '".addslashes($final_image_big)."',";
			}
			if($txtlength!=0)
			{
				$sql .= "product_length = '".addslashes($txtlength)."',";
			}
			if($txtwidth!=0)
			{
				$sql .= "product_width = '".addslashes($txtwidth)."',";
			}
			if($txtheight!=0)
			{
				$sql .= "product_height = '".addslashes($txtheight)."',";
			}
			$sql .=" product_artist_id = '".addslashes($ddlArtist)."',";
			$sql .=" product_stock = '".addslashes($txtStock)."',";
			$sql .=" reorder_level = '".addslashes($txtReorderLevel)."',";
			$sql .=" nproduct_shipping_weight = '".addslashes($txtShippingWeight)."',";
			$sql .=" discount = '".addslashes($txtDiscount)."',";
		$sql .=" discountdescription = '".addslashes($txtDiscountDesc)."'";
			$sql .=" WHERE product_id = '".addslashes($productid)."' ";
		//echo $sql;
		mysql_query($sql) or die (mysql_error());
		//update category count
		if($oldcategory!=$ddlCategory){
		   	 $routesql="Select route from " . $tableprefix . "categories where category_id ='$oldcategory'";
	         $result=mysql_query($routesql);
	         $row = mysql_fetch_array($result);
	         $route = $row["route"];
			 $qryupdatecatcount="update " . $tableprefix . "categories set count=count-1 where category_id in($route)";
			 mysql_query($qryupdatecatcount);

			 $routesql="Select route from " . $tableprefix . "categories where category_id ='$ddlCategory'";
	         $result=mysql_query($routesql);
	         $row = mysql_fetch_array($result);
	         $route = $row["route"];
			 $qryupdatecatcount="update " . $tableprefix . "categories set count=count+1 where category_id in($route)";
			 mysql_query($qryupdatecatcount);

		}

/*-----------Digital Product Block Starts-----------------*/

		if($_POST['txtDigitalProduct'] == 'Y' && $message == "")
		{

			$assignedname = randomDigitalProduct()."_".$_FILES['txtProductZip']['name'];
								
			if (move_uploaded_file($_FILES['txtProductZip']['tmp_name'], "../digital_product/" . $assignedname))
			{
			
				chmod("../digital_product/$assignedname", 0777);
			
				$update_digital_product = "UPDATE ".$tableprefix."digital_product
										   SET vdigital_product_name = ".GetSQLValueString($assignedname,"text")."
											WHERE ndigital_productid = ".$productid;
				
				mysql_query($update_digital_product) or die(mysql_error());		
				
				unlink("../digital_product/".$_POST['digital_image_buffer']);				  
			
			}
			
		}	

/*-----------Digital Product Block Ends-----------------*/
		
		$message = "<br>Changes saved successfully!";
    }
} else if ($_POST["btnDelete"] == "Delete") {
	$sql = "DELETE FROM  ".$tableprefix."products
			WHERE product_id = '".addslashes($productid)."'
			";
	mysql_query($sql);

	     $routesql="Select route from " . $tableprefix . "categories where category_id ='$ddlCategory'";
         $result=mysql_query($routesql);
         $row = mysql_fetch_array($result);
         $route = $row["route"];
		 $qryupdatecatcount="update " . $tableprefix . "categories set count=count-1 where category_id in($route)";
		 mysql_query($qryupdatecatcount);

	header("Location:catalog.php?catid=$ddlCategory");
	exit;
}

$catlist = make_selectlist(0, 0);
$artistlist = makeArtistList();

$sql = "SELECT * FROM ".$tableprefix."products WHERE product_id= '".addslashes($productid)."' ";
$result = mysql_query($sql);
if(mysql_num_rows($result) != 0){
	$row = mysql_fetch_array($result);
	$txtProductName =$row["product_name"];
	$txtProductCode =$row["product_code"];
	$txtDescription =$row["product_description"];
	$txtPrice = $row["product_price"];
	$ddlCategory = $row["product_category"];
	$ddlArtist = $row["product_artist_id"];
	$imgsmall = $row["product_image_small"];
	$imgbig = $row["product_image_big"];
	$txtStock = $row["product_stock"];
	
	$txtlength =$row["product_length"];
	$txtwidth =$row["product_width"];
	$txtheight =$row["product_height"];
	
	$txtReorderLevel = $row["reorder_level"];
	$txtDiscount=$row["discount"];
	$txtDiscountDesc=$row["discountdescription"];
	$oldcategory=$ddlCategory;
	
/*-------Product shipping weight starts------*/	
	
	$txtShippingWeight = $row["nproduct_shipping_weight"];
	
	
/*-------Product shipping weight ends------*/
	
/*-----------Digital Product Block Starts-----------------*/

	if($row["vdigital_product"] == "Y")
	{
		$digital_product_display = "";
		
		$canshipblock="none";
		
		$select_digital_product_zip = "SELECT vdigital_product_name FROM ".$tableprefix."digital_product 
									   WHERE ndigital_productid = ".$row["product_id"];
		$result_digital_product_zip = mysql_query($select_digital_product_zip);	
		
		if(mysql_num_rows($result_digital_product_zip) > 0)
		{
		
			$digital_product_zip_row = mysql_fetch_assoc($result_digital_product_zip);
					
		}						   
		
		
	}
	else
	{
		$digital_product_display = "none";		
		$canshipblock="";
	}		
	
/*-----------Digital Product Block Ends-----------------*/	

}

include "../includes/htmltop.php";
?>
<script type="text/javascript" src="<?php echo SITE_URL?>/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
	window.onload = function()
	{
		CKEDITOR.replace( 'editor1' );
	};
</script>
<SCRIPT>
function confirmDelete(){
	if(confirm("Are you sure you want to delete this record?") ){
		return true;
	}
	return false;
}

function openWindow(id)
{
	var url = "../viewimage.php?id="+id;
	window.open(url,"Image","height=500,width=500,scrollbars=yes");
}

</SCRIPT>

<body>
<center>
		
		<div align="left" id="layout">
		
		
				
				
				<!--header area start -->
<?php

	include_once("../includes/topheader_admin.php")

?>
				
				<!--header area end -->
				
				
				
				
				<div align="left" class="main_body">
				<!--main body start -->
				
				
				
<?php
		include_once("../includes/admintopmenu.php")
?>		
																					
								
					<div align="left" class="content_area">
					
					<!--content area start -->
							
					<div align="left" class="page_title">Product Editing</div>
					<div align="center" class="text_information grey_tr"><?php echo $message?></div>
            		<br>
											
					<div align="left">
					
					<form name="frmProductDetails" action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST" enctype="multipart/form-data">
					<input type="hidden" name="productid" value="<?php echo $productid;?>" >
					<input type="hidden" name="oldcategory" value="<?php echo $oldcategory;?>" >
					
					<table cellpadding="0" cellspacing="0" width="100%" class="manage_table">
						
						<tr><td colspan="3">&nbsp;</td></tr>
						<tr><td colspan="3" align="left">
						<?php
						  if ($row["product_image_big"]!= "" and $row["product_image_small"]!= "") {
								 $imageurl =  "<a href='#' onclick='openWindow(".$productid.");'> ";
								  if(!function_exists('gd_info')){
									$imageurl .= "<img src='".$prodimagedir.urlencode($row["product_image_small"])."' border='0' width='100' height='100' >";
								  }else{
									$imageurl .= "<img src='../getimagethumbnail.php?imagename=".urlencode($row["product_image_small"])."' border='0' >";
								   }
								$imageurl .= "</a>";

							}else if($row["product_image_small"]!= ""){
								if(!function_exists('gd_info')){
									$imageurl .= "<img src='".urlencode($prodimagedir.$row["product_image_small"])."' border='0' width='100' height='100' >";
								  }else{
									$imageurl .= "<img src='../getimagethumbnail.php?imagename=".urlencode($row["product_image_small"])."' border='0' >";
								   }
							}

						echo $imageurl;

						?>

						<?php //if($imgsmall!=""){ echo "&nbsp;<img src='$prodimagedir".urlencode($imgsmall) ."' >"; }?></td></tr>
						<tr><td colspan="3">&nbsp;</td></tr>
						<tr><td align="left" width="25%">Product Name &nbsp; <span class="required">*</span></td><td width="5%">&nbsp;</td><td width="70%" align="left"><input class="textbox" type="text" value="<?php echo htmlentities($txtProductName);?>" name="txtProductName" size="50" maxlength="100"></td></tr>
						<tr><td align="left" width="25%">Product Code &nbsp; <span class="required">*</span></td><td width="5%">&nbsp;</td><td align="left"><input class="textbox" type="text" value="<?php echo htmlentities($txtProductCode);?>" name="txtProductCode" size="50" maxlength="100"></td></tr>
						<tr><td align="left" valign="top">Description&nbsp;<span class="required">*</span></td><td >&nbsp;</td><td align="left">
						<textarea id="editor1" name="txtDescription"><?php echo nl2br(stripslashes($txtDescription));?></textarea>
						
						<?php
										 $sBasePath                      = "../FCKeditor/";
										//echo $sBasePath                      = dirname(dirname($_SERVER['PHP_SELF'])) == "/" ? "/includes/fckeditor/" : dirname(dirname($_SERVER['PHP_SELF'])) ."/includes/fckeditor/";
										$oFCKeditor 					= new FCKeditor('txtDescription') ;
										$oFCKeditor->BasePath			= $sBasePath ;
										$oFCKeditor->Value				= stripslashes($txtDescription);
										//$oFCKeditor->Config['SkinPath'] = 'editor/skins/silver/' ;
										$oFCKeditor->Width  = '100%' ;
										$oFCKeditor->Height = '330' ;
										$oFCKeditor->Create() ;
									?>
						
						</td></tr>
						<tr><td align="left" >Price&nbsp;<span class="required">*</span></td>
							<td >&nbsp;</td>
							<td align="left"><input type="text" class="textbox" value="<?php echo htmlentities($txtPrice);?>" name="txtPrice" size="30" maxlength="100">&nbsp;<b>USD</b></td>
						</tr>
						<tr>
															  <td colspan="3" align="left"> <div id="canshipBlock" style="display:<?php echo $canshipblock;?>">
															  <table cellpadding="0" cellspacing="0" border="0" width="100%">
															  <tr>
															    <td colspan="3"><span class="required"><strong>*</strong></span><strong> Length ,Width ,Height Fields are required for Canada Post Shipping </strong></td>
															    </tr>
															  <tr>
															  <td width="25%">Length (cm)</td>
															   <td width="5%">&nbsp;</td>
															    <td width="70%"><input name="txtlength" type="text" id="txtlength" size="10" maxlength="3" value="<?php echo $txtlength;?>"></td>
															  </tr>
															   <tr>
															  <td>Width (cm) </td>
															   <td>&nbsp;</td>
															    <td><input name="txtwidth" type="text" size="10" maxlength="3" value="<?php echo $txtwidth;?>"></td>
															  </tr>
															   <tr>
															     <td>Height (cm</td>
															     <td>&nbsp;</td>
															     <td><input name="txtheight" type="text" size="10" maxlength="3" value="<?php echo $txtheight;?>"></td>
														        </tr>
															  </table>
															  </div>
															 </td>
														  </tr>
						<tr><td align="left" >Category&nbsp;<span class="required">*</span></td><td align="left">&nbsp;</td>
							<td align="left">
							<?php echo makeDropDownList("ddlCategory", $catlist, $ddlCategory, true,"textbox", $properties, $behaviors)?>
							</td>
						</tr>
						<tr><td align="left" >Seller&nbsp;<span class="required">*</span></td><td >&nbsp;</td>
							<td align="left">
							<?php echo makeDropDownList("ddlArtist",$artistlist, $ddlArtist, true, "textbox", $properties, $behaviors)?>
							</td>
						</tr>
						<tr><td align="left" >Stock Available&nbsp;</td><td >&nbsp;</td><td align="left"><input type="text" class="textbox" value="<?php echo htmlentities($txtStock);?>" name="txtStock" size="30" maxlength="100">&nbsp;<b>no(s)</b></td></tr>
						<tr><td align="left" >Stock Reorder Level&nbsp;</td><td >&nbsp;</td><td align="left"><input type="text"  class="textbox" value="<?php echo htmlentities($txtReorderLevel);?>" name="txtReorderLevel" size="30" maxlength="100">&nbsp;<b>no(s)
																	<br><span class="required">*</span>&nbsp;Define a minimum stock level,and reorder when stock reaches that level.</b></td></tr>
						
						<tr>
							<td align="left">Product Shipping Weight&nbsp;</td>
							<td>&nbsp;</td>
							<td align='left'><input type="text"  value="<?php echo htmlentities($txtShippingWeight);?>"  class="textbox" name="txtShippingWeight" size="30">&nbsp;<b>lbs</b></td>
						</tr>
				<!--Digital Product Block Starts-->		
						
						<tr>
							<td colspan="3">
								<div id="digitalProductBlock" style="display:<?php echo $digital_product_display?>">
									<table cellpadding="2" cellspacing="2" width="100%" border="0">
										<tr>
											<td width="30%" align="left">Upload Digital Product&nbsp;</td>
											<td width="33%" align='left'>
											<input type="file" class="textbox" name="txtProductZip">
											<input type="hidden" name="digital_image_buffer" value="<?php echo $digital_product_zip_row['vdigital_product_name']?>">
											<input type="hidden" name="txtDigitalProduct" value="<?php echo $row["vdigital_product"]?>">
											</td>
											<td width="37%" class="text_information" align="left">File Type :&nbsp;.zip,.pdf, .rar , .psd , .opf, azw,.lit,.pdb, .pkg,.mp3,.mpeg,.mp4,.avi </td>
										</tr>
									</table>
								</div>		
							</td>
						</tr>
						
				<!--Digital Product Block Ends-->		

						<tr><td align="left" >Product Image (Small)&nbsp;</td><td >&nbsp;</td><td align="left"><input type="file" value="" name="userfile[]" size="40" class="textbox"><?php if($imgsmall!=""){ echo "&nbsp;Existing: ".urldecode($imgsmall); }?></td></tr>
						<tr><td align="left" >Product Image (Big)&nbsp;</td><td >&nbsp;</td><td align="left"><input type="file" value="" name="userfile[]" size="40" class="textbox"><?php if($imgbig!=""){ echo "&nbsp;Existing: ".$imgbig; }?></td></tr>
						<tr><td align="left" >Discount(%)&nbsp;</td><td >&nbsp;</td>
						<td align="left">
						<input type="text"  class="textbox" value="<?php echo htmlentities($txtDiscount);?>" name="txtDiscount" size="3" maxlength="3"></td></tr>

						<tr><td align="left" >Discount Description&nbsp;</td><td >&nbsp;</td>
						<td align="left">
						<textarea name="txtDiscountDesc"  class="textbox" rows=5 cols="40"><?php echo htmlentities($txtDiscountDesc);?></textarea>
						</td></tr>
						<tr>
							<td>Product Images [Bulk Upload]</td>
							<td></td>
							<td><a style="cursor:pointer" href="product_viewimages_add.php" title="Bulk Upload"><img src="../images/bulk_upload.jpg" border="0"></a>
						    <input type="hidden" name="enable_canadapost" value="<?php echo $chkcanship;?>"></td>
						</tr>
						<tr><td colspan="3">&nbsp;</td></tr>
						<tr><td colspan="3" align="center">
								<input type="submit" value="Save Changes" name="btnSaveChanges" class="button">&nbsp;&nbsp;
								<input type="submit" class="button" value="Delete" name="btnDelete" onClick="return confirmDelete();" >&nbsp;&nbsp;
								<input type="button" class="button" value="Back To Catalog" name="btnBack" onClick="window.location.href='catalog.php?catid=<?php echo $ddlCategory?>';" >&nbsp;&nbsp;
								<input type="button" class="button" value="Back To List Products" name="btnBack" onClick="window.location.href='listProducts.php?page=<?php echo $_GET['page']?>';" >
							</td>
						</tr>
						<tr>
							<td colspan="3" align="left">
								<div align="left" class="blackbartextCopy">
								<br>
								<br>
									<font color="RED">**</font>&nbsp;Image (Small) Best Size - 120 X 150 <br>
									<font color="RED">**</font>&nbsp;Image (Big) Best Size - 400 X 400
								</div>
							</td>
						</tr>
					</table>
																									</form>											

						</div>
						
						
				<!--content area end-->
								
				</div>
				
								
					<div align="left" class="clear_float"><img src="<?php echo $imagefolder;?>/clear.gif" alt="" width="1" height="1" /></div>
				<!--main body end -->
				</div>
				
				
<?php
	include "../includes/footer.php";
?>