gdidc/backoffice/module/shop/good_add.php
2021-10-26 18:19:06 +09:00

712 lines
25 KiB
PHP

<?
include $_SERVER[DOCUMENT_ROOT] . "/backoffice/header.php";
include $_SERVER[DOCUMENT_ROOT] . "/module/category/category.lib.php";
include $_SERVER[DOCUMENT_ROOT] . "/module/shop/shop.lib.php";
if(!in_array("shop_good_manage",$_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["AUTH"]) && $_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["GRADE"]!="ROOT"):
jsMsg("권한이 없습니다.");
jsHistory("-1");
endif;
//DB연결
$dblink = SetConn($_conf_db["main_db"]);
//전체 카테고리 가져오기
$arrAllCategory = getCategoryAll();
//분류 리스트
$arrCategory = getCategoryList(0);//1차카테고리
$catrs = mysql_query("select * from tbl_category order by cat_code");
?>
<div id="admin-container">
<? include "menu_good.php"; ?>
<div id="admin-content">
<h2 class="admin-title">상품 등록</h2>
<script language="javascript">
//카테고리 이름 자바스크립트 변수 생성
var arrayAllCategory = new Array();
<?
foreach ($arrAllCategory AS $key => $val){
?>
arrayAllCategory[<?=$key?>] = "<?=$val?>";
<?
}
?>
</script>
<form name="frmInfo" method="post" action="good_evn.php" ENCTYPE="multipart/form-data" onSubmit="return goodCheckForm(this)">
<input type="hidden" name="evnMode" value="insert">
<!-- 기본정보 -->
<h3 class="admin-title-middle">기본정보</h3>
<table class="admin-table-type1">
<colgroup>
<col width="140" />
<col width="*" />
</colgroup>
<tbody>
<tr>
<th>상품코드</th>
<td class="space-left"><input type="text" name="g_code" style="width:200" maxlength="30" value="<?=date("YmdHis").rand(100,999)?>" class="input" /></td>
</tr>
<tr>
<th>상품분류</th>
<td class="space-left">
<input type="hidden" name="cat_no" id="cat_no">
<select name="cat" id="cat" class="first-depth" depth="1">
<option value="">==========1차분류==========</option>
<?for($i=0;$i<$arrCategory["total"];$i++){?>
<option value="<?=$arrCategory["list"][$i][cat_no]?>"><?=$arrCategory["list"][$i][cat_name]?></option>
<?}?>
</select>
<?
for($i=2;$i<$_SITE["PRODUCT"]["CATEGORY_DEPTH"]+1;$i++){ //카테고리 $_SITE["PRODUCT"]["CATEGORY_DEPTH"]차까지 만듬 => 1차 초기화는 따로위에서 함
?>
<select name="cat<?=$i?>" id="cat<?=$i?>" class="subcategory depth<?=$i?>" depth="<?=$i?>">
<option value="">==========<?=$i?>차분류==========</option>
</select>
<?
}
?>
</td>
</tr>
<!-- <tr>
<th>추가분류</th>
<td class="space-left">
<select name="addcaList">
<option value="">선택</option>
<?php
for ($i=0; $row = mysql_fetch_assoc($catrs); $i++) {
unset($space);
for ($j=0; $j<$row['cat_depth']; $j++) {
$space .= "&nbsp;&nbsp;&nbsp;";
}
?>
<option value="<?php echo $row['cat_no']; ?>"><?php echo $space.$row['cat_name']; ?></option>
<?php
}
?>
</select>
<button value="추가" type="button" class="addcat">추가</button>
<button value="삭제" type="button" class="delcat">삭제</button>
<select multiple="multiple" name="rel_category[]" style="width:30%;height:150px;">
<?php
if ($arrExtCat['total'] > "0") {
for ($i=0; $i<$arrExtCat['total']; $i++) {
$arrExtCatCode = explode("/", $arrExtCat["list"][$i]["cat_code"]);
$strExtCat = "";
for($j=0;$j<count($arrExtCatCode)-1;$j++){
$strExtCat .= $arrAllCategory[$arrExtCatCode[$j]];
if($j != count($arrExtCatCode)-2){
$strExtCat .= " > ";
}
}
echo "<option value=\"".$arrExtCat['list'][$i]['cat_no']."\">".$strExtCat."</option>";
}
}
?>
</select>
</td>
</tr>
<tr>
<th>관련상품</th>
<td class="space-left">
<select name="caList">
<option value="">선택</option>
<?php
//DB연결
$dblink = SetConn($_conf_db["main_db"]);
$catrs = mysql_query("select * from tbl_category order by cat_code");
for ($i=0; $row = mysql_fetch_assoc($catrs); $i++) {
unset($space);
for ($j=0; $j<$row['cat_depth']; $j++) {
$space .= "&nbsp;&nbsp;&nbsp;";
}
?>
<option value="<?php echo $row['cat_no']; ?>"><?php echo $space.$row['cat_name']; ?></option>
<?php
}
?>
</select>
<select multiple="multiple" name="pickList" style="width:30%;height:150px;"></select>
<button value="추가" type="button" class="addrel">추가</button>
<button value="삭제" type="button" class="delrel">삭제</button>
<select multiple="multiple" name="rel_product[]" style="width:30%;height:150px;">
<?php
if (strlen(str_replace(",","",$arrInfo['list'][0]['rel_g_idx']))) {
$rel_idx = explode(",",$arrInfo['list'][0]['rel_g_idx']);
for ($i=0; $i<count($rel_idx); $i++) {
$rel_info = getGoodInfo($rel_idx[$i]);
echo "<option value=\"".$rel_info['list'][0]['idx']."\">".$rel_info['list'][0]['g_name']."</option>";
}
}
?>
</select>
</td>
</tr> -->
<tr>
<th>상품명</th>
<td class="space-left"><input type="text" name="g_name" style="width:90%" maxlength="200" class="input" /></td>
</tr>
<!-- <tr>
<th>간략설명</th>
<td class="space-left"><textarea name="memo" class="textarea" style="width:90%;height:60px"></textarea></td>
</tr> -->
<tr>
<th>정렬순서</th>
<td class="space-left"><input type="text" name="sort_num" size="4" maxlength="8" value="0" class="input" /> (숫자가 높을수록 위쪽에 표시됨)</td>
</tr>
<tr style="display:none">
<th>개별결제자 아이디</th>
<td class="space-left"><input type="text" name="author_name" size="20" maxlength="30" class="input" /> 개별결제 사용시만 결제자 아이디 작성해 주시면 됩니다.</td>
</tr>
<!-- <tr>
<th>아이콘</th>
<td class="space-left">
<ul style="display:inline-block;width:90%;padding-top:10px;">
<?
$arrIcons = explode("|",$arrInfo["list"][0][icons]);
if ($handle = opendir($_SERVER[DOCUMENT_ROOT] . "/uploaded/shop_icons/")) {
$cc=0;
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
?>
<li style="float:left;width:160px;height:40px;"><input type="checkbox" name="shop_icon[]" value="<?=$file?>"<?=in_array($file,$arrIcons)?" checked":""?>><img src="/uploaded/shop_icons/<?=$file?>"></li>
<?
//if($cc%8 == 7) echo "<br />";
//$cc++;
}
}
closedir($handle);
}
?>
</ul>
<div style="color:#d33131;clar:both;">(FTP를 이용하여 /www/uploaded/shop_icons 폴더에 아이콘을 업로드 시키면 나타납니다.)</div>
</td>
</tr> -->
</tbody>
</table>
<br />
<!-- 상품 추가정보 -->
<h3 class="admin-title-middle">상품 추가정보</h3>
<table class="admin-table-type1">
<colgroup>
<col width="140" />
<col width="*" />
</colgroup>
<tbody>
<tr>
<th>브랜드</th>
<td class="space-left"><input type="text" name="brand" style="width:200" maxlength="50" value="<?=stripslashes($arrInfo["list"][0][brand])?>" class="input" /></td>
</tr>
<tr>
<th>판매자</th>
<td class="space-left"><input type="text" name="vendor" style="width:200" maxlength="50" value="<?=stripslashes($arrInfo["list"][0][vendor])?>" class="input" /></td>
</tr>
<tr>
<th>원산지/제조사</th>
<td class="space-left"><input type="text" name="madein" style="width:200" maxlength="50" value="<?=stripslashes($arrInfo["list"][0][madein])?>" class="input" /></td>
</tr>
<tr>
<th>옵션1</th>
<td class="space-left"><input type="text" name="etc_1" style="width:50%" value="<?=stripslashes($arrInfo["list"][0]["etc_1"])?>" class="input" /></td>
</tr>
<tr>
<th>옵션2</th>
<td class="space-left"><input type="text" name="etc_2" style="width:50%" value="<?=stripslashes($arrInfo["list"][0]["etc_2"])?>" class="input" /></td>
</tr>
<tr>
<th>옵션3</th>
<td class="space-left"><input type="text" name="etc_3" style="width:50%" value="<?=stripslashes($arrInfo["list"][0]["etc_3"])?>" class="input" /></td>
</tr>
<tr>
<th>옵션4</th>
<td class="space-left"><input type="text" name="etc_4" style="width:50%" value="<?=stripslashes($arrInfo["list"][0]["etc_4"])?>" class="input" /></td>
</tr>
<tr>
<th>옵션5</th>
<td class="space-left"><input type="text" name="etc_5" style="width:50%" value="<?=stripslashes($arrInfo["list"][0]["etc_5"])?>" class="input" /></td>
</tr>
<!-- <tr>
<th>소비자가</th>
<td class="space-left"><input type="text" name="sale_price" style="width:200" maxlength="20" class="input" /> (숫자만 입력)</td>
</tr> -->
<tr>
<th>판매가</th>
<td class="space-left"><input type="text" name="price" style="width:200" maxlength="20" class="input" /> (숫자만 입력)</td>
</tr>
<tr>
<th>적립금</th>
<td class="space-left"><input type="text" name="point" style="width:100" maxlength="20" value="0" class="input" />
<select name="point_unit">
<option value="F">고정금액</option>
<option value="P">%</option>
</select>
</td>
</tr>
<tr>
<th>상품진열</th>
<td class="space-left"><input type="radio" id="is_show_y" name="is_show" value="Y" checked><label for="is_show_y"><font color=blue>진열함</font></label>
<input type="radio" id="is_show_n" name="is_show" value="N"><label for="is_show_n"><font color=red>진열안함</font></label>
</td>
</tr>
<tr>
<th>메인노출 여부</th>
<td class="space-left">
<input type="radio" id="main_show_y" name="main_show" value="Y"><label for="main_show_y"><font color=blue>노출함</font></label> &nbsp;
<input type="radio" id="main_show_n" name="main_show" value="N" checked><label for="main_show_n"><font color=red>노출안함</font></label> &nbsp;
</td>
</tr>
<!-- <tr style="display:<?=$siteip_chk==true?"":"none"?>">
<th>재고관리</th>
<td class="space-left">
<input type="radio" id="stock_type_1" name="stock_type" value="1" checked onclick="checkStockManage(1);"><label for="stock_type_1"><font color=blue>재고관리 안함</font></label> &nbsp;
<input type="radio" id="stock_type_2" name="stock_type" value="2" onclick="checkStockManage(2);"><label for="stock_type_2"><font color=green>일반 재고관리</font></label> &nbsp;
<input type="radio" id="stock_type_3" name="stock_type" value="3" onclick="checkStockManage(3);"><label for="stock_type_3"><font color=red>연계 재고관리</font></label>
<table class="admin-table-type1" id="layerStock" style="position:relative; display:none; width:200px !important;">
<tr>
<th>재고량</th>
<td class="space-left"><input type="text" name="stock" style="width:100" maxlength="10" class="input" /></td>
</tr>
</table>
</td>
</tr> -->
</tbody>
</table>
<br />
<!-- 옵션 추가정보 -->
<h3 class="admin-title-middle" style="display:<?=$arrInfo["list"][0][stock_type]=="2"?"":"none"?>;">상품 옵션정보 &nbsp; <a href="javascript:append_opt();"><img src="/backoffice/images/k_add.gif" alt="추가" align="top" /></a> <a href="javascript:remove_opt();"><img src="/backoffice/images/k_delete.gif" alt="삭제" align="top" /></a></h3>
<!-- 옵션관련 변수 처리는 /common/js/shop.js 에서 처리합니다 -->
<input type="hidden" id="opt_hidden_count" name="opt_hidden_count">
<!-- 개별 재고관리 -->
<table class="admin-table-type1" id="layerOption1" style="position:relative; display:<?=$arrInfo["list"][0][stock_type]=="2"?"":"none"?>;">
<colgroup>
<col width="140" />
<col width="*" />
</colgroup>
<tbody>
<tr>
<th>추가옵션</th>
<td>
<div style="width:480px;">
<table class="admin-table-type1" id="product_opt">
<colgroup>
<col width="150" />
<col width="200" />
<col width="130" />
</colgroup>
<tbody>
<tr>
<th class="space-center">옵션명</th>
<th class="space-center">옵션항목</th>
<th class="space-center">항목설정</th>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
<!-- 개별 재고관리 -->
<!-- 연계 재고관리 -->
<div id="layerOption2" style="position:relative; display:<?=$arrInfo["list"][0][stock_type]=="3"?"":"none"?>;">
<a href="javascript:;" id="addItemBtn" class="btn-pack medium dark">옵션추가</a>
<table id="stockoptiontbl" border="1px" class="admin-table-type1">
<tr>
<th>옵션명</th>
<th>항목명</th>
<th>가격</th>
<th>재고</th>
<th>옵션삭제</th>
</tr>
<tr class="item1">
<td><input type="text" class="input" name="opt_subject[]" id="opt_subject1"/><!-- <a href="javascript:;" class="addBtn btn-pack">항목추가</a> --></td>
<td><input type="text" class="input" name="opt_contents[]" id="opt_contents_1"/></td>
<td><input type="text" class="input" name="opt_price[]"/></td>
<td><input type="text" class="input" name="opt_stock[]"/></td>
<td><a href="javascript:;" class="delBtn btn-pack">삭제</a></td>
</tr>
</table>
<!-- <div class="mgb5">세로/가로, 재고,추가금 (세로, 가로의 항목명이 없는 것, 값이 없는 옵션은 포함되지 않습니다.)</div>
<table class="admin-table-type1">
<tbody>
<tr>
<td width="10%"><table width="100%" cellspacing="0" cellpadding="0"></tr><td width="50%" bgcolor="#000000" align="center"><input type="text" name="relOptName2" style="width:50" class='input' maxlength="50" value="세로항목"></td><td width="10"></td><td width="50%" bgcolor="#FFCC00" align="center"><input type="text" name="relOptName1" style="width:50" class='input' maxlength="50" value="가로항목"></td></tr></table></td>
<?for($i=0;$i<9;$i++){?>
<?switch($i){
case(0):$val="옵션1";break;
case(1):$val="옵션2";break;
default:$val="";break;
}
?>
<td bgcolor="#FFCC00" width="10%"><input name="relOpt1_<?=$i?>" type="text" class='input' value="<?=$val?>" size="4"> <input name="" type="text" class='input' value="추가금" size="6" readonly></td>
<?}?>
</tr>
<?for($i=0;$i<9;$i++){?>
<?switch($i){
case(0):$val="옵션A";break;
case(1):$val="옵션B";break;
default:$val="";break;
}
?>
<tr>
<td bgcolor="#000000"><input name="relOpt2_<?=$i?>" type="text" class='input' value="<?=$val?>" size="10"></td>
<?for($j=0;$j<9;$j++){?>
<td>
<input name="rel_stock_<?=$i?>_<?=$j?>" type="text" class='input' size="4">
<input name="rel_price_<?=$i?>_<?=$j?>" type="text" class='input' size="6">
</td>
<?}?>
</tr>
<?}?>
</tbody>
</table> -->
</div>
<!-- 연계 재고관리 -->
<!-- 옵션 추가정보 -->
<!-- 상품 사진 -->
<br />
<h3 class="admin-title-middle">상품 사진 | <input type="radio" id="image_type_1" name="image_type" value="1" checked onclick="checkImageType(1);"><label for="image_type_1"><font color=blue>대표이미지</font></label> <!-- <input type="radio" id="image_type_2" name="image_type" value="2" onclick="checkImageType(2);"><label for="image_type_2"><font color=green>개별이미지</font></label> --></h3>
<!-- 이미지 타입 1 -->
<div id="layerImage1" style="position:relative; display:block;">
<div class="mgb5" style="line-height:20px;">
아래 이미지중 대표이미지로 설정된 이미지를 장바구니, 상품목록, 상품상세 이미지를 자동으로 생성(나머지는 확대이미지로 사용) <br />
이미지크기는 600px내외 1:1 비율이 적당합니다. 이미지파일의 확장자는 RGB모드의 jpg, gif, png 입니다.
</div>
<table class="admin-table-type1">
<colgroup>
<col width="140" />
<col width="*" />
</colgroup>
<tbody>
<?
for($i=0;$i<$_SITE["PRODUCT"]["IMAGE_COUNT"];$i++){
?>
<tr>
<th>사진 <?=$i+1?></th>
<td class="space-left"><input type="file" name="photo_file[]" style="width:50%" class="input" /> <input type="radio" name="p_image" value="<?=$i?>" id="idPhoto<?=$i?>"<?=$i==0?" checked":""?>><label for="idPhoto<?=$i?>">대표이미지</label></td>
</tr>
<?
}
?>
</tbody>
</table>
</div>
<!-- 이미지 타입 2 -->
<div id="layerImage2" style="position:relative; display:none;">
<div class="mgb5" style="line-height:20px;">
아래 이미지중 대표이미지로 설정된 이미지를 장바구니, 상품목록, 상품상세 이미지를 자동으로 생성(나머지는 확대이미지로 사용)
</div>
<table class="admin-table-type1">
<colgroup>
<col width="140" />
<col width="*" />
</colgroup>
<tbody>
<tr>
<th>장바구니 사진</th>
<td class="space-left"><input type="file" name="photo_file_s" style="width:50%" class="input" /> </td>
</tr>
<tr>
<th>상품목록 사진</th>
<td class="space-left"><input type="file" name="photo_file_m" style="width:50%" class="input" /> </td>
</tr>
<tr>
<th>상세정보 사진</th>
<td class="space-left"><input type="file" name="photo_file_l" style="width:50%" class="input" /> </td>
</tr>
<?
for($i=0;$i<$_SITE["PRODUCT"]["IMAGE_COUNT"];$i++){
?>
<tr>
<th>확대사진 <?=$i+1?></th>
<td class="space-left"><input type="file" name="photo_file[]" style="width:50%" class="input" /> </td>
</tr>
<?
}
?>
</tbody>
</table>
</div>
<br />
<h3 class="admin-title-middle">상품 설명</h3>
<table width="100%;" border="0" cellspacing="1" cellpadding="6" bgcolor="#dedede">
<colgroup>
<col width="140" />
<col width="*" />
</colgroup>
<tbody>
<tr>
<th bgcolor="#f8f8f8">상세설명</th>
<td bgcolor="#ffffff">
<?
include $_SERVER[DOCUMENT_ROOT] . "/webedit/Editor.html";
?>
</td>
</tr>
<!-- <tr>
<th bgcolor="#f8f8f8">배송/교환안내</th>
<td bgcolor="#ffffff">
<?
$edit_name = "mokcha";
//include $_SERVER[DOCUMENT_ROOT] . "/webedit/Editor.html";
?>
</td>
</tr> -->
<!-- <tr>
<th bgcolor="#f8f8f8">모바일 상세설명</th>
<td bgcolor="#ffffff">
<?
$edit_name = "author_text";
//include $_SERVER[DOCUMENT_ROOT] . "/webedit/Editor.html";
?>
</td>
</tr> -->
</table>
<div class="admin-buttons">
<div class="cen">
<span class="btn_pack xlarge icon"><span class="check"></span><input type="submit" value="상품등록" style="font-weight:bold" /></span>
</div>
</div>
</form>
</div>
</div>
<div id="layerProductOpt" style="position:absolute; display:none; background-color:#FFCC00; border-size:3px;bordercolor:#CCCCCC;"></div>
<div id="layerImageShow" style="position:absolute; display:none; background-color:#FFFFFF; border-size:3px;bordercolor:#EEEEEE"></div>
<div id="layerGoodCat" style="position:absolute; display:none; background-color:#FFCC00; border-size:3px;bordercolor:#CCCCCC"></div>
<div id="layerRelGood" style="position:absolute; display:none; background-color:#FF0000; border-size:3px;bordercolor:#CCCCCC">
<iframe id="iframeRelGood" name="iframeRelGood" border="1" width="800" height="400"></iframe>
</div>
<script language="javascript">
jQuery(function($) {
function reset_category(obj) {
$(obj).empty().append("<option value=\"\">=========="+$(obj).attr("depth")+"차분류==========</option>");
}
function category_set(obj) {
var cat = $(obj).val();
if (cat.length) {
$("#cat_no").val(cat);
$.ajax({
type:"POST",
url:"/module/category/ajax.category.php",
data:{
mode : "getsub",
cat : cat
},
datatype:"json",
success: function(msg){
//if (!$("#debug").length) $("body").prepend("<div id='debug' style='position:absolute;width:80%;50%;background-color:#fff;left:10%;top:10%;z-index:9999;'></div>");
//$("#debug").html(msg);
data = JSON.parse(msg);
if (data.success && data.calist.length) {
var target, idx;
idx = parseInt($(obj).attr("depth")) + 1;
target = ".depth"+idx;
if ($(target).length) {
reset_category(target);
for(var i=0; i<data.calist.length; i++) {
$(target).append("<option value=\""+data.calist[i].cat_no+"\">"+data.calist[i].cat_name+"</option>");
}
}
}
},
error:function(msg){
alert("로드에러");
document.reload();
},
complete : function(){
},
beforeSend : function() {
}
});
}
}
// 초기화
$(".subcategory").each(function(idx) {
reset_category(this);
$(this).bind("change",function() {
category_set(this);
});
});
$("#cat").change(function() {
category_set(this);
});
$("select[name=caList]").change(function() {
if ($(this).val() != "") {
var cat = $(this).val();
$.ajax({
type:"POST",
url:"/module/shop/ajax.good.php",
data:{
mode : "getproduct",
cat : cat
},
datatype:"json",
success: function(msg){
//if (!$("#debug").length) $("body").prepend("<div id='debug' style='position:absolute;width:80%;50%;background-color:#fff;left:10%;top:10%;z-index:9999;'></div>");
//$("#debug").html(msg);
data = JSON.parse(msg);
if (data.success) {
var target;
target = "select[name=pickList]";
if ($(target).length) {
$(target).empty();
for(var i=0; i<data.result.length; i++) {
$(target).append("<option value=\""+data.result[i].idx+"\">"+data.result[i].g_name+"</option>");
}
}
}
},
error:function(msg){
alert("로드에러");
document.reload();
},
complete : function(){
},
beforeSend : function() {
}
});
}
});
$(".addcat").click(function() {
if ($("select[name=addcaList] option:selected").length) {
$("select[name=addcaList] option:selected").each(function(idx) {
var obj = this;
$("select[name='rel_category[]'] option").each(function() {
if ($(this).val() == $(obj).val()) {
$(this).remove();
}
});
$("select[name='rel_category[]']").append("<option value='"+$(obj).val()+"'>"+$(obj).text()+"</option>");
});
} else {
alert("분류를 선택해주세요");
return false;
}
});
$(".delcat").click(function() {
if ($("select[name='rel_category[]'] option:selected").length) {
$("select[name='rel_category[]'] option:selected").each(function(idx) {
$(this).remove();
});
} else {
alert("분류를 선택해주세요");
return false;
}
});
$(".addrel").click(function() {
if ($("select[name=pickList] option:selected").length) {
$("select[name=pickList] option:selected").each(function(idx) {
var obj = this;
$("select[name='rel_product[]'] option").each(function() {
if ($(this).val() == $(obj).val()) {
$(this).remove();
}
});
$("select[name='rel_product[]']").append("<option value='"+$(obj).val()+"'>"+$(obj).text()+"</option>");
});
} else {
alert("상품을 선택해주세요");
return false;
}
});
$(".delrel").click(function() {
if ($("select[name='rel_product[]'] option:selected").length) {
$("select[name='rel_product[]'] option:selected").each(function(idx) {
$(this).remove();
});
} else {
alert("상품을 선택해주세요");
return false;
}
});
});
//상품연계재고관리시(관리자용)
$(document).ready(function(){
// 옵션추가 버튼 클릭시
$("#addItemBtn").click(function(){
// item 의 최대번호 구하기
var lastItemNo = $("#stockoptiontbl tr:last").attr("class").replace("item", "");
var newitem = $("#stockoptiontbl tr:eq(1)").clone();
newitem.removeClass();
newitem.find("td:eq(0)").attr("rowspan", "1");
newitem.addClass("item"+(parseInt(lastItemNo)+1));
$("#stockoptiontbl").append(newitem);
$("#opt_hidden_count").val($("#opt_hidden_count").val() + 1);
});
// 항목추가 버튼 클릭시
$(".addBtn").live("click", function(){
var clickedRow = $(this).parent().parent();
var cls = clickedRow.attr("class");
// tr 복사해서 마지막에 추가
var newrow = clickedRow.clone();
newrow.find("td:eq(0)").remove();
newrow.insertAfter($("#stockoptiontbl ."+cls+":last"));
// rowspan 조정
resizeRowspan(cls);
$("#opt_hidden_count").val($("#opt_hidden_count").val() + 1);
});
// 삭제버튼 클릭시
$(".delBtn").live("click", function(){
var clickedRow = $(this).parent().parent();
var cls = clickedRow.attr("class");
// 각 항목의 첫번째 row를 삭제한 경우 다음 row에 td 하나를 추가해 준다.
if( clickedRow.find("td:eq(0)").attr("rowspan") ){
if( clickedRow.next().hasClass(cls) ){
clickedRow.next().prepend(clickedRow.find("td:eq(0)"));
}
}
clickedRow.remove();
// rowspan 조정
resizeRowspan(cls);
$("#opt_hidden_count").val($("#opt_hidden_count").val() - 1);
});
// cls : rowspan 을 조정할 class ex) item1, item2, ...
function resizeRowspan(cls){
var rowspan = $("."+cls).length;
$("."+cls+":first td:eq(0)").attr("rowspan", rowspan);
}
});
</script>
<?
//DB해제
SetDisConn($dblink);
include $_SERVER[DOCUMENT_ROOT] . "/backoffice/footer.php" ;
?>