123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <?php
- require_once('conn.php');
- require_once('functions.php');
- // Check login status
- checkLogin("信息管理");
- // Initialize variables
- $id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
- $keys = isset($_GET['Keys']) ? urlencode($_GET['Keys']) : '';
- $page = isset($_GET['Page']) ? $_GET['Page'] : 1;
- $category_id = isset($_GET['category_id']) ? intval($_GET['category_id']) : 0;
- // Get the return URL
- $href_str = "products.php?keys=" . $keys . "&Page=" . $page;
- if ($category_id) {
- $href_str .= "&category_id=" . $category_id;
- }
- // Check if the product exists
- if ($id <= 0) {
- header("Location: " . $href_str);
- exit();
- }
- // Fetch product data
- $sql = "SELECT * FROM products WHERE id = " . (int)$id;
- $result = mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) <= 0) {
- // Product not found, redirect
- header("Location: " . $href_str);
- exit();
- }
- $row = mysqli_fetch_assoc($result);
- $product_name = htmlspecialcharsFix($row['ProductName']);
- $product_img = htmlspecialcharsFix($row['ProductImg']);
- $unit = htmlspecialcharsFix($row['unit']);
- $moq = htmlspecialcharsFix($row['moq']);
- $nosale = $row['nosale'];
- $note = htmlspecialcharsFix($row['note']);
- $tips = htmlspecialcharsFix($row['tips']);
- $category_id = $row['category_id'] ? intval($row['category_id']) : 0;
- ?>
- <!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=utf-8" />
- <title>编辑产品</title>
- <link rel="stylesheet" href="css/common.css" type="text/css" />
- <script language="javascript" src="js/jquery-1.7.2.min.js"></script>
- <script type="text/javascript" src="js/js.js"></script>
- <script type="text/javascript" src="js/SearchArea.js"></script>
- <script type="text/javascript" src="xheditor-1.1.9/xheditor-1.1.9-zh-cn.min.js"></script>
- </head>
- <body>
- <div id="man_zone">
- <form name="form1" method="post" action="save_product.php">
- <table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
- <tbody>
- <tr>
- <th width="8%">产品名称</th>
- <td><input type="text" id="ProductName" name="ProductName" value="<?php echo $product_name; ?>" class="txt1" />
- <input type="hidden" name="id" value="<?php echo $id; ?>" />
- <input type="hidden" name="keys" value="<?php echo $keys; ?>" />
- <input type="hidden" name="page" value="<?php echo $page; ?>" />
- <input type="hidden" name="category_id" value="<?php echo $category_id; ?>" />
- </td>
- </tr>
- <tr>
- <th width="8%">产品分类</th>
- <td>
- <select name="category_id" id="category_id" class="select1">
- <option value="0">-- 请选择分类 --</option>
- <?php
- // Build category tree
- $category_data = buildCategoryTree($conn);
- $cat_tree = $category_data['tree'];
-
- // Output options
- outputCategoryOptions($cat_tree, $category_id);
- ?>
- </select>
- </td>
- </tr>
- <tr>
- <th width="8%">产品图片</th>
- <td><input type="text" id="ProductImg" name="ProductImg" placeholder="186x*186px" value="<?php echo $product_img; ?>" class="txt1" style="width:390px;float:left;" />
- <iframe src="uploadfile.php" frameborder="0" scrolling="no" style="width:400px;height:22px;float:left;margin-left:10px;"></iframe></td>
- </tr>
- <tr>
- <th width="8%">计价单位</th>
- <td><input type="text" id="unit" name="unit" value="<?php echo $unit; ?>" class="txt1"/></td>
- </tr>
- <tr>
- <th width="8%">起订数量</th>
- <td><input type="text" id="moq" name="moq" value="<?php echo $moq; ?>" class="txt1"/></td>
- </tr>
- <tr>
- <th width="8%">默认售价</th>
- <td>
- <div class="Price">
- <?php
- $price_sql = "SELECT num, price FROM price WHERE AreaId = 0 AND productId = " . $id . " ORDER BY num ASC";
- $price_result = mysqli_query($conn, $price_sql);
- if (mysqli_num_rows($price_result) > 0) {
- while ($price_row = mysqli_fetch_assoc($price_result)) {
- ?>
- <div class="priceitem">
- <label>≥</label>
- <input type="number" class="txt3 num" name="num[]" value="<?php echo $price_row['num']; ?>">
- <label class="unit"><?php echo $unit; ?></label>
- <label>售价</label>
- <input type="text" class="txt3 price" name="price[]" value="<?php echo $price_row['price']; ?>">
- <label>RMB</label>
- <span class="additem"></span>
- <span class="delitem"></span>
- <span class="note"></span>
- </div>
- <?php
- }
- } else {
- ?>
- <div class="priceitem">
- <label>≥</label>
- <input type="number" class="txt3 num" name="num[]">
- <label class="unit"><?php echo $unit; ?></label>
- <label>售价</label>
- <input type="text" class="txt3 price" name="price[]">
- <label>RMB</label>
- <span class="additem"></span>
- <span class="delitem"></span>
- <span class="note"></span>
- </div>
- <?php
- }
- ?>
- </div>
- </td>
- </tr>
- <tr>
- <th width="8%">不报价地区</th>
- <td>
- <ul class="areadd">
- <?php
- if (!empty($nosale)) {
- // 确保nosale是逗号分隔的字符串格式
- $nosale_str = is_array($nosale) ? implode(',', $nosale) : $nosale;
- $area_sql = "SELECT id, countryName FROM country WHERE id IN(" . $nosale_str . ")";
- $area_result = mysqli_query($conn, $area_sql);
- while ($area_row = mysqli_fetch_assoc($area_result)) {
- ?>
- <li><input type="hidden" name="nosale[]" value="<?php echo $area_row['id']; ?>"><span class="cname"><?php echo htmlspecialcharsFix($area_row['countryName']); ?></span><span class="close"></span></li>
- <?php
- }
- }
- ?>
- </ul>
- <input type="text" id="AreaSearch" class="fastsearch">
- <div id="arealist" class="productlist"><ul></ul></div>
- </td>
- </tr>
- <tr>
- <th width="8%">不报价处理方式</th>
- <td><input type="text" id="note" name="note" value="<?php echo $note; ?>" class="txt1"/></td>
- </tr>
- <tr>
- <th width="8%">备注</th>
- <td><input type="text" id="tips" name="tips" value="<?php echo $tips; ?>" class="txt1"/></td>
- </tr>
- <tr>
- <th></th>
- <td colspan="2">
- <input type="submit" name="save" value="确定" class="btn1" />
- <input type="reset" name="reset" value="重置" class="btn1" />
- <input type="button" value="返回" class="btn1" onClick="location.href='<?php echo $href_str; ?>'" />
- </td>
- </tr>
- </tbody>
- </table>
- </form>
- </div>
- </body>
- </html>
- <?php mysqli_close($conn); ?>
|