-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_lables.php
164 lines (128 loc) · 4.68 KB
/
print_lables.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
<?php
session_start();
include 'common.php';
require_once('tcpdf/config/lang/eng.php');
require_once('tcpdf/tcpdf.php');
//echo '<pre>';
//print_r($GLOBALS);
//echo '</pre>';
/*
2015-01-02: added str_pad to tackle problem of barcode reading when sample_id<100)
*/
function print_lable_general($pdf, $style, $line1,$line2,$line3,$line4,$number)
{
$pdf->SetFont('helveticaB', '', 9);
for($i=0;$i<$number;$i++)
{
$pdf->AddPage();
//3 mm allside
//25-6=19/4=5
//50-6=44
$pdf->SetXY(3,3);
$pdf->Cell (44,5,$line1,$border=0, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M');
$pdf->SetXY(3,8);
$pdf->Cell (44,5,$line2,$border=0, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M');
$pdf->SetXY(3,13);
$pdf->Cell (44,5,$line3,$border=0, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M');
$pdf->SetXY(3,18);
$pdf->Cell (44,5,$line4,$border=0, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M');
}
}
function print_lable_incremental($pdf, $style, $line1,$line2,$line3,$line4,$number)
{
$pdf->SetFont('helveticaB', '', 9);
for($i=0;$i<$number;$i++)
{
$pdf->AddPage();
//3 mm allside
//25-6=19/4=5
//50-6=44
$pdf->SetXY(3,3);
$pdf->Cell (44,5,$line1,$border=0, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M');
$pdf->SetXY(3,8);
$pdf->Cell (44,5,$line2." ".($i+1),$border=0, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M');
$pdf->SetXY(3,13);
$pdf->Cell (44,5,$line3,$border=0, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M');
$pdf->SetXY(3,18);
$pdf->Cell (44,5,$line4,$border=0, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M');
}
}
class MYPDF_BARCODE extends TCPDF
{
public function Header()
{
}
// Page footer
public function Footer()
{
}
}
login_varify();
// for barcode
$style = array(
'position' => '',
'align' => 'C',
'stretch' => false,
'fitwidth' => true,
'cellfitalign' => '',
'border' => false,
'hpadding' => 'auto',
'vpadding' => '0',
'fgcolor' => array(0,0,0),
'bgcolor' => false, //array(255,255,255),
'text' => true,
'font' => 'helvetica',
'fontsize' => 10,
'stretchtext' => 4
);
$pdf = new MYPDF_BARCODE('', 'mm', array("50","25"), true, 'UTF-8', false);
$pdf->SetMargins(0,0, $right=-1, $keepmargins=true);
$pdf->setPrintFooter(false);
$pdf->setPrintHeader(false);
$pdf->SetAutoPageBreak(TRUE, 0);
$pdf->setCellPaddings(0,0,0,0);
//minimum 2 mm margin
//25-4=21 available Y
//50-5=46 available X
//5 line 1, 10 barcode, 5 line 3
function general_form()
{
echo '<form method=post><table border=1>
<tr><th colspan=10 style="background-color:lightblue;">Print multiple copies of lableswith 4 lines</th></tr>
<tr><td>line1</td><td><input type=text name=line1></td></tr>
<tr><td>line1</td><td><input type=text name=line2></td></tr>
<tr><td>line1</td><td><input type=text name=line3></td></tr>
<tr><td>line1</td><td><input type=text name=line4></td></tr>
<tr><td>copies</td><td><input type=text name=number></td></tr>
<tr><th style="background-color:lightblue;" colspan=10 ><input type=submit name=action value=general></th></tr>
</table></form>';
}
function incremental_form()
{
echo '<form method=post><table border=1>
<tr><th colspan=10 style="background-color:lightblue;">Print multiple copies of lableswith 4 lines</th></tr>
<tr><td>line1</td><td><input type=text name=line1></td></tr>
<tr><td>line1</td><td><input type=text name=line2><td>1 to </td><td><input type=text name=number></td></tr>
<tr><td>line1</td><td><input type=text name=line3></td></tr>
<tr><td>line1</td><td><input type=text name=line4></td></tr>
<tr><th style="background-color:lightblue;" colspan=10 ><input type=submit name=action value=incremental></th></tr>
</table></form>';
}
if(isset($_POST['action']))
{
if($_POST['action']=='general')
{
print_lable_general($pdf,$style,$_POST['line1'],$_POST['line2'],$_POST['line3'],$_POST['line4'],$_POST['number']);
}
elseif($_POST['action']=='incremental')
{
print_lable_incremental($pdf,$style,$_POST['line1'],$_POST['line2'],$_POST['line3'],$_POST['line4'],$_POST['number']);
}
$pdf->Output('labels.php', 'I');
}
else
{
general_form();
incremental_form();
}
?>