/home/mjc1/public_html/j3demo/adm/customer_list.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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<?php
$sub_menu 
"200100";
include(
"./_common.php");
include(
"./auth_check.php"); // 관리자 권한 체크
include($j3_adm_path."/shop_header.php");

//$order_key = urldecode($order_key);
if($order_key==''){ 
    if(
$_COOKIE['ok_customer']!=''){
        
$order_key $_COOKIE['ok_customer']; 
    } else {
        
$order_key 'a.data_created'
    }
}

if(
$order_key == 'a.data_created'){ $order_key .= ' desc'; }

$where " and login_id <> '' {$ocode_where} "// $ocode_where은 common.php에 지정되어 있음
/*if($biztype=='' || $biztype=='1'){
    $where .= " and biztype = '1' "; $biztype = "1";
} else if($biztype=='0'){
    $where .= " and biztype = '0' ";
} else if($biztype=='2'){
    $where .= " and biztype = '2' ";
}*/
$where .= " and biztype in ('1','2') "// 매입처, 매출처, 매입매출처 탭으로 구성할려다가 그냥 매출처/매입매출처 한꺼번에 표시처리로 정리

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

if(
$stz!=''){
    
$where .= " and c.per_biz_type = '{$stz}' ";
}

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

$list_num $config['page_line'];
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.*, c.* from customers a 
            left join customer_begin_balance b on a.code = b.ccode
            left join customers_s c on a.code = c.ccode
        WHERE 1=1 
$where order by $order_key limit $from_record$list_num";
$result      =    mysql_query($sql,$connect_j3);

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

$office_array office_array_get();

$qstr $_SERVER['QUERY_STRING'];

//if($app_id=='ryunen' || $app_id=='lulucosmetic'){ // 루루코스매틱만 단가등급 보임
    
