-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprint_report_pdf_A4_ri.php
184 lines (150 loc) · 4.04 KB
/
print_report_pdf_A4_ri.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
<?php
session_start();
/*
echo '<html>';
echo '<head>';
echo '</head>';
echo '<body>';
*/
/*
echo '<pre>';
print_r($GLOBALS);
echo '</pre>';
*/
/*
<Fasting>
<Diabetes_Mellitus>
>126
</Fasting>
<Post-Prandial>
>200
</Post-Prandial>
</Diabetes_Mellitus>
*/
include 'common.php';
if(!login_varify())
{
exit();
}
function search_form($filename)
{
$link=start_nchsls();
$sql='desc sample';
if(!$result=mysql_query($sql,$link)){echo mysql_error();}
$tr=1;
echo '<table border=1><form action=\''.$filename.'\' target=_blank method=post>';
echo ' <tr>
<td title=\'1) Tickmark to include the field for search. 2) Use % as wildcard. e.g. [%esh = Mahesh,Jignesh] [Mahesh%=Mahesh,Maheshbhai, Maheshkumar]\'><input type=submit name=submit value=print></td>';
/*echo ' <td>Technician:</td><td>';
mk_select_from_table('technician','','');
echo '</td>';
*/
echo '<td>Authorized Signatory:</td><td>';
mk_select_from_table('authorized_signatory','','');
echo '</td>';
echo '</tr>';
while($ar=mysql_fetch_assoc($result))
{
if($tr%3==1){echo '<tr>';}
if($ar['Field']=='sample_id')
{
echo '<td><input type=checkbox checked name=\'chk_from_'.$ar['Field'].'\' ></td><td>from_'.$ar['Field'].'</td>';
echo '<td><input type=text name=\'from_'.$ar['Field'].'\' ></td>';
echo '<td><input type=checkbox name=\'chk_to_'.$ar['Field'].'\' ></td><td>to_'.$ar['Field'].'</td>';
echo '<td><input type=text name=\'to_'.$ar['Field'].'\' >';
$tr++;
}
else
{
echo '<td><input type=checkbox name=\'chk_'.$ar['Field'].'\' ></td><td>'.$ar['Field'].'</td><td>';
if(!mk_select_from_table($ar['Field'],'',''))
{
echo '<input type=text name=\''.$ar['Field'].'\' >';
}
}
echo '</td>';
if($tr%3==0){echo '</tr>';}
$tr++;
}
echo '</form></table>';
}
if(isset($_POST['authorized_signatory']))
{
if(strlen($_POST['authorized_signatory'])==0)
{
echo '<h4>No authorized Signatory given</h4>';
}
}
$search_str='select sample_id from sample ';
$where=array();
if(isset($_POST['submit']))
{
foreach($_POST as $key=>$value)
{
if(substr($key,0,4)=='chk_' && $value=='on')
{
//echo substr($key,4).'='.$_POST[substr($key,4)].'<br>';
$where[substr($key,4)]=$_POST[substr($key,4)];
}
}
}
//print_r($where);
$sample_id_where='';
if(isset($where['from_sample_id']) && isset($where['to_sample_id']) )
{
$sample_id_where='sample_id between \''.$where['from_sample_id'].'\' and \''.$where['to_sample_id'].'\' ';
}
elseif(isset($where['from_sample_id']))
{
$sample_id_where=' sample_id=\''.$where['from_sample_id'].'\' ';
}
elseif(isset($where['to_sample_id']))
{
$sample_id_where=' sample_id=\''.$where['to_sample_id'].'\' ';
}
$other_wheree='';
foreach($where as $key=>$value)
{
if($key!='from_sample_id' && $key!='to_sample_id' )
{
$other_wheree=$other_wheree.' '.$key.' like \''.$value.'\' and';
}
}
$other_where=substr($other_wheree,0,-3);
if(strlen($sample_id_where)>0 && strlen($other_where)>0)
{
$search_str=$search_str.' where '.$sample_id_where.' and '.$other_where;
}
elseif(strlen($sample_id_where)>0 && strlen($other_where)==0)
{
$search_str=$search_str.' where '.$sample_id_where;
}
elseif(strlen($sample_id_where)==0 && strlen($other_where)>0)
{
$search_str=$search_str.' where '.$other_where;
}
$printed=array();
if(isset($_POST['submit']) && substr($search_str,-7)!='sample ')
{
$link=start_nchsls();
if(!$search_result=mysql_query($search_str,$link)){echo mysql_error();}
while($ar=mysql_fetch_assoc($search_result))
{
$printed[]=$ar['sample_id'];
}
foreach($printed as $value)
{
if(get_sample_status($value)!='verified')
{
echo $value.' is not verified. PDF report can not be printed<br>';
}
}
print_report_pdf_A4_ri($printed,$_POST['authorized_signatory']);
}
else
{
main_menu();
search_form('print_report_pdf_A4_ri.php');
echo '<h1>No coditions are given for selecting records</h1>';
}
?>