<?
session_start();
?><?
require_once("../../config/configDB.php");
require("../inc/yqrdb.php");
require("../inc/resizeToFile.func.php");
$mydb=new yqrdb($config_db);
if(isset($_POST["action"]))
{
//echo "µ¥»÷µÄÌá½»°´Å¥!";
$id=$_POST["id"];
$id_category=$_POST["id_category"];
$id_manufacturer=$_POST["id_manufacturer"];
$pos=$_POST["pos"];
$title=$_POST["title"];
$price=$_POST["price"];
$description=$_POST["description"];
$content=$_POST["content"];
//---------------------------------------------------ÉÏ´«´úÂ뿪ʼ
$iconurl=$_FILES["picture"]["name"];
$picture=basename($iconurl);
$isUploaded=false;
if(move_uploaded_file($_FILES["picture"]["tmp_name"],"./".$picture))
{
echo "ÉÏ´«³É¹¦!";
$toDir="../../web/img/products";
resizeToFile($picture,80,80,$toDir."/small/".$picture,100);
resizeToFile($picture,120,120,$toDir."/medium/".$picture,100);
resizeToFile($picture,500,500,$toDir."/large/".$picture,100);
unlink($picture);
$isUploaded=true;
}
//---------------------------------------------------ÉÏ´«´úÂë½áÊø
$active=$_POST["active"];
$measuring_unit=$_POST["measuring_unit"];
$technical_details=$_POST["technical_details"];
if($isUploaded){
$sql="update ".$config_table["product"]." set id_category=$id_category,id_manufacturer=$id_manufacturer,pos=$pos,title='$title',price=$price,description='$description',content='$content',picture='$picture',active=$active,measuring_unit='$measuring_unit',technical_details='$technical_details' where id=$id";
}else{
$sql="update ".$config_table["product"]." set id_category=$id_category,id_manufacturer=$id_manufacturer,pos=$pos,title='$title',price=$price,description='$description',content='$content',active=$active,measuring_unit='$measuring_unit',technical_details='$technical_details' where id=$id";
}
$a=$mydb->executeUpdate($sql);
if($a)
{
echo "³É¹¦ÐÞ¸Ä!<br/>";
}
//echo "Ìá½»½áÊø!";
}
$sql_show="select * from ".$config_table["product"]." where id=".$_GET["id"];
$arr=$mydb->executeQuery($sql_show);
//print_r($arr);
$id=$arr[0]["id"];
$id_category=$arr[0]["id_category"];
$id_manufacturer=$arr[0]["id_manufacturer"];
$pos=$arr[0]["pos"];
$title2=$arr[0]["title"];
$price=$arr[0]["price"];
$description=$arr[0]["description"];
$content=$arr[0]["content"];
$picture=$arr[0]["picture"];
$active=$arr[0]["active"];
$measuring_unit=$arr[0]["measuring_unit"];
$technical_details=$arr[0]["technical_details"];
//$=$arr[0][""];
$sql_ctg="select * from ".$config_table["category"]." where 1";
$arr_ctg=$mydb->executeQuery($sql_ctg);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Ð޸IJúÆ·ÐÅÏ¢</title>
<link href="../css/red_theme.css" rel="stylesheet" type="text/css" />
</head>
<body>
<? include("top_bar.php"); ?>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1" style="width:500px">
<input type="hidden" name="id" value="<?=$id?>">
<a href="javascript:history.go(-1);">ºóÍË</a>
<table><tr><td>
<table width="347" border="0" cellpadding="3">
<tr>
<td width="85">Ñ¡Ôñ·ÖÀà:</td>
<td width="244">
<select name="id_category">
<? for($i=0;$i<count($arr_ctg);$i++){
$title=$arr_ctg[$i]["title"];
$id=$arr_ctg[$i]["id"];
?>
<option value="<?=$id?>" <? if($id==$id_category){?> selected<? }?>>
<?=$title?></option>
<? } ?>
</select> </td>
</tr>
<tr>
<td>ÌṩÉÌ:</td>
<td>
<input name="id_manufacturer" type="text" value="<?=$id_manufacturer?>" /> </td>
</tr>
<tr>
<td>λÖÃ:</td>
<td>
<input name="pos" type="text" value="<?=$pos?>" /> </td>
</tr>
<tr>
<td>±êÌâ:</td>
<td>
<input type="text" name="title" value="<?=$title2?>" /> </td>
</tr>
<tr>
<td>¼Û¸ñ:</td>
<td><input type="text" name="price" value="<?=$price?>"/></td>
</tr>
<tr>
<td>ÃèÊö:</td>
<td>
<textarea name="description" rows="5"><?=$description?></textarea></td>
</tr>
<tr>
<td>ÄÚÈÝ:</td>
<td>
<textarea name="content" rows="5"><?=$content?></textarea>
</td>
</tr>
<tr>
<td>ͼƬ:</td>
<td>
<input type="file" name="picture" /></td>
</tr>
<tr>
<td>״̬:</td>
<td>
<input name="active" type="radio" value="1" <? if($active==1){ ?>checked="checked" <? } ?> /> yes
<input type="radio" name="active" value="0" <? if($active==0){ ?>checked="checked" <? } ?>/>
no </td>
</tr>
<tr>
<td>µ¥Î»:</td>
<td>
<input type="text" name="measuring_unit" value="<?=$measuring_unit?>" /> </td>
</tr>
<tr>
<td>Ïêϸ:</td>
<td height="5"><textarea name="technical_details" rows="5"><?=$technical_details?></textarea></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Ìá½»" /></td>
<td><input type="reset" name="Submit2" value="ÖØÖÃ" />
<input type="hidden" name="action" value="create"/>
</td>
</tr>
</table>
</td><td>
<img src="../../web/img/products/small/<?=$picture?>" border="0"/>
</td></tr></table>
</form>
</body>
</html>