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
|
<?php $dir = "."; include_once($dir."/_common.php"); $new_cust = "Y"; $new_deal = "Y"; if($midx!=''){ $sql = "select d.nidx, ifnull(d.dealdate,now()) as pdealdate, a.midx, a.ccode, c.code1 as ccode1, c.comp_name, c.cur_recvbl, ifnull(b.totamt,0) as totamt, ifnull(d.amount,0) as amount, ifnull(d.dealtype,\"\") as dealtype , d.remarks as premarks from sale_m a left join (select aa.midx, sum(aa.tot_amt) as totamt from sale_d aa where 1=1 group by aa.midx) b on a.midx = b.midx left join customers c on a.ccode = c.code left join receive d on a.midx = d.dealidx where 1=1 and a.midx = '{$midx}' "; $res = mysql_query($sql,$connect_e1000y); $pinfo = mysql_fetch_array($res); $pinfo['dealdate'] = substr($pinfo['pdealdate'],0,10); if($pinfo['nidx']>0){ $pinfo['cur_recvbl'] = $pinfo['cur_recvbl'] + $pinfo['amount']; // 수정 입금 전미불 계산위해서 입금액을을 전미불에서 더해준다. } } else if($nidx!=''){ $sql = "select a.nidx, ifnull(a.dealdate,now()) as pdealdate, ifnull(c.midx,0) as midx, a.ccode, b.code1 as ccode1, b.comp_name, b.cur_recvbl, ifnull(d.totamt,0) as totamt, ifnull(a.amount,0) as amount, ifnull(a.dealtype,\"\") as dealtype , a.remarks as premarks from receive a left join customers b on a.ccode = b.code left join sale_m c on a.dealidx = c.midx left join (select aa.midx, sum(aa.tot_amt) as totamt from sale_d aa where 1=1 group by aa.midx) d on c.midx = d.midx where 1=1 and nidx = {$nidx} "; $res = mysql_query($sql,$connect_e1000y); $pinfo = mysql_fetch_array($res); $pinfo['dealdate'] = substr($pinfo['pdealdate'],0,10); $pinfo['cur_recvbl'] = $pinfo['cur_recvbl'] + $pinfo['amount']; // 수정 입금 전미불 계산위해서 입금액을을 전미불에서 더해준다. $midx = $pinfo['midx']; } else { $pinfo['dealdate'] = date("Y-m-d",time()); } if($nidx>'0' && $midx>'0'){ // 입금전표 수정 이면서 이미 딜이 있을경우 거래처/딜 수정못하게 처리 $new_cust = "N"; $new_deal = "N"; } ?>
<form name='receive_reg_form' method='post' action=''> <input type='hidden' name='qstr' value=''> <input type='hidden' name='dealidx' value='<?php echo $midx;?>'> <input type='hidden' name='nidx' value='<?php echo $pinfo['nidx'];?>'>
<div class='cust_modal1'> <h4>기본정보</h4> <table class="order-sheet table-top-border"> <caption class="screen_out">기본정보</caption> <colgroup> <col style="width:100px;"><col style="width:230px;"> <col style="width:100px;"><col style="width:230px;"> </colgroup>
<tbody> <tr> <th>입금일자</th> <td> <input type='text' name='dealdate' id='dealdate2' class='input_readonly width_80' value='<?php echo $pinfo['dealdate'];?>' maxlength=10> </td> <th>결제방법</th> <td> <select name='dealtype' disabled> <option value='0' <?php if($pinfo['dealtype']=='0'){?>selected<?php }?>>현금</option> <option value='2' <?php if($pinfo['dealtype']=='2'){?>selected<?php }?>>통장</option> </select> </td> </tr> </table> </div>
<div class='cust_modal2'> <h4>거래처 정보</h4> <table class="order-sheet table-top-border"> <caption class="screen_out">거래처 정보</caption> <colgroup> <col style="width:100px;"><col style="width:230px;"> <col style="width:100px;"><col style="width:230px;"> </colgroup>
<tbody> <tr> <th>거래처</th> <td colspan=3> <input type='hidden' name='ccode' value='<?php echo $pinfo['ccode'];?>'> <input type='text' name='ccode1' value='<?php echo $pinfo['ccode1'];?>' class='input_readonly width_60'> <input type='text' name='comp_name' value='<?php echo $pinfo['comp_name'];?>' class='width_120 customer-sel-btn2' > <?php if($new_cust=='Y'){?> <img src='./images/glass.png' class='customer-sel-btn glass_class'><?php }?> </td> </tr> <tr> <th>거래금액</th> <td><input type='text' name='totamt' class='number_class input_readonly totamt_class' value='<?php echo number_format($pinfo['totamt']);?>' maxlength=12></td> <th>전미수</th> <td><input type='text' name='old_mibul' class='input_readonly' value='<?php echo number_format($pinfo['cur_recvbl']);?>' maxlength=4></td> </tr> </table> </div>
<div class='cust_modal2'> <h4>입금 정보</h4> <table class="order-sheet table-top-border"> <caption class="screen_out">입금 정보</caption> <colgroup> <col style="width:100px;"><col style="width:230px;"> <col style="width:100px;"><col style="width:230px;"> </colgroup>
<tbody> <tr> <th>입금액</th> <td colspan=3> <input type='text' name='amount' class='number_class amount_class' value='<?php echo number_format($pinfo['amount']);?>'> <span class='amount_auto_class'> <input type='checkbox' name='amount_ck' value='1'> 입금액 입력</span> </td> </tr> <tr> <th>메모</th> <td><input type='text' name='remarks' class='' value='<?php echo $pinfo['premarks'];?>'></td> <th>현미수</th> <td><input type='text' name='now_mibul' class='input_readonly' value=''></td> </tr> <tr> <th>거래번호</th> <td colspan=3><input type='text' name='midx' class='input_readonly' value='<?php echo $pinfo['midx'];?>'> <?php if($new_deal=='Y'){?> <img src='./images/glass.png' class='sale-sel-btn glass_class'><?php }?> </td> </tr> </table> </div>
</form> <script> $(function(){ $("#dealdate2").datepicker({ showOn: "button", buttonImage: "./images/common/calendar.png", buttonImageOnly: true, buttonText: "Select date", dateFormat: "yy-mm-dd", changeMonth: true, changeYear: true, monthNames: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'], monthNamesShort: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'], dayNames: ['일','월','화','수','목','금','토'], dayNamesShort: ['일','월','화','수','목','금','토'], dayNamesMin: ['일','월','화','수','목','금','토'], showMonthAfterYear: true, yearSuffix: '년' });
$(".customer-sel-btn").click(function(){ // 거래처 ? 검색일경우 customer_search('',1); }); $(".customer-sel-btn2").keypress(function(){ // 거래처명란에서 엔터로 검색일경우 if(event.keyCode==13){ var v_cn = $(".customer-sel-btn2").val() customer_search(encodeURI(v_cn),1); } });
$(".sale-sel-btn").click(function(){ sale_search('',1); });
$("form[name='receive_reg_form'] input[name='amount_ck']").click(function(){ // 입금액 입력 if($(this).is(":checked")){ var v = formatCurrency(number_ch($("input[name='totamt']").val())); $("input[name='amount']").val(v); } else { $("input[name='amount']").val("0"); } $("form[name='receive_reg_form'] input[name='amount']").change(); });
$("form[name='receive_reg_form'] input[name='amount']").change(function(){ var old_mibul = number_ch($("form[name='receive_reg_form'] input[name='old_mibul']").val()); var now_mibul = old_mibul-number_ch($(this).val()); $("form[name='receive_reg_form'] input[name='now_mibul']").val(formatCurrency(now_mibul)); });
$(".input_readonly").attr("readonly",true);
if('<?php echo $pinfo['midx'];?>'==''){ // 입금액 자동체크는 전표번호 있을때만 가능 $(".amount_auto_class").hide(); }
if($("input[name='dealidx']").val()==''){ $("select[name='dealtype']").attr("disabled",false); }
$("form[name='receive_reg_form'] input[name='amount']").change(); })
function receive_save(){ // 입금전표 저장/수정 $form_obj = $("form[name='receive_reg_form']"); var midx = $form_obj.find("input[name='dealidx']").val(); var nidx = $form_obj.find("input[name='nidx']").val();
if(midx!='' && midx>'0'){ if($form_obj.find("input[name='totamt']").val()!=$form_obj.find("input[name='amount']").val()){ //alert('매출자료의 총 매출금액과 총입금액이 동일해야 합니다.'); return; } }
var form_data = $form_obj.serialize(); $.ajax({type:"post", url:"ajax.receive_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(); var v_sum_qty = $(xml).find("sum_qty").text(); var v_sum_tot_amt = $(xml).find("sum_tot_amt").text(); var v_sum_sump_amt = $(xml).find("sum_sump_amt").text(); var v_sum_vat = $(xml).find("sum_vat").text(); if(v_mode_ok!='Y' && v_msg!=''){ alert(v_msg); } else { if(v_mode=='update'){ alert('입금전표가 수정 되었습니다.'); } else if(v_mode=='new'){ alert('입금전표가 저장 되었습니다.'); } $("#modal_member_box").dialog("close"); if($("input[name='receive_page']").val()=='Y'){ document.location.reload(); } } }, error:function(rtn,status,error){ alert(error); } }); }
function customer_search(v_cn,v_page){ // 거래처 검색 if('<?php echo $new_cust;?>'=='N'){ return; } sti_val = "comp_name"; $.get("customer_list.inc.php?biztype=1&modetype=receive&sti="+sti_val+"&stx="+v_cn+"&page="+v_page,function(rtn){ $("#modal_member_box2").html(rtn).dialog({ resizable: true, height:780, width:1100, modal: true, title: "거래처 [검색]", buttons: { 닫기: function() { $( this ).dialog( "close" ); } } }); }); }
function sale_search(v_cn,v_page){ // 매입전표 검색 sti_val = "a.ccode"; url = "biztype=1&modetype=receive&sti="+sti_val+"&stx="+v_cn+"&page="+v_page+"&sdate="+$("#ssdate").val()+"&edate="+$("#eesdate").val()+"&stc="+$("form[name='sale_search_form_pop'] input[name='stc']").val(); $.get("sale_list.inc.php?"+url,function(rtn){ $("#modal_member_box2").html(rtn).dialog({ resizable: true, height:780, width:1100, modal: true, title: "매입전표 [검색]", buttons: { 닫기: function() { $( this ).dialog( "close" ); } } }); }); } </script>
|