-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrep.php
452 lines (406 loc) · 17 KB
/
rep.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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
<?php
include_once("menu.php");
/*
File: helloworld.php
Test / example page demonstrating the basic xajax implementation.
Title: Hello world sample page.
Please see <copyright.inc.php> for a detailed description, copyright
and license information.
*/
/*
@package xajax
@version $Id: helloworld.php 362 2007-05-29 15:32:24Z calltoconstruct $
@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
@license http://www.xajaxproject.org/bsd_license.txt BSD License
*/
/*
Section: Standard xajax startup
- include <xajax.inc.php>
- instantiate main <xajax> object
*/
require ('./xajax_core/xajax.inc.php');
$xajax = new xajax();
/*
- enable deubgging if desired
- set the javascript uri (location of xajax js files)
*/
//$xajax->configure('debug', true);
$xajax->configure('javascript URI', './');
// 반복되는 구조 변수
$thead[11001]=$tableD.'
<tr>
<td width="70" class="style2">병원</td>
<td width="80" class="style2">매출</td>
<td width="100" class="style2">지출</td>
<td width="55" class="style2">누적매출</td>
<td width="55" class="style2">누적지출</td>
<td width="108" class="style2">보유현금누계</td>
<td width="100" class="style2">CCRATE</td>
</tr>';
$thead[11002]=$tableD.'
<tr>
<td width="70" class="style2">병원</td>
<td width="80" class="style2">매출</td>
<td width="100" class="style2">누적매출</td>
<td width="108" class="style2">보유현금누계</td>
<td width="100" class="style2">CCRATE</td>
</tr>';
$thead[1001]=$tableD.'
<thead>
<tr>
<td class="style2">DATE</td>
<td class="style2">수입</td>
<td class="style2">이익</td>
<td class="style2">현금수입</td>
<td class="style2">현금영수증 수입</td>
<td class="style2">카드 수입</td>
<td class="style2">통장 수입</td>
<td class="style2">매출환불(통장)</td>
<td class="style2">현금지출</td>
<td class="style2">통장지출</td>
<td class="style2">카드(법인)지출</td>
<td class="style2">카드(개인)지출</td>
<td class="style2">보유현금</td>
</tr>
</thead>';
$thead[1002]=$tableD.'
<thead>
<tr>
<td class="style2">DATE</td>
<td class="style2">수입</td>
<td class="style2">이익</td>
<td class="style2">현금수입</td>
<td class="style2">현금영수증 수입</td>
<td class="style2">카드수입</td>
<td class="style2">통장수입</td>
<td class="style2">비고</td>
</tr>
</thead>';
// 반올림 함수
function round_up ($value, $precision=2) {
$amt = explode(".", $value);
if(strlen($amt[1]) > $precision) {
$next = (int)substr($amt[1],$precision);
$amt[1] = (float)(".".substr($amt[1],0,$precision));
if($next != 0) {
$rUp = "";
for($x=1;$x<$precision;$x++) $rUp .= "0";
$amt[1] = $amt[1] + (float)(".".$rUp."1");
}
}
else {
$amt[1] = (float)(".".$amt[1]);
}
return $amt[0]+$amt[1];
}
/*
Function: inquiry
inquiry
*/
function inquiry($sale_code,$end_date)
{
global $menu2,$thead,$menu,$extColor,$tabColor,$thColor;
$objResponse = new xajaxResponse();
$style[1000]=' style="width:4%;background-color:'.$extColor.';"';
$selTab[11001]=' style="width:24%;"';
$selTab[11002]=' style="width:24%;"';
$selTab[1001]=' style="width:24%;"';
$selTab[1002]=' style="width:24%;"';
// $selTab[$exps_code]=' style="font-weight: bolder;background-color:'.$tabColor.';width:24%;"';
$selClass[$sale_code]=' class="tabS"';
$sCol[11001]='color:#FFFFFF;';
$sCol[11002]='color:#FFFFFF;';
$sCol[1001]='color:#FFFFFF;';
$sCol[1002]='color:#FFFFFF;';
$sCol[$sale_code]='color:'.$thColor.';';
$setTime=$end_date;
if(session_is_registered('reg_date')){
$date_input=str_replace("-","",$end_date);// '-' 제거
$_SESSION['session_reg_date']=$date_input;
}
$menuDiv='<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" align="center"'.$style[1000].'></td>
<td width="150" height="30" align="center" '.$selTab[11001].'><div '.$selClass[11001].'><a href="report.php"><span style="'.$sCol[11001].'">일매출전체(피부과)</span></a></div></td>
<td width="150" height="30" align="center" '.$selTab[1001].'><div '.$selClass[1001].'><a href="#" onclick="xajax_inquiry(1001,\''.$end_date.'\')"><span style="'.$sCol[1001].'">일매출병원(피부과)</span></a></div></td>
<td width="150" height="30" align="center" '.$selTab[11002].'><div '.$selClass[11002].'><a href="#" onclick="xajax_inquiry(11002,\''.$end_date.'\')"><span style="'.$sCol[11002].'">일매출병원(코스메틱)</span></a></div></td>
<td width="150" height="30" align="center" '.$selTab[1002].'><div '.$selClass[1002].'><a href="#" onclick="xajax_inquiry(1002,\''.$end_date.'\')"><span style="'.$sCol[1002].'">일매출전체(코스메틱)</span></a></div></td>
<td width="100" height="30" align="center" class="box_Bottomline"> </td>
</tr>
</table>';
$m=substr($end_date,5,2);
$start_date=date("Y-m-d", mktime(0,0,0,$m,1,substr($end_date,0,4)));
$query="inquiry".$start_date.$end_date.' '.$m;
$objResponse->assign('date_start', 'value', $start_date);
$objResponse->assign('date_end', 'value', $end_date);
$objResponse->assign('sale_code', 'value', $sale_code);
$start_date=str_replace("-","",$start_date);// '-' 제거
$end_date=str_replace("-","",$end_date);// '-' 제거
if($sale_code>10000){
$updated=$thead[$sale_code].'<tbody>';
$sale_code=$sale_code-10000;
$updated=$updated.selectAll($sale_code,$start_date,$end_date).'</table>';
}else{
$updated=selectSale($sale_code,$start_date,$end_date).'</table>';
}
// $objResponse->assign('div2', 'innerHTML', $date_input);
$objResponse->assign('content', 'innerHTML', $updated);
$objResponse->call('bottom');//div scolling
$objResponse->assign('menu', 'innerHTML', $menu);
$msg=$_SESSION['sunap']."님은 ".$setTime."일자 자료입력 중입니다.";
$objResponse->assign('msgDiv', 'innerHTML', $msg);
$objResponse->assign('tabs2', 'innerHTML', $menuDiv);
return $objResponse;
}
/*
Function: selectSale
seclectSale
*/
function selectSale($sale_code,$start_date,$end_date)
{
global $thead, $connect;
$selSql="select `reg_date` from toto_pay where `sale_code` = '".$sale_code."' and `reg_date` between '".$start_date."' and '".$end_date."' order by reg_date asc";
$result = mysql_query($selSql, $connect);
$total = mysql_num_rows($result); // 총 레코드 수
$num=$total;
while($total--){
$row = mysql_fetch_row($result);
if($row[0]==$cur_date){
}else{
$reg_date=substr($row[14],0,4);
$reg_date=$reg_date."-".substr($row[14],4,2);
$reg_date=$reg_date."-".substr($row[14],6,2);
$reged_date=$reged_date."|".$row[0];//입력된 reg_date 구하기
}
$cur_date=$row[0];
}
$reg_arr=explode("|",$reged_date);
$arr_size=count($reg_arr);
$num=0;
for($ac=$start_date;$ac<=$end_date;$ac++){
$numOfList++;
$selSql="select * from toto_pay where `sale_code` = '".$sale_code."' and `reg_date` = '".$ac."' order by reg_date asc";
$result = mysql_query($selSql, $connect);
$total = mysql_num_rows($result); // 총 레코드 수
$num=$total;
while($total--){
$row = mysql_fetch_row($result);
$income=$income+$row[8]+$row[9]+$row[10]+$row[11];
$cash_income=$cash_income+$row[8];
$cscd_income=$cscd_income+$row[9];
$card_income=$card_income+$row[10];
$yet_income=$yet_income+$row[11];
$t_income=$t_income+$row[8]+$row[9]+$row[10]+$row[11];//총합
$t_cash_income=$t_cash_income+$row[8];
$t_cscd_income=$t_cscd_income+$row[9];
$t_card_income=$t_card_income+$row[10];
$t_yet_income=$t_yet_income+$row[11];
}
$exps_code=$sale_code+2999;
$selSql2="select `cash_mony` from toto_exp where `exps_code` = '".$exps_code."' and `reg_date` = '".$ac."' and exps_gubn='0'";
$result2 = mysql_query($selSql2, $connect);
$total2 = mysql_num_rows($result2); // 총 레코드 수
while($total2--){
$row2 = mysql_fetch_row($result2);
$cash_outcome=$cash_outcome+$row2[0];
$t_cash_outcome=$t_cash_outcome+$row2[0];
}
$selSql2="select `cash_mony` from toto_exp where `exps_code` = '".$exps_code."' and `reg_date` = '".$ac."' and exps_gubn='1'";
$result2 = mysql_query($selSql2, $connect);
$total2 = mysql_num_rows($result2); // 총 레코드 수
while($total2--){
$row2 = mysql_fetch_row($result2);
$cscd_outcome=$cscd_outcome+$row2[0];
$t_cscd_outcome=$t_cscd_outcome+$row2[0];
}
$selSql2="select `cash_mony` from toto_exp where `exps_code` = '".$exps_code."' and `reg_date` = '".$ac."' and exps_gubn='2'";
$result2 = mysql_query($selSql2, $connect);
$total2 = mysql_num_rows($result2); // 총 레코드 수
while($total2--){
$row2 = mysql_fetch_row($result2);
$card_legal=$card_legal+$row2[0];
$t_card_legal=$t_card_legal+$row2[0];
}
$selSql2="select `cash_mony` from toto_exp where `exps_code` = '".$exps_code."' and `reg_date` = '".$ac."' and exps_gubn='3'";
$result2 = mysql_query($selSql2, $connect);
$total2 = mysql_num_rows($result2); // 총 레코드 수
while($total2--){
$row2 = mysql_fetch_row($result2);
$card_indiv=$card_indiv+$row2[0];
$t_card_indiv=$t_card_indiv+$row2[0];
}
$outcome=$cash_outcome+$cscd_outcome+$card_legal+$card_indiv;
$t_outcome=$t_cash_outcome+$t_cscd_outcome+$t_card_legal+$t_card_indiv;
$reg_date=substr($ac,0,4);
$reg_date=$reg_date."-".substr($ac,4,2);
$reg_date=$reg_date."-".substr($ac,6,2);
$reged_date=$reged_date."|".$row[0];//입력된 reg_date 구하기
if($numOfList%5){
$ts="tdStyle";
}else{
$ts="fifthStyle";
}
$updated=$updated.'<tr>
<td class="'.$ts.'">'.$reg_date.'</td>';
$updated=$updated.'<td class="'.$ts.'">'.comma($income).'</td>';
$updated=$updated.'<td class="'.$ts.'">'.comma($income-$outcome).'</td>';
$updated=$updated.'<td class="'.$ts.'">'.comma($cash_income).'</td>';
$updated=$updated.'<td class="'.$ts.'">'.comma($cscd_income).'</td>';
$updated=$updated.'<td class="'.$ts.'">'.comma($card_income).'</td>';
$updated=$updated.'<td class="'.$ts.'">'.comma($yet_income).'</td>';
if($sale_code=="1001"){
$updated=$updated.'<td class="'.$ts.'">0</td>';
$updated=$updated.'<td class="'.$ts.'">'.comma($cash_outcome).'</td>';
$updated=$updated.'<td class="'.$ts.'">'.comma($cscd_outcome).'</td>';
$updated=$updated.'<td class="'.$ts.'">'.comma($card_legal).'</td>';
$updated=$updated.'<td class="'.$ts.'">'.comma($card_indiv).'</td>';
}
$updated=$updated.'<td class="'.$ts.'">'.comma($cash_income+$cscd_income-$cash_outcome).'</td>
</tr>';
$income=0;
$cash_income=0;
$cscd_income=0;
$card_income=0;
$yet_income=0;
$cash_outcome=0;
$cscd_outcome=0;
$card_legal=0;
$card_indiv=0;
$outcome=0;
}
$summation=$summation.'<tr><td class="summ">합계</td>';
$summation=$summation.'<td class="summ">'.comma($t_income).'</td>';
$summation=$summation.'<td class="summ">'.comma($t_income-$t_outcome).'</td>';
$summation=$summation.'<td class="summ">'.comma($t_cash_income).'</td>';
$summation=$summation.'<td class="summ">'.comma($t_cscd_income).'</td>';
$summation=$summation.'<td class="summ">'.comma($t_card_income).'</td>';
$summation=$summation.'<td class="summ">'.comma($t_yet_income).'</td>';
if($sale_code=="1001"){
$summation=$summation.'<td class="summ">0</td>';
$summation=$summation.'<td class="summ">'.comma($t_cash_outcome).'</td>';
$summation=$summation.'<td class="summ">'.comma($t_cscd_outcome).'</td>';
$summation=$summation.'<td class="summ">'.comma($t_card_legal).'</td>';
$summation=$summation.'<td class="summ">'.comma($t_card_indiv).'</td>';
}
$summation=$summation.'<td class="summ">'.comma($t_cash_income+$t_cscd_income).'</td></tr>';
$summation=$summation.'<tr><td class="summ">평균</td>';
$summation=$summation.'<td class="summ">'.comma(ceil($t_income/$arr_size)).'</td>';
$summation=$summation.'<td class="summ">'.comma(ceil(($t_income-$t_outcome)/$arr_size)).'</td>';
$summation=$summation.'<td class="summ">'.comma(ceil($t_cash_income/$arr_size)).'</td>';
$summation=$summation.'<td class="summ">'.comma(ceil($t_cscd_income/$arr_size)).'</td>';
$summation=$summation.'<td class="summ">'.comma(ceil($t_card_income/$arr_size)).'</td>';
$summation=$summation.'<td class="summ">'.comma(ceil($t_yet_income/$arr_size)).'</td>';
if($sale_code=="1001"){
$summation=$summation.'<td class="summ">0</td>';
$summation=$summation.'<td class="summ">'.comma(ceil($t_cash_outcome/$arr_size)).'</td>';
$summation=$summation.'<td class="summ">'.comma(ceil($t_cscd_outcome/$arr_size)).'</td>';
$summation=$summation.'<td class="summ">'.comma(ceil($t_card_legal/$arr_size)).'</td>';
$summation=$summation.'<td class="summ">'.comma(ceil($t_card_indiv/$arr_size)).'</td>';
}
$summation=$summation.'<td class="summ">'.comma(ceil(($t_cash_income+$t_cscd_income)/$arr_size)).'</td></tr>';
$updated=$thead[$sale_code].'<tbody>'.$summation.$updated.$summation.'</tbody></table>';
return $updated;
}
/*
Function: selectAll
seclectAll
*/
function selectAll($sale_code,$start_date,$end_date)
{
global $thead, $connect, $tableD;
$selSql1="select `reg_date` from toto_pay where `sale_code` = '".$sale_code."' and `reg_date` between '".$start_date."' and '".$end_date."' order by reg_date asc";
$result = mysql_query($selSql1, $connect);
$total1 = mysql_num_rows($result); // 총 레코드 수
$num=$total1;
// 병원이름 출력 2011-03-31
$docSql="select * from toto_doctor order by `no` asc";
$docRes = mysql_query($docSql, $connect);
$docTot = mysql_num_rows($docRes); // 총 레코드 수
$docNum=$docTot;
$docRow = mysql_fetch_row($docRes);
$hosp_name = $docRow[3];
if($total1){
while($total1--){
$row = mysql_fetch_row($result);
if($row[0]==$cur_date){
}else{
$reg_date=substr($row[14],0,4);
$reg_date=$reg_date."-".substr($row[14],4,2);
$reg_date=$reg_date."-".substr($row[14],6,2);
$reged_date=$reged_date."|".$row[0];//입력된 reg_date 구하기
}
$cur_date=$row[0];
}
$reg_arr=explode("|",$reged_date);
$arr_size=count($reg_arr);
$num=0;
for($ac=$start_date;$ac<=$end_date;$ac++){//피부과 자료 정리
$numOfList++;
$selSql="select sum(cash_mony+cscd_mony+card_mony+yet__mony), sum(card_mony), sum(cash_mony+cscd_mony) from toto_pay where `sale_code` = '".$sale_code."' and rmdy_doct = '".$docRow[1]."' and `reg_date` = '".$ac."' order by reg_date asc";
$result = mysql_query($selSql, $connect);
$total = mysql_num_rows($result); // 총 레코드 수
$num=$total;
while($total--){
$row = mysql_fetch_row($result);
$income=$row[0];
$card_in=$row[1];//카드 총합
$income_sum=$income_sum+$row[0];//총합
$card_income=$card_income+$row[1];//카드 총합
$cash_income=$cash_income+$row[2];//현금 총합
}
if($sale_code==1001){//병원 합계 일 때 만 지출 계산
$selSql2="select `cash_mony` from toto_exp where `exps_code` = '4000' and `reg_date` = '".$ac."' order by reg_date asc";
$result2 = mysql_query($selSql2, $connect);
$total2 = mysql_num_rows($result2); // 총 레코드 수
$outcome_today=0;
while($total2--){
$row2 = mysql_fetch_row($result2);
$outcome_today=$outcome_today+$row2[0];
$outcome=$outcome+$row2[0];
}
}
}
$updated=$updated.'<tr>
<td class="tdStyle">'.$hosp_name.'</td>';
$updated=$updated.'<td class="tdStyle">'.comma($income).'</td>';
if($sale_code==1001)//병원 합계 일 때 만 지출 계산
$updated=$updated.'<td class="tdStyle">'.comma($outcome_today).'</td>';
$updated=$updated.'<td class="tdStyle">'.comma($income_sum).'</td>';
if($sale_code==1001)//병원 합계 일 때 만 지출 계산
$updated=$updated.'<td class="tdStyle">'.comma($outcome).'</td>';
$updated=$updated.'<td class="tdStyle">'.comma($cash_income).'</td>';
if($income==0){//당일 매출이 없을 경우 2011-08-30
$ccrate="-";
}else{
$ccrate=round_up(($card_income/$income),3);
}
$updated=$updated.'<td class="tdStyle">'.$ccrate.'</td></tr>';
$updated=$updated.'<tr>
<td class="tdStyle">합계</td>';
$updated=$updated.'<td class="tdStyle">'.comma($income).'</td>';
if($sale_code==1001)//병원 합계 일 때 만 지출 계산
$updated=$updated.'<td class="tdStyle">'.comma($outcome_today).'</td>';
$updated=$updated.'<td class="tdStyle">'.comma($income_sum).'</td>';
if($sale_code==1001)//병원 합계 일 때 만 지출 계산
$updated=$updated.'<td class="tdStyle">'.comma($outcome).'</td>';
$updated=$updated.'<td class="tdStyle">'.comma($cash_income).'</td>';
$updated=$updated.'<td class="tdStyle">'.$ccrate.'</td></tr>';
$updated=$updated;
}else{
$updated='자료가 없습니다';
}
return $updated;
}
$reqInquiry =& $xajax->registerFunction('inquiry');
/*
Section: processRequest
This will detect an incoming xajax request, process it and exit. If this is
not a xajax request, then it is a request to load the initial contents of the page
(HTML).
Everything prior to this statement will be executed upon each request (whether it
is for the initial page load or a xajax request. Everything after this statement
will be executed only when the page is first loaded.
*/
$xajax->processRequest();
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>