|
@@ -0,0 +1,67 @@
|
|
|
+<?php
|
|
|
+require_once 'conn.php';
|
|
|
+require_once 'functions.php';
|
|
|
+
|
|
|
+checklogin("信息管理");
|
|
|
+// Get product ID
|
|
|
+$product_id = isset($_POST['product_id']) ? (int)$_POST['product_id'] : 0;
|
|
|
+
|
|
|
+if (empty($product_id)) {
|
|
|
+ echo '<p class="error-message" style="color:red;text-align:center;padding:10px;">无效的产品ID</p>';
|
|
|
+ exit;
|
|
|
+}
|
|
|
+
|
|
|
+// Get all specifications for this product
|
|
|
+$sql = "SELECT ps.id as spec_id, ps.spec_name, ps.sort_order, ps.spec_value, ps.spec_code,
|
|
|
+ ps.min_order_quantity, p.id as product_id, p.unit
|
|
|
+ FROM product_specifications ps
|
|
|
+ JOIN products p ON ps.product_id = p.id
|
|
|
+ WHERE ps.product_id = $product_id
|
|
|
+ ORDER BY ps.sort_order, ps.id";
|
|
|
+
|
|
|
+$result = $conn->query($sql);
|
|
|
+$html = '';
|
|
|
+
|
|
|
+if ($result && $result->num_rows > 0) {
|
|
|
+ while ($row = $result->fetch_assoc()) {
|
|
|
+ $product_id = $row['product_id'];
|
|
|
+ $spec_id = $row['spec_id'];
|
|
|
+ $spec_name = htmlspecialcharsFix($row['spec_name']);
|
|
|
+ $spec_value = htmlspecialcharsFix($row['spec_value'] ?? '');
|
|
|
+ $spec_code = htmlspecialcharsFix($row['spec_code'] ?? '');
|
|
|
+ $unit = htmlspecialcharsFix($row['unit']);
|
|
|
+ $min_qty = !empty($row['min_order_quantity']) ? intval($row['min_order_quantity']) : 1;
|
|
|
+
|
|
|
+ // 构建完整的规格显示文本
|
|
|
+ $spec_display = $spec_name;
|
|
|
+ if (!empty($spec_value)) {
|
|
|
+ $spec_display .= ': ' . $spec_value;
|
|
|
+ }
|
|
|
+ if (!empty($spec_code)) {
|
|
|
+ $spec_display .= ' <span style="font-size:12px;color:#666;">(编码: ' . $spec_code . ')</span>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $html .= '<div class="specitem">
|
|
|
+ <div class="specdelete" title="删除此规格">✕</div>
|
|
|
+ <input type="hidden" name="spec_product_id[]" value="' . $product_id . '">
|
|
|
+ <input type="hidden" name="spec_id[]" value="' . $spec_id . '">
|
|
|
+
|
|
|
+ <span class="spec-label">规格:</span>
|
|
|
+ <span class="spec-name">' . $spec_display . '</span>
|
|
|
+
|
|
|
+ <span class="spec-label" style="margin-left:15px;">起订数量:</span>
|
|
|
+ <input type="number" class="spec-small-input" name="spec_moq[]" value="' . $min_qty . '" min="1">
|
|
|
+ <span class="unit">' . $unit . '</span>
|
|
|
+
|
|
|
+ <span class="spec-label" style="margin-left:15px;">售价:</span>
|
|
|
+ <input type="text" class="spec-small-input" name="spec_price[]" value="" required min="0.01">
|
|
|
+ <span>RMB</span>
|
|
|
+ </div>';
|
|
|
+ }
|
|
|
+ echo $html;
|
|
|
+} else {
|
|
|
+ echo '<p style="padding:10px; background:#fff3f3; color:#d9534f; text-align:center; margin:10px 0; border-radius:4px;">该产品没有规格信息,请先在产品管理中添加规格</p>';
|
|
|
+}
|
|
|
+
|
|
|
+$conn->close();
|
|
|
+?>
|