$configshop['danganame_view'] = "1";
//}
?>
<div id="wrap" class='container_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='customer_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">
                <select name='order_key' class='order_key_class'>
                    <option value='a.data_created' <?php if($order_key=='a.data_created'){?>selected<?php }?>>가입최신순</option>
                    <option value='comp_name' <?php if($order_key=='comp_name'){?>selected<?php }?>>상호명순</option>
                    <option value='login_id' <?php if($order_key=='login_id'){?>selected<?php }?>>아이디순</option>
                </select>
                <input type='hidden' name='order_key_key' class='order_key_key' value='ok_customer'><!-- 오더키가 중복 안되게 shop_header.php에 있는 js에 해당 키를 선택하게 해주는 필드 -->
                <a class="lignt-blue-btn" id='btn_order_new'>신규등록</a><!--<a class="blue-btn">주문복사</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='stz'>
                    <option value=''>=구분=</option>
                    <option value='0' <?php if($stz=='0'){ echo "selected"; }?>>개인</option>
                    <option value='1' <?php if($stz=='1'){ echo "selected"; }?>>기업</option>
                </select>
                <select name='sti'>
                    <option value='a.comp_name' <?php if($sti=='a.comp_name'){?>selected<?php }?>>상호명</option>
                    <option value='a.login_id' <?php if($sti=='a.login_id'){?>selected<?php }?>>아이디</option>
                    <option value='a.comp_sn' <?php if($sti=='a.comp_sn'){?>selected<?php }?>>사업자번호</option>
                    <option value='a.ceo_name' <?php if($sti=='a.ceo_name'){?>selected<?php }?>>대표자</option>
                    <option value='a.telno' <?php if($sti=='a.telno'){?>selected<?php }?>>전화번호</option>
                    <option value='a.hpno' <?php if($sti=='a.hpno'){?>selected<?php }?>>핸드폰</option>
                    <option value='a.email' <?php if($sti=='a.email'){?>selected<?php }?>>이메일</option>
                    <option value='a.memo' <?php if($sti=='a.memo'){?>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 screen_out">
        <div class="item_tab_navi">
            <a value='0'><span>매입처 관리</span></a>
            <a value='1' class="on"><span>매출처 관리</span></a>
            <!--<a value='2'><span>매입.매출처 관리</span></a>-->
        </div>
    </div><!--//item_tab-->
<!-- 탭 구분 영역 끝 -->

    <form name='customer_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:70px;"><col style="width:40px;"><col style="width:110px;">
                <col style="width:70px;"><col style="width:80px;"><col style="width:90px;">
                <col style="width:90px;"><col style="width:70px;">
                <col style="width:120px;">
<?php if($config['recom_name_use']=='1'){  ?>
                <col style="width:70px;">
<?php }?>
                <col style="width:120px;"><col style="width:80px;">
<?php if($configshop['danganame_view']=='1'){  ?>
                <col style="width:80px;">
<?php ?>
<?php 
if($config['login_free']=='1'){  ?>
                <col style="width:100px;">
<?php ?>
<?php 
if($config['cust_sell']=='1'){  ?>
                <col style="width:70px;">
<?php ?>
                </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>
                        <th scope="col">이메일</th>
<?php if($config['recom_name_use']=='1'){  ?>
                        <th scope="col">추천아이디</th>
<?php }?>
                        <th scope="col">메모</th><th scope="col">가입일</th>
<?php if($configshop['danganame_view']=='1'){  ?>
                        <th scope="col">단가등급</th>
<?php ?>
<?php 
if($config['login_free']=='1'){  ?>
                        <th scope="col">사업장</th>
<?php ?>
<?php 
if($config['cust_sell']=='1'){  ?>
                        <th scope="col">회원판매</th>
<?php ?>
                    </tr>
                </thead>
                <tbody >
<?php 
    
for($i=0;$i<count($list_array);$i++){ 
        
$info $list_array[$i];
?>
                    <tr class='table_tr'>
                        <td class="tcenter ">
                            <input type='checkbox' name='code_idx[]' value='<?php echo $i;?>'>
                            <input type='hidden' name='codes[]' value='<?php echo $info['code'];?>'>
                        </td>
                        <td class="linetxt "><?php echo $info['login_id'];?></td>
                        <td class="tcenter "><?php echo $per_biz_type_tit[$info['per_biz_type']];?></td>
                        <td class="linetxt click_edit"><?php echo $info['comp_name'];?></td>
                        <td class="tcenter "><?php echo $info['ceo_name'];?></td>
                        <td class="linetxt "><?php echo $info['telno'];?></td>
                        <td class="linetxt "><?php echo $info['hpno'];?></td>
                        <td class="linetxt "><?php echo $info['comp_sn'];?></td>
                        <td class="cost "><?php echo number_format($info['cur_point']);?></td>
                        <td class="linetxt "><?php echo $info['email'];?></td>
<?php if($config['recom_name_use']=='1'){  ?>
                        <td class="linetxt "><?php echo $info['recom_name'];?></td>
<?php ?>
                        <td class="linetxt "><?php echo $info['memo'];?></td>
                        <td class="tcenter "><?php echo substr($info['data_created'],0,10);?></td>
<?php if($configshop['danganame_view']=='1'){  ?>
                        <td class="tcenter "><?php echo get_multi_price_name($info['ccode']);?></td>
<?php ?>
<?php 
if($config['login_free']=='1'){  ?>
                        <td class="linetxt ellipsis"><?php echo "({$info['ocode']})".$office_array[$info['ocode']];?></td>
<?php ?>
<?php 
if($config['cust_sell']=='1'){  ?>
                        <td class="linetxt ellipsis"><?php echo $info['seller_yn'];?></td>
<?php }?>
                    </tr>
<?php 
    

?>
                </tbody>
            </table>
        </div>
    </div>
    <span class='help_info'>아이디가 있는 거래처만 표시합니다.</span>
    </form>

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

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

<script>
var qstr = '<?php echo $qstr;?>';
$(function(){
    $(".item_tab_navi a").click(function(){ //네비게이션 탭 처리
        v = $(this).attr("value");
        vv = qstr_rmv(qstr,"biztype");
        document.location.href="?"+vv+"&biztype="+v;
    });

    if('<?php echo $biztype?>'!=''){ // 매입/매출 거래처 선택시
        var itna_obj = $(".item_tab_navi a");
        $(itna_obj).each(function(){
            if($(this).attr("value")=='<?php echo $biztype?>'){
                $(this).addClass("on");
            } else {
                $(this).removeClass("on");
            }
        });
    }

    $(".click_edit").css("cursor","pointer").click(function(){ // 거래처 수정
        var code = $(this).closest("tr").find("input[name='codes[]']").val();
        setsave("qstr",qstr,1);
        document.location.href="customer_reg.php?code="+code;
    });

    $(".sub-btn #btn_order_new").click(function(){ // 거래처 신규 버튼
        setsave("qstr",qstr,1);
        document.location.href="customer_reg.php";
    });

    $(document).on("change",".biztype_sel_class",function(){ // 거래구분 선택시
        if($(this).val()=='0'){
            $(".biztype0").show(); $(".biztype1").hide();
        } else if($(this).val()=='1'){
            $(".biztype1").show(); $(".biztype0").hide();
        }
        
    });

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

    $("#sel_delete").click(function(){ // 선택삭제
        var ck_cnt = 0;
        var v = $("input[name='code_idx[]']").each(function(){
            if($(this).is(":checked")){ ck_cnt++; }
        });
        if(ck_cnt==0){ alert('삭제하실 거래처를 선택하세요.'); return; }
        if(confirm('정말로 선택하신 '+ck_cnt+'개의 거래처를 삭제하시겠습니까?')){
            $("input[name='sel_del']").val("Y");
            var form_data = $("form[name='customer_list_form']").serialize();

            $.ajax({type:"post", url:"ajax.customer_reg_process.php", data:form_data, async:false, 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();
                    if(v_mode_ok!='Y'){
                        alert(v_msg);
                    } else {
                        document.location.href='?<?php echo $qstr."&time=".time();?>';
                    }
                },
                error:function(rtn,status,error){    alert(error);        }
            });
        }
    });

    $("#xls_down").click(function(){ // 엑셀다운로드
        //alert('준비중입니다.'); return;
        setsave("qstr",qstr,1);
        document.customer_search_form.action='customer_list.xls.php';
        document.customer_search_form.target = '_blank';
        document.customer_search_form.submit();
    });

    $("#search_btn_press").click(function(){ // 검색버튼 누를때
        document.customer_search_form.action='?';
        document.customer_search_form.target = '';
        document.customer_search_form.submit();
    });

});
</script>
<style>
    .sortable-placeholder { height:60px;}
</style>

<?php
include($j3_adm_path."/shop_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>