zapujceny HW
[mirrors/SokoMan.git] / assistants / print-labels.inc.php
1 <?php
2 if(isset($_POST['print'])) {
3 $time = round(microtime(true)*100);
4 $prefix = 'SPOJE';
5 $enctype = 'code128b';
6 $geometry = '';
7 $count = $_POST['cols']*$_POST['rows']*$_POST['pages'];
8
9 $table = '-p A4 -t '.escapeshellarg(
10 $_POST['cols'].'x'.$_POST['rows'].
11 '+'.$_POST['left'].'+'.$_POST['bottom'].'-'.$_POST['right'].'-'.$_POST['top']
12 );
13
14 $barcodes = '';
15 for($i=0;$i<$count;$i++) $barcodes.=' -b '.escapeshellarg(strtoupper($prefix.base_convert($time+$i,10,36)));
16
17 switch(strtolower($_POST['print'])) {
18 case 'debug': case 'dbg':
19 break;
20 case 'pdf':
21 $convert='| ps2pdf -dCompatibility=1.2 - -';
22 header('Content-Type: application/pdf');
23 break;
24 default: case 'ps':
25 $convert='';
26 header('Content-Type: application/postscript');
27 header("Content-Disposition: attachment; filename=labels.ps");
28 break;
29 }
30 error_reporting(0);
31 $cmd="barcode -e $enctype $geometry $table $barcodes $convert";
32 if($_POST['print']=='Debug') die($cmd);
33 system($cmd);
34 die();
35 }
36 ?>
37 <form action="?" method="POST">
38 <input type="number" name="cols" value="4" /> &harr; Sloupců<br />
39 <input type="number" name="rows" value="13" /> &varr; Řádků<br />
40 <input type="number" name="pages" value="1" /> &crarr; Stran<br />
41 <table>
42 <tr><td></td><td><input type="number" name="top" value="20" /></td><td></td></tr>
43 <tr><td><input type="number" name="left" value="2" /></td><td>Okraje</td><td><input type="number" name="right" value="1" /></td></tr>
44 <tr><td></td><td><input type="number" name="bottom" value="25" /></td><td></td></tr>
45 </table>
46 <input type="submit" name="print" value="Debug" />
47 <input type="submit" name="print" value="PS" />
48 <input type="submit" name="print" value="PDF" />
49 </form>
50 Pozor! Každý arch vytiskni jen jednou a radši ho hned po vytištění smaž!
This page took 0.277957 seconds and 4 git commands to generate.