상품개별삭제를 목록에서 일괄삭제로 변경 #218

This commit is contained in:
gnuboard
2013-06-10 15:15:06 +09:00
parent b39a9ece35
commit ff24fe19c0
4 changed files with 181 additions and 117 deletions

View File

@ -0,0 +1,106 @@
<?php
// itemlistdelete.php 에서 include 하는 파일
if (!defined('_GNUBOARD_')) exit;
if (!defined('_ITEM_DELETE_')) exit; // 개별 페이지 접근 불가
if (!function_exists("itemdelete")) {
// 상품삭제
// 메세지출력후 주문개별내역페이지로 이동
function itemdelete($it_id)
{
global $g4, $is_admin;
$sql = " select it_explan, it_mobile_explan, it_img1, it_img2, it_img3, it_img4, it_img5, it_img6, it_img7, it_img8, it_img9, it_img10
from {$g4['shop_item_table']} where it_id = '$it_id' ";
$it = sql_fetch($sql);
// 상품 이미지 삭제
$dir_list = array();
for($i=1; $i<=10; $i++) {
$file = G4_DATA_PATH.'/item/'.$it['it_img'.$i];
if(is_file($file) && $it['it_img'.$i]) {
@unlink($file);
$dir = dirname($file);
delete_item_thumbnail($dir, basename($file));
if(!in_array($dir, $dir_list))
$dir_list[] = $dir;
}
}
// 이미지디렉토리 삭제
for($i=0; $i<count($dir_list); $i++) {
if(is_dir($dir_list[$i]))
rmdir($dir_list[$i]);
}
// 상, 하단 이미지 삭제
@unlink(G4_DATA_PATH."/item/$it_id"."_h");
@unlink(G4_DATA_PATH."/item/$it_id"."_t");
// 장바구니 삭제
$sql = " delete from {$g4['shop_cart_table']} where it_id = '$it_id' ";
sql_query($sql);
// 이벤트삭제
$sql = " delete from {$g4['shop_event_item_table']} where it_id = '$it_id' ";
sql_query($sql);
// 사용후기삭제
$sql = " delete from {$g4['shop_item_ps_table']} where it_id = '$it_id' ";
sql_query($sql);
// 상품문의삭제
$sql = " delete from {$g4['shop_item_qa_table']} where it_id = '$it_id' ";
sql_query($sql);
// 관련상품삭제
$sql = " delete from {$g4['shop_item_relation_table']} where it_id = '$it_id' or it_id2 = '$it_id' ";
sql_query($sql);
//------------------------------------------------------------------------
// HTML 내용에서 에디터에 올라간 이미지의 경로를 얻어 삭제함
//------------------------------------------------------------------------
$imgs = get_editor_image($it['it_explan']);
for($i=0;$i<count($imgs[1]);$i++) {
$p = parse_url($imgs[1][$i]);
if(strpos($p['path'], "/data/") != 0)
$data_path = preg_replace("/^\/.*\/data/", "/data", $p['path']);
else
$data_path = $p['path'];
$destfile = G4_PATH.$data_path;
if(is_file($destfile))
@unlink($destfile);
}
$imgs = get_editor_image($it['it_mobile_explan']);
for($i=0;$i<count($imgs[1]);$i++) {
$p = parse_url($imgs[1][$i]);
if(strpos($p['path'], "/data/") != 0)
$data_path = preg_replace("/^\/.*\/data/", "/data", $p['path']);
else
$data_path = $p['path'];
$destfile = G4_PATH.$data_path;
if(is_file($destfile))
@unlink($destfile);
}
//------------------------------------------------------------------------
// 상품 삭제
$sql = " delete from {$g4['shop_item_table']} where it_id = '$it_id' ";
sql_query($sql);
}
}
itemdelete($it_id);
?>

View File

