-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_si.php
158 lines (128 loc) · 2.89 KB
/
search_si.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
<?php
//$GLOBALS['nojunk']='';
require_once 'project_common.php';
require_once 'base/verify_login.php';
////////User code below/////////////////////
echo ' <link rel="stylesheet" href="project_common.css">
<script src="project_common.js"></script>';
$link=get_link($GLOBALS['main_user'],$GLOBALS['main_pass']);
main_menu($link);
echo '<h3>Search and display Sample IDs</h3>';
//echo '<pre>';print_r($GLOBALS);
//echo '</pre>';
echo '<div id=response></div>';
if($_POST['action']=='get_search_condition')
{
get_search_condition($link);
}
elseif($_POST['action']=='set_search')
{
set_search($link);
}
elseif($_POST['action']=='search_summary')
{
$search_array=prepare_search_array($link);
if(count($search_array)==0)
{
echo '<h3>No meaningful search conditions provided!!</h3>';
exit(0);
}
//echo '<pre>';
//print_r($_POST);
//print_r($search_array);
$from=' ';
$counter=0;
foreach ($search_array as $kd=>$vd)
{
$tn='r'.$counter;
$from=$from.' result '.$tn.' ,';
$counter++;
}
if(substr($from,-1,1)==',')
{
$from=substr($from,0,-1);
}
$counter=0;
$w=' ';
foreach ($search_array as $kd=>$vd)
{
$tn='r'.$counter;
$w= $w. ' ('.$tn.'.examination_id=\''.$kd.'\' and '.$tn.'.result like \'%'.$vd.'%\' ) and ';
if($counter>0)
{
$tp=' r'.($counter-1);
$w=$w.' '.$tn.'.sample_id='.$tp.'.sample_id and ';
}
$counter++;
}
if(substr($w,-4,4)=='and ')
{
$w=substr($w,0,-4);
}
$sql='select * from '.$from.' where '.$w;
//echo $sql;
$ret=array();
$result=run_query($link,$GLOBALS['database'],$sql);
while($ar=get_single_row($result))
{
show_sid_button_release_status($link,$ar['sample_id']);
}
//print_r($ret);
//echo '</pre>';
}
elseif($_POST['action']=='search_detail')
{
$search_array=prepare_search_array($link);
if(count($search_array)==0)
{
echo '<h3>No meaningful search conditions provided!!</h3>';
exit(0);
}
//echo '<pre>';
//print_r($_POST);
//print_r($search_array);
$from=' ';
$counter=0;
foreach ($search_array as $kd=>$vd)
{
$tn='r'.$counter;
$from=$from.' result '.$tn.' ,';
$counter++;
}
if(substr($from,-1,1)==',')
{
$from=substr($from,0,-1);
}
$counter=0;
$w=' ';
foreach ($search_array as $kd=>$vd)
{
$tn='r'.$counter;
$w= $w. ' ('.$tn.'.examination_id=\''.$kd.'\' and '.$tn.'.result like \'%'.$vd.'%\' ) and ';
if($counter>0)
{
$tp=' r'.($counter-1);
$w=$w.' '.$tn.'.sample_id='.$tp.'.sample_id and ';
}
$counter++;
}
if(substr($w,-4,4)=='and ')
{
$w=substr($w,0,-4);
}
$sql='select * from '.$from.' where '.$w;
//echo $sql;
$ret=array();
$result=run_query($link,$GLOBALS['database'],$sql);
while($ar=get_single_row($result))
{
view_sample($link,$ar['sample_id']);
}
//print_r($ret);
//echo '</pre>';
}
//////////////user code ends////////////////
tail();
//echo '<pre>';print_r($_POST);echo '</pre>';
//////////////Functions///////////////////////
?>