/home/mjc1/public_html/otms_old/category.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
$dir 
".";
include_once(
$dir."/_common.php");
include(
'./header.php'); 

$create_sql "CREATE TABLE `zom_category` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `om_site` varchar(5) DEFAULT '' COMMENT '사이트 11, au, gm',
  `c_code` int(11) DEFAULT '0' COMMENT '분류코드',
  `c_depth` int(1) DEFAULT '0' COMMENT '분류순차',
  `c_name` varchar(250) DEFAULT '' COMMENT '분류명',
  `c_parent` int(11) DEFAULT '0' COMMENT '상위분류코드',
  `update_date` datetime DEFAULT NULL COMMENT '업데이트일시',
  `c_sort` varchar(12) DEFAULT '' COMMENT '분류표시순서',
  PRIMARY KEY (`idx`),
  KEY `idx_om_site` (`om_site`),
  KEY `idx_c_code` (`c_code`),
  KEY `idx_c_parent` (`c_parent`),
  KEY `idx_c_depth` (`c_depth`),
  KEY `idx_c_sort` (`c_sort`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='오픈마켓 카테고리'"
;

if(
$eid==''){
    
alert('로그인 후에 이용가능합니다.',"index.php"); exit;
}

if(
$order_key==''){ 
    if(
$_COOKIE['ok_product']!=''){
        
$_COOKIE['ok_product'] = str_replace("%20"," ",$_COOKIE['ok_product']);
        
$order_key $_COOKIE['ok_product']; 
    } else {
        
$order_key 'a.om_site, a.c_sort'
    }
}

$where " and a.c_sort <> '' ";

if(
$stx!=''){
    
$where .= " and {$sti} like '%{$stx}%' ";
}

if(
$stc!=''){
    
$where .= " and a.c_depth = '{$stc}' ";
}

if(
$stpc!=''){
    
$where .= " and a.om_site = '{$stpc}' ";
}

$sql  =   "select count(*) as cnt from zom_category a WHERE 1=1 {$where} ";
$result      =    mysql_query($sql,$connect_om);
$row mysql_fetch_array($result);
$total_count $row['cnt'];

$list_num 30;
if(
$_COOKIE['page_line']!=''){ $list_num $_COOKIE['page_line']; }
$total_page  ceil($total_count $list_num);  // 전체 페이지 계산
if ($page 1) { $page 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page 1) * $list_num// 시작 열을 구함

$sql "select a.*, b.c_name as pc_name, b.c_code as pc_code from zom_category a left join zom_category b on a.c_parent = b.c_code WHERE 1=1 $where order by $order_key limit $from_record$list_num ";
$result      =    mysql_query($sql,$connect_om);

//_pr($sql);
while($cus_info=mysql_fetch_array($result)){
    
$list_array[] = $cus_info;
}

$qstr $_SERVER['QUERY_STRING'];
?>

<!--<div id="contents" style="background:#999"><img src="http://placehold.it/960x150" alt="롤링배너"></div>-->
<div id="contents" style="height:2px;border-bottom:1px solid #eee;background:#2f6ba9">
    <span class="screen_out">header 하단 선</span>
</div>

<div id="wrap">
    <div id="sub-title">
        <h2>카테고리 관리</h2>
        <div class="sub-location">
            <a href="./index.php" class="home"><span class="screen_out">홈</span></a>
            <span class="location-gt"></span>
            <a>카테고리 관리</a>
            <span class="location-gt"></span>
            <a>카테고리 관리</a>
        </div>
    </div>
<form name='category_search_form' method='get'>
    <input type='hidden' name='biztype' size='' value='<?php echo $biztype;?>'>
    <div id="sub-contents-area">
        <div class="sub-btn-area">
            <div class="sub-btn">
                <a class="lignt-blue-btn" id='btn_new_cate_11'>11번가 GET </a><!--<a class="blue-btn" id='cate_prod_move'>분류상품이동</a><?php if($Orow['ordstate']==0){ ?><a class="black-btn">전체삭제</a><?php }?><a class="gray-btn" id='buy_print'>인쇄</a>--><!--<a class="gray-btn" id='xls_down'>엑셀</a><a class="black-btn" id='sel_delete'>선택삭제</a>-->
            </div>
        </div>
        <div class="sub-btn-area">
            <div class="sub-btn sub-btn-search">
                <select name='stc'>
                    <option value='' <?php if($stc==''){ echo "selected"; }?>>-분류차수-</option>
                    <option value='1' <?php if($stc=='1'){ echo "selected"; }?>>1차만</option>
                    <option value='2' <?php if($stc=='2'){ echo "selected"; }?>>2차만</option>
                    <option value='3' <?php if($stc=='3'){ echo "selected"; }?>>3차만</option>
                    <option value='4' <?php if($stc=='4'){ echo "selected"; }?>>4차만</option>
                </select>
                <select name='sti'>
                    <option value='a.c_name' <?php if($sti=='a.name'){?>selected<?php }?>>카테고리명</option>
                    <option value='a.c_code' <?php if($sti=='a.code2'){?>selected<?php }?>>코드</option>
                </select>
                <input type='text' id='stx' name='stx' size='' value='<?php echo $stx;?>' class="stx_class">&nbsp;<a href="#" class="black-btn" id='search_btn_press'>검색</a>
            </div>
        </div>
    </div>
</form>
    <div class="item_tab">
        <div class="item_tab_navi">
            <a value='0' class="on"><span>전체</span></a>
            <a value='1'><span>11번가</span></a>
        </div>
    </div>

<form name='category_list_form' method='post'>
<input type='hidden' name='sel_del' value=''>
    <div class="div-list-area">
        <div class="cust-list-area">
            <table class="order-sheet2">
                <caption class="screen_out">매입처 원장 조회<caption>
                <colgroup>
                <col style="width:30px;">
                <col style="width:60px;">
                <col style="width:60px;"><col style="width:120px;"><col style=";">
                <col style="width:60px;"><col style="width:120px;">
                <col style="width:200px;"><col style="width:200px;">
                </colgroup>

                <thead>
                    <tr>
                        <th scope="col"><input type='checkbox' name='ck_all' class='check_all_class'></th>
                        <th scope="col">번호</th>
                        <th scope="col">사이트</th><th scope="col">코드</th><th scope="col">분류명</th>
                        <th scope="col">분류차수</th><th scope="col">순번코드</th>
                        <th scope="col">상위분류</th><th scope="col">업데이트일자</th>
                    </tr>
                </thead>
                <tbody>
<?php 
    $num 
$total_count - ($page 1) * $list_num;
    for(
$i=0;$i<count($list_array);$i++){ 
        
$info $list_array[$i];
?>
                    <tr>
                        <td class="tcenter ">
                            <input type='checkbox' name='code_idx[]' value='<?php echo $i;?>'>
                            <input type='hidden' name='codes[]' value='<?php echo $info['idx'];?>'>
                        </td>
                        <td class="tcenter "><?php echo $num;?></td>
                        <td class="linetxt "><?php echo $info['om_site'];?></td>
                        <td class="linetxt "><?php echo $info['c_code'];?></td>
                        <td class="linetxt click_edit">
                            <?php                                
                                $cnt 
= ($info['c_depth']-1)*3;
                                for(
$j=0;$j<$cnt;$j++){
                                    echo 
"&nbsp;";
                                }
                                if(
$info['c_depth']>1){    echo "└"; }
                            
?>
                            <?php echo $info['c_name'];?>
                        </td>
                        <td class="linetxt "><?php echo $info['c_depth'];?></td>
                        <td class="tcenter "><?php echo $info['c_sort'];?></td>
                        <td class="linetxt "><?php if($info['pc_code']!=''){ echo $info['pc_name']." ({$info['pc_code']})"; }?></td>
                        <td class="tcenter "><?php echo $info['update_date'];?></td>
                    </tr>
<?php 
        $num
--;
    } 
?>
                </tbody>
            </table>
        </div>
    </div>
</form>

    <div class='pg_wrap' style='padding-top:0px;'>
        <?php echo get_paging(10$page$total_page"?$qstr");?>
    </div>

<span class='help_info'>카테고리 가져오기는 많은 시간이 걸립니다. 자주하실 필요 없습니다.</span>

</div><!--//wrap-->

<script>
var qstr = '<?php echo $qstr;?>';
$(function(){
    $(".item_tab_navi a").click(function(){ //네비게이션 탭 처리
        v = $(this).attr("value");
        if(v==0){
            document.location.href="?";
        } else {
            document.location.href="?stpc=11";
        }
    });

    $(".check_all_class").click(function(){ // 전체선택 전체선택 해제
        if($(this).is(":checked")){
            $("input[name='code_idx[]']").prop("checked",true);
        } else {
            $("input[name='code_idx[]']").prop("checked",false);            
        }
    });

    $("#btn_new_cate_11").click(function(){
        if(confirm('11번가의 카테고리를 새롭게 갱신하시겠습니까?\n많은 시간이 걸립니다.(10~20분)')){
            $("#modal_member_box").dialog({
                resizable: true, height:480, width:500, modal: true, title: "카테고리 [가져오기]"
            });

            setTimeout(function(){
                $.ajax({type:"post", url:"ajax.11.category_update.php", async:true, dataType : "xml", 
                    success:function(xml){    
                        var v_mode = $(xml).find("mode").text();
                        var v_mode_ok = $(xml).find("mode_ok").text();
                        var v_msg = $(xml).find("msg").text();
                        var v_cate_cnt = $(xml).find("cate_cnt").text();
                        var v_use_time = $(xml).find("use_time").text();
                        if(v_mode_ok!='Y'){
                            alert(v_msg);
                        } else {
                            alert(v_cate_cnt+'개의 카테고리 갱신이 완료 되었습니다.'+v_use_time+'초');
                            document.location.reload();
                        }
                    },
                    error:function(rtn,status,error){    alert(error);        }
                });                
            },1000);
        }
    });

    $("#xls_down").click(function(){ // 엑셀다운로드
        document.category_search_form.action='category_xls_down.php';
        document.category_search_form.target = '_blank';
        document.category_search_form.submit();
    });

    $("#search_btn_press").click(function(){
        document.category_search_form.action='?';
        document.category_search_form.target = '';
        document.category_search_form.submit();
    });

});
</script>
<?php include('./footer.php'); ?>
<div id="modal_member_box" title="거래처수정" style="display:none;width:100%; height:100%; padding-top:3px;padding-left:3px;background-color:#FFFFFF;position:relative;">
    <div style='font-size:16px;line-height:30px;'>
        카테고리 가져오는중입니다. 잠시만 기다려 주세요. <br>
        가져오기가 완료되면 자동으로 화면이 변경됩니다.<br>
        <p style='padding-left:100px;padding-top:30px;'><img src='./images/common/process_ani.gif' width=300></p>
    </div>
</div>