/home/mjc1/public_html/emillennium/customer_list.inc.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
<?php
$dir 
".";
include_once(
$dir."/_common.php");

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

//_pr($_GET);

if($order_key==''){ 
    if(
$_COOKIE['ok_customer']!=''){
        
$order_key $_COOKIE['ok_customer']; 
    } else {
        
$order_key 'comp_name'
    }
}

$where " ";
if(
$biztype=='' || $biztype=='1'){
    
$where .= " and (biztype = '1' || biztype = '2') "$biztype "1";
} else if(
$biztype=='0'){
    
$where .= " and (biztype = '0' || biztype = '2') ";
} else if(
$biztype=='2'){
    
$where .= " and biztype = '2' ";
}

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

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

$list_num 15;
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 * from customers a WHERE 1=1 $where order by $order_key limit $from_record$list_num";
$result      =    mysql_query($sql,$connect_e1000y);

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

$qstr $_SERVER['QUERY_STRING'];
//_pr($_GET);
?>
<style>
    .container_wrap2 { font-size:0.9em; width:1050px !important;}
    #sub-title { margin-top:0px; }
</style>
<!--<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" class='container_wrap2'>
    <div id="sub-title">
        <h2>거래처검색</h2>
    </div>
<form name='customer_search_form' method='get' onsubmit='return false;'>
    <input type='hidden' name='biztype' size='' value='<?php echo $biztype;?>'>
    <div id="sub-contents-area">
        <div class="sub-btn-area">
            <div class="sub-btn sub-btn-search" style='margin-left:150px;width:900px;'>
                <select name='sti'>
                    <option value='a.comp_name' <?php if($sti=='a.comp_name'){?>selected<?php }?>>상호명</option>
                    <option value='a.code1' <?php if($sti=='a.code1'){?>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' style='color:white;'>검색</a>
            </div>
        </div>
    </div>
</form>

<form name='customer_list_form' method='post'>
<input type='hidden' name='sel_del' value=''>
<input type='hidden' name='modetype' value='<?php echo $modetype;?>'>
    <div class="div-list-area">
        <div class="cust-list-area">
            <table class="order-sheet2">
                <caption class="screen_out">상품 검색 리스트<caption>
                <colgroup>
                <col style="width:60px;"><col style="width:120px;">
                <col style="width:70px;">
                <col style="width:110px;"><col style="width:110px;">
                <col style="width:110px;"><col style="width:100px;">
                <col style="width:140px;"><col style="width:130px;"><col style="width:50px;">
                </colgroup>

                <thead>
                    <tr>
                        <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"><?php if($biztype=='1'){?>현재미수금<?php } else if($biztype=='0') {?>현재미불금<?php }?></th>
                        <th scope="col">이메일</th><th scope="col">메모</th><th scope="col">세액</th>
                    </tr>
                </thead>
                <tbody>
<?php 
    
for($i=0;$i<count($list_array);$i++){ 
        
$info $list_array[$i];
?>
                    <tr class='tr_select_customer'>
                        <input type='hidden' name='ccode' value='<?php echo $info['code'];?>'>
                        <input type='hidden' name='code1' value='<?php echo $info['code1'];?>'>
                        <input type='hidden' name='comp_name' value='<?php echo $info['comp_name'];?>'>
                        <input type='hidden' name='telno' value='<?php echo $info['telno'];?>'>
                        <input type='hidden' name='hpno' value='<?php echo $info['hpno'];?>'>
                        <input type='hidden' name='faxno' value='<?php echo $info['faxno'];?>'>
                        <input type='hidden' name='ceo_name' value='<?php echo $info['ceo_name'];?>'>
                        <input type='hidden' name='vattype' value='<?php echo $info['vattype'];?>'>
                        <input type='hidden' name='cur_arrear' value='<?php echo $info['cur_arrear'];?>'>
                        <input type='hidden' name='cur_recvbl' value='<?php echo $info['cur_recvbl'];?>'>
                        <td class="linetxt "><?php echo $info['code1'];?></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 if($biztype=='1'){ echo number_format($info['cur_recvbl']); } else if($biztype=='0') { echo number_format($info['cur_arrear']); }?></td>
                        <td class="linetxt "><?php echo $info['email'];?></td>
                        <td class="linetxt "><?php echo $info['memo'];?></td>
                        <td class="linetxt "><?php echo $tax_type[$info['vattype']];?></td>
                    </tr>
<?php 
    

?>
                </tbody>
            </table>
        </div>
    </div>
</form>

    <div class='pg_wrap' style='padding-top:0px;'>
        <?php echo get_paging2($list_num$page$total_page"javascript:customer_search('{$stx}',");?>
    </div>

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

<script>
$(function(){

    $("form[name='customer_search_form'] #search_btn_press").click(function(){ // 거래처 검색 dialog안에서 검색버튼누를때
        var v_cn = $("form[name='customer_search_form'] #stx").val()
        if('<?php echo $modetype;?>'=='pop'){
            customer_search3(encodeURI(v_cn),1);
        } else {
            customer_search(encodeURI(v_cn),1);
        }
    });

    $("form[name='customer_search_form'] #stx").keypress(function(){ // 거래처 검색 dialog안에서 검색란 엔터칠때
        if(event.keyCode==13){
            var v_cn = $("form[name='customer_search_form'] #stx").val()
            if('<?php echo $modetype;?>'=='pop'){
                customer_search3(encodeURI(v_cn),1);
            } else {
                customer_search(encodeURI(v_cn),1);
            }
        }
    });

    $(".tr_select_customer").css("cursor","pointer").click(function(){
        if('<?php echo $modetype;?>'=='list' || '<?php echo $modetype;?>'=='income' || '<?php echo $modetype;?>'=='sms'){ //매출/매입/출금/입금/sms/거래명세표/원장 리스트에서 불러올때
            $s_form = $(this).closest("tr");
            $sfn = $("#search_form_name").val(); // 해당 검색폼 명 받아옴
            $p_form = $("form[name='"+$sfn+"']");

            $p_form.find("input[name='stc']").val($s_form.find("input[name='ccode']").val());
            $p_form.find("input[name='stc_search']").val($s_form.find("input[name='comp_name']").val());

            $("#modal_member_box").dialog("close");
        } else if('<?php echo $modetype;?>'=='payment' || '<?php echo $modetype;?>'=='receive'){ // 출금등록에서 검색처리
            if('<?php echo $biztype;?>'=='0'){
                $p_form = $("form[name='payment_reg_form']");
            } else {
                $p_form = $("form[name='receive_reg_form']");
            }
            $s_form = $(this).closest("tr");
        
            $p_form.find("input[name='ccode']").val($s_form.find("input[name='ccode']").val());
            $p_form.find("input[name='ccode1']").val($s_form.find("input[name='code1']").val());
            $p_form.find("input[name='comp_name']").val($s_form.find("input[name='comp_name']").val());
            if('<?php echo $biztype;?>'=='0'){
                $p_form.find("input[name='old_mibul']").val(formatCurrency($s_form.find("input[name='cur_arrear']").val()));
            } else {
                $p_form.find("input[name='old_mibul']").val(formatCurrency($s_form.find("input[name='cur_recvbl']").val()));
            }
            $("#modal_member_box2").dialog("close");
        } else if('<?php echo $modetype;?>'=='pop'){ // 출금/입금 등록 매출/매입검색에서 거래처 검색
            $s_form = $(this).closest("tr");
            $sfn = $("#search_form_name2").val(); // 해당 검색폼 명 받아옴
            $p_form = $("form[name='"+$sfn+"']");

            $p_form.find("input[name='stc']").val($s_form.find("input[name='ccode']").val());
            $p_form.find("input[name='stc_search']").val($s_form.find("input[name='comp_name']").val());
            $("#modal_member_box3").dialog("close");
        } else if('<?php echo $modetype;?>'=='ledger'){ // 매입/매출원장시 검색 처리
            if('<?php echo $biztype;?>'=='0'){
                $p_form = $("form[name='buy_ledger_search_form']");
            } else {
                $p_form = $("form[name='sale_ledger_search_form']");
            }
            $s_form = $(this).closest("tr");

            $p_form.find("input[name='stc']").val($s_form.find("input[name='ccode']").val());
            $p_form.find("input[name='stc_search']").val($s_form.find("input[name='comp_name']").val());

            $("#modal_member_box").dialog("close");
        } else { // 전표생성에서 검색처리
            if('<?php echo $biztype;?>'=='0'){
                $p_form = $("#buy_form");
            } else {
                $p_form = $("#sale_form");
            }
            $s_form = $(this).closest("tr");

            $p_form.find("input[name='ccode']").val($s_form.find("input[name='ccode']").val());
            $p_form.find("input[name='ccode1']").val($s_form.find("input[name='code1']").val());
            $p_form.find("input[name='comp_name']").val($s_form.find("input[name='comp_name']").val());
            $p_form.find("input[name='telno']").val($s_form.find("input[name='telno']").val());
            $p_form.find("input[name='hpno']").val($s_form.find("input[name='hpno']").val());
            $p_form.find("input[name='faxno']").val($s_form.find("input[name='faxno']").val());
            $p_form.find("input[name='ceo_name']").val($s_form.find("input[name='ceo_name']").val());
            $p_form.find("select[name='tax_type'] option").eq($s_form.find("input[name='vattype']").val()).attr("selected",true);
            
            if($("<?php if($biztype=='0'){?>#buy_form<?php } else {?>#sale_form<?php }?> input[name='seqs[]']").size()==0){
                add_line();
            }
            get_all_save();
            $("#modal_member_box").dialog("close");
        }
    });
    if('<?php echo count($list_array);?>'=='1' && '<?php echo $stx;?>'!='' && '<?php echo $page;?>'=='1'){
        setTimeout(function(){
            $(".tr_select_customer").eq(0).click();                    
            //alert('asdasd');
        },400);
    }
});

</script>