#176 상품선택옵션 등록 추가

This commit is contained in:
chicpro
2013-05-21 18:11:00 +09:00
parent 1a28b508b3
commit 2f99359626
3 changed files with 317 additions and 6 deletions

View File

@ -338,6 +338,129 @@ $pg_anchor ='<ul class="anchor">
<label for="chk_all_it_origin">전체적용</label>
</td>
</tr>
<?php
$opt_subject = explode(',', $it['it_option_subject']);
?>
<tr>
<th scope="row">상품선택옵션</th>
<td colspan="2">
<table class="frm_tbl">
<tbody>
<tr>
<th>옵션명</th>
<th>옵션항목(,로 구분)</th>
</tr>
<tr>
<td><input type="text" id="opt1_subject" name="opt1_subject" value="<?php echo $opt_subject[0]; ?>" class="frm_input" size="15" /></td>
<td><input type="text" id="opt1" name="opt1" value="" class="frm_input" size="50" /></td>
<td rowspan="3"><button type="button" id="option_table_create">옵션목록생성</button></td>
</tr>
<tr>
<td><input type="text" id="opt2_subject" name="opt2_subject" value="<?php echo $opt_subject[1]; ?>" class="frm_input" size="15" /></td>
<td><input type="text" id="opt2" name="opt2" value="" class="frm_input" size="50" /></td>
</tr>
<tr>
<td><input type="text" id="opt3_subject" name="opt3_subject" value="<?php echo $opt_subject[2]; ?>" class="frm_input" size="15" /></td>
<td><input type="text" id="opt3" name="opt3" value="" class="frm_input" size="50" /></td>
</tr>
</tbody>
</table>
<div id="option_table"><?php include_once(G4_ADMIN_PATH.'/shop_admin/itemoption.php'); ?></div>
</td>
</tr>
<script>
$(function() {
<?php if($it['it_id'] && $po_run) { ?>
//옵션항목설정
var arr_opt1 = new Array();
var arr_opt2 = new Array();
var arr_opt3 = new Array();
var opt1 = opt2 = opt3 = '';
$(".opt1-cell").each(function() {
opt1 = $(this).text();
if(opt1 && $.inArray(opt1, arr_opt1) == -1)
arr_opt1.push(opt1);
});
$(".opt2-cell").each(function() {
opt2 = $(this).text();
if(opt2 && $.inArray(opt2, arr_opt2) == -1)
arr_opt2.push(opt2);
});
$(".opt3-cell").each(function() {
opt3 = $(this).text();
if(opt3 && $.inArray(opt3, arr_opt3) == -1)
arr_opt3.push(opt3);
});
$("input[name=opt1]").val(arr_opt1.join());
$("input[name=opt2]").val(arr_opt2.join());
$("input[name=opt3]").val(arr_opt3.join());
<?php } ?>
// 옵션목록생성
$("#option_table_create").click(function() {
var opt1_subject = $.trim($("#opt1_subject").val());
var opt2_subject = $.trim($("#opt2_subject").val());
var opt3_subject = $.trim($("#opt3_subject").val());
var opt1 = $.trim($("#opt1").val());
var opt2 = $.trim($("#opt2").val());
var opt3 = $.trim($("#opt3").val());
var $option_table = $("#option_table");
if(!opt1_subject || !opt1) {
alert("옵션명과 옵션항목을 입력해 주십시오.");
return false;
}
$.post(
"<?php echo G4_ADMIN_URL; ?>/shop_admin/itemoption.php",
{ opt1_subject: opt1_subject, opt2_subject: opt2_subject, opt3_subject: opt3_subject, opt1: opt1, opt2: opt2, opt3: opt3 },
function(data) {
$option_table.removeClass("a");
$option_table.empty().html(data);
if($option_table.height() > 500) {
$option_table.addClass("a");
}
}
);
});
// 모두선택
$("input[name=opt_chk_all]").live("click", function() {
if($(this).is(":checked")) {
$("input[name='opt_chk[]']").attr("checked", true);
} else {
$("input[name='opt_chk[]']").attr("checked", false);
}
});
// 선택삭제
$("#sel_option_delete").live("click", function() {
var $el = $("input[name='opt_chk[]']:checked");
if($el.size() < 1) {
alert("삭제하려는 옵션을 하나 이상 선택해 주십시오.");
return false;
}
$el.closest("tr").remove();
});
// 일괄적용
$("#opt_value_apply").live("click", function() {
var opt_price = $.trim($("#opt_com_price").val());
var opt_stock = $.trim($("#opt_com_stock").val());
var opt_noti = $.trim($("#opt_com_noti").val());
var opt_use = $("#opt_com_use").val();
$("input[name='opt_price[]']").val(opt_price);
$("input[name='opt_stock_qty[]']").val(opt_stock);
$("input[name='opt_noti_qty[]']").val(opt_noti);
$("select[name='opt_use[]']").val(opt_use);
});
});
</script>
<tr>
<th scope="row"><label for="it_basic">기본설명</label></th>
<td>
@ -1058,12 +1181,6 @@ function categorychange(f)
//f.it_explan_html[ca_explan_html[idx]].checked = true;
f.it_stock_qty.value = ca_stock_qty[idx];
f.it_sell_email.value = ca_sell_email[idx];
f.it_opt1_subject.value = ca_opt1_subject[idx];
f.it_opt2_subject.value = ca_opt2_subject[idx];
f.it_opt3_subject.value = ca_opt3_subject[idx];
f.it_opt4_subject.value = ca_opt4_subject[idx];
f.it_opt5_subject.value = ca_opt5_subject[idx];
f.it_opt6_subject.value = ca_opt6_subject[idx];
}
}

