-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommon.php.save
410 lines (355 loc) · 11.4 KB
/
common.php.save
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
402
403
404
405
406
407
408
409
410
<?php
//require_once('tcpdf/config/lang/eng.php');
require_once('tcpdf/tcpdf.php');
require_once('reference_interval.php');
// calibration, EQC,Kit,checklist
$reflex='no';
//$GLOBALS['final_stage']=array('verified','released');
$GLOBALS['final_stage']=array('released');
//if 'no'=>it will bypass reflex testing
date_default_timezone_set('Asia/Kolkata');
/////////////////////////////////////////////
////////////mysql to mysqli//////////////////
/////////////////////////////////////////////
$GLOBALS['link']='';
if(substr(phpversion(),0,1)>=7)
{
require_once 'new_to_old.php';
}
///////comment upto here to enable older mysql <7
/////////////////////////////////
function login_varify()
{
return mysql_connect('127.0.0.1',$_SESSION['login'],$_SESSION['password']);
}
/////////////////////////////////
function select_nchsls($link)
{
return mysql_select_db('biochemistry',$link);
}
///////////////////////////////////
function start_nchsls()
{
if(!$link=login_varify())
{
exit();
}
if(!select_nchsls($link))
{
exit();
}
return $link;
}
function my_mysql_query($sql,$link)
{
if(strpos($sql,'update')>=0 || strpos($sql,'delete')>=0||strpos($sql,'insert'>=0))
{
$log='insert into log values(\'\',sysdate(),current_user(),\''.mysql_real_escape_string($sql,$link).'\')';
//echo $log;
mysql_query($log,$link);
}
return mysql_query($sql,$link);
}
/*
select resident in charge
grant previlages and create users
TAT- sample and exam wise OK
EQA-data and comment
Monthly summary
calibration data
kit management-batch management
complain,feedback
repeat-batch to know pending, not-entered receipt, not-run sample
printed-dispatched
*/
// <li><a href=new_request_barcode_general_option2_OPD.php>New OPD Blood(S,P)</a>
function main_menu()
{
echo '<link rel="stylesheet" type="text/css" href="horizontal.css">
<script type="text/javascript" href=menu.js></script>
<table border=0><tr><td>
<div id="navbar">
<ul>
<li><a href="#">New</a>
<ul>
<li><a href=new_request_barcode_general_option2.php>New General</a>
<li><a href=new_request_barcode_general_option2_OPD.php>New OPD</a>
</ul>
<li><a href="#">Edit</a>
<ul>
<li><a href=edit_request.php>Edit</a>
<li><a href=delete_sample_request.php>Delete Sample</a>
<li><a href=delete_examination_request.php>Delete Examination</a>
<li><a href=attachment.php>Manage Attachment</a>
</ul>
<li><a href="#">Worklist</a>
<ul>
<li><a href=1_by_1.php>1-by-1</a>
<li><a href=examination_wise_worklist.php>Examination wise worklist</a>
<li><a href=sample_wise_worklist.php>Sample wise worklist</a>
</ul>
<li><a href="#">Result</a>
<ul>
<li><a href=import_results_XL_640.php>Import from Erba XL-640</a>';
echo ' <li><a href=import_autoverify_results_XL_640.php>Import-cum-autoverify Erba XL-640</a>
<li><a href=autoverify.php>Autoverify 1-by-1</a>
<li><a href=search_autoverify.php>Search-cum-Autoverify</a>';
echo ' <li><a href=critical_report.php>Critical Report</a>
<li><a href=examination_wise_results.php>Examination wise Entry</a>
</ul>
<li><a href="#">Report</a>
<ul>
<li><a href=print_report.php>Print</a>
<li><a href=print_report_pdf_A4_ri_last.php>Print-PDF-A4</a>
<li><a href=print_report_pdf_A4_discontinuous_ri.php>Print(barcode)</a>
</ul>
<li><a href="#">Quality</a>
<ul>
<li><a href=import_qc.php>Import QC</a>
<li><a href=lj_chart.php>LJ chart/ insert/comment QC</a>
<li><a href=refrigerator_temperature.php>Refrigerator Temperatures</a>
<li><a href=environmental_parameter.php>Environmental Parameter</a>
<li><a href=equipment_log.php>Equipment Log</a>
<li><a href=equipment_record.php>Equipment Record</a>
<li><a href=nc.php>Nonconformity Records</a>
<li><a href=reagent.php>Reagents</a>
<li><a href=calibration.php>Calibrations</a>
<li><a href=TAT.php>Turnaround time</a>
</ul>
<li><a href="#">Documents/Records</a>
<ul>
<li><a target=_blank href=view_scope.php>Scope</a></li>
<li><a href=view_data.php>View (from database)</a>
<li><a href=NCHSLS target="_blank">View(from file system)</a>
<li><a href=docs>Docs Upload</a>
<li><a href="monthly_sample_id_change.php">update sample_id</a>
<li><a href=print_label_48.php>Print 48 lables</a></li>
<li><a href=print_lables.php>Print barcode labels</a></li>
<li><a href=new_request.php>New</a>
<li><a href=new_request_FS.php>New Copy[F-S]</a>
<li><a href=release.php>Release</a>
</ul>
<li><a href="schedule.php">Reminders</a>
<li><a href="#">'.$_SESSION['login'].'</a>
<ul>
<li><a href="logout.php">Logout</a>
<li><a href="change_password.php">Change Password</a>
<li><a href="mlamp.php" target=_blank>About</a>
<li><a href="suggestion.php" target=_blank>Suggestion</a>
</ul>
</ul></div>
</td></tr></table>';
}
function mk_select_from_table($field,$disabled,$default)
{
$link=start_nchsls();
//$sql='select * from '.$field;
$sql='select `'.$field.'` from '.$field;
if(!$result=mysql_query($sql,$link)){return FALSE;}
echo '<select id="fld" '.$disabled.' name='.$field.'>';
while($result_array=mysql_fetch_assoc($result))
{
if($result_array[$field]==$default)
{
echo '<option selected > '.$result_array[$field].' </option>';
}
else
{
echo '<option > '.$result_array[$field].' </option>';
}
}
echo '</select>';
return TRUE;
}
function mk_select_from_sql($sql,$name,$disabled,$default)
{
$link=start_nchsls();
if(!$result=mysql_query($sql,$link)){return FALSE;}
echo '<select '.$disabled.' name='.$name.'>';
while($result_array=mysql_fetch_assoc($result))
{
if($result_array[$name]==$default)
{
echo '<option selected > '.$result_array[$name].' </option>';
}
else
{
echo '<option > '.$result_array[$name].' </option>';
}
}
echo '</select>';
return TRUE;
}
function mk_select_from_array_return_key($name, $select_array,$disabled,$default)
{
echo '<select '.$disabled.' name='.$name.'>';
foreach($select_array as $key=>$value)
{
if($value==$default)
{
echo '<option selected value=\''.$key.'\' > '.$value.' </option>';
}
else
{
echo '<option value=\''.$key.'\' > '.$value.' </option>';
}
}
echo '</select>';
return TRUE;
}
function mk_select_from_array_return_value($name, $select_array,$disabled,$default)
{
echo '<select '.$disabled.' name='.$name.'>';
foreach($select_array as $key=>$value)
{
if($value==$default)
{
echo '<option selected value=\''.$value.'\' > '.$value.' </option>';
}
else
{
echo '<option value=\''.$value.'\' > '.$value.' </option>';
}
}
echo '</select>';
return TRUE;
}
function edit_sample($sample_id,$filename,$disabled='',$type_preservative_change='',$status_change='no')
{
$link=start_nchsls();
$counter=1;
$sql_sample_data='select * from sample where sample_id='.$sample_id;
if(mysql_num_rows($result_sample_data=mysql_query($sql_sample_data,$link))!=1){echo 'No such Sample';return FALSE;}
$sample_array=mysql_fetch_assoc($result_sample_data);
echo '<form method=post action=\''.$filename.'\'>';
echo ' <table border=1 bgcolor=lightyellow CELLPADDING=0 CELLSPACING=0>
<tr>
<td>
<button type=submit name=action '.$disabled.' value=save_sample>save sample</button>
</td>
<th colspan=8 align=left>Sample Entry Form</th></tr>';
foreach($sample_array as $key=>$value)
{
if($counter%4==1){echo '<tr>';}
if($key=='sample_id' || $key=='released_by' ||$key=='released_at')
{
echo '<td>'.$key.'</td><td><input type=text readonly value=\''.$value.'\' name='.$key.'></td>';
}
elseif( ($key=='sample_type' || $key=='preservative') && $type_preservative_change=='no')
{
echo '<td>'.$key.'</td><td><input type=text readonly value=\''.$value.'\' name='.$key.'></td>';
}
elseif($key=='status' && $type_preservative_change=='no')
{
echo '<td>'.$key.'</td><td><input type=text readonly value=\''.$value.'\' name='.$key.'></td>';
}
else
{
echo '<td>'.$key.'</td><td>';
if(!mk_select_from_table($key,$disabled,$value))
{
echo '<input type=text '.$disabled.' value=\''.$value.'\' name='.$key.'>';
}
echo '</td>';
}
if($counter%4==0){echo '<tr>';}
$counter++;
}
echo '</form></table>';
return TRUE;
}
function save_sample($post_array)
{
$link=start_nchsls();
$sql='update sample set ';
foreach ($post_array as $key => $value)
{
if($key!='action')
{
$sql=$sql.' '.$key.'=\''.$value.'\' , ';
}
}
$sql=substr($sql,0,-2);
$sql=$sql.' where sample_id= \''.$post_array['sample_id'].'\'';
//echo $sql;
if(!mysql_query($sql,$link)){echo mysql_error(); return FALSE;}
return TRUE;
}
function change_sample_status($sample_id,$str)
{
$link=start_nchsls();
$sql='update sample set status=\''.$str.'\' where sample_id=\''.$sample_id.'\'';
if(!mysql_query($sql,$link)){echo mysql_error(); return FALSE;}
return TRUE;
}
function sample_printed($sample_id_array)
{
$link=start_nchsls();
foreach($sample_id_array as $sample_id)
{
$sql='update sample set details=\'printed\' where sample_id=\''.$sample_id.'\'';
if(!mysql_query($sql,$link)){echo mysql_error();}
}
}
function save_sample_FS($copy_sample_id,$paste_sample_id)
{
$link=start_nchsls();
$csql='select * from sample where sample_id=\''.$copy_sample_id.'\'';
$cresult=mysql_query($csql,$link);
if(mysql_num_rows($cresult)!=1)
{
echo 'from_sample_id do not exist<br>';
return;
}
$ar=mysql_fetch_assoc($cresult);
$sql='update sample set ';
foreach ($ar as $key => $value)
{
if($key=='sample_id')
{
$sql=$sql.' '.$key.'=\''.$paste_sample_id.'\' , ';
}
else if($key=='preservative' && $value=='None')
{
$sql=$sql.' '.$key.'=\''.'Fluoride'.'\' , ';
}
else if($key=='preservative' && $value=='Fluoride')
{
$sql=$sql.' '.$key.'=\''.'None'.'\' , ';
}
else
{
$sql=$sql.' '.$key.'=\''.$value.'\' , ';
}
}
$sql=substr($sql,0,-2);
$sql=$sql.' where sample_id= \''.$paste_sample_id.'\'';
//echo $sql;
if(!mysql_query($sql,$link)){echo mysql_error();}
}
function select_profile($sample_id,$filename)
{
$link=start_nchsls();
$sql_sample_data='select sample_type,preservative from sample where sample_id='.$sample_id;
if(mysql_num_rows($result_sample_data=mysql_query($sql_sample_data,$link))!=1){echo 'No such Sample';return FALSE;}
$sample_array=mysql_fetch_assoc($result_sample_data);
$sql='select * from profile where (sample_type=\''.$sample_array['sample_type'].'\' and preservative=\''.$sample_array['preservative'].'\') or profile like \'Z_%\' ';
$result=mysql_query($sql,$link);
echo '<form method=post action=\''.$filename.'\'>';
echo '<table border=1 bgcolor=lightyellow CELLPADDING=0 CELLSPACING=0 >
<tr><th colspan=8 align=left>Profiles</th>';
echo '<th nowrap><input type=hidden name=sample_id value=\''.$sample_id. '\'> </th>';
$counter=0;
echo '</tr><tr>';
echo '<input type=hidden name=action value=profile></td>';
while($ar=mysql_fetch_assoc($result))
{
foreach ($ar as $key => $value)
{ if($key=='profile')
{
echo '<td nowrap><button type=submit name=profile value=\''.$value.'\'>'.$value.'</button></td>';
$counter++;
}
if($counter%5==0){echo '</tr><tr>';}
}
}