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
359
360
361
|
<?php $dir = "."; include_once($dir."/_common.php"); include('./include/header.php');
if($eid==''){ alert('e천년경영 로그인 후에 이용가능합니다.',"index.php"); exit; }
//ck_category_init(); // 첫 사용자 카테고리 초기화
/*$sql = "select * from sale_m "; $res = mysql_query($sql,$connect_e1000y); while($info=mysql_fetch_array($res)){ $sql = "insert into sale_u set pcode = '{$info['code']}', Mid = '{$eid}' "; //_pr($sql); mysql_query($sql,$connect_e1000y); }*/
if($sdate==''){ $sdate = date("Y-m-",time())."01"; } if($edate==''){ $edate = date("Y-m-d",time()); }
$order_key = 'a.dealdate desc, data_created desc ';
if($smode=='comp'){ $where = " and a.dealdate >= '{$sdate}' and a.dealdate <= '{$edate}' and b.taxno <> '' "; $where1 = " and aa.dealdate >= '{$sdate}' and aa.dealdate <= '{$edate}' and bb.taxno <> '' "; $where2 = " and aaa.dealdate >= '{$sdate}' and aaa.dealdate <= '{$edate}' and bbb.taxno <> '' "; } else { $where = " and a.dealdate >= '{$sdate}' and a.dealdate <= '{$edate}' and b.taxno is null "; $where1 = " and aa.dealdate >= '{$sdate}' and aa.dealdate <= '{$edate}' and bb.taxno is null "; $where2 = " and aaa.dealdate >= '{$sdate}' and aaa.dealdate <= '{$edate}' and bbb.taxno is null "; }
if($stx!=''){ $where .= " and {$sti} like '%{$stx}%' "; }
if($stc!=''){ $where .= " and a.ccode = '{$stc}' "; $where1 .= " and aa.ccode = '{$stc}' "; $where2 .= " and aaa.ccode = '{$stc}' "; }
if($stpc!=''){ $where .= " and prod_cate_code2 = '{$stpc}' "; }
$sql = "select e.deal_month, a.ccode, c.comp_name, c.code1, c.comp_sn, b.tax_type,e.pname, count(b.qty) as pcnt, sum(b.sup_amt) as sum_sup_amt, sum(b.vat) as sum_vat, sum(b.tot_amt) as sum_tot_amt from sale_m a left join sale_d b on a.midx = b.midx left join customers c on a.ccode = c.code left join ((select b.tax_type as tax_type, substring(a.dealdate,1,7) as deal_month, pname from sale_m a left join sale_d b on a.midx = b.midx where 1=1 {$where} and b.tax_type = 0 order by a.dealdate desc limit 1) union (select bb.tax_type as tax_type, substring(aa.dealdate,1,7) as deal_month, pname from sale_m aa left join sale_d bb on aa.midx = bb.midx where 1=1 {$where1} and bb.tax_type = 1 order by aa.dealdate desc limit 1) union (select bbb.tax_type as tax_type, substring(aaa.dealdate,1,7) as deal_month, pname from sale_m aaa left join sale_d bbb on aaa.midx = bbb.midx where 1=1 {$where2} and bbb.tax_type = 2 order by aaa.dealdate desc limit 1) ) e on b.tax_type = e.tax_type where 1=1 {$where} group by a.ccode, c.comp_name, b.tax_type order by a.ccode, tax_type; "; $result = mysql_query($sql,$connect_e1000y);
//_pr($sql); while($cus_info=mysql_fetch_array($result)){ $list_array[] = $cus_info; }
//_pr($list_array);
$qstr = $_SERVER['QUERY_STRING'];
$sql = "select a.code, a.comp_name from customers a where 1=1 and (a.biztype = 1 or a.biztype = 2) order by comp_name"; $result = mysql_query($sql,$connect_e1000y); while($cus_info=mysql_fetch_array($result)){ $comp_array[] = $cus_info; } ?> <style> .order-sheet2 { font-size:0.9em; } </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"> <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='sale_search_form' method='get'> <input type='hidden' name='search_form_name' id='search_form_name' value='sale_search_form'> <!-- 거래처 검색에서 리턴폼 명칭 정의--> <input type='hidden' name='biztype' size='' value='<?php echo $biztype;?>'> <input type='hidden' name='smode' size='' value='<?php echo $smode;?>'> <div id="sub-contents-area"> <div class="sub-btn-area"> <div class="sub-btn"> <a class="lignt-blue-btn" id='btn_tax_send'>발행</a><!--<a class="blue-btn" id='btn_state_email'>메일전송</a>--><a class="gray-btn" id='xls_down'>엑셀</a> </div> </div> <div class="sub-btn-area"> <div class="sub-btn sub-btn-search"> <a class='blue-btn sum_btn_class'>집계</a> <a class='gray-btn detail_btn_class'>상세</a> 기간 : <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'> 거래처검색 : <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'> <img src='./images/glass.png' class='customer-sel-btn glass_class'> <select name='sti' style='display:none;'> <option value='a.remarks' <?php if($sti=='a.remarks'){?>selected<?php }?>>전표비고</option> </select> <input type='text' id='stx' name='stx' size='' value='<?php echo $stx;?>' class="stx_class" style='display:none;'> <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' <?php if($smode==''){?>class="on"<?php }?>><span>발행대기건</span></a> <a value='1' <?php if($smode=='comp'){?>class="on"<?php }?>><span>발행내역건</span></a> <a value='2' <?php if($smode=='nts'){?>class="on"<?php }?>><span>국세청발행내역</span></a> <?php if($_SERVER['REMOTE_ADDR']=='58.151.27.172'){ ?> <a value='3'><span>매입 세금계산서</span></a> <?php } ?> </div> </div>
<form name='sale_list_form' method='post'> <input type='hidden' name='sel_mode' value='sum'> <input type='hidden' name='sdate' value='<?php echo $sdate?>'> <input type='hidden' name='edate' value='<?php echo $edate?>'> <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:90px;"><col style="width:100px;"><col style="width:140px;"> <col style="width:70px;"><col style="width:70px;"><col style="width:180px;"> <col style="width:100px;"><col style="width:90px;"><col style="width:120px;"> </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> </tr> </thead> <tbody> <?php $tmp_ccode = "0"; $s_amt = 0; $s_vat = 0; $s_tot = 0; $cnt = 0; for($i=0;$i<count($list_array);$i++){ $info = $list_array[$i]; //echo $tmp_ccode." = ".$info['ccode']." - {$i}<br>"; if($tmp_ccode!=$info['ccode']){ // 거래처가 바꼈을때 if($i>0){ ?> <tr> <td class="tcenter " colspan=7></td> <td class="cost cost_color_db"><?php echo number_format($s_amt);?></td> <td class="cost cost_color_db"><?php echo number_format($s_vat);?></td> <td class="cost cost_color_db"><?php echo number_format($s_tot);?></td> </tr> <?php $s_amt = 0; $s_vat = 0; $s_tot = 0; } ?> <tr> <td class="tcenter "> <input type='checkbox' name='code_idx[]' value='<?php echo $cnt;?>' class='sub_checkbox'> <input type='hidden' name='codes[]' value='c^<?php echo $info['ccode'];?>'> </td> <td class="linetxt cust_sum_class" colspan=9>거래처명 : [<?php echo $info['code1'];?>]<?php echo $info['comp_name'];?></td> </tr> <?php $tmp_ccode = $info['ccode']; $cnt++; } ?> <tr> <td class="tcenter "> <input type='checkbox' name='code_idx[]' value='<?php echo $cnt;?>'> <input type='hidden' name='codes[]' value='g^<?php echo $info['ccode'];?>^<?php echo $info['tax_type'];?>'> </td> <td class="tcenter "><?php echo $info['code1'];?></td> <td class="tcenter "><?php echo $info['comp_sn']?></td> <td class="linetxt click_edit"><?php echo $info['comp_name'];?></td> <td class="tcenter"><?php echo $info['deal_month'];?></td> <td class="tcenter"><?php echo $tax_yn[$info['tax_type']];?></td> <td class="linetxt "><?php echo $info['pname']; if($info['pcnt']>1){ echo "외 ".($info['pcnt']-1)."건"; }?></td> <td class="cost "><?php echo number_format($info['sum_sup_amt']);?></td> <td class="cost "><?php echo number_format($info['sum_vat']);?></td> <td class="cost "><?php echo number_format($info['sum_tot_amt']);?></td> </tr> <?php $cnt++; $s_amt += $info['sum_sup_amt']; $s_vat += $info['sum_vat']; $s_tot += $info['sum_tot_amt']; } if(count($list_array)>0){ ?> <tr> <td class="tcenter " colspan=7></td> <td class="cost cost_color_db"><?php echo number_format($s_amt);?></td> <td class="cost cost_color_db"><?php echo number_format($s_vat);?></td> <td class="cost cost_color_db"><?php echo number_format($s_tot);?></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"); if(v==0){ document.location.href="./taxbill.php"; } else if(v==1){ document.location.href="./taxbill_detail.php?smode=comp"; } else if(v==2){ document.location.href="./taxbill_nts.php"; } else if(v==3){ document.location.href="./taxbill_buy_nts.php"; } });
$(".click_edit").css("cursor","pointer").click(function(){ // 전표상세보기 수정 });
$(".check_all_class").click(function(){ // 전체선택 전체선택 해제 if($(this).is(":checked")){ $("input[name='code_idx[]']").prop("checked",true); } else { $("input[name='code_idx[]']").prop("checked",false); } });
$("#xls_down").click(function(){ // 엑셀다운로드 document.sale_search_form.action='taxbill_xls_down.php'; document.sale_search_form.target = '_blank'; document.sale_search_form.submit(); document.sale_search_form.action='?'; document.sale_search_form.target = ''; });
$("#search_btn_press").click(function(){ // 검색버튼 누를때 document.sale_search_form.action='?'; document.sale_search_form.target = ''; document.sale_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(""); });
$(".sub_checkbox").click(function(){ var v = $(this).val(); var $code_obj = $("input[name='code_idx[]']"); vv =parseInt(v)+1; for(i=vv;i<$code_obj.size();i++){ if($code_obj.eq(i).hasClass("sub_checkbox")){ return; } else { if($(this).is(":checked")==true){ $code_obj.eq(i).prop("checked", true); } else { $code_obj.eq(i).prop("checked", false); } } } });
$(".sum_btn_class").click(function(){ // 집계화면보기 document.location.href='taxbill.php'; }); $(".detail_btn_class").click(function(){ // 상세화면보기 document.location.href='taxbill_detail.php'; });
$("#btn_tax_send").click(function(){ // 세금계산서 발행 클릭 get_tax_process(); }); });
function get_tax_process(){ // 세금계산서 발행
var cnt = $("input[name='code_idx[]']:checked").size(); if(cnt==0){ alert('발행하실 전표를 선택하시기 바랍니다.'); return; }
$.post("taxbill.reg.inc.php?",$("form[name='sale_list_form']").serialize(), function(rtn){ $("#modal_member_box").html(rtn).dialog({ resizable: true, height:360, width:740, modal: true, title: "세금계산서 발행", buttons: { 닫기: function() { $( this ).dialog( "close" ); } } }); }); } 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?biztype=1&modetype=list&sti="+sti_val+"&stx="+v_cn+"&page="+v_page,function(rtn){ $("#modal_member_box").html(rtn).dialog({ resizable: true, height:780, width:1100, modal: true, title: "거래처 [검색]", buttons: { 닫기: function() { $( this ).dialog( "close" ); } } }); }); } </script> <?php include('./include/footer.php'); ?> <div id="modal_member_box" title="1차모달" 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="2차모달" style="display:none;width:100%; height:100%; padding-top:3px;padding-left:3px;background-color:#FFFFFF;position:relative;"></div>
|