-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanage_barcoded_batch_of_XL_640.php
executable file
·160 lines (133 loc) · 3.82 KB
/
manage_barcoded_batch_of_XL_640.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
<?php
session_start();
echo '<html>';
echo '<head>';
echo '</head>';
echo '<body>';
//echo '<pre>';
//print_r($GLOBALS);
//echo '</pre>';
include 'common.php';
function send_whole_sample_to_XL_640($sample_id)
{
$link=start_nchsls();
$sql='select * from examination where sample_id=\''.$sample_id.'\'';
$result=mysql_query($sql,$link);
$sample_id_str='S|'.$sample_id;
$examinations='E|';
while($array_ex=mysql_fetch_assoc($result))
{
$examinations=$examinations.'^^^'.$array_ex['code'].'`';
}
$examinations=substr($examinations,0,-1);
error_reporting(E_ALL);
/* Get the port for the WWW service. */
$service_port = 12377;
/* Get the IP address for the target host. */
$address = '127.0.0.1';
/* Create a TCP/IP socket. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
} else {
//echo "OK.\n";
}
//echo "Attempting to connect to '$address' on port '$service_port'...";
$sock = socket_connect($socket, $address, $service_port);
if ($sock === false) {
echo "socket_connect() failed.\nReason: ($socket) " . socket_strerror(socket_last_error($socket)) . "\n";
} else {
//echo "OK Success!!!!!!!!!.\n";
}
/////////////////
socket_write($socket, chr(5), 1);
$bytee=socket_read($socket,1);
if($bytee==chr(6))
{
//with fake chksum
$to_send=chr(2).'1H||||||||||||NCHSLS'.chr(13).$sample_id_str.chr(13).$examinations.chr(13).chr(3)."XX".chr(13).chr(10);
socket_write($socket,$to_send,strlen($to_send));
/*
socket_write($socket, chr(2), 1);
$header_nch='1H||||||||||||NCHSLS';
socket_write($socket, $header_nch, strlen($header_nch));
socket_write($socket, chr(13), 1);
socket_write($socket,$sample_id_str , strlen($sample_id_str));
socket_write($socket, chr(13), 1);
socket_write($socket,$examinations , strlen($examinations));
socket_write($socket, chr(13), 1);
socket_write($socket, chr(3), 1);
socket_write($socket, chr(10), 1);*/
}
$bytee=socket_read($socket,1);
if($bytee==chr(6))
{
socket_write($socket, chr(4), 1);
}
////////////////////////////
//echo "Closing socket...";
socket_close($socket);
echo $sample_id.',';
//echo "OK.\n\n";
}
if(!login_varify())
{
exit();
}
main_menu();
echo '
<table>
<th colspan=3>Manage Barcoded Batch for XL-640</th>
<form method=post action=manage_barcoded_batch_of_XL_640.php>
<tr>
<td><input type=submit value=clear_batch name=submit ></td>
<td><input type=submit name=submit value=refresh></td>
<td><input type=submit name=submit value=send_batch></td></tr>
</form>
</table>
';
$link=start_nchsls();
if(!isset($_POST['submit']))
{
echo '<br>current batch:(total=';
$sql='select * from inquiry';
$result=mysql_query($sql,$link);
echo mysql_num_rows($result).')';
while($array_res=mysql_fetch_assoc($result))
{
echo $array_res['sample_id'].',';
}
exit(0);
}
switch ($_POST['submit'])
{
case 'clear_batch':
$sql='delete from inquiry';
$result=mysql_query($sql,$link);
echo '<br>'.$sql.':: Query Result: number of records deleted:'.mysql_affected_rows($link);
break;
case 'refresh':
break;
case 'send_batch':
$counter=0;
echo '<br>batch sent:';
$sql='select * from inquiry';
$result=mysql_query($sql,$link);
while($array_inq=mysql_fetch_assoc($result))
{
send_whole_sample_to_XL_640($array_inq['sample_id']);
$counter++;
sleep(1);
}
echo '(total '.$counter.')';
break;
}
echo '<br>current batch:(total=';
$sql='select * from inquiry';
$result=mysql_query($sql,$link);
echo mysql_num_rows($result).')';
while($array_res=mysql_fetch_assoc($result))
{
echo $array_res['sample_id'].',';
}
?>