@ -10,102 +10,6 @@ if ($w == '' || $w == 'u')
else if ($w == 'd')
auth_check($auth[$sub_menu], "d");
// 상품삭제
// 메세지출력후 주문개별내역페이지로 이동
function itemdelete($it_id)
{
global $g4, $is_admin;
$sql = " select it_explan, it_mobile_explan, it_img1, it_img2, it_img3, it_img4, it_img5, it_img6, it_img7, it_img8, it_img9, it_img10
from {$g4['shop_item_table']} where it_id = '$it_id' ";
$it = sql_fetch($sql);
// 상품 이미지 삭제
$dir_list = array();
for($i=1; $i<=10; $i++) {
$file = G4_DATA_PATH.'/item/'.$it['it_img'.$i];
if(is_file($file) && $it['it_img'.$i]) {
@unlink($file);
$dir = dirname($file);
delete_item_thumbnail($dir, basename($file));
if(!in_array($dir, $dir_list))
$dir_list[] = $dir;
}
}
// 이미지디렉토리 삭제
for($i=0; $i<count($dir_list); $i++) {
if(is_dir($dir_list[$i]))
rmdir($dir_list[$i]);
}
// 상, 하단 이미지 삭제
@unlink(G4_DATA_PATH."/item/$it_id"."_h");
@unlink(G4_DATA_PATH."/item/$it_id"."_t");
// 장바구니 삭제
$sql = " delete from {$g4['shop_cart_table']} where it_id = '$it_id' ";
sql_query($sql);
// 이벤트삭제
$sql = " delete from {$g4['shop_event_item_table']} where it_id = '$it_id' ";
sql_query($sql);
// 사용후기삭제
$sql = " delete from {$g4['shop_item_ps_table']} where it_id = '$it_id' ";
sql_query($sql);
// 상품문의삭제
$sql = " delete from {$g4['shop_item_qa_table']} where it_id = '$it_id' ";
sql_query($sql);
// 관련상품삭제
$sql = " delete from {$g4['shop_item_relation_table']} where it_id = '$it_id' or it_id2 = '$it_id' ";
sql_query($sql);
//------------------------------------------------------------------------
// HTML 내용에서 에디터에 올라간 이미지의 경로를 얻어 삭제함
//------------------------------------------------------------------------
$imgs = get_editor_image($it['it_explan']);
for($i=0;$i<count($imgs[1]);$i++) {
$p = parse_url($imgs[1][$i]);
if(strpos($p['path'], "/data/") != 0)
$data_path = preg_replace("/^\/.*\/data/", "/data", $p['path']);
else
$data_path = $p['path'];
$destfile = G4_PATH.$data_path;
if(is_file($destfile))
@unlink($destfile);
}
$imgs = get_editor_image($it['it_mobile_explan']);
for($i=0;$i<count($imgs[1]);$i++) {
$p = parse_url($imgs[1][$i]);
if(strpos($p['path'], "/data/") != 0)
$data_path = preg_replace("/^\/.*\/data/", "/data", $p['path']);
else
$data_path = $p['path'];
$destfile = G4_PATH.$data_path;
if(is_file($destfile))
@unlink($destfile);
}
//------------------------------------------------------------------------
// 상품 삭제
$sql = " delete from {$g4['shop_item_table']} where it_id = '$it_id' ";
sql_query($sql);
}
@mkdir(G4_DATA_PATH."/item", 0707);
@chmod(G4_DATA_PATH."/item", 0707);
@ -428,6 +332,7 @@ else if ($w == "u")
where it_id = '$it_id' ";
sql_query($sql);
}
/*
else if ($w == "d")
{
if ($is_admin != 'super')
@ -443,6 +348,7 @@ else if ($w == "d")
itemdelete($it_id);
}
*/
if ($w == "" || $w == "u")
{

View File

@ -135,7 +135,7 @@ if ($sfl || $stx) // 검색렬일 때만 처음 버튼을 보여줌
<a href="./itemsellrank.php" class="btn_add_optional">상품판매순위</a>
</div>
<form name="fitemlistupdate" method="post" action="./itemlistupdate.php" autocomplete="off">
<form name="fitemlistupdate" method="post" action="./itemlistupdate.php" onsubmit="return fitemlist_submit(this);" autocomplete="off">
<input type="hidden" name="sca" value="<?php echo $sca; ?>">
<input type="hidden" name="sst" value="<?php echo $sst; ?>">
<input type="hidden" name="sod" value="<?php echo $sod; ?>">
@ -146,6 +146,7 @@ if ($sfl || $stx) // 검색렬일 때만 처음 버튼을 보여줌
<table>
<thead>
<tr>
<th scope="col" rowspan="2"><input type="checkbox" name="chkall" value="1" id="chkall" title="현재 페이지 게시판 전체선택" onclick="check_all(this.form)"></th>
<th scope="col" rowspan="2"><?php echo subject_sort_link('it_id', 'sca='.$sca); ?>상품코드 <span class="sound_only">순 정렬</span></a></th>
<th scope="col" colspan="2" rowspan="2">분류 및 <?php echo subject_sort_link('it_name', 'sca='.$sca); ?>상품명 <span class="sound_only">순 정렬</span></a></th>
<th scope="col" id="sit_amt"><?php echo subject_sort_link('it_price', 'sca='.$sca); ?>판매가격 <span class="sound_only">순 정렬</span></a></th>
@ -169,6 +170,9 @@ if ($sfl || $stx) // 검색렬일 때만 처음 버튼을 보여줌
$gallery = $row['it_gallery'] ? 'Y' : '';
?>
<tr>
<td rowspan="2">
<input type="checkbox" name="chk[]" value="<?php echo $i ?>" id="chk_<?php echo $i ?>" title="<?php echo get_text($row['bo_subject']) ?> 게시판선택">
</td>
<td rowspan="2">
<input type="hidden" name="it_id[<?php echo $i; ?>]" value="<?php echo $row['it_id']; ?>">
<?php echo $row['it_id']; ?>
@ -191,7 +195,7 @@ if ($sfl || $stx) // 검색렬일 때만 처음 버튼을 보여줌
<a href="<?php echo $href; ?>"><img src="./img/icon_view.jpg" alt="<?php echo htmlspecialchars2(cut_str($row['it_name'],250, "")); ?> 보기"></a>
<a href="./item_copy.php?it_id=<?php echo $row['it_id']; ?>&amp;ca_id=<?php echo $row['ca_id']; ?>" class="item_copy" target="_blank"><img src="./img/icon_copy.jpg" alt="<?php echo htmlspecialchars2(cut_str($row['it_name'],250, "")); ?> 복사"></a>
<a href="./itemform.php?w=u&amp;it_id=<?php echo $row['it_id']; ?>&amp;ca_id=<?php echo $row['ca_id']; ?>&amp;<?php echo $qstr; ?>"><img src="./img/icon_mod.jpg" alt="<?php echo htmlspecialchars2(cut_str($row['it_name'],250, "")); ?> 수정"></a>
<a href="./itemformupdate.php?w=d&amp;it_id=<?php echo $row['it_id']; ?>&amp;ca_id=<?php echo $row['ca_id']; ?>&amp;<?php echo $qstr; ?>" onclick="return delete_confirm();"><img src="./img/icon_del.jpg" alt="<?php echo htmlspecialchars2(cut_str($row['it_name'],250, "")); ?> 삭제"></a>
<!-- <a href="./itemformupdate.php?w=d&amp;it_id=<?php echo $row['it_id']; ?>&amp;ca_id=<?php echo $row['ca_id']; ?>&amp;<?php echo $qstr; ?>" onclick="return delete_confirm();"><img src="./img/icon_del.jpg" alt="<?php echo htmlspecialchars2(cut_str($row['it_name'],250, "")); ?> 삭제"></a> -->
</td>
</tr>
<tr>
@ -206,9 +210,15 @@ if ($sfl || $stx) // 검색렬일 때만 처음 버튼을 보여줌
</tbody>
</table>
<div class="btn_confirm">
<input type="submit" value="일괄수정" class="btn_submit" accesskey="s">
<div class="btn_list">
<input type="submit" name="act_button" value="선택수정" onclick="document.pressed=this.value">
<?php if ($is_admin == 'super') { ?>
<input type="submit" name="act_button" value="선택삭제" onclick="document.pressed=this.value">
<?php } ?>
</div>
<!-- <div class="btn_confirm">
<input type="submit" value="일괄수정" class="btn_submit" accesskey="s">
</div> -->
</form>
</section>
@ -216,6 +226,22 @@ if ($sfl || $stx) // 검색렬일 때만 처음 버튼을 보여줌
<?php echo get_paging($config['cf_write_pages'], $page, $total_page, "{$_SERVER['PHP_SELF']}?$qstr&amp;page="); ?>
<script>
function fitemlist_submit(f)
{
if (!is_checked("chk[]")) {
alert(document.pressed+" 하실 항목을 하나 이상 선택하세요.");
return false;
}
if(document.pressed == "선택삭제") {
if(!confirm("선택한 자료를 정말 삭제하시겠습니까?")) {
return false;
}
}
return true;
}
$(function() {
$(".item_copy").click(function() {
var href = $(this).attr("href");

View File

@ -4,24 +4,50 @@ include_once('./_common.php');
check_demo();
auth_check($auth[$sub_menu], "w");
// 판매가격 일괄수정
for ($i=0; $i<count($_POST['it_id']); $i++)
{
$sql = "update {$g4['shop_item_table']}
set ca_id = '{$_POST['ca_id'][$i]}',
it_name = '{$_POST['it_name'][$i]}',
it_cust_price = '{$_POST['it_cust_price'][$i]}',
it_price = '{$_POST['it_price'][$i]}',
it_point = '{$_POST['it_point'][$i]}',
it_stock_qty = '{$_POST['it_stock_qty'][$i]}',
it_use = '{$_POST['it_use'][$i]}',
it_order = '{$_POST['it_order'][$i]}'
where it_id = '{$_POST['it_id'][$i]}' ";
sql_query($sql);
if (!count($_POST['chk'])) {
alert($_POST['act_button']." 하실 항목을 하나 이상 체크하세요.");
}
if ($_POST['act_button'] == "선택수정") {
auth_check($auth[$sub_menu], 'w');
for ($i=0; $i<count($_POST['chk']); $i++) {
// 실제 번호를 넘김
$k = $_POST['chk'][$i];
$sql = "update {$g4['shop_item_table']}
set ca_id = '{$_POST['ca_id'][$k]}',
it_name = '{$_POST['it_name'][$k]}',
it_cust_price = '{$_POST['it_cust_price'][$k]}',
it_price = '{$_POST['it_price'][$k]}',
it_point = '{$_POST['it_point'][$k]}',
it_stock_qty = '{$_POST['it_stock_qty'][$k]}',
it_use = '{$_POST['it_use'][$k]}',
it_order = '{$_POST['it_order'][$k]}'
where it_id = '{$_POST['it_id'][$k]}' ";
sql_query($sql);
}
} else if ($_POST['act_button'] == "선택삭제") {
if ($is_admin != 'super')
alert('상품 삭제는 최고관리자만 가능합니다.');
auth_check($auth[$sub_menu], 'd');
// _ITEM_DELETE_ 상수를 선언해야 itemdelete.inc.php 가 정상 작동함
define('_ITEM_DELETE_', true);
for ($i=0; $i<count($_POST['chk']); $i++) {
// 실제 번호를 넘김
$k = $_POST['chk'][$i];
// include 전에 $it_id 값을 반드시 넘겨야 함
$it_id = $_POST['it_id'][$k];
include ('./itemdelete.inc.php');
}
}
//goto_url("./itemlist.php?sort1=$sort1&amp;sort2=$sort2&amp;sel_ca_id=$sel_ca_id&amp;sel_field=$sel_field&amp;search=$search&amp;page=$page");
goto_url("./itemlist.php?sca=$sca&amp;sst=$sst&amp;sod=$sod&amp;sfl=$sfl&amp;stx=$stx&amp;page=$page");
?>