View File

@ -289,6 +289,33 @@ sql_query(" delete from {$g4['shop_item_relation_table']} where it_id2 = '$it_id
// 이벤트상품을 우선 삭제함
sql_query(" delete from {$g4['shop_event_item_table']} where it_id = '$it_id' ");
// 선택옵션
sql_query(" delete from {$g4['shop_item_option_table']} where io_type = '0' and it_id = '$it_id' "); // 기존선택옵션삭제
$option_count = count($_POST['opt_id']);
if($option_count) {
// 실재하는 1차 옵션항목
$arr_opt1 = array();
$opt2_cnt = $opt3_cnt = 0;
for($i=0; $i<$option_count; $i++) {
$opt_val = explode(chr(30), $_POST['opt_id'][$i]);
if(!in_array($opt_val[0], $arr_opt1))
$arr_opt1[] = $opt_val[0];
if($opt_val[1])
$opt2_cnt++;
if($opt_val[2])
$opt3_cnt++;
}
$it_option_subject = $opt1_subject;
if($opt2_subject && $opt2_cnt)
$it_option_subject .= ','.$opt2_subject;
if($opt3_subject && $opt3_cnt)
$it_option_subject .= ','.$opt3_subject;
$it_option = implode(',', $arr_opt1);
}
// 상품요약정보
$value_array = array();
for($i=0; $i<count($_POST['ii_article']); $i++) {
@ -422,6 +449,19 @@ if ($w == "" || $w == "u")
}
}
// 선택옵션등록
for($i=0; $i<$option_count; $i++) {
$sql = " insert into {$g4['shop_item_option_table']}
set io_id = '{$_POST['opt_id'][$i]}',
io_type = '0',
it_id = '$it_id',
io_price = '{$_POST['opt_price'][$i]}',
io_stock_qty = '{$_POST['opt_stock_qty'][$i]}',
io_noti_qty = '{$_POST['opt_noti_qty'][$i]}',
io_use = '{$_POST['opt_use'][$i]}' ";
sql_query($sql);
}
// 동일 분류내 상품 동일 옵션 적용
$ca_fields = '';
if(is_checked('chk_ca_it_gallery')) $ca_fields .= " , it_gallery = '$it_gallery' ";

View File

