사용후기 관련된 코드 변경

This commit is contained in:
gnuboard
2013-06-14 16:56:34 +09:00
parent 8e05a87f05
commit 7dbff272b4
23 changed files with 700 additions and 82 deletions

View File

@ -147,6 +147,16 @@ if ($row['it_id']) {
$next_href2 = '';
}
// 관리자가 확인하 사용후기의 갯수를 얻음
$sql = " select count(*) as cnt from `{$g4['shop_item_use_table']}` where it_id = '{$it_id}' and is_confirm = '1' ";
$row = sql_fetch($sql);
$item_use_count = $row['cnt'];
// 상품문의의 갯수를 얻음
$sql = " select count(*) as cnt from `{$g4['shop_item_qa_table']}` where it_id = '{$it_id}' ";
$row = sql_fetch($sql);
$item_qa_count = $row['cnt'];
// 관련상품의 갯수를 얻음
$sql = " select count(*) as cnt
from {$g4['shop_item_relation_table']} a
@ -159,14 +169,15 @@ $item_relation_count = $row['cnt'];
<?php
function pg_anchor($anc_id) {
global $default;
global $item_use_count, $item_qa_count, $item_relation_count;
?>
<ul class="sanchor">
<li><a href="#sit_inf" <?php if ($anc_id == 'inf') echo 'class="sanchor_on"'; ?>>상품정보</a></li>
<li><a href="#sit_use" <?php if ($anc_id == 'use') echo 'class="sanchor_on"'; ?>>사용후기 <span class="item_use_count"></span></a></li>
<li><a href="#sit_qa" <?php if ($anc_id == 'qa') echo 'class="sanchor_on"'; ?>>상품문의 <span class="item_qa_count"></span></a></li>
<li><a href="#sit_use" <?php if ($anc_id == 'use') echo 'class="sanchor_on"'; ?>>사용후기 <span class="item_use_count"><?php echo $item_use_count; ?></span></a></li>
<li><a href="#sit_qa" <?php if ($anc_id == 'qa') echo 'class="sanchor_on"'; ?>>상품문의 <span class="item_qa_count"><?php echo $item_qa_count; ?></span></a></li>
<?php if ($default['de_baesong_content']) { ?><li><a href="#sit_dvr" <?php if ($anc_id == 'dvr') echo 'class="sanchor_on"'; ?>>배송정보</a></li><?php } ?>
<?php if ($default['de_change_content']) { ?><li><a href="#sit_ex" <?php if ($anc_id == 'ex') echo 'class="sanchor_on"'; ?>>교환정보</a></li><?php } ?>
<li><a href="#sit_rel" <?php if ($anc_id == 'rel') echo 'class="sanchor_on"'; ?>>관련상품 <span class="item_relation_count"></span></a></li>
<li><a href="#sit_rel" <?php if ($anc_id == 'rel') echo 'class="sanchor_on"'; ?>>관련상품 <span class="item_relation_count"><?php echo $item_relation_count; ?></span></a></li>
</ul>
<?php } ?>
@ -659,9 +670,9 @@ else
return false;
});
$(".item_use_count").text("<?php echo $use_total_count; ?>");
$(".item_qa_count").text("<?php echo $qa_total_count; ?>");
$(".item_relation_count").text("<?php echo $item_relation_count; ?>");
//$(".item_use_count").text("<?php echo $use_total_count; ?>");
//$(".item_qa_count").text("<?php echo $qa_total_count; ?>");
//$(".item_relation_count").text("<?php echo $item_relation_count; ?>");
});
// 바로구매 또는 장바구니 담기

View File

