관련상품등록 관련 스크립트 수정

This commit is contained in:
chicpro
2013-02-04 14:00:57 +09:00
parent 335f5975c6
commit 31ebc0df87
4 changed files with 59 additions and 36 deletions

View File

@ -459,25 +459,32 @@ if ($ii) {
<select id="relationselect" name="relationselect" size=8 style='width:250px;' onclick="relation_img(this.value, 'sel_span')" ondblclick="relation_del(this);">
<?
$str = array();
$sql = " select b.ca_id, b.it_id, b.it_name, b.it_amount
from $g4[yc4_item_relation_table] a
left join $g4[yc4_item_table] b on (a.it_id2=b.it_id)
$sql = " select b.ca_id, b.it_id, b.it_name, b.it_amount, b.it_img1, b.it_img2, b.it_img3, b.it_img4, b.it_img5, b.it_img6, b.it_img7, b.it_img8, b.it_img9, b.it_img10
from {$g4['yc4_item_relation_table']} a
left join {$g4['yc4_item_table']} b on (a.it_id2 = b.it_id)
where a.it_id = '$it_id'
order by b.ca_id, b.it_name ";
$result = sql_query($sql);
while($row=sql_fetch_array($result))
{
$sql2 = " select ca_name from $g4[yc4_category_table] where ca_id = '$row[ca_id]' ";
$sql2 = " select ca_name from {$g4['yc4_category_table']} where ca_id = '{$row['ca_id']}' ";
$row2 = sql_fetch($sql2);
// 김선용 2006.10
if(file_exists(G4_DATA_PATH."/item/{$row['it_id']}_s"))
$it_image = "{$row['it_id']}_s";
else
$it_image = "";
// 상품이미지썸네일
$it_image = "";
for($k=1;$k<=10; $k++) {
$idx = 'it_img'.$k;
$filepath = G4_DATA_PATH.'/item/'.$row['it_id'];
$filename = $row[$idx];
echo "<option value='$row[it_id]/$it_image/{$row['it_amount']}'>$row2[ca_name] : ".cut_str(get_text(strip_tags($row[it_name])),30);
$str[] = $row[it_id];
if(file_exists($filepath.'/'.$filename) && $filename != "") {
$it_image = $filename;
break;
}
}
echo "<option value='{$row['it_id']}/$it_image/{$row['it_amount']}'>{$row2['ca_name']} : ".cut_str(get_text(strip_tags($row['it_name'])),30);
$str[] = $row['it_id'];
}
$str = implode(",", $str);
?>
@ -492,7 +499,7 @@ if ($ii) {
<option value=''>분류별 관련상품
<option value=''>----------------------
<?
$sql = " select ca_id, ca_name from $g4[yc4_category_table] where length(ca_id) = 2 order by ca_id ";
$sql = " select ca_id, ca_name from {$g4['yc4_category_table']} where length(ca_id) = 2 order by ca_id ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
echo "<option value='$row[ca_id]'>$row[ca_name]\n";
@ -521,16 +528,19 @@ if ($ii) {
// 김선용 2006.10
function relation_img(name, id)
{
item_image_dir = "<?=$g4['path']?>/data/item";
if(!name) return;
var item_image_url = "";
if(!name) return;
temp = name.split("/");
if(temp[1] == ''){
temp[1] = "no_image.gif";
var item_image_dir = "<?=$g4['shop_img_url']?>";
}
item_image_url = "<?=G4_SHOP_IMG_URL?>";
} else {
item_image_url = "<?=G4_DATA_URL?>/item/"+temp[0];
}
view_span = document.getElementById(id);
item_price = number_format(String(temp[2]));
view_span.innerHTML = "<img src='"+item_image_dir+"/"+temp[1]+"' width=100 height=80 border=1 style='border-color:#333333; cursor:pointer' onclick=\"popup_window('"+g4_path+"/shop/item.php?it_id="+temp[0]+"', '', '')\" title='새창으로 상품보기' alt='새창으로 상품보기'><br>"+item_price+" 원";
view_span.innerHTML = "<a href=\"<?=G4_SHOP_URL?>/item.php?it_id="+temp[0]+"\" target=\"_blank\"><img src=\""+item_image_url+"/"+temp[1]+"\"width=\"100\" height=\"80\" border=\"1\" style=\"border-color:#333333;\" title=\"상품 새창으로 보기\"></a><br>"+item_price+" 원";
}
function relation_add(fld)

View File

@ -1,8 +1,9 @@
<?
$sub_menu = "400300";
include_once("./_common.php");
include_once(G4_LIB_PATH.'/thumbnail.lib.php');
$sql = " select ca_id, it_id, it_name, it_amount
$sql = " select ca_id, it_id, it_name, it_amount, it_img1, it_img2, it_img3, it_img4, it_img5, it_img6, it_img7, it_img8, it_img9, it_img10
from {$g4['yc4_item_table']}
where ca_id like '$ca_id%'
and it_id <> '$it_id'
@ -24,7 +25,18 @@ for($i=0;$row=sql_fetch_array($result);$i++) {
$it_name = addslashes($row['it_name']);
$options .= "<option value=\"".$row['it_id']."/".$row['it_amount']."\">$ca_name : $it_name</option>\n";
// 상품이미지
for($i=1; $i<=10; $i++) {
$idx = 'it_img'.$i;
$filepath = G4_DATA_PATH.'/item/'.$row['it_id'];
$filename = $row[$idx];
if(file_exists($filepath.'/'.$filename) && $filename != "")
break;
}
$it_img = it_img_thumb($filename, $filepath, 100, 80);
$options .= "<option value=\"".$row['it_id']."/".$it_img."/".$row['it_amount']."\">$ca_name : $it_name</option>\n";
}
echo $options;

View File

@ -51,23 +51,23 @@ function itemdelete($it_id)
@rmdir(G4_DATA_PATH.'/item/'.$it_id);
// 장바구니 삭제
$sql = " delete from $g4[yc4_cart_table] where it_id = '$it_id' ";
$sql = " delete from `{$g4['yc4_cart_table']}` where it_id = '$it_id' ";
sql_query($sql);
// 이벤트삭제
$sql = " delete from $g4[yc4_event_item_table] where it_id = '$it_id' ";
$sql = " delete from `{$g4['yc4_event_item_table']}` where it_id = '$it_id' ";
sql_query($sql);
// 사용후기삭제
$sql = " delete from $g4[yc4_item_ps_table] where it_id = '$it_id' ";
$sql = " delete from `{$g4['yc4_item_ps_table']}` where it_id = '$it_id' ";
sql_query($sql);
// 상품문의삭제
$sql = " delete from $g4[yc4_item_qa_table] where it_id = '$it_id' ";
$sql = " delete from `{$g4['yc4_item_qa_table']}` where it_id = '$it_id' ";
sql_query($sql);
// 관련상품삭제
$sql = " delete from $g4[yc4_item_relation_table] where it_id = '$it_id' or it_id2 = '$it_id' ";
$sql = " delete from `{$g4['yc4_item_relation_table']}` where it_id = '$it_id' or it_id2 = '$it_id' ";
sql_query($sql);
// 선택옵션정보삭제
@ -86,9 +86,9 @@ function itemdelete($it_id)
//------------------------------------------------------------------------
// HTML 내용에서 에디터에 올라간 이미지의 경로를 얻어 삭제함
//------------------------------------------------------------------------
$sql = " select * from $g4[yc4_item_table] where it_id = '$it_id' ";
$sql = " select * from {$g4['yc4_item_table']} where it_id = '$it_id' ";
$it = sql_fetch($sql);
$s = $it[it_explan];
$s = $it['it_explan'];
$img_file = Array();
while($s) {
@ -114,7 +114,7 @@ function itemdelete($it_id)
// 상품 삭제
$sql = " delete from $g4[yc4_item_table] where it_id = '$it_id' ";
$sql = " delete from {$g4['yc4_item_table']} where it_id = '$it_id' ";
sql_query($sql);
}
@ -242,13 +242,13 @@ if ($w == "" || $w == "u")
// 관련상품을 우선 삭제함
sql_query(" delete from $g4[yc4_item_relation_table] where it_id = '$it_id' ");
sql_query(" delete from {$g4['yc4_item_relation_table']} where it_id = '$it_id' ");
// 관련상품의 반대도 삭제
sql_query(" delete from $g4[yc4_item_relation_table] where it_id2 = '$it_id' ");
sql_query(" delete from {$g4['yc4_item_relation_table']} where it_id2 = '$it_id' ");
// 이벤트상품을 우선 삭제함
sql_query(" delete from $g4[yc4_event_item_table] where it_id = '$it_id' ");
sql_query(" delete from {$g4['yc4_event_item_table']} where it_id = '$it_id' ");
// 개별배송비처리
if($default['de_send_cost_case'] == "개별배송") {
@ -398,7 +398,7 @@ else if ($w == "d")
and b.ca_mb_id = '$member[mb_id]' ";
$row = sql_fetch($sql);
if (!$row[it_id])
alert("\'{$member[mb_id]}\' 님께서 삭제 할 권한이 없는 상품입니다.");
alert("\'{$member['mb_id']}\' 님께서 삭제 할 권한이 없는 상품입니다.");
}
itemdelete($it_id);
@ -412,13 +412,13 @@ if ($w == "" || $w == "u")
{
if (trim($it_id2[$i]))
{
$sql = " insert into $g4[yc4_item_relation_table]
$sql = " insert into {$g4['yc4_item_relation_table']}
set it_id = '$it_id',
it_id2 = '$it_id2[$i]' ";
sql_query($sql, false);
// 관련상품의 반대로도 등록
$sql = " insert into $g4[yc4_item_relation_table]
$sql = " insert into {$g4['yc4_item_relation_table']}
set it_id = '$it_id2[$i]',
it_id2 = '$it_id' ";
sql_query($sql, false);
@ -431,7 +431,7 @@ if ($w == "" || $w == "u")
{
if (trim($ev_id[$i]))
{
$sql = " insert into $g4[yc4_event_item_table]
$sql = " insert into {$g4['yc4_event_item_table']}
set ev_id = '$ev_id[$i]',
it_id = '$it_id' ";
sql_query($sql, false);
@ -452,7 +452,7 @@ if ($w == "u") {
goto_url("./itemlist.php?$qstr");
}
echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=$g4[charset]\">";
echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">";
?>
<script>
if (confirm("계속 입력하시겠습니까?"))

View File

@ -80,6 +80,7 @@ function thumbnail($filename, $source_path, $target_path, $thumb_width, $thumb_h
imagepng($dst, $thumb_file, 0); // 0 (no compression) ~ 9
chmod($thumb_file, 0606); // 추후 삭제를 위하여 파일모드 변경
return str_replace($target_path.'/', '', $thumb_file);
return basename($thumb_file);
}
?>