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

521 lines
18 KiB
PHP

<?
include $_SERVER[DOCUMENT_ROOT] . "/backoffice/header.php";
include $_SERVER[DOCUMENT_ROOT] . "/module/product/product.lib.php";
include $_SERVER[DOCUMENT_ROOT] . "/module/category/category.lib.php";
include $_SERVER[DOCUMENT_ROOT] . "/common/fckeditor/fckeditor.php";
if(!in_array("product_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차카테고리
//제품정보
$arrInfo = getProductInfo(mysql_real_escape_string($_REQUEST[idx]));
$etc_1 = explode("//",$arrInfo['list'][0]['etc_1']);
$etc_2 = explode("//",$arrInfo['list'][0]['etc_2']);
$etc_3 = explode("//",$arrInfo['list'][0]['etc_3']);
$etc_4 = explode("//",$arrInfo['list'][0]['etc_4']);
$etc_5 = explode("//",$arrInfo['list'][0]['etc_5']);
$etc_6 = explode("//",$arrInfo['list'][0]['etc_6']);
//카테고리 정보
$arrCatCode = explode("/", $arrInfo["list"][0]["cat_code"]);
$arrExtCat = getProductExtCat(mysql_real_escape_string($_REQUEST[idx]));
$catrs = mysql_query("select * from tbl_category order by cat_code");
//DB해제
SetDisConn($dblink);
?>
<script language="javascript">
function photoView(b_idx, idx) {
var window_left = (screen.width-640)/2;
var window_top = (screen.height-480)/2;
obj = window.open('/module/product/photo_view.php?b_idx='+b_idx+'&idx='+idx,"photo_view_win",'width=200,height=200,status=no,scrollbars=no,top=' + window_top + ',left=' + window_left + '');
}
function catalog_download(idx) {
var window_left = (screen.width-640)/2;
var window_top = (screen.height-480)/2;
obj = window.open('/module/product/catalog_download.php?idx='+idx,"download_win",'width=200,height=200,status=no,scrollbars=no,top=' + window_top + ',left=' + window_left + '');
}
</script>
<div id="admin-container">
<? include "menu.php"; ?>
<div id="admin-content">
<h2 class="admin-title">제품 관리</h2>
<form name="frmInfo" method="post" action="product_evn.php" ENCTYPE="multipart/form-data" >
<input type="hidden" name="evnMode" value="edit">
<input type="hidden" name="idx" value="<?=$arrInfo["list"][0][idx]?>">
<input type="hidden" name="rt_url" value="<?=$_REQUEST[listURL]?>">
<?php
$dblink = SetConn($_conf_db["main_db"]);
?>
<!-- 기본정보 -->
<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="hidden" name="cat_no" id="cat_no" value="<?php echo $arrInfo['list'][0]['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]?>"<?=$arrCatCode[0]==$arrCategory["list"][$i][cat_no]?" selected":""?>><?=$arrCategory["list"][$i][cat_name]?></option>
<?}?>
</select>
<?php
for($i=2;$i<$_SITE["PRODUCT"]["CATEGORY_DEPTH"]+1;$i++){ //카테고리 $_SITE["PRODUCT"]["CATEGORY_DEPTH"]차까지 만듬 => 1차 초기화는 따로위에서 함
$_dep = $i-2;
?>
<select name="cat<?=$i?>" id="cat<?=$i?>" class="subcategory depth<?=$i?>" depth="<?=$i?>">
<option value="">==========<?=$i?>차분류==========</option>
<?php
if (strlen($arrCatCode[$_dep])) {
$subCa = getCategoryList($arrCatCode[$_dep]);
for ($j=0; $j<$subCa['total']; $j++) {
?>
<option value="<?php echo $subCa['list'][$j]['cat_no']; ?>" <?=$arrCatCode[$_dep+1]==$subCa['list'][$j]['cat_no']?" selected='selected'":""?>><?php echo $subCa['list'][$j]['cat_name']; ?></option>
<?php
}
}
?>
</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"><input type="text" name="sort_num" style="width:100" maxlength="8" value="<?=$arrInfo["list"][0]["sort_num"]?>" class="input" /> (숫자가 높을수록 앞쪽에 위치함)</td>
</tr>
<!-- <tr>
<th>메인표시</th>
<td class="space-left"><input type="checkbox" name="show_main" value="Y"<?=$arrInfo["list"][0]["show_main"]=="Y"?" checked":""?>> 표시함</td>
</tr> -->
<tr>
<th>제품명</th>
<td class="space-left"><input type="text" name="p_name" style="width:50%" maxlength="200" value="<?=stripslashes($arrInfo["list"][0]["p_name"])?>" 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">
<textarea name="memo" id="memo" cols="150" rows="5"><?=stripslashes($arrInfo["list"][0]["memo"])?></textarea>
</td>
</tr> -->
<!-- <tr>
<th>카다로그</th>
<td class="space-left">
<?php if (count($arrInfo['catalog_files'][0]) > 0) { ?>
<label for="delCatalog0">삭제 </label><input type="checkbox" name="delCatalog[]" id="delCatalog0" value="<?=$arrInfo["catalog_files"][0][idx]?>"> <a href="javascript:catalog_download('<?=$arrInfo["list"][0]["idx"]?>')"><?=$arrInfo["catalog_files"][0][ori_name]?></a>
<?php } else { ?>
<input type="file" name="catalog_file[]" style="width:50%" class="input" />
<?php } ?>
</td>
</tr> -->
<!-- <tr>
<th>카다로그</th>
<td class="space-left">
<?php if (count($arrInfo['catalog_files1'][0]) > 0) { ?>
<label for="delCatalog1">삭제 </label><input type="checkbox" name="delCatalog[]" id="delCatalog1" value="<?=$arrInfo["catalog_files1"][0][idx]?>"> <a href="javascript:catalog_download('<?=$arrInfo["list"][1]["idx"]?>')"><?=$arrInfo["catalog_files1"][0][ori_name]?></a>
<?php } else { ?>
<input type="file" name="catalog_file1[]" style="width:50%" class="input" />
<?php } ?>
</td>
</tr>
<tr>
<th>카다로그</th>
<td class="space-left">
<?php if (count($arrInfo['catalog_files2'][0]) > 0) { ?>
<label for="delCatalog2">삭제 </label><input type="checkbox" name="delCatalog[]" id="delCatalog2" value="<?=$arrInfo["catalog_files2"][0][idx]?>"> <a href="javascript:catalog_download('<?=$arrInfo["list"][2]["idx"]?>')"><?=$arrInfo["catalog_files2"][0][ori_name]?></a>
<?php } else { ?>
<input type="file" name="catalog_file2[]" style="width:50%" class="input" />
<?php } ?>
</td>
</tr>
<tr>
<th>카다로그</th>
<td class="space-left">
<?php if (count($arrInfo['catalog_files3'][0]) > 0) { ?>
<label for="delCatalog3">삭제 </label><input type="checkbox" name="delCatalog[]" id="delCatalog3" value="<?=$arrInfo["catalog_files3"][0][idx]?>"> <a href="javascript:catalog_download('<?=$arrInfo["list"][3]["idx"]?>')"><?=$arrInfo["catalog_files3"][0][ori_name]?></a>
<?php } else { ?>
<input type="file" name="catalog_file3[]" style="width:50%" class="input" />
<?php } ?>
</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_idx']))) {
$rel_idx = explode(",",$arrInfo['list'][0]['rel_idx']);
for ($i=0; $i<count($rel_idx); $i++) {
$rel_info = getproductInfo($rel_idx[$i]);
//echo "<option value="".$rel_info['list'][0]['idx']."">".$rel_info['list'][0]['p_name']."</option>";
}
}
?>
</select>
</td>
</tr> -->
</tbody>
</table>
<br />
<!-- 제품 사진 -->
<h3 class="admin-title-middle">제품 사진</h3>
<table class="admin-table-type1">
<colgroup>
<col width="140" />
<col width="*" />
</colgroup>
<tbody>
<?
//업로드 한것
if($arrInfo["total_files"]>0){
for($i=0; $i < $arrInfo["total_files"]; $i++){
?>
<tr>
<th>업로드된 사진 <?=$i+1?> </th>
<td class="space-left">
<label for="delPhoto<?=$i?>">삭제</label> <input type="checkbox" name="delPhoto[]" id="delPhoto<?=$i?>" value="<?=$arrInfo["files"][$i][idx]?>"> &nbsp; <a href="javascript:photoView('<?=$arrInfo["list"][0][idx]?>','<?=$arrInfo["files"][$i][idx]?>');"><?=$arrInfo["files"][$i][ori_name]?></a> &nbsp;
<input type="radio" name="p_image" value="<?=$arrInfo["files"][$i][re_name]?>" id="idPhoto<?=$i?>_ori"<?=$arrInfo["files"][$i][re_name]==$arrInfo["list"][0][p_image]?" checked":""?>><label for="idPhoto<?=$i?>_ori">대표이미지</label>
</td>
</tr>
<?}?>
<?}?>
<?
for($i=0; $i < intval($_SITE["PRODUCT"]["IMAGE_COUNT"] - $arrInfo["total_files"]); $i++){
?>
<tr>
<th>사진 <?=$i+1?></th>
<td class="space-left"><input type="file" name="photo_file[]" style="width:50%"> <input type="radio" name="p_image" value="<?=$i?>" id="idPhoto<?=$i?>"><label for="idPhoto<?=$i?>">대표이미지</label></td>
</tr>
<?
}
?>
<tbody>
</table>
<br />
<!-- 제품 설명 -->
<h3 class="admin-title-middle">상세정보</h3>
<table class="admin-table-type1">
<colgroup>
<col width="140" />
<col width="*" />
</colgroup>
<tr>
<th>상세설명</th>
<td class="space-left">
<?php
$edit_content = stripslashes($arrInfo["list"][0][contents]);
$edit_height="240";
include $_SERVER[DOCUMENT_ROOT] . "/webedit/Editor.html";
?>
</td>
</tr>
<!-- <tr>
<th>상세설명2</th>
<td class="space-left">
<?php
$edit_name = "contents1";
$edit_content = stripslashes($arrInfo["list"][0][contents1]);
$edit_height="240";
//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="refresh"></span><input type="submit" value="제품수정" style="font-weight:bold" /></span>
</div>
</div>
</div>
</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:{
cat : cat,
mode : "getsub"
},
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, 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/product/ajax.product.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].p_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;
}
});
$("form[name=frmInfo]").submit(function() {
if ($("input[name=cat_no]").val() == ""){
alert("제품 분류를 선택해 주십시요.");
$("input[name=cat_no]").focus();
return false;
}
if ($("input[name=p_name]").val() == ""){
alert("제품명을 입력해 주십시요.");
$("input[name=cat_no]").focus();
return false;
}
try{ contents.outputBodyHTML(); } catch(e){ }
$("select[name='rel_product[]'] option").each(function(idx) {
$(this).attr("selected","selected");
});
$("select[name='rel_category[]'] option").each(function(idx) {
$(this).attr("selected","selected");
});
});
});
</script>
</form>
<?
//DB해제
SetDisConn($dblink);
include $_SERVER[DOCUMENT_ROOT] . "/backoffice/footer.php" ;
?>