-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_searched.php
112 lines (89 loc) · 2.08 KB
/
print_searched.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
<?php
$GLOBALS['nojunk']='';
require_once 'project_common.php';
require_once 'base/verify_login.php';
////////User code below/////////////////////
$link=get_link($GLOBALS['main_user'],$GLOBALS['main_pass']);
////////Start
$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);
//////////////////////end of search, now printing starts
$first=TRUE;
$error=false;
$at_least_one_sample=false;
$pdf = new ACCOUNT1('P', 'mm', 'A4', true, 'UTF-8', false);
while($ar=get_single_row($result))
{
$sid=$ar['sample_id'];
$released=get_one_ex_result($link,$sid,$GLOBALS['released_by']);
$interim_released=get_one_ex_result($link,$sid,$GLOBALS['interim_released_by']);
if(sample_exist($link,$sid))
{
if(strlen($released)!=0 || strlen($interim_released)!=0 )
{
$at_least_one_sample=true;
print_sample($link,$sid,$pdf);
}
else
{
sample_id_view_button($sid,'_blank',$sid.' is not released');
$error=true;
}
}
}
//echo '|'.$error.'|'.$at_least_one_sample.'|';
if($error===false && $at_least_one_sample!==false)
{
$pdf->Output('report.pdf', 'I');
}
else
{
echo 'nothing to print. Can I Hibernate?';
}
//print_r($ret);
//echo '</pre>';
//////////////user code ends////////////////
//tail();
//echo '<pre>';print_r($_POST);echo '</pre>';
//////////////Functions///////////////////////
?>