Commit | Line | Data |
---|---|---|
5a22a51f TM |
1 | <?php |
2 | if(isset($_POST['print'])) { | |
b5a32995 TM |
3 | $time = round(microtime(true)*100); |
4 | $prefix = 'SPOJE'; | |
5a22a51f TM |
5 | $enctype = 'code128b'; |
6 | $geometry = ''; | |
7 | $count = $_POST['cols']*$_POST['rows']*$_POST['pages']; | |
9de26d46 | 8 | $papersize = isset($_POST['paper']) ? $_POST['paper'] : 'a4'; |
5a22a51f | 9 | |
9de26d46 | 10 | $table = '-p '.escapeshellarg($papersize).' -t '.escapeshellarg( |
5a22a51f TM |
11 | $_POST['cols'].'x'.$_POST['rows']. |
12 | '+'.$_POST['left'].'+'.$_POST['bottom'].'-'.$_POST['right'].'-'.$_POST['top'] | |
13 | ); | |
14 | ||
15 | $barcodes = ''; | |
b5a32995 | 16 | for($i=0;$i<$count;$i++) $barcodes.=' -b '.escapeshellarg(strtoupper($prefix.base_convert($time+$i,10,36))); |
5a22a51f | 17 | |
ecdaa8cd | 18 | switch(strtolower($_POST['print'])) { |
395c4f02 TM |
19 | case 'debug': case 'dbg': |
20 | break; | |
5a22a51f | 21 | case 'pdf': |
9de26d46 | 22 | $convert='| ps2pdf -dOptimize=true -sPAPERSIZE='.escapeshellarg($papersize).' -dCompatibility=1.2 - -'; |
5a22a51f TM |
23 | header('Content-Type: application/pdf'); |
24 | break; | |
25 | default: case 'ps': | |
26 | $convert=''; | |
27 | header('Content-Type: application/postscript'); | |
28 | header("Content-Disposition: attachment; filename=labels.ps"); | |
29 | break; | |
30 | } | |
31 | error_reporting(0); | |
395c4f02 TM |
32 | $cmd="barcode -e $enctype $geometry $table $barcodes $convert"; |
33 | if($_POST['print']=='Debug') die($cmd); | |
34 | system($cmd); | |
5a22a51f TM |
35 | die(); |
36 | } | |
37 | ?> | |
38 | <form action="?" method="POST"> | |
00370507 TM |
39 | <input type="number" name="cols" value="4" /> ↔ Sloupců<br /> |
40 | <input type="number" name="rows" value="13" /> ↕ Řádků<br /> | |
0472e63b | 41 | <input type="number" name="pages" value="1" /> ↵ Stran<br /> |
9de26d46 TM |
42 | Formát papíru: <select name="paper"> |
43 | <option>a4</option> | |
44 | <option>letter</option> | |
45 | <select><br /> | |
5a22a51f | 46 | <table> |
fcd9da73 | 47 | <tr><td></td><td><input type="number" name="top" value="20" /></td><td></td></tr> |
5ad14c31 | 48 | <tr><td><input type="number" name="left" value="2" /></td><td>Okraje</td><td><input type="number" name="right" value="1" /></td></tr> |
fcd9da73 | 49 | <tr><td></td><td><input type="number" name="bottom" value="25" /></td><td></td></tr> |
5a22a51f | 50 | </table> |
395c4f02 | 51 | <input type="submit" name="print" value="Debug" /> |
ecdaa8cd TM |
52 | <input type="submit" name="print" value="PS" /> |
53 | <input type="submit" name="print" value="PDF" /> | |
5a22a51f | 54 | </form> |
8ffb8610 | 55 | Pozor! Každý arch vytiskni jen jednou a radši ho hned po vytištění smaž! |