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
|
<? include_once("./_common.php"); include("./header.php"); include("./commonST.php");
// Notice Error 방지 isset($_POST['txtdate']) ? $txtdate = $_POST['txtdate'] : $txtdate = ""; isset($_POST['txtdate2']) ? $txtdate2 = $_POST['txtdate2'] : $txtdate2 = ""; isset($_POST['orderdate']) ? $orderdate = $_POST['orderdate'] : $orderdate = ""; isset($_POST['orderstate']) ? $orderstate = $_POST['orderstate'] : $orderstate = ""; isset($_POST['duration']) ? $duration = $_POST['duration'] : $duration = "-7"; isset($_POST['mode']) ? $mode = $_POST['mode'] : $mode = ""; if(!isset($sid)) $sid = "";
if(( $id == "" ) && ( $sid == "" )) { echo "<script>alert('천년스마트발주 로그인 후에 이용가능합니다.');location.href = './index.php';</script>"; } // part : # 거래분야(0:매입,1:매출,2: 매입,매출) if(isset($row) && $row['part'] == "0"){ echo "<script>alert('발주처만 이용 가능합니다.');location.href = './index.php';</script>"; }
// 접속권한 체크 include("./checkLicenses.php");
// 기간 검색하지 않고 '오늘'로 두고 바로 조회 버튼클릭 했을 경우 예외처리 if($duration == 0){ $txtdate = date("Y-m-d", time()); $txtdate2 = date("Y-m-d", time()); }
// Notice Error 방지 if (!isset($category_code)) $category_code = ""; if (!isset($uid)) $uid = ""; if (!isset($txtdate)) $txtdate = ""; if (!isset($txtdate2)) $txtdate2 = ""; if (!isset($detail)) $detail = ""; if (!isset($orderdate)) $orderdate = ""; if (!isset($orderstate)) $orderstate = ""; if (!isset($ordertype)) $ordertype = ""; if (!isset($ocopy)) $ocopy = ""; if (!isset($limitbaln)) $limitbaln = ""; if (!isset($trnum)) $trnum = "0"; if (!isset($ordertype)) $ordertype = "";
if (!isset($today)) $today = ""; if (!isset($hidden)) $hidden = ""; if (!isset($new)) $new = "";
if (!isset($id)) $id = ""; if (!isset($sid)) $sid = ""; if (!isset($cuscode)) $cuscode = ""; if (!isset($sacode)) $sacode = "";
if ($txtdate == ""){ $txtdate = ($txtdate == "") ? date("Y-m-d", strtotime("-7 Day")) : $txtdate; } if ($txtdate2 == ""){ $txtdate2 = ($txtdate2 == "") ? date("Y-m-d", time()) : $txtdate2; }
$sql = "SELECT * FROM customer WHERE code = '{$cuscode}'"; $result = mysql_query($sql); $cuso = mysql_fetch_array($result);
//--------주문처 정보 -----------// $Ctopsql = " SELECT code, compname, telno1, fax FROM office WHERE code = '{$sacode}'"; $Cresult = mysql_query($Ctopsql); if( mysql_num_rows($Cresult) > 0){ $crow = mysql_fetch_array($Cresult);
$Cname = $crow['compname']; $Ctel = $crow['telno1']; $Cfax = $crow['fax']; }
// Query
$orderoption = ""; if($orderdate == "") { $orderoption = "ORDER BY orddate desc, 1, ordno "; $txtfield = "orddate"; } if($orderdate == "1") { $orderoption = "ORDER BY orddate desc, 1, ordno "; $txtfield = "orddate"; } if($orderdate == "2") { $orderoption = "ORDER BY deldate desc, 1, ordno "; $txtfield = "deldate"; }
$ordertype = ""; if($orderstate == "2") $ordertype = "AND ordstate = '0' "; if($orderstate == "3") $ordertype = "AND ordstate = '1' "; if($orderstate == "4") $ordertype = "AND ordstate = '2' "; if($orderstate == "5") $ordertype = "AND ordstate = '3' "; if($orderstate == "6") $ordertype = "AND ordstate = '4' ";
$charSet_sql = "set names utf8"; mysql_query($charSet_sql);
$order_sql = " SELECT 0, m.orddate, m.ordtime, m.ordstate, m.deldate,SUM(d.ordqnt * d.price) AS sumtotal, d.ordno, COUNT(d.ordno) AS number, '0' AS countdate FROM ordbook_d AS d LEFT JOIN ordbook_m AS m ON m.ordno = d.ordno WHERE m.{$txtfield} BETWEEN '{$txtdate}' AND '{$txtdate2}' AND ocode = '{$sacode}' AND ccode = '{$cuscode}' AND part = '1' {$ordertype} GROUP BY m.ordno
UNION ALL SELECT 1, m.orddate, m.ordtime, m.ordstate, m.deldate,SUM(d.ordqnt * d.price) AS sumtotal, d.ordno, COUNT(d.ordno) AS number, COUNT(m.orddate) as countdate FROM ordbook_d AS d LEFT JOIN ordbook_m AS m ON m.ordno = d.ordno WHERE m.{$txtfield} BETWEEN '{$txtdate}' AND '{$txtdate2}' AND ocode = '{$sacode}' AND ccode = '{$cuscode}' AND part = '1' {$ordertype} GROUP BY m.orddate {$orderoption} ";
$order_result = mysql_query($order_sql) or die (mysql_error());
// 온라인 주문 배송 정보 사용에 다른 옵션 가져오기 $sql = "select optvalue from options where optname = '온주배송정보사용' "; $res_optval1 = mysql_query($sql); $info_optval1 = mysql_fetch_array($res_optval1); $sid = $sid."x"; $sid = substr($sid,0,strlen($sid)-1); //print_r($info_optval1);
// if($custom_order=='1'){ $_SESSION['edit_start'] = null; $_SESSION['new_start'] = null; } ?> <script> // 일차를 파라메터로 받는다 function setDay(t){ var now = new Date; if ((now.getMonth()+1) < 10){ month = "0"+(now.getMonth()+1); }else{ month = (now.getMonth()+1); } if (now.getDate() < 10){ date = "0"+now.getDate(); }else{ date = now.getDate(); } var today = now.getFullYear() + "-" + month + "-" + date; // 현재날짜 document.searchFrm.txtdate2.value = today; document.searchFrm.txtdate.value = getThatday(today,t); // 현재날짜와 일차를 파라미터로 보내서 결과리턴한다. }
//날짜, 일차를 파라메터로 받는다. function getThatday(today, t){ var pdate=new Array(); var pday=today.split("-"); // 날짜를 구분자로 나누어 배열로 변환한다. var ptoday=new Date(pday[0],pday[1]-1,pday[2]); // 데이트객체 생성한다. var ptimestamp=ptoday.valueOf()+1000*60*60*24*t; // t일후의 타임스탬프를 얻는다. 음수라면 이전날짜를 얻는다. var thatday=new Date(ptimestamp); // t일후의 날짜객체 생성한다. pdate[pdate.length]=thatday.getFullYear(); // 년 if (thatday.getMonth()+1 < 10){ pdate[pdate.length]="0"+(thatday.getMonth()+1); // 월 }else{ pdate[pdate.length]=thatday.getMonth()+1; // 월 } if (thatday.getDate() < 10){ pdate[pdate.length]="0"+thatday.getDate(); // 일 }else{ pdate[pdate.length]=thatday.getDate(); // 일 }
return pdate.join("-"); // 배열을 / 구분자로 합쳐 스트링으로 변환후 반환 }
// 검색 function Search(){ searchFrm.submit(); } </script> <form name='searchFrm' id="searchFrm" method="post"> <!--<input type='hidden' id='txtdate' name='txtdate'value='<?=$txtdate?>'> <input type='hidden' id='txtdate2' name='txtdate2'value='<?=$txtdate2?>'>-->
<div class="snb"> <!-- p class="txt">발주(구매) <span class="f11 blue">주문한 내역을 확인하실 수 있습니다.</span></p --> <p class="txt">발주(구매) <span class="f11 blue">수주처 : <?=$Cname?></span> <?if($_SESSION['sa_uid']=='hschina'){?> <span class="f11 blue" style='position:absolute;right:20px;top:90px;'> 발주처 : <?=$cuso['compname']?></span> <?} else{?> <span class="f11 blue"> / 발주처 : <?=$cuso['compname']?></span> <?}?> </p> </div>
<!--div class="save_top"> <h2 class="screen_out">발주(구매) 등록하기</h2> <p class="pr bt25"><a href="./buyWrite.php?detail=y&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>&new=y" onclick="">발주등록</a></p> 다시 사용시 basic.css 파일에서 ls_v3 top:192px; 로 수정 </div-->
<div class="buy_section"> <div class="search"> <h2>발주조회</h2> <div class="buy"> <select title="선택" id="tabMenu1" name="orderdate"> <option value='1' <? if($orderdate == '1'){ echo "selected"; } ?>>주문일자</option> <option value='2' <? if($orderdate == '2'){ echo "selected"; } ?>>납품일자</option> </select> </div>
<div class="buy"> <select title="선택" id="tabMenu2" name="orderstate"> <option value='1' <? if($orderstate == '1'){ echo "selected"; } ?>>전체</option> <option value='2' <? if($orderstate == '2'){ echo "selected"; } ?>>작성</option> <option value='3' <? if($orderstate == '3'){ echo "selected"; } ?>>신청</option> <option value='4' <? if($orderstate == '4'){ echo "selected"; } ?>>접수</option> <option value='5' <? if($orderstate == '5'){ echo "selected"; } ?>>배송</option> <option value='6' <? if($orderstate == '6'){ echo "selected"; } ?>>도착</option> </select> </div>
<div class="buy"> <select title="선택" id="duration" name="duration" onchange="setDay(this.value);"> <option value="0" <? if($duration == '0'){ echo "selected"; } ?>>오늘</option> <option value="-3" <? if($duration == '-3'){ echo "selected"; } ?>>최근 3일</option> <option value="-5" <? if($duration == '-5'){ echo "selected"; } ?>>최근 5일</option> <option value="-7" <? if($duration == '-7'){ echo "selected"; } ?>>최근 7일</option> <option value="-30" <? if($duration == '-30'){ echo "selected"; } ?>>최근 1개월</option> <option value="-90" <? if($duration == '-90'){ echo "selected"; } ?>>최근 3개월</option> <option value="-180" <? if($duration == '-180'){ echo "selected"; } ?>>최근 6개월</option> <option value="-365" <? if($duration == '-365'){ echo "selected"; } ?>>최근 1년</option> </select> </div> <div class='buy'> <input type='text' id='txtdate' name='txtdate' value='<?=$txtdate?>' class='it' placeholder='시작일(YYYY-MM-DD)'> </div> <div class='buy'> <input type='text' id='txtdate2' name='txtdate2' value='<?=$txtdate2?>' class='it' placeholder='시작일(YYYY-MM-DD)'> </div>
<span class="ls ls_v3"><input type="button" title="조회" value="조 회" class="btn_sl" onclick="Search();" ></span> </div><!-- class="search" --> <input type=hidden name='mode' value='search'> </form> <div class="list"> <h2>발주내역</h2> <table> <caption>발주(구매) 조회 내역입니다.</caption> <thead> <tr> <th class="time">주문일자</th> <!-- <th class="orderNum">주문번호</th> --> <th class="process">진행상태</th> <th class="delivery">납품예정일</th> <th class="case">건수</th> <th class="sum">금액</th> </tr> </thead>
<tbody> <? $no = 0 ; while ($orderRow = mysql_fetch_array($order_result)){ $irecved = $orderRow['ordstate']; $state_code = array(0, 1, 2, 3, 4); $state_txt = array("<font color='#ff0000'>작성", "<font color='green'>신청", "<font color='#0090bf'>접수", "<font color='#0e8a08'>배송", "<font color='#888888'>도착"); $irecved = str_replace($state_code, $state_txt, $orderRow['ordstate']); if($orderRow[0] == "1"){ //td rowspan용 숫자 구하기 $no = 0 ; } $ordtime = substr($orderRow['ordtime'],6,2).":".substr($orderRow['ordtime'],8,2); if($orderRow[0] == "0"){ $count = $orderRow['number']; $date = $orderRow['orddate']; } if($orderRow[0] == "1" && $orderRow['countdate'] == $count){ //일자별 금액과 일자별합계금액이 같으면 소계 안보이기 ?> <tr> <th colspan="5" bgcolor="#5076a9" style="height:3px;"></th> </tr> <? }else{ if($orderRow['orddate'] == $date){ $countdate = count($orderRow['orddate']); } if($orderRow[0] == "1"){ // 소계 나오는 부분 if($orderdate == "2"){ }else{ ?> <tr class="total"> <td class="time"></td> <!-- <td class="orderNum"></td> --> <td class="process">일계</td> <td class="delivery"></td> <td class="case"><?=$orderRow['number'];?></td> <td class="sum blue"><?=number_format($orderRow['sumtotal']);?></td> </tr> <? } }else{ ?> <?if($custom_order=='1'){?> <tr onclick="location.href='buyWrite_new2.php?uid=<?=$orderRow['ordno']?>&detail=y&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>'"> <?} else if($sid == "ggrbook" || $sid == "gyu1001" || $info_optval1[0]=='1'){?> <tr onclick="location.href='buyWrite_order.php?search_view=Y&mode=prod&orderdate=1&orderstate=&set_date=0+day&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>&uid=<?=$orderRow['ordno']?>&detail=y&new='"> <?}else{?> <tr onclick="location.href='buyWrite.php?uid=<?=$orderRow['ordno']?>&detail=y&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>'"> <?}?> <td class="time"><?=$orderRow['orddate']?><br /><?=$ordtime;?></td> <!-- <td class="orderNum"><?=$orderRow['ordno']?></td> --> <td class="process"><span class="gray"><?=$irecved?></span></td> <td class="delivery"><?=$orderRow['deldate']?></td> <td class="case"><?=$orderRow['number']?></td> <td class="sum blue"><?=number_format($orderRow['sumtotal']);?></td> </tr> <? } } } ?> </tbody> </table> </div>
</div><!-- id="list" -->
<? include("./footer.php"); ?>
|