@ -0,0 +1,154 @@
<?php
include_once('./_common.php');
$po_run = false;
if($it['it_id']) {
$opt_subject = explode(',', $it['it_option_subject']);
$opt1_subject = $opt_subject[0];
$opt2_subject = $opt_subject[1];
$opt3_subject = $opt_subject[2];
$sql = " select * from {$g4['shop_item_option_table']} where io_type = '0' and it_id = '{$it['it_id']}' order by io_no asc ";
$result = sql_query($sql);
if(mysql_num_rows($result))
$po_run = true;
} else if(!empty($_POST)) {
$po_run = true;
$opt1_subject = trim($_POST['opt1_subject']);
$opt2_subject = trim($_POST['opt2_subject']);
$opt3_subject = trim($_POST['opt3_subject']);
$opt1_val = trim($_POST['opt1']);
$opt2_val = trim($_POST['opt2']);
$opt3_val = trim($_POST['opt3']);
$opt1_count = $opt2_count = $opt3_count = 0;
if($opt1_val) {
$opt1 = explode(',', $opt1_val);
$opt1_count = count($opt1);
}
if($opt2_val) {
$opt2 = explode(',', $opt2_val);
$opt2_count = count($opt2);
}
if($opt3_val) {
$opt3 = explode(',', $opt3_val);
$opt3_count = count($opt3);
}
}
if($po_run) {
?>
<table class="frm_tbl">
<tbody>
<tr>
<td rowspan="2"><input type="checkbox" name="opt_chk_all" value="1"></td>
<td colspan="3">옵션항목</td>
<td rowspan="2">추가금액</td>
<td rowspan="2">재고수량</td>
<td rowspan="2">통보수량</td>
<td rowspan="2">사용여부</td>
</tr>
<tr>
<td><?php echo $opt1_subject; ?></td>
<td><?php echo $opt2_subject; ?></td>
<td><?php echo $opt3_subject; ?></td>
</tr>
<?php
if($it['it_id']) {
for($i=0; $row=sql_fetch_array($result); $i++) {
$opt_id = $row['io_id'];
$opt_val = explode(chr(30), $opt_id);
$opt_1 = $opt_val[0];
$opt_2 = $opt_val[1];
$opt_3 = $opt_val[2];
$opt_price = $row['io_price'];
$opt_stock_qty = $row['io_stock_qty'];
$opt_noti_qty = $row['io_noti_qty'];
$opt_use = $row['io_use'];
?>
<tr>
<input type="hidden" name="opt_id[]" value="<?php echo $opt_id; ?>">
<td><input type="checkbox" name="opt_chk[]" value="1"></td>
<td class="opt1-cell"><?php echo $opt_1; ?></td>
<td class="opt2-cell"><?php echo $opt_2; ?></td>
<td class="opt3-cell"><?php echo $opt_3; ?></td>
<td><input type="text" name="opt_price[]" value="<?php echo $opt_price; ?>" class="frm_input" size="5"></td>
<td><input type="text" name="opt_stock_qty[]" value="<?php echo $opt_stock_qty; ?>" class="frm_input" size="5"></td>
<td><input type="text" name="opt_noti_qty[]" value="<?php echo $opt_noti_qty; ?>" class="frm_input" size="5"></td>
<td>
<select name="opt_use[]">
<option value="1" <?php echo get_selected('1', $opt_use); ?>>사용함</option>
<option value="0" <?php echo get_selected('0', $opt_use); ?>>사용안함</option>
</select>
</td>
</tr>
<?php
} // for
} else {
for($i=0; $i<$opt1_count; $i++) {
$j = 0;
do {
$k = 0;
do {
$opt_1 = trim($opt1[$i]);
$opt_2 = trim($opt2[$j]);
$opt_3 = trim($opt3[$k]);
$opt_id = $opt_1;
if($opt_2)
$opt_id .= chr(30).$opt_2;
if($opt_3)
$opt_id .= chr(30).$opt_3;
$opt_price = 0;
$opt_stock_qty = 0;
$opt_noti_qty = 0;
$opt_use = 1;
?>
<tr>
<input type="hidden" name="opt_id[]" value="<?php echo $opt_id; ?>">
<td><input type="checkbox" name="opt_chk[]" value="1"></td>
<td class="opt1-cell"><?php echo $opt_1; ?></td>
<td class="opt2-cell"><?php echo $opt_2; ?></td>
<td class="opt3-cell"><?php echo $opt_3; ?></td>
<td><input type="text" name="opt_price[]" value="<?php echo $opt_price; ?>" class="frm_input" size="5"></td>
<td><input type="text" name="opt_stock_qty[]" value="<?php echo $opt_stock_qty; ?>" class="frm_input" size="5"></td>
<td><input type="text" name="opt_noti_qty[]" value="<?php echo $opt_noti_qty; ?>" class="frm_input" size="5"></td>
<td>
<select name="opt_use[]">
<option value="1" <?php echo get_selected('1', $opt_use); ?>>사용함</option>
<option value="0" <?php echo get_selected('0', $opt_use); ?>>사용안함</option>
</select>
</td>
</tr>
<?php
$k++;
} while($k < $opt3_count);
$j++;
} while($j < $opt2_count);
} // for
}
?>
</tbody>
</table>
<div><button type="button" id="sel_option_delete">선택삭제</button></div>
<div>
<label for="opt_com_price">추가금액</label><input type="text" name="opt_com_price" value="0" id="opt_com_price" class="frm_input" size="5">
<label for="opt_com_stock">재고수량</label><input type="text" name="opt_com_stock" value="0" id="opt_com_stock" class="frm_input" size="5">
<label for="opt_com_noti">통보수량</label><input type="text" name="opt_com_noti" value="0" id="opt_com_noti" class="frm_input" size="5">
<label for="opt_com_use">사용여부</label>
<select name="opt_com_use" id="opt_com_use">
<option value="1">사용함</option>
<option value="0">사용안함</option>
</select>
<button type="button" id="opt_value_apply">일괄적용</button>
</div>
<?php
}
?>