-
Notifications
You must be signed in to change notification settings - Fork 0
/
HNfind.php
401 lines (369 loc) · 13.1 KB
/
HNfind.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="w3.css">
<link rel="stylesheet" type="text/css" href="source/progress_bar.css">
<link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
function che(pre_id){
var test = confirm("คุณกำลังไปหน้าเช็คสถานะใบยาของใบยาหมายเลข"+pre_id);
if(test){
window.open('check_report.php?pre_id='+pre_id,'_self');
}
}
</script>
</HEAD>
<BODY>
<?php
?>
<div class="w3-row-padding w3-section w3-container">
<div class="w3-row w3-border-bottom">
<div class="w3-center w3-center w3-xxlarge">
<i class="fa fa-clone" aria-hidden="true"></i> ใบยาในระบบ
</div>
<div class="w3-third">
</div>
</div>
<?php
require("connection.php");
error_reporting(0);
$total=0;
//$d=strtotime("-8 hours");
//$ref=date("Y-m-d H:i:s",$d);
date_default_timezone_set("Etc/GMT-7");
if(!isset($_GET['c_date'])) $_GET['c_date']= date("Y-m-d");
$c_date=$_GET['c_date'];
if(!isset($_GET['c_id']))$_GET['c_id']='';
$c_id=$_GET['c_id'];
$query ="SELECT * from status ";
$result=odbc_exec($db,$query);
while($list=odbc_fetch_array($result)){
$temps=$list['s_id'];
$s_name = iconv("TIS-620", "UTF-8", $list['s_name']);
$temps2='1';
$temps3='1';
$temps4='1';
if($temps<16&&$temps>9||$temps==102||$temps==30||$temps==31||$temp==103){ //103 คือจัดยาวันอื่นเ เพิ่งเพิ่มมานะ
if($temps==10){
$temps2=20;
}
if($temps==11){
$temps2=21;
}
if($temps==14){
$temps2=22;
}
if($temps==15){
$temps2=23;
$temps3=32;
$temps4=40;
}
if($temps==102){
$temps2=202;
$temps3=302;
$temps4=402;
}
$query2 = "SELECT count(s_id) AS count
FROM prescription
where (s_id=$temps
or s_id=$temps2
or s_id=$temps3
or s_id=$temps4)
AND in_datetime > '$c_date'
AND in_datetime <= dateadd(day, 1, '$c_date')
AND c_id=$c_id";
$result2=odbc_exec($db,$query2);
if($list=odbc_fetch_array($result2)){
$count=$list['count'];
$total=$total+$count;
}
if($temps==14)$s_name='รอหยิบยาสำเร็จรูป';
if($temps==30)$s_name='รอหยิบยาKeli';
if($temps==31)$s_name='จัดยาKeli';
/*
echo "<TR>
<TD>$s_name</TD>
<TD>$count</TD>
</TR>";
*/
}
}
/*
echo "<TR>
<TD>รวม</TD>
<TD>$total</TD>
</TR>";
*/
if(!isset($_GET['s_id']))$_GET['s_id']=1000;
$s_id=$_GET['s_id'];
?>
</table>
</div>
<div class="w3-container w3-rest w3-margin-bottom">
<div class="w3-container w3-center w3-card-2 w3-section">
<form method=get name=f1 action='HNfind.php'>
<?php
$s_id='1000';
//ทำ drop down
$query = " SELECT * from status " ;
$result=odbc_exec($db,$query);
while($list=odbc_fetch_array($result))
{
$temp = iconv("TIS-620", "UTF-8", $list['s_id']);
$tempn = iconv("TIS-620", "UTF-8", $list['s_name']);
if($temp==14)$tempn='รอหยิบยาสำเร็จรูป';
if($temp==30)$tempn='รอหยิบยาKeli';
if($temp==31)$tempn='จัดยาKeli';
//ตั้งแต่ 10 - 16 เอามาแสดง
if($temp<17&&$temp>9||$temp==101||$temp==102||$temp==30||$temp==31||$temp==103){
//echo "<option value='$temp'>$tempn</option>";
}
}
?>
</select>
<div class="w3-center w3-center w3-xlarge">
<i class="fa fa-calendar" aria-hidden="true"></i> เลือกวันที่
</div>
<input class="w3-input w3-large w3-border w3-margin-top w3-margin-bottom" type="date" name="c_date" required value=<?php echo date("Y-m-d"); ?> style="margin: auto; max-width: 400px;" >
<input class="w3-btn w3-blue" type="submit" value="ตกลง">
</form>
</div>
<div class="w3-container w3-card-2 w3-margin-bottom">
<div class="w3-container">
<h2>รายละเอียดของแต่ละใบยา</h2>
</div>
<table class="w3-table-all w3-margin-bottom">
<TR>
<Th>เวลา</Th>
<Th>ใบยา</Th>
<Th>คิว</Th>
<Th>สถานะ</Th>
<Th>HN</Th>
<Th>คนไข้</Th>
<!-- <Th>Operator ID</Th> -->
<!-- <Th>Check</Th> -->
</TR>
<?php
if($s_id==1000){
$query ="SELECT *
from Prescription
where s_id!=16
and s_id!=24
and s_id!=33
and s_id!=41
and s_id!=101
and s_id!=201
and s_id!=301
and s_id!=401
AND in_datetime > '$c_date'
AND in_datetime <= dateadd(day, 1, '$c_date')
AND c_id=$c_id
ORDER BY in_datetime ASC";
$result=odbc_exec($db,$query);
if(!$list=odbc_fetch_array($result)){
echo '
<div class="w3-panel w3-orange">
<span onclick="this.parentElement.style.display=\'none\'" class="w3-closebtn">×</span>
<h3>ไม่พบใบยาในระบบ!</h3>
<p>โปรดลองใหม่อีกครั้งหนึ่ง</p>
</div>';
}
$result=odbc_exec($db,$query);
while($list=odbc_fetch_array($result)){
$pre_id=$list['pre_id'];
$date=$list['in_datetime'];
$temps=$list['s_id'];
$q_id=$list['q_id'];
$c_id=$list['c_id'];
$query2 ="SELECT * from status where s_id=$temps ";
$result2=odbc_exec($db,$query2);
if($list2=odbc_fetch_array($result2)){
$t_id=$list2['t_id'];
$s_name = iconv("TIS-620", "UTF-8", $list2['s_name']);
}
$query2 ="SELECT * from type where t_id=$t_id ";
$result2=odbc_exec($db,$query2);
if($list2=odbc_fetch_array($result2)){
$t_name = iconv("TIS-620", "UTF-8", $list2['t_name']);
}
$query2 ="SELECT * from queue where q_id=$q_id ";
$result2=odbc_exec($db,$query2);
if($list2=odbc_fetch_array($result2)){
$q_name = iconv("TIS-620", "UTF-8", $list2['q_name']);
}
$query2 ="SELECT c_name from get_cusinfo where HN='$c_id'";
$result2=odbc_exec($db2,$query2);
if($list2=odbc_fetch_array($result2)){
$c_name = iconv("TIS-620", "UTF-8", $list2['c_name']);
}
$query2 ="SELECT * from oprel where pre_id=$pre_id and s_id=$temps";
$result2=odbc_exec($db,$query2);
if($list2=odbc_fetch_array($result2)){
$o_id=$list2['o_id'];
$op_time=$list2['op_time'];
$query2 ="SELECT * from operator where o_id='$o_id' ";
$result2=odbc_exec($db,$query2);
if($list2=odbc_fetch_array($result2)){
$o_name = iconv("TIS-620", "UTF-8", $list2['o_name']);
}
echo "<TR>
<TD>".date("H:i", strtotime($date))."</TD>
<TD><a href='../check_status/check_status.php?c_date=$c_date&q_name=$q_name'>$pre_id</a></TD>
<TD>$q_name</TD>
<TD>$s_name</TD>
<TD>$c_id</TD>
<TD>$c_name</TD>
</TR>";
}
else echo "<TR>
<TD>".date("H:i", strtotime($date))."</TD>
<TD><a href='../check_status/check_status.php?c_date=$c_date&q_name=$q_name'>$pre_id</a></TD>
<TD>$q_name</TD>
<TD>$s_name</TD>
<TD>$c_id</TD>
<TD>$c_name</TD>
</TR>";
$op_time='';
$o_id='';
$o_name='';
$c_name='';
$q_name='';
$t_name='';
}
}else{
$temps2='1';
$temps3='1';
$temps4='1';
if($s_id==10){
$temps2=20;
}
if($s_id==11){
$temps2=21;
}
if($s_id==14){
$temps2=22;
}
if($s_id==15){
$temps2=23;
$temps3=32;
$temps4=40;
}
if($s_id==16){
$temps2=24;
$temps3=33;
$temps4=41;
}
if($s_id==101){
$temps2=201;
$temps3=301;
$temps4=401;
}
if($s_id==102){
$temps2=202;
$temps3=302;
$temps4=402;
}
$query ="SELECT * from Prescription
where (s_id=$s_id or s_id=$temps2
or s_id=$temps3
or s_id=$temps4)
AND in_datetime > '$c_date'
AND in_datetime <= dateadd(day, 1, '$c_date')
AND c_id=$c_id
ORDER BY in_datetime ASC ";
$result=odbc_exec($db,$query);
if(!$list=odbc_fetch_array($result)){
echo '
<div class="w3-panel w3-orange">
<span onclick="this.parentElement.style.display=\'none\'" class="w3-closebtn">×</span>
<h3>ไม่พบใบยาในระบบ!</h3>
<p>โปรดลองใหม่อีกครั้งหนึ่ง</p>
</div>';
}
$result=odbc_exec($db,$query);
while($list=odbc_fetch_array($result)){
$pre_id=$list['pre_id'];
$temps=$list['s_id'];
$date=$list['in_datetime'];
$q_id=$list['q_id'];
$c_id=$list['c_id'];
$query2 ="SELECT * from status where s_id=$temps ";
$result2=odbc_exec($db,$query2);
if($list=odbc_fetch_array($result2)){
$t_id=$list['t_id'];
$s_name = iconv("TIS-620", "UTF-8", $list['s_name']);
}
$query2 ="SELECT * from type where t_id=$t_id ";
$result2=odbc_exec($db,$query2);
if($list=odbc_fetch_array($result2)){
$t_name = iconv("TIS-620", "UTF-8", $list['t_name']);
}
$query2 ="SELECT * from queue where q_id=$q_id ";
$result2=odbc_exec($db,$query2);
if($list=odbc_fetch_array($result2)){
$q_name = iconv("TIS-620", "UTF-8", $list['q_name']);
}
$query2 ="SELECT c_name from get_cusinfo where HN='$c_id'";
$result2=odbc_exec($db2,$query2);
if($list2=odbc_fetch_array($result2)){
$c_name = iconv("TIS-620", "UTF-8", $list2['c_name']);
}
$query2 ="SELECT * from oprel where pre_id=$pre_id and s_id=$temps ";
$result2=odbc_exec($db,$query2);
if($list=odbc_fetch_array($result2)){
$o_id=$list['o_id'];
$op_time=$list['op_time'];
$query2 ="SELECT * from operator where o_id='$o_id '";
$result2=odbc_exec($db,$query2);
if($list=odbc_fetch_array($result2)){
$o_name = iconv("TIS-620", "UTF-8", $list['o_name']);
}
echo "<TR>
<TD>".date("H:i", strtotime($date))."</TD>
<TD><a href='../check_status/check_status.php?c_date=$c_date&q_name=$q_name'>$pre_id</a></TD>
<TD>$q_name</TD>
<TD>$s_name</TD>
<TD>$c_id</TD>
<TD>$c_name</TD>
</TR>";
}
else echo "<TR>
<TD>".date("H:i", strtotime($date))."</TD>
<TD><a href='../check_status/check_status.php?c_date=$c_date&q_name=$q_name'>$pre_id</a></TD>
<TD>$q_name</TD>
<TD>$s_name</TD>
<TD>$c_id</TD>
<TD>$c_name</TD>
</TR>";
$op_time='';
$o_id='';
$o_name='';
$c_name='';
$q_name='';
$t_name='';
}
}
?>
</table>
</div>
</div>
</div>
<footer class="w3-center w3-section w3-small">
<hr>
*แผนกห้องยาเปิดบริการเวลา 8:00 น. ถึง 16.00 น.
<br>
ติดต่อสอบถามเพิ่มเติมได้ที่ 02-222-1828 ต่อ 163
<br>
*Dispensary service operates from 8:00 am to 4.00 pm.
<br>
For more information please contact 02-222-1828, internal number: 163
</footer>
</BODY>
</HTML>