@ -4,8 +4,8 @@ include_once(G4_LIB_PATH.'/thumbnail.lib.php');
$it_id = $_REQUEST['it_id'];
$itemuse_write = G4_BBS_URL.'/write.php?bo_table=itemuse&amp;wr_1='.$it_id;
$itemuse_board = G4_BBS_URL.'/board.php?bo_table=itemuse&amp;wr_1='.$it_id;
$itemuse_form = "./itemuseform.php?it_id=".$it_id;
$itemuse_list = "./itemuselist.php";
include_once(G4_PATH.'/head.sub.php');
?>
@ -30,7 +30,7 @@ include_once(G4_PATH.'/head.sub.php');
wr_4 : 관리자확인
*/
//$sql_common = " from `{$g4['write_prefix']}itemuse` where wr_is_comment = 0 and wr_1 = '{$it['it_id']}' and wr_4 = '1' ";
$sql_common = " from `{$g4['write_prefix']}itemuse` where wr_is_comment = 0 and wr_1 = '{$it_id}' ";
$sql_common = " from `{$g4['shop_item_use_table']}` where it_id = '{$it_id}' and is_confirm = '1' ";
// 테이블의 전체 레코드수만 얻음
$sql = " select COUNT(*) as cnt " . $sql_common;
@ -42,34 +42,34 @@ $total_page = ceil($total_count / $rows); // 전체 페이지 계산
if ($page == "") $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 레코드 구함
$sql = "select * $sql_common order by wr_num limit $from_record, $rows ";
$sql = "select * $sql_common order by is_id desc limit $from_record, $rows ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$use_num = $total_count - ($page - 1) * $rows - $i;
$use_star = get_star($row['wr_3']);
$use_name = get_text($row['wr_name']);
$use_subject = conv_subject($row['wr_subject'],50,"…");
//$use_content = ($row['wr_content']);
$use_content = get_view_thumbnail($row['wr_content'], 300);
$use_time = substr($row['wr_datetime'], 2, 8);
$use_href = G4_BBS_URL.'/board.php?bo_table=itemuse&amp;wr_id='.$row['wr_id'];
$is_num = $total_count - ($page - 1) * $rows - $i;
$is_star = get_star($row['is_score']);
$is_name = get_text($row['is_name']);
$is_subject = conv_subject($row['is_subject'],50,"…");
//$is_content = ($row['wr_content']);
$is_content = get_view_thumbnail($row['is_content'], 300);
$is_time = substr($row['is_time'], 2, 8);
$is_href = './itemuselist.php?bo_table=itemuse&amp;wr_id='.$row['wr_id'];
// http://stackoverflow.com/questions/6967081/show-hide-multiple-divs-with-jquery?answertab=votes#tab-top
?>
<tr>
<td class="td_num"><?php echo $use_num; ?><span class="sound_only">번</span></td>
<td class="td_num"><?php echo $is_num; ?><span class="sound_only">번</span></td>
<td>
<a href="<?php echo $use_href; ?>" class="use_href" onclick="return false;" target="<?php echo $i; ?>"><?php echo $use_subject; ?></a>
<a href="#sit_use" class="use_href" onclick="return false;" target="<?php echo $i; ?>"><?php echo $is_subject; ?></a>
<div id="use_div<?php echo $i; ?>" class="use_div" style="display:none;">
<?php echo $use_content; ?>
<?php echo $is_content; ?>
</div>
</td>
<td><?php echo $use_name; ?></td>
<td><?php echo $use_time; ?></td>
<td><img src="<?php echo G4_URL; ?>/img/shop/s_star<?php echo $use_star; ?>.png" alt="별<?php echo $use_star; ?>개"></td>
<td><?php echo $is_name; ?></td>
<td><?php echo $is_time; ?></td>
<td><img src="<?php echo G4_URL; ?>/img/shop/s_star<?php echo $is_star; ?>.png" alt="별<?php echo $is_star; ?>개"></td>
</tr>
<?php
@ -126,23 +126,25 @@ echo itemuse_page(10, $page, $total_page, "./itemuse.php?it_id=$it_id&amp;page="
<div class="sit_use_btn">
<!-- <a href="javascript:itemusewin('it_id=<?php echo $it_id; ?>');">사용후기 쓰기<span class="sound_only"> 새 창</span></a> -->
<a href="<?php echo $itemuse_write; ?>" id="itemuse_write" onclick="return false;" class="btn02">사용후기 쓰기<span class="sound_only"> 새 창</span></a>
<a href="<?php echo $itemuse_board; ?>" id="itemuse_board" target="_blank" class="btn01">더보기</a>
<a href="<?php echo $itemuse_form; ?>" id="itemuse_form" onclick="return false;" class="btn02">사용후기 쓰기<span class="sound_only"> 새 창</span></a>
<a href="<?php echo $itemuse_list; ?>" id="itemuse_list" class="btn01">더보기</a>
</div>
<script>
$(function(){
$("#itemuse_write").click(function(){
window.open(this.href, "itemuse_write", "width=800,height=550");
});
$("#itemuse_board").click(function(){
window.open(this.href, "itemuse_board", "width=800,height=550");
$("#itemuse_form").click(function(){
window.open(this.href, "itemuse_form", "width=800,height=550");
});
$(".use_href").click(function(){
$(".use_div").hide();
$("#use_div"+$(this).attr("target")).show();
var $content = $("#use_div"+$(this).attr("target"));
$(".use_div").each(function(index, value){
if ($(this).get(0) == $content.get(0)) { // 객체의 비교시 .get(0) 를 사용한다.
$(this).is(":hidden") ? $(this).show() : $(this).hide();
} else {
$(this).hide();
}
});
});
$(".pg_page").click(function(){

107
shop/itemuseform.php Normal file
View File

@ -0,0 +1,107 @@
<?php
include_once("./_common.php");
include_once(G4_CKEDITOR_PATH.'/ckeditor.lib.php');
// 사용후기의 내용에 쓸수 있는 최대 글자수 (한글은 영문3자)
$is_content_max_length = 10000;
$w = escape_trim($_REQUEST['w']);
$it_id = escape_trim($_REQUEST['it_id']);
$is_id = escape_trim($_REQUEST['is_id']);
if (!$is_member) {
alert("사용후기는 회원만 평가가 가능합니다.", G4_BBS_URL."/login.php");
}
if ($w == "") {
$is_score = 10;
} else if ($w == "u") {
$use = sql_fetch(" select * from {$g4['shop_item_use_table']} where is_id = '$is_id' ");
if (!$use) {
alert_close("사용후기 정보가 없습니다.");
}
$it_id = $use['it_id'];
$is_score = $use['is_score'];
if (!$is_admin && $use['mb_id'] != $member['mb_id']) {
alert_close("자신의 사용후기만 수정이 가능합니다.");
}
}
include_once(G4_PATH.'/head.sub.php');
?>
<style>
ul {list-style:none;margin:0px;padding:0px;}
label {width:130px;vertical-align:top;padding:3px 0;}
</style>
<div style="padding:10px;">
<form name="fitemuse" method="post" action="./itemuseformupdate.php" onsubmit="return fitemuse_submit(this);" autocomplete="off">
<input type="hidden" name="w" value="<?php echo $w; ?>">
<input type="hidden" name="it_id" value="<?php echo $it_id; ?>">
<input type="hidden" name="is_id" value="<?php echo $is_id; ?>">
<fieldset style="padding:0 10px 10px;">
<legend><strong>사용후기 쓰기</strong></legend>
<ul style="padding:10px;">
<li>
<label for="is_subject">제목</label>
<input type="text" id="is_subject" name="is_subject" size="100" class="ed" minlength="2" maxlength="250" required itemname="제목" value="<?php echo get_text($use['is_subject']); ?>">
</li>
<li>
<label for="" style="width:200px;">내용</label>
<?php echo editor_html('is_content', $use['is_content']); ?>
</li>
<li>
<label>평가</label>
<input type=radio name=is_score value='10' <?php echo ($is_score==10)?"checked='checked'":""; ?>><img src='<?php echo G4_SHOP_URL; ?>/img/star5.gif' align=absmiddle>
<input type=radio name=is_score value='8' <?php echo ($is_score==8)?"checked='checked'":""; ?>><img src='<?php echo G4_SHOP_URL; ?>/img/star4.gif' align=absmiddle>
<input type=radio name=is_score value='6' <?php echo ($is_score==6)?"checked='checked'":""; ?>><img src='<?php echo G4_SHOP_URL; ?>/img/star3.gif' align=absmiddle>
<input type=radio name=is_score value='4' <?php echo ($is_score==4)?"checked='checked'":""; ?>><img src='<?php echo G4_SHOP_URL; ?>/img/star2.gif' align=absmiddle>
<input type=radio name=is_score value='2' <?php echo ($is_score==2)?"checked='checked'":""; ?>><img src='<?php echo G4_SHOP_URL; ?>/img/star1.gif' align=absmiddle>
</li>
</ul>
<input type="submit" value=" 확 인 ">
</fieldset>
</form>
</div>
<script type="text/javascript">
self.focus();
function fitemuse_submit(f)
{
/*
if (document.getElementById('tx_is_content')) {
var len = ed_is_content.inputLength();
if (len == 0) {
alert('내용을 입력하십시오.');
ed_is_content.returnFalse();
return false;
} else if (len > 1000) {
alert('내용은 1000글자 까지만 입력해 주세요.');
ed_is_content.returnFalse();
return false;
}
}
*/
<?php echo get_editor_js('is_content'); ?>
if (is_content_editor_data.length > <?php echo $is_content_max_length; ?>) {
alert("내용은 <?php echo $is_content_max_length; ?> 글자 이내에서 작성해 주세요. (한글은 영문 3자)\n\n현재 : "+is_content_editor_data.length+" 글자");
CKEDITOR.instances.is_content.focus();
return false;
}
return true;
}
$(function() {
$("#is_subject").focus();
});
</script>
<?php
include_once(G4_PATH.'/tail.sub.php');
?>

View File

@ -0,0 +1,67 @@
<?php
include_once('./_common.php');
if (!$is_member) {
alert_close("사용후기는 회원만 등록이 가능합니다.");
}
$is_subject = trim($_REQUEST['is_subject']);
$is_content = trim($_REQUEST['is_content']);
if ($w == "" || $w == "u") {
$is_name = $member['mb_name'];
$is_password = $member['mb_password'];
if (!$is_subject) alert("제목을 입력하여 주십시오.");
if (!$is_content) alert("내용을 입력하여 주십시오.");
}
$url = "./item.php?it_id=$it_id";
if ($w == "") {
/*
$sql = " select max(is_id) as max_is_id from {$g4['shop_item_use_table']} ";
$row = sql_fetch($sql);
$max_is_id = $row['max_is_id'];
$sql = " select max(is_id) as max_is_id from {$g4['shop_item_use_table']} where it_id = '$it_id' and mb_id = '{$member['mb_id']}' ";
$row = sql_fetch($sql);
if ($row['max_is_id'] && $row['max_is_id'] == $max_is_id)
alert("같은 상품에 대하여 계속해서 평가하실 수 없습니다.");
*/
$sql = "insert {$g4['shop_item_use_table']}
set it_id = '$it_id',
mb_id = '{$member['mb_id']}',
is_score = '$is_score',
is_name = '$is_name',
is_password = '$is_password',
is_subject = '$is_subject',
is_content = '$is_content',
is_time = '".G4_TIME_YMDHIS."',
is_ip = '{$_SERVER['REMOTE_ADDR']}' ";
if (!$default['de_item_use_use'])
$sql .= ", is_confirm = '1' ";
sql_query($sql);
if ($default['de_item_use_use']) {
alert_opener("평가하신 글은 관리자가 확인한 후에 출력됩니다.", $url);
} else {
alert_opener("사용후기가 등록 되었습니다.", $url);
}
} else if ($w == "u") {
$sql = " select is_password from {$g4['shop_item_use_table']} where is_id = '$is_id' ";
$row = sql_fetch($sql);
if ($row['is_password'] != $is_password)
alert("패스워드가 틀리므로 수정하실 수 없습니다.");
$sql = " update {$g4['shop_item_use_table']}
set is_subject = '$is_subject',
is_content = '$is_content',
is_score = '$is_score'
where is_id = '$is_id' ";
sql_query($sql);
alert_opener("사용후기가 수정 되었습니다.", $url);
}
?>

View File

@ -2,11 +2,42 @@
include_once('./_common.php');
include_once(G4_LIB_PATH.'/thumb.lib.php');
$sfl = escape_trim($_REQUEST['sfl']);
$stx = escape_trim($_REQUEST['stx']);
$g4['title'] = '사용후기';
include_once('./_head.php');
$sql_common = " from {$g4['shop_item_ps_table']} where is_confirm = '1' ";
$sql_order = " order by is_time desc ";
$sql_common = " from `{$g4['shop_item_use_table']}` a join `{$g4['shop_item_table']}` b on (a.it_id=b.it_id) ";
$sql_search = " where a.is_confirm = '1' ";
if ($stx) {
$sql_search .= " and ( ";
switch ($sfl) {
case "a.it_id" :
$sql_search .= " ($sfl like '$stx%') ";
break;
case "a.is_name" :
case "a.mb_id" :
$sql_search .= " ($sfl = '$stx') ";
break;
default :
$sql_search .= " ($sfl like '%$stx%') ";
break;
}
$sql_search .= " ) ";
}
if (!$sst) {
$sst = "a.is_id";
$sod = "desc";
}
$sql_order = " order by $sst $sod ";
/*
$sql_common = " from {$g4['shop_item_use_table']} where is_confirm = '1' ";
$sql_order = " order by is_id desc ";
*/
$sql = " select count(*) as cnt
$sql_common
@ -21,9 +52,25 @@ if ($page == "") { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페
$from_record = ($page - 1) * $rows; // 시작 열을 구함
?>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">전체보기</a>
<form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="sfl" required title="검색항목선택">
<option value="">선택</option>
<option value="b.it_name" <?php echo get_selected($_GET['sfl'], "b.it_name", true); ?>>상품명</option>
<option value="a.it_id" <?php echo get_selected($_GET['sfl'], "a.it_id"); ?>>상품코드</option>
<option value="a.is_subject"<?php echo get_selected($_GET['sfl'], "a.is_subject"); ?>>후기제목</option>
<option value="a.is_content">후기제목</option>
<option value="a.is_name">작성자명</option>
<option value="a.mb_id">작성자아이디</option>
</select>
<input type="text" name="stx" required title="검색어" value="<?php echo $stx; ?>">
<input type="submit" value="검색">
</form>
<div id="sps">
<p><?php echo $config['cf_title']; ?> 전체 사용후기 목록입니다.</p>
<!-- <p><?php echo $config['cf_title']; ?> 전체 사용후기 목록입니다.</p> -->
<?php
$sql = " select *
@ -37,8 +84,7 @@ $from_record = ($page - 1) * $rows; // 시작 열을 구함
$num = $total_count - ($page - 1) * $rows - $i;
$star = get_star($row['is_score']);
$thumb = new g4_thumb(G4_DATA_PATH.'/itemuse', 500);
$is_content = $thumb->run($row['is_content']);
$is_content = get_view_thumbnail($row['is_content'], 500);
$is_time = substr($row['is_time'], 2, 14);
$small_image = $row['it_id'];
@ -68,11 +114,11 @@ $from_record = ($page - 1) * $rows; // 시작 열을 구함
<dd><img src="<?php echo G4_URL; ?>/img/shop/s_star<?php echo $star; ?>.png" alt="별<?php echo $star; ?>개"></dd>
</dl>
<p id="sps_con_<?php echo $i; ?>">
<div id="sps_con_<?php echo $i; ?>" style="display:none;">
<?php echo $is_content; // 상품 문의 내용 ?>
</p>
</div>
<div class="sps_con_btn"><button class="sps_con_<?php echo $i; ?>">보기</button></div>
<div class="sps_con_btn"><button class="sps_con_<?php echo $i; ?>">보기</button></div>
</section>
</li>
@ -89,15 +135,15 @@ $from_record = ($page - 1) * $rows; // 시작 열을 구함
<script>
$(function(){
// 사용후기 더보기
$('.sps_con_btn button').click(function(){
$this = $(this);
sps_con_no = $this.attr('class');
$('#'+sps_con_no).toggleClass('sps_con_full');
$(".sps_con_btn button").click(function(){
var sps_con_no = $(this).attr("class");
$("#"+sps_con_no).is(":hidden") ? $("#"+sps_con_no).show() : $("#"+sps_con_no).hide();
});
$('.sps_con_btn button').toggle(function(){
$this.text('닫기');
$(".sps_con_btn button").toggle(function(){
$(this).text("닫기");
}, function(){
$this.text('더보기');
$(this).text("보기");
});
});
</script>

View File

@ -45,18 +45,18 @@ $url = "./item.php?it_id=$it_id";
if ($w == '')
{
$sql = " select max(is_id) as max_is_id from {$g4['shop_item_ps_table']} ";
$sql = " select max(is_id) as max_is_id from {$g4['shop_item_use_table']} ";
$row = sql_fetch($sql);
$max_is_id = $row['max_is_id'];
$sql = " select max(is_id) as max_is_id from {$g4['shop_item_ps_table']}
$sql = " select max(is_id) as max_is_id from {$g4['shop_item_use_table']}
where it_id = '$it_id'
and mb_id = '{$member['mb_id']}' ";
$row = sql_fetch($sql);
if ($row['max_is_id'] && $row['max_is_id'] == $max_is_id)
alert("같은 상품에 대하여 계속해서 평가하실 수 없습니다.");
$sql = "insert {$g4['shop_item_ps_table']}
$sql = "insert {$g4['shop_item_use_table']}
set it_id = '$it_id',
mb_id = '{$member['mb_id']}',
is_score = '$is_score',
@ -66,23 +66,23 @@ if ($w == '')
is_content = '$is_content',
is_time = '".G4_TIME_YMDHIS."',
is_ip = '{$_SERVER['REMOTE_ADDR']}' ";
if (!$default['de_item_ps_use'])
if (!$default['de_item_use_use'])
$sql .= ", is_confirm = '1' ";
sql_query($sql);
if ($default['de_item_ps_use'])
if ($default['de_item_use_use'])
alert("평가하신 글은 관리자가 확인한 후에 표시됩니다.", $url);
else
goto_url($url);
}
else if ($w == 'u')
{
$sql = " select is_password from {$g4['shop_item_ps_table']} where is_id = '$is_id' ";
$sql = " select is_password from {$g4['shop_item_use_table']} where is_id = '$is_id' ";
$row = sql_fetch($sql);
if ($row['is_password'] != $is_password)
alert("패스워드가 틀리므로 수정하실 수 없습니다.");
$sql = " update {$g4['shop_item_ps_table']}
$sql = " update {$g4['shop_item_use_table']}
set is_subject = '$is_subject',
is_content = '$is_content',
is_score = '$is_score'
@ -95,7 +95,7 @@ else if ($w == 'd')
{
if ($is_member)
{
$sql = " select count(*) as cnt from {$g4['shop_item_ps_table']} where mb_id = '{$member['mb_id']}' and is_id = '$is_id' ";
$sql = " select count(*) as cnt from {$g4['shop_item_use_table']} where mb_id = '{$member['mb_id']}' and is_id = '$is_id' ";
$row = sql_fetch($sql);
if (!$row['cnt'])
alert("자신의 사용후기만 삭제하실 수 있습니다.");
@ -104,13 +104,13 @@ else if ($w == 'd')
{
$is_password = sql_password($is_password);
$sql = " select is_password from {$g4['shop_item_ps_table']} where is_id = '$is_id' ";
$sql = " select is_password from {$g4['shop_item_use_table']} where is_id = '$is_id' ";
$row = sql_fetch($sql);
if ($row['is_password'] != $is_password)
alert("패스워드가 틀리므로 삭제하실 수 없습니다.");
}
$sql = " delete from {$g4['shop_item_ps_table']} where mb_id = '{$member['mb_id']}' and is_id = '$is_id' ";
$sql = " delete from {$g4['shop_item_use_table']} where mb_id = '{$member['mb_id']}' and is_id = '$is_id' ";
sql_query($sql);
goto_url($url);