재입고SMS 알림 기능 추가

This commit is contained in:
chicpro
2014-02-26 11:06:10 +09:00
parent 4a9c29d3be
commit e2ea67feba
13 changed files with 452 additions and 4 deletions

View File

@ -6,6 +6,7 @@ $menu['menu500'] = array (
array('500110', '매출현황', G5_ADMIN_URL.'/shop_admin/sale1.php', 'sst_order_stats'),
array('500100', '상품판매순위', G5_ADMIN_URL.'/shop_admin/itemsellrank.php', 'sst_rank'),
array('500120', '주문내역출력', G5_ADMIN_URL.'/shop_admin/orderprint.php', 'sst_print_order', 1),
array('500400', '재입고SMS알림', G5_ADMIN_URL.'/shop_admin/itemstocksms.php', 'sst_stock_sms', 1),
array('500300', '이벤트관리', G5_ADMIN_URL.'/shop_admin/itemevent.php', 'scf_event'),
array('500310', '이벤트일괄처리', G5_ADMIN_URL.'/shop_admin/itemeventlist.php', 'scf_event_mng'),
array('500500', '배너관리', G5_ADMIN_URL.'/shop_admin/bannerlist.php', 'scf_banner', 1),

View File

@ -88,6 +88,12 @@ for ($i=0; $row=sql_fetch_array($result); $i++)
$script .= "ca_sell_email['{$row['ca_id']}'] = '{$row['ca_sell_email']}';\n";
}
// 재입고알림 설정 필드 추가
if(!sql_query(" select it_stock_sms from {$g5['g5_shop_item_table']} limit 1 ", false)) {
sql_query(" ALTER TABLE `{$g5['g5_shop_item_table']}`
ADD `it_stock_sms` tinyint(4) NOT NULL DEFAULT '0' AFTER `it_stock_qty` ", true);
}
$pg_anchor ='<ul class="anchor">
<li><a href="#anc_sitfrm_cate">상품분류</a></li>
<li><a href="#anc_sitfrm_ini">기본정보</a></li>
@ -507,6 +513,13 @@ $(function(){
<label for="chk_all_it_soldout">전체적용</label>
</td>
</tr>
<tr>
<th scope="row"><label for="it_stock_sms">재입고SMS 알림</label></th>
<td colspan="2">
<?php echo help("상품이 품절인 경우에 체크해 놓으면 상품상세보기에서 고객이 재입고SMS 알림을 신청할 수 있게 됩니다."); ?>
<input type="checkbox" name="it_stock_sms" value="1" id="it_stock_sms" <?php echo ($it['it_stock_sms']) ? "checked" : ""; ?>> 예
</td>
</tr>
<tr>
<th scope="row"><label for="it_stock_qty">재고수량</label></th>
<td>

View File

@ -292,6 +292,7 @@ $sql_common = " ca_id = '$ca_id',
it_use = '$it_use',
it_soldout = '$it_soldout',
it_stock_qty = '$it_stock_qty',
it_stock_sms = '$it_stock_sms',
it_noti_qty = '$it_noti_qty',
it_sc_type = '$it_sc_type',
it_sc_method = '$it_sc_method',

View File

@ -39,7 +39,9 @@ $sql = " select it_id,
it_name,
it_use,
it_stock_qty,
it_noti_qty
it_stock_sms,
it_noti_qty,
it_soldout
$sql_common
order by $sort1 $sort2
limit $from_record, $rows ";
@ -118,6 +120,8 @@ $listall = '<a href="'.$_SERVER['PHP_SELF'].'" class="ov_listall">전체목록</
<th scope="col">가재고</th>
<th scope="col">재고수정</th>
<th scope="col"><a href="<?php echo title_sort("it_use") . "&amp;$qstr1"; ?>">판매</a></th>
<th scope="col"><a href="<?php echo title_sort("it_soldout") . "&amp;$qstr1"; ?>">품절</a></th>
<th scope="col"><a href="<?php echo title_sort("it_stock_sms") . "&amp;$qstr1"; ?>">재입고알림</a></th>
<th scope="col">관리</th>
</tr>
</thead>
@ -160,18 +164,20 @@ $listall = '<a href="'.$_SERVER['PHP_SELF'].'" class="ov_listall">전체목록</
<input type="hidden" name="it_id[<?php echo $i; ?>]" value="<?php echo $row['it_id']; ?>">
<?php echo $row['it_id']; ?>
</td>
<td><a href="<?php echo $href; ?>"><?php echo get_it_image($row['it_id'], 50, 50); ?><?php echo cut_str(stripslashes($row['it_name']), 60, "&#133"); ?></a></td>
<td><a href="<?php echo $href; ?>"><?php echo get_it_image($row['it_id'], 50, 50); ?> <?php echo cut_str(stripslashes($row['it_name']), 60, "&#133"); ?></a></td>
<td class="td_num<?php echo $it_stock_qty_st; ?>"><?php echo $it_stock_qty; ?></td>
<td class="td_num"><?php echo number_format($wait_qty); ?></td>
<td class="td_num"><?php echo number_format($temporary_qty); ?></td>
<td class="td_num"><input type="text" name="it_stock_qty[<?php echo $i; ?>]" value="<?php echo $row['it_stock_qty']; ?>" class="frm_input" size="10" autocomplete="off"></td>
<td class="td_chk"><input type="checkbox" name="it_use[<?php echo $i; ?>]" value="1" <?php echo ($row['it_use'] ? "checked" : ""); ?>></td>
<td class="td_chk"><input type="checkbox" name="it_soldout[<?php echo $i; ?>]" value="1" <?php echo ($row['it_soldout'] ? "checked" : ""); ?>></td>
<td class="td_chk"><input type="checkbox" name="it_stock_sms[<?php echo $i; ?>]" value="1" <?php echo ($row['it_stock_sms'] ? "checked" : ""); ?>></td>
<td class="td_mngsmall"><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; ?>">수정</a></td>
</tr>
<?php
}
if (!$i)
echo '<tr><td colspan="8" class="empty_table"><span>자료가 없습니다.</span></td></tr>';
echo '<tr><td colspan="10" class="empty_table"><span>자료가 없습니다.</span></td></tr>';
?>
</tbody>
</table>

View File

@ -11,7 +11,9 @@ for ($i=0; $i<count($_POST['it_id']); $i++)
{
$sql = "update {$g5['g5_shop_item_table']}
set it_stock_qty = '{$_POST['it_stock_qty'][$i]}',
it_use = '{$_POST['it_use'][$i]}'
it_use = '{$_POST['it_use'][$i]}',
it_soldout = '{$_POST['it_soldout'][$i]}',
it_stock_sms = '{$_POST['it_stock_sms'][$i]}'
where it_id = '{$_POST['it_id'][$i]}' ";
sql_query($sql);
}

View File

@ -0,0 +1,181 @@
<?php
$sub_menu = '500400';
include_once('./_common.php');
auth_check($auth[$sub_menu], "r");
$g5['title'] = '재입고SMS 알림';
include_once (G5_ADMIN_PATH.'/admin.head.php');
// 테이블 생성
if(!isset($g5['g5_shop_item_stocksms_table']))
die('<meta charset="utf-8">dbconfig.php 파일에 <strong>$g5[\'g5_shop_item_stocksms_table\'] = G5_SHOP_TABLE_PREFIX.\'item_stocksms\';</strong> 를 추가해 주세요.');
if(!sql_query(" select ss_id from {$g5['g5_shop_item_stocksms_table']} limit 1", false)) {
sql_query(" CREATE TABLE IF NOT EXISTS `{$g5['g5_shop_item_stocksms_table']}` (
`ss_id` int(11) NOT NULL AUTO_INCREMENT,
`it_id` varchar(20) NOT NULL DEFAULT '',
`ss_hp` varchar(255) NOT NULL DEFAULT '',
`ss_send` tinyint(4) NOT NULL DEFAULT '0',
`ss_send_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`ss_datetime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`ss_ip` varchar(25) NOT NULL DEFAULT '',
PRIMARY KEY (`ss_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ", true);
}
$sql_search = " where 1 ";
if ($search != "") {
if ($sel_field != "") {
$sql_search .= " and $sel_field like '%$search%' ";
}
}
if ($sel_field == "") $sel_field = "it_it";
if ($sort1 == "") $sort1 = "ss_send";
if ($sort2 == "") $sort2 = "asc";
$sql_common = " from {$g5['g5_shop_item_stocksms_table']} ";
// 미전송 건수
$sql = " select count(*) as cnt " . $sql_common . " where ss_send = '0' ";
$row = sql_fetch($sql);
$unsend_count = $row['cnt'];
// 테이블의 전체 레코드수만 얻음
$sql = " select count(*) as cnt " . $sql_common;
$row = sql_fetch($sql);
$total_count = $row['cnt'];
$rows = $config['cf_page_rows'];
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if ($page == "") { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$sql = " select *
$sql_common
$sql_search
order by $sort1 $sort2
limit $from_record, $rows ";
$result = sql_query($sql);
$qstr1 = 'sel_field='.$sel_field.'&amp;search='.$search;
$qstr = $qstr1.'&amp;sort1='.$sort1.'&amp;sort2='.$sort2.'&amp;page='.$page;
$listall = '<a href="'.$_SERVER['PHP_SELF'].'" class="ov_listall">전체목록</a>';
?>
<div class="local_ov01 local_ov">
<?php echo $listall; ?>
전체 <?php echo number_format($total_count); ?>건, 미전송 <?php echo number_format($unsend_count); ?>건
</div>
<form name="flist" class="local_sch01 local_sch">
<input type="hidden" name="doc" value="<?php echo $doc; ?>">
<input type="hidden" name="sort1" value="<?php echo $sort1; ?>">
<input type="hidden" name="sort2" value="<?php echo $sort2; ?>">
<input type="hidden" name="page" value="<?php echo $page; ?>">
<label for="sel_field" class="sound_only">검색대상</label>
<select name="sel_field" id="sel_field">
<option value="it_id" <?php echo get_selected($sel_field, 'it_id'); ?>>상품코드</option>
<option value="ss_hp" <?php echo get_selected($sel_field, 'ss_hp'); ?>>휴대폰번호</option>
</select>
<label for="search" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>
<input type="text" name="search" value="<?php echo $search; ?>" required class="frm_input required">
<input type="submit" value="검색" class="btn_submit">
</form>
<form name="fitemstocksms" action="./itemstocksmsupdate.php" method="post" onsubmit="return fitemstocksms_submit(this);">
<input type="hidden" name="sort1" value="<?php echo $sort1; ?>">
<input type="hidden" name="sort2" value="<?php echo $sort2; ?>">
<input type="hidden" name="sel_field" value="<?php echo $sel_field; ?>">
<input type="hidden" name="search" value="<?php echo $search; ?>">
<input type="hidden" name="page" value="<?php echo $page; ?>">
<div class="tbl_head01 tbl_wrap">
<table>
<caption><?php echo $g5['title']; ?> 목록</caption>
<thead>
<tr>
<th scope="col">
<label for="chkall" class="sound_only">알림요청 전체</label>
<input type="checkbox" name="chkall" value="1" id="chkall" onclick="check_all(this.form)">
</th>
<th scope="col">상품명</th>
<th scope="col">휴대폰번호</th>
<th scope="col">SMS전송</th>
<th scope="col">SMS전송일시</th>
<th scope="col">등록일시</th>
</tr>
</thead>
<tbody>
<?php
for ($i=0; $row=mysql_fetch_array($result); $i++)
{
// 상품정보
$sql = " select it_name from {$g5['g5_shop_item_table']} where it_id = '{$row['it_id']}' ";
$it = sql_fetch($sql);
if($it['it_name'])
$it_name = get_text($it['it_name']);
else
$it_name = '상품정보 없음';
$bg = 'bg'.($i%2);
?>
<tr class="<?php echo $bg; ?>">
<td>
<label for="chk_<?php echo $i; ?>" class="sound_only"><?php echo $it_name; ?> 알림요청</label>
<input type="checkbox" name="chk[]" value="<?php echo $i ?>" id="chk_<?php echo $i; ?>">
<input type="hidden" name="ss_id[<?php echo $i; ?>]" value="<?php echo $row['ss_id']; ?>">
</td>
<td><?php echo $it_name; ?></td>
<td><?php echo $row['ss_hp']; ?></td>
<td><?php echo ($row['ss_send'] ? '전송완료' : '전송전'); ?></td>
<td><?php echo (is_null_time($row['ss_send_time']) ? '' : $row['ss_send_time']); ?></td>
<td><?php echo (is_null_time($row['ss_datetime']) ? '' : $row['ss_datetime']); ?></td>
</tr>
<?php
}
if (!$i)
echo '<tr><td colspan="6" class="empty_table"><span>자료가 없습니다.</span></td></tr>';
?>
</tbody>
</table>
</div>
<div class="btn_confirm01 btn_confirm">
<input type="submit" name="act_button" value="선택SMS전송" class="btn_submit" onclick="document.pressed=this.value">
<?php if ($is_admin == 'super') { ?>
<input type="submit" name="act_button" value="선택삭제" class="btn_submit" onclick="document.pressed=this.value">
<?php } ?>
</div>
</form>
<?php echo get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, "{$_SERVER['PHP_SELF']}?$qstr&amp;page="); ?>
<script>
function fitemstocksms_submit(f)
{
if (!is_checked("chk[]")) {
alert(document.pressed+" 하실 항목을 하나 이상 선택하세요.");
return false;
}
if(document.pressed == "선택삭제") {
if(!confirm("선택한 자료를 정말 삭제하시겠습니까?")) {
return false;
}
}
return true;
}
</script>
<?php
include_once (G5_ADMIN_PATH.'/admin.tail.php');
?>

View File

@ -0,0 +1,86 @@
<?php
$sub_menu = '500400';
include_once('./_common.php');
check_demo();
if (!count($_POST['chk'])) {
alert($_POST['act_button']." 하실 항목을 하나 이상 체크하세요.");
}
if ($_POST['act_button'] == "선택SMS전송") {
include_once(G5_LIB_PATH.'/icode.sms.lib.php');
if($config['cf_sms_use'] == 'icode')
{
$SMS = new SMS;
$SMS->SMS_con($config['cf_icode_server_ip'], $config['cf_icode_id'], $config['cf_icode_pw'], $config['cf_icode_server_port']);
}
auth_check($auth[$sub_menu], 'w');
$cnt = 0;
for ($i=0; $i<count($_POST['chk']); $i++) {
// 실제 번호를 넘김
$k = $_POST['chk'][$i];
$sql = " select a.ss_id, a.ss_hp, a.ss_send, b.it_id, b.it_name
from {$g5['g5_shop_item_stocksms_table']} a left join {$g5['g5_shop_item_table']} b on ( a.it_id = b.it_id )
where a.ss_id = '{$_POST['ss_id'][$k]}' ";
$row = sql_fetch($sql);
if(!$row['ss_id'] || !$row['it_id'] || $row['ss_send'])
continue;
// SMS
if($config['cf_sms_use'] == 'icode') {
$sms_contents = iconv_euckr(get_text($row['it_name']).' 상품이 재입고 되었습니다. '.$default['de_admin_company_name']);
$receive_number = preg_replace("/[^0-9]/", "", $row['ss_hp']); // 수신자번호
$send_number = preg_replace("/[^0-9]/", "", $default['de_admin_company_tel']); // 발신자번호
if($receive_number && $send_number) {
$SMS->Add($receive_number, $send_number, $config['cf_icode_id'], $sms_contents, "");
$cnt++;
}
}
// SMS 전송으로 변경함
$sql = " update {$g5['g5_shop_item_stocksms_table']}
set ss_send = '1',
ss_send_time = '".G5_TIME_YMDHIS."'
where ss_id = '{$_POST['ss_id'][$k]}' ";
sql_query($sql);
}
// SMS
if($config['cf_sms_use'] == 'icode' && $cnt)
{
$SMS->Send();
}
} else if ($_POST['act_button'] == "선택삭제") {
if ($is_admin != 'super')
alert('자료의 삭제는 최고관리자만 가능합니다.');
auth_check($auth[$sub_menu], 'd');
check_token();
for ($i=0; $i<count($_POST['chk']); $i++) {
// 실제 번호를 넘김
$k = $_POST['chk'][$i];
$sql = " delete from {$g5['g5_shop_item_stocksms_table']} where ss_id = '{$_POST['ss_id'][$k]}' ";
sql_query($sql);
}
}
$qstr1 = 'sel_field='.$sel_field.'&amp;search='.$search;
$qstr = $qstr1.'&amp;sort1='.$sort1.'&amp;sort2='.$sort2.'&amp;page='.$page;
goto_url('./itemstocksms.php?'.$qstr);
?>