-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_multiple_scanned_barcode.php
100 lines (84 loc) · 2.5 KB
/
print_multiple_scanned_barcode.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
<?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']);
?>
<script>
function clear_list()
{
// alert("hi");
// var xhr = new XMLHttpRequest();
// xhr.open("POST", 'print_report_barcode_scan.php', true);
// xhr.setRequestHeader('Content-Type','application/json');
//xhr.send(JSON.stringify({"sample_id_array":"YToxOntpOjA7czo3OiIxMDAxMDAwIjt9"}));
// xhr.send();
}
</script>
<?php
main_menu($link);
if($_POST['action']=='get_scan')
{
get_dbid();
}
//////////////user code ends////////////////
tail();
//echo '<pre>';print_r($_POST);echo '</pre>';
//////////////Functions///////////////////////
function get_dbid()
{
if(isset($_POST['sample_id_array']))
{
$received=unserialize(base64_decode($_POST['sample_id_array']));
}
else
{
$received=array();
}
if(isset($_POST['sample_id']))
{
$k=array_search($_POST['sample_id'],$received);
if($k!==FALSE)
{
unset($received[$k]);
echo $k;
}
else
{
$received[] = $_POST['sample_id'];
}
$serialized=base64_encode(serialize(array_filter($received)));
}
else
{
$serialized=base64_encode(serialize(array_filter($received)));
}
//echo '<form id=xyz fname=wqeq&lname=qwe method=post>';
echo '<form id=xyz method=post>';
echo '<div class="basic_form">';
echo ' <label class="my_label text-danger" for="mrd">Database ID</label>
<input type=text name=sample_id autofocus class="form-control text-danger" \>';
echo '<input type=hidden id=sample_id_array name=sample_id_array value=\''.$serialized.'\'>';
echo '<input type=hidden id=sample_id_array2 name=sample_id_array2 value=\''.$serialized.'\'>';
echo '</div>';
echo '<button type=submit class="btn btn-primary form-control"
name=action
formaction=print_multiple_scanned_barcode.php
value=get_scan>Add/Remove Sample</button>';
echo '<button type=submit
formtarget=_blank
id=print_action
onclick="clear_list();"
class="btn btn-secondary form-control"
name=action formaction=print_report_barcode_scan.php
value=print>Print</button>';
echo '<input type=hidden name=session_name value=\''.session_name().'\'>';
echo '</form>';
echo '<h3 class=text-info>If any sample is in list ,it will be removed on rescan</h3>';
echo '<pre>';print_r(array_filter($received));echo '</pre>';
}
//formtarget=_blank
?>