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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
|
<? session_start(); include_once("../_common.php"); if(( $id == "" ) && ( $sid == "" )) { ?> <script> alert("천년스마트발주 로그인 후에 이용가능합니다."); parent.location.href = "../index.php"; </script> <? } include("../commonST.php");
$charSet_sql = "set names utf8"; mysql_query($charSet_sql);
$optionqry = "SELECT optname, optvalue FROM options"; $optresult = mysql_query($optionqry); while( $optrow = mysql_fetch_array($optresult)){ //$optrow['optname'] = iconv_utf8($optrow['optname']); if($optrow['optname'] == "온주마감기능") $opt_ord_yn = $optrow['optvalue']; if($optrow['optname'] == "온주마감시간") $opt_ord_endtime = $optrow['optvalue']; }
if($opt_ord_yn != "" && $opt_ord_yn == "5189") { if($opt_ord_endtime!='00:00~00:00'){ $end_flag = 0; $v = explode("~",$opt_ord_endtime); $stime = trim($v[0]); $etime = trim($v[1]); $ctime = date("H:i"); if($etime>$stime){ if($stime<=$ctime && $ctime<=$etime){ $end_flag = 1; } } else { if(($stime<=$ctime && $ctime<='23:59') || ($etime>=$ctime && $ctime>='00:00')){ $end_flag = 1; } }
if($end_flag==1){ ?> <script> alert("온라인 주문서시간이 마감되었습니다."); parent.location.reload(); </script> <?php exit; } }
}
function table_field_ck($table, $field){ //특정 테이블에 필드가 있는지 체크
$sql = "show columns from {$table} like '{$field}';"; $res = mysql_query($sql); while($info=mysql_fetch_array($res)){ return 1; } return 0; }
// 특정업체의 상품명에 의해서 sb_log_write(가 에러나서 정상적으로 동작안하는 경우가 발생해서 특정업체일경우 sb_log_write( 제외함 if($sid=='siryu2010'){ $log_enabled = "N"; } else { $log_enabled = "Y"; }
if($log_enabled=="Y"){ sb_log_write($_POST, "", ""); // post값 로그 }
if($_SERVER['REMOTE_ADDR']=='58.151.27.172'){ //print_r($_POST); exit; }
if($sid=='king'){ //print_r($_POST); exit; }
$dbv = '9999999'; $dbname = explode("_",$sa_dbname); if($dbname[0]=='jegocs'){ $dbv = '126'; } else if($dbname[0]=='makeprocs'){ $dbv = '57'; }
$sql = "select * from dbversion"; $res = mysql_query($sql); $dbver_info = mysql_fetch_array($res); //print_r($dbver_info); if($dbver_info['ver']>=$dbv){ // 천년 126버젼이상일경우 lastmodify 필드 추가 작업 $add_sql1 = ", lastmodify"; $add_sql2 = ", '".date("Y-m-d H:i:s",time())."'"; $add_sql3 = ", lastmodify = '".date("Y-m-d H:i:s",time())."'"; }
// 온라인 주문 배송 정보 사용에 다른 옵션 가져오기 $sql = "select optvalue from options where optname = '온주배송정보사용' "; //echo $sql; $res_optval1 = mysql_query($sql); $info_optval1 = mysql_fetch_array($res_optval1); $sid = $sid."x"; $sid = substr($sid,0,strlen($sid)-1); if(!isset($_POST['referPath'])) $_POST['referPath'] = ""; if($_POST['referPath'] == ""){ $referPath = "N"; }else{ $referPath = "Y"; }
// form submit 하기 전 bigo를 비워준다. if($bigo == "80자 이내로 입력하세요."){ $bigo = ""; } // form submit 하기 전 shop_memo를 비워준다. if($shop_memo == "80자 이내로 입력하세요."){ $shop_memo = ""; }
$qry = "SELECT * FROM customer WHERE loginid = '{$id}'"; $result = mysql_query($qry) or die (mysql_error()); if( mysql_num_rows($result) > 0){ $row = mysql_fetch_array($result); // mysql_close();
// 담당자 정보 가져옴 $sql = "select code, name from local_user where code = '{$row['charge']}'"; $res = mysql_query($sql); $lu_info = mysql_fetch_array($res); $lu_code = $lu_info['code'];
$salestop = $row['salestop']; $salestopbigo = $row['stopsalebigo'];
} if(!isset($_GET['state_update'])){ $_GET['state_update'] = ""; } // shop_phone02, shop_memo, shop_receiver_uname, shop_receiver_zipcode, shop_receiver_address, shop_receiver_phone01, shop_receiver_phone02 if( $salestop == "1"){ //거래중지인 경우 ?> <script> <?if($_GET['state_update'] != "Y" && $referPath != "Y"){?> parent.alert('귀사에 대한 온라인 주문이\n허용되지 않아 주문 할 수 없습니다.\n중지사유: <?=$salestopbigo;?> '); parent.location.href="../buy.php"; <?}else if($referPath == "Y"){?> parent.parent.alert('귀사에 대한 온라인 주문이\n허용되지 않아 주문 할 수 없습니다.\n중지사유: <?=$salestopbigo;?> '); parent.parent.location.href="../buy.php"; <?}else{?> parent.state_save('../../onlinecs/mobile/process/ordstateProcess.php?state=1&uid=<?=$uid?>&dateop=<?=$optregdate?>&ordtime=<?=date("ymdHis")?>&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>', 'rfrm'); <?}?> </script> <? } else { if($new == "y"){ //신규주문
if($optregdate == "1"){ $tiqry = "INSERT INTO ordbook_m ( part, route, ordstate, ocode, ccode, orddate, deldate, bigo, shop_phone02, shop_memo, shop_receiver_uname, shop_receiver_zipcode, shop_receiver_address, shop_receiver_phone01, shop_receiver_phone02,ucode) VALUE ( '1', '1', '0', '$ocode', '$ccode', '$orddate', '$deldate', '$bigo', '$shop_phone02', '$shop_memo', '$shop_receiver_uname', '$shop_receiver_zipcode', '$shop_receiver_address_', '$shop_receiver_phone01', '$shop_receiver_phone02','$lu_code')";
} else { $tiqry = "INSERT INTO ordbook_m ( part, route, ordstate, ocode, ccode, orddate, deldate, ordtime, bigo, shop_phone02, shop_memo, shop_receiver_uname, shop_receiver_zipcode, shop_receiver_address, shop_receiver_phone01, shop_receiver_phone02,ucode) VALUE ( '1', '1', '0', '$ocode', '$ccode', '$orddate', '$deldate', '$time', '$bigo', '$shop_phone02', '$shop_memo', '$shop_receiver_uname', '$shop_receiver_zipcode', '$shop_receiver_address_', '$shop_receiver_phone01', '$shop_receiver_phone02','$lu_code')"; } if($log_enabled=="Y"){ sb_log_write("", $tiqry, ""); // sql 로그 } mysql_query($tiqry);
/* echo $tiqry; $mqry = "SELECT max(ordno) AS maxordno FROM ordbook_m"; $mresult = mysql_query($mqry); $mrow = mysql_fetch_array($mresult); $maxordno = $mrow[maxordno]; echo ($maxordno); */ $maxordno = mysql_insert_id();
if($custom_order=='1'){ $c_pname[] = ""; }
for($i=0;$i< count( $c_pname ) -1 ;$i++) { $newseq = $_REQUEST['newnum'][$i]; //DB상품번호 $pcode = $_REQUEST['c_code'][$i]; //상품코드 $pname = $_REQUEST['c_pname'][$i]; //상품명 $pname = addslashes($pname); $pnorm = $_REQUEST['c_pnorm'][$i]; //규격 $pnorm = addslashes($pnorm); $ordqnt = $_REQUEST['c_ordqnt'][$i]; //수량 $price = $_REQUEST['c_price2'][$i]; //단가 $money = $_REQUEST['c_money2'][$i]; //금액 $bigo = $_REQUEST['c_bigo'][$i]; //비고
$add_where = ""; $add_sql11 = ""; $add_sql22 = ""; $add_sql33 = ""; if($sid=='smg1' || $sid=='dadam'){ $add_sql11 = ", shipping_gubun, nursery_code"; $add_sql22 = ", 0, 0"; $add_sql33 = ", shipping_gubun = 0, nursery_code = 0 "; foreach($_REQUEST['c_shipping_gubun'] as $k=>$v){ if($v==$i){ $add_sql11 = ", shipping_gubun, nursery_code"; $add_sql22 = ", 1, '{$_REQUEST['c_nursery_code'][$i]}'"; $add_sql33 = " , shipping_gubun = 1, nursery_code = '{$_REQUEST['c_nursery_code'][$i]}' "; } } }
if(table_field_ck("ordbook_d", "parentseq")){ $ps_add1 = ", parentseq "; $ps_add2 = ", $newseq "; } else { $ps_add1 = ""; $ps_add2 = ""; }
if($_SESSION['sa_type'] == 9){ //3천년경영 9제조경영은 자동증가값이므로 Insert 안함 $niqry = "INSERT INTO ordbook_d (pname, pcode, pnorm , ordqnt, price, bigo, ordno {$add_sql1} {$add_sql11}) VALUES ( '$pname', '$pcode', '$pnorm', '$ordqnt', '$price', '$bigo', '$maxordno' {$add_sql2} {$add_sql22})"; } else { $niqry = "INSERT INTO ordbook_d (pname, pcode, pnorm , ordqnt, price, bigo, ordno, seq {$add_sql1} {$add_sql11} {$ps_add1}) VALUES ( '$pname', '$pcode', '$pnorm', '$ordqnt', '$price', '$bigo', '$maxordno', '$newseq' {$add_sql2} {$add_sql22} {$ps_add2})"; } if($log_enabled=="Y"){ sb_log_write("", $niqry, ""); // sql 로그 }
mysql_query($niqry); $newseq++; //echo ($niqry); //echo ($maxordno); }
//sb_log_write("", "", $maxordno); // midx 로그
if($custom_order=='1'){ $add_para = "&mode=prod"; // 대성활어일경우 해당 변수 붙힘 $_SESSION['new_start'] = null; // 관련 세션 초기화 $_SESSION['end_save'] = "Y"; // 저장 중복 안되게 키값 처리 }
?> <script language="javascript"> <?php if($custom_order=='1'){ ?> alert('발주 되었습니다.'); url = "../buy.php"; location.replace(url); <? } else if($_GET['state_update'] != "Y" && $referPath != "Y"){?> parent.alert('발주 되었습니다.'); //parent.location.href = "../buyWrite.php?uid=<?=$maxordno?>&detail=y&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>"; //부모창 새로고침 <? // 개구리서적 주문개발 처리 if($sid == "ggrbook" || $sid == "gyu1001" || $sid == "steelhun" || $sid == "hschina" || $info_optval1['optvalue']=='1'){ ?> url = "../buyWrite_order.php?uid=<?=$maxordno?>&detail=y&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>"; <?}else{?> url = "../buyWrite.php?uid=<?=$maxordno?>&detail=y&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>"; <?}?> parent.location.replace(url); <?}else if($referPath == "Y"){?> parent.parent.alert('발주 되었습니다.'); <? // 개구리서적 주문개발 처리 if($sid == "ggrbook" || $sid == "gyu1001" || $sid == "steelhun" || $sid == "hschina" || $info_optval1['optvalue']=='1'){ ?> url = "../buyWrite_order.php?uid=<?=$maxordno?>&detail=y&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>"; <?}else{?> url = "../buyWrite.php?uid=<?=$maxordno?>&detail=y&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>"; <?}?> parent.parent.location.replace(url); //parent.parent.location.href = "../buyWrite.php?uid=<?=$maxordno?>&detail=y&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>"; //부모창 새로고침 <?}else{?> parent.state_save('../../onlinecs/mobile/process/ordstateProcess.php?state=1&uid=<?=$maxordno?>&dateop=<?=$optregdate?>&ordtime=<?=date("ymdHis")?>&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>', 'rfrm'); <?}?> </script> <? }else{ if($sid=='ryunen'){ //print_r($_POST); exit; } $view_result = array(); $view_sql = "SELECT * FROM ordbook_m WHERE ordno = '{$uid}'"; if(false !== $res = @mysql_query($view_sql)){ while($row = @mysql_fetch_assoc($res)) array_push($view_result, $row); } if($shop_receiver_uname == "") $shop_receiver_uname = $view_result[0]['shop_receiver_uname']; if($shop_receiver_phone01 == "") $shop_receiver_phone01 = $view_result[0]['shop_receiver_phone01']; if($shop_receiver_phone02 == "") $shop_receiver_phone02 = $view_result[0]['shop_receiver_phone02']; if($shop_receiver_zipcode == "") $shop_receiver_zipcode = $view_result[0]['shop_receiver_zipcode']; if($shop_receiver_address_ == "") $shop_receiver_address_ = $view_result[0]['shop_receiver_address']; if($shop_memo == "") $shop_memo = $view_result[0]['shop_memo'];
if($view_result[0]['ordstate']>='2'){ // 스마트발주에서 추가발주 열어놓은 상태에서 천년에서 완납한경우 추가발주 불가능하게 처리 ?> <script> parent.alert('이미 완납된 주문은 추가발주가 불가합니다.'); </script> <?php exit; }
//상단 주문일자,납품예정,메모 업데이트 //$tqry = "UPDATE ordbook_m SET orddate = '{$orddate}', deldate = '{$deldate}', bigo = '{$bigo}', shop_phone02 = '{$shop_phone02}', shop_memo = '{$shop_memo}', shop_receiver_uname = '{$shop_receiver_uname}', shop_receiver_zipcode = '{$shop_receiver_zipcode}', shop_receiver_address = '{$shop_receiver_address_}', shop_receiver_phone01 = '{$shop_receiver_phone01}', shop_receiver_phone02 = '{$shop_receiver_phone02}' WHERE ordno = '{$uid}' "; $tqry = "UPDATE ordbook_m SET orddate = '{$orddate}', deldate = '{$deldate}', bigo = '{$bigo}', shop_memo = '{$shop_memo}', shop_receiver_uname = '{$shop_receiver_uname}', shop_receiver_zipcode = '{$shop_receiver_zipcode}', shop_receiver_address = '{$shop_receiver_address_}', shop_receiver_phone01 = '{$shop_receiver_phone01}', shop_receiver_phone02 = '{$shop_receiver_phone02}', ucode = '{$lu_code}' WHERE ordno = '{$uid}' ";
if($log_enabled=="Y"){ sb_log_write("", $tqry, ""); // sql 로그 }
if($custom_order=='1'){ $c_pname[] = ""; }
mysql_query($tqry); //echo $tqry; //echo count( $tablecount);
if($custom_order=='1'){ $sql = "delete from ordbook_d where ordno = '{$uid}' "; mysql_query($sql); $newseq = 1; }
for($i=0;$i< count( $c_pname ) -1 ;$i++){ $seq = $_REQUEST['c_seq'][$i]; //DB상품번호 $pcode = $_REQUEST['c_code'][$i]; //상품코드 $pname = $_REQUEST['c_pname'][$i]; //상품명 $pname = addslashes($pname); $pnorm = $_REQUEST['c_pnorm'][$i]; //규격 $pnorm = addslashes($pnorm); $ordqnt = $_REQUEST['c_ordqnt'][$i]; //수량 $price = $_REQUEST['c_price2'][$i]; //단가 $money = $_REQUEST['c_money2'][$i]; //금액 $bigo = $_REQUEST['c_bigo'][$i]; //비고
//echo ($i); //echo ($_REQUEST['c_seq'][0]);
$add_where = ""; $add_sql11 = ""; $add_sql22 = ""; $add_sql33 = ""; if($sid=='smg1' || $sid=='dadam'){ $add_sql11 = ", shipping_gubun, nursery_code"; $add_sql22 = ", 0, 0"; $add_sql33 = ", shipping_gubun = 0, nursery_code = 0 "; foreach($_REQUEST['c_shipping_gubun'] as $k=>$v){ if($v==$i){ $add_sql11 = ", shipping_gubun, nursery_code"; $add_sql22 = ", 1, '{$_REQUEST['c_nursery_code'][$i]}'"; $add_sql33 = " , shipping_gubun = 1, nursery_code = '{$_REQUEST['c_nursery_code'][$i]}' "; } } }
if(table_field_ck("ordbook_d", "parentseq")){ $ps_add1 = ", parentseq "; $ps_add2 = ", $newseq "; } else { $ps_add1 = ""; $ps_add2 = ""; }
if($custom_order=='1'){
if($_SESSION['sa_type'] == 9){ //3천년경영 9제조경영은 자동증가값이므로 Insert 안함 $iqry = "INSERT INTO ordbook_d (pname, pcode, pnorm , ordqnt, price, bigo, ordno {$add_sql1} {$add_sql11}) VALUES ( '{$pname}', '{$pcode}', '{$pnorm}', '{$ordqnt}', '{$price}', '{$bigo}', '{$uid}' {$add_sql2} {$add_sql22})"; }else{ $iqry = "INSERT INTO ordbook_d (pname, pcode, pnorm , ordqnt, price, bigo, ordno, seq {$add_sql1} {$add_sql11} {$ps_add1}) VALUES ( '{$pname}', '{$pcode}', '{$pnorm}', '{$ordqnt}', '{$price}', '{$bigo}', '{$uid}', '{$newseq}' {$add_sql2} {$add_sql22} {$ps_add2})"; } if($log_enabled=="Y"){ sb_log_write("", $iqry, ""); // sql 로그 }
mysql_query($iqry); $newseq++; } else {
if(!($_REQUEST['c_seq'][$i] == '')){ //기존자료일 경우 update
if(table_field_ck("ordbook_d", "parentseq")){ $ps_add = ", parentseq = '{$seq}' "; } else { $ps_add = ""; }
//echo($pname.'<br>'); $sql = "select * from ordbook_m where ordno = '{$uid}' "; $res = mysql_query($sql); $info = mysql_fetch_array($res); if($info['ordstate']<'2'){ $uqry = "UPDATE ordbook_d SET pname = '{$pname}', pcode = '{$pcode}', pnorm = '{$pnorm}', ordqnt = '{$ordqnt}', price = '{$price}', bigo = '{$bigo}' {$add_sql3} {$add_sql33} {$ps_add} WHERE ordno = '{$uid}' AND seq = '{$seq}'";
if($log_enabled=="Y"){ sb_log_write("", $uqry, ""); // sql 로그 }
mysql_query($uqry); } //echo($uqry.' update<br>'); $newseq = $_REQUEST['c_seq'][$i]+1; }else if( $_REQUEST['c_seq'][$i] == ''){ //신규자료일 경우 insert if(! $pcode == ''){ if($_SESSION['sa_type'] == 9){ //3천년경영 9제조경영은 자동증가값이므로 Insert 안함 $iqry = "INSERT INTO ordbook_d (pname, pcode, pnorm , ordqnt, price, bigo, ordno {$add_sql1} {$add_sql11}) VALUES ( '{$pname}', '{$pcode}', '{$pnorm}', '{$ordqnt}', '{$price}', '{$bigo}', '{$uid}' {$add_sql2} {$add_sql22})"; }else{ $iqry = "INSERT INTO ordbook_d (pname, pcode, pnorm , ordqnt, price, bigo, ordno, seq {$add_sql1} {$add_sql11} {$ps_add1}) VALUES ( '{$pname}', '{$pcode}', '{$pnorm}', '{$ordqnt}', '{$price}', '{$bigo}', '{$uid}', '{$newseq}' {$add_sql2} {$add_sql22} {$ps_add2})"; } if($log_enabled=="Y"){ sb_log_write("", $iqry, ""); // sql 로그 }
mysql_query($iqry); $newseq++; } //echo($iqry.' insert<br>'); } }
//sb_log_write("", "", $uid); // midx 로그 } if($sid=='ryunen'){ //print_r($_POST); exit; }
if($custom_order=='1'){ $add_para = "&mode=prod"; // 대성활어일경우 해당 변수 붙힘 $_SESSION['edit_start'] = null; // 관련 세션 초기화 }
?> <script> <?php if($custom_order=='1'){ ?> alert('발주 수정 되었습니다.'); url = "../buy.php"; location.replace(url); <?} else if($_GET['state_update'] != "Y" && $referPath != "Y"){ if($sid == "ggrbook" || $sid == "gyu1001" || $sid == "steelhun" || $sid == "hschina" || $info_optval1['optvalue']=='1'){ ?> parent.alert('발주 되었습니다.1'); parent.parent.location.replace("../buyWrite_order.php?uid=<?=$uid?>&detail=y&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>"); <? }else{ ?> parent.alert('발주 되었습니다.'); parent.location.reload(); <?}?> <?}else if($referPath == "Y"){?> parent.parent.alert('발주 되었습니다.2'); <? // 개구리서적 주문개발 처리 if($sid == "ggrbook" || $sid == "gyu1001" || $sid == "steelhun" || $sid == "hschina" || $info_optval1['optvalue']=='1'){ ?> parent.parent.location.href = "../buyWrite_order.php?uid=<?=$uid?>&detail=y&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>"; //부모창 새로고침 <?}else{?> parent.parent.location.href = "../buyWrite.php?uid=<?=$uid?>&detail=y&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>"; //부모창 새로고침 <?}?> <?}else{?> parent.state_save('process/ordstateProcess.php?state=1&uid=<?=$uid?>&dateop=<?=$optregdate?>&ordtime=<?=date("ymdHis")?>&txtdate=<?=$txtdate?>&txtdate2=<?=$txtdate2?>', 'rfrm'); <?}?> </script> <? } } ?>
|