/home/mjc1/public_html/j3demo/adm/pt_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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<?php
$sub_menu 
"200400";
include(
"./_common.php");
include(
"./auth_check.php"); // 관리자 권한 체크
include($j3_adm_path."/shop_header.php");

if(
$sdate==''){ $sdate date("Y-m-",time())."01"; }
if(
$edate==''){ $edate date("Y-m-d",time()); }

if(
$order_key==''){ 
    
$order_key 'dealdate desc'
}

$where " and dealdate >= '$sdate' and dealdate <= '$edate' ";

if(
$stc!=''){
    
$where .= " and aa.ccode = '{$stc}' ";
}

if(
$stx!=''){
    
$where .= " and aa.pcode = '{$stx}' ";
}

//$sql  =   "select count(*) as cnt from point_edit a WHERE 1=1 $where ";
$sql "select count(*) as cnt from
            (select 1, ccode, dealdate, '포인트조정' as pname, '' as qty, '' as price, '' as tot_amt, ''  as amount, '' as usept, '' as savept, point as editpt
            from point_edit
            union all
            select 2, ccode, dealdate, '입금' as pname, '' as qty, '' as price, '' as tot_amt, amount, usepoint as usept, savepoint as savept, '' as editpt
            from receive where (savepoint>0 or usepoint>0)
            union all
            select 3, ccode, dealdate, a.pname, a.qty, a.price, a.tot_amt, '' as amount, '' as usept, savepoint as savept, '' as editpt
            from sale_d a left join sale_m b on a.midx = b.midx where savepoint>0) aa left join customers bb on aa.ccode = bb.code
        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.*, b.login_id, b.comp_name from point_edit a left join customers b on a.ccode = b.code WHERE 1=1 $where order by $order_key limit $from_record, $list_num";
$sql "select aa.*, bb.comp_name, bb.login_id from
            (select 1, ccode, dealdate, '포인트조정' as pname, '' as qty, '' as price, '' as tot_amt, ''  as amount, '' as usept, '' as savept, point as editpt, '' as pcode
            from point_edit
            union all
            select 2, ccode, dealdate, '입금' as pname, '' as qty, '' as price, '' as tot_amt, amount, usepoint as usept, savepoint as savept, '' as editpt, '' as pcode
            from receive where (savepoint>0 or usepoint>0)
            union all
            select 3, ccode, dealdate, a.pname, a.qty, a.price, a.tot_amt, '' as amount, '' as usept, savepoint as savept, '' as editpt, a.pcode as pcode
            from sale_d a left join sale_m b on a.midx = b.midx where savepoint>0) aa left join customers bb on aa.ccode = bb.code
        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;
}

$qstr $_SERVER['QUERY_STRING'];
?>
<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>
<!-- 검색영역 -->
    <input type='hidden' name='search_form_name' id='search_form_name' value='point_search_form'>
    <form name='point_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_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">
                기간 : <input type='text' name='sdate' id='sdate' value='<?php echo $sdate;?>' class='width_80'> ~ <input type='text' name='edate' id='edate' value='<?php echo $edate;?>' class='width_80'>
                &nbsp;&nbsp;
                거래처검색 : 
                <input type='text' name='stc' value='<?php echo $stc;?>' class='input_readonly width_60'>
                <input type='text' name='stc_search' value='<?php echo $stc_search;?>' class='cust_search_class width_80'>&nbsp;<img src='<?php echo $j3_url;?>/img/glass.png' class='customer-sel-btn glass_class'>
                &nbsp;&nbsp;
                상품검색 : 
                <input type='text' id='stx' name='stx' size='' value='<?php echo $stx;?>' class="input_readonly width_60">
                <input type='text' name='stx_search' value='<?php echo $stx_search;?>' class='prod_search_class width_80'>&nbsp;<img src='<?php echo $j3_url;?>/img/glass.png' class='product-sel-btn glass_class'>
                <!--<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:120px;"><col style="width:80px;"><col style="width:150px;">
                <col style="width:50px;"><col style="width:70px;"><col style="width:80px;">
                <col style="width:80px;"><col style="width:70px;"><col style="width:70px;">
                <col style="width:70px;">
                </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">사용PT</th><th scope="col">적립PT</th>
                        <th scope="col">조정PT</th>
                    </tr>
                </thead>
                <tbody>
<?php 
    
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['nidx'];?>'>
                        </td>
                        <td class="tcenter "><?php echo $info['comp_name']." (".$info['login_id'].")";?></td>
                        <td class="linetxt"><?php echo $info['dealdate'];?></td>
                        <td class="linetxt"><?php echo $info['pname'];?></td>
                        <td class="cost"><?php echo number_format($info['qty']);?></td>
                        <td class="cost "><?php echo number_format($info['price']);?></td>
                        <td class="cost "><?php echo number_format($info['tot_amt']);?></td>
                        <td class="cost "><?php echo number_format($info['amount']);?></td>
                        <td class="cost "><?php echo number_format($info['usept']);?></td>
                        <td class="cost "><?php echo number_format($info['savept']);?></td>
                        <td class="cost "><?php echo number_format($info['editpt']);?></td>
                    </tr>
<?php 
    

?>
                </tbody>
            </table>
        </div>
    </div>
    </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);
        add_point(code);
    });

    $(".sub-btn #btn_order_new").click(function(){ // 거래처 신규 버튼
        add_point('');
    });

    $(".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.point_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.reload();
                    }
                },
                error:function(rtn,status,error){    alert(error);        }
            });
        }
    });

    $("#xls_down").click(function(){ // 엑셀다운로드
        alert('준비중입니다.'); return;
        document.point_search_form.action='customer_xls_down.php';
        document.point_search_form.target = '_blank';
        document.point_search_form.submit();
    });

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

    $(".customer-sel-btn").click(function(){ // 거래처 ? 검색일경우
        customer_search('',1);
    });

    $(".cust_search_class").keypress(function(){ // 거래처명란에서 엔터로 검색일경우
        if(event.keyCode==13){
            var v_cn = $(".cust_search_class").val()
            customer_search(encodeURI(v_cn),1);
        }
    }).change(function(){
        $("input[name='stc']").val("");
    });

    $(".product-sel-btn").click(function(){ // 상품 ? 검색일경우
        product_search('',1);
    });

    $(".prod_search_class").keypress(function(){ // 상품검색란에서 엔터로 검색일경우
        if(event.keyCode==13){
            var v_cn = $(".prod_search_class").val()
            product_search(encodeURI(v_cn),1);
        }
    }).change(function(){
        $("input[name='stx']").val("");
    });

});

function add_point(code){
    if(code==''){ title = "신규"; } else { title = "수정"; }
    $.get("point_reg.inc.php?code="+code,function(rtn){
        $("#modal_member_box").html(rtn).dialog({
            resizable: true, height:320, width:740, modal: true, title:"포인트조정 ["+title+"]",
            buttons: {
                저장: function() {
                    form_save();
                },
                닫기: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
    });
}

function form_save(){
    $form_obj = $("form[name='point_reg_form']");
    if($form_obj.find("input[name='login_id']").val()==''){
        alert('거래처를 선택하시기 바랍니다.'); return;
    }
    if($form_obj.find("input[name='po_point']").val()==''){
        alert('포인트를 입력하시기 바랍니다.'); return;
    }
    if($form_obj.find("input[name='po_content']").val()==''){
        alert('내용을 입력하시기 바랍니다.'); return;
    }
    //$form_obj.prop("action","ajax.point_reg_process.php");
    form_data = $form_obj.serialize(); 
    $.ajax({type:"post", url:"ajax.point_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.reload();
                    }
                },
                error:function(rtn,status,error){    alert(error);        }
            });
}

function customer_search(v_cn,v_page){
    var sti_val = $("form[name='customer_search_form'] select[name='sti'] option:selected").val();
    if(sti_val==undefined){ sti_val = "comp_name"; }
    $.get("customer_list.inc.php?mode=search&stc="+v_cn,function(rtn){
        $("#modal_member_box").html(rtn).dialog({
            resizable: true, height:780, width:1000, modal: true, title: "거래처 [검색]",
            buttons: {
                닫기: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
    });    
}

function product_search(v_cn,v_page){ // 상품 검색

    var sti_val = $("form[name='customer_search_form'] select[name='sti'] option:selected").val();
    if(sti_val==undefined){ sti_val = "a.name"; }
    $.get("product_list.inc.php?mode=search&stp="+v_cn,function(rtn){
        $("#modal_member_box").html(rtn).dialog({
            resizable: true, height:820, width:1150, modal: true, title: "상품 [검색]",
            buttons: {
                닫기: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
    });
}
</script>

<?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>
<div id="modal_member_box2" title="거래처수정" style="display:none;width:100%; height:100%; padding-top:3px;padding-left:3px;background-color:#FFFFFF;position:relative;"></div>