-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint.php
executable file
·72 lines (62 loc) · 2.65 KB
/
print.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
<?php
/*
Copyright (C) 2015 Baskın Burak Şenbaşlar
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
include "db.php";
$res=$conn->query("select * from print_queue",PDO::FETCH_ASSOC);
$last="";
foreach($res as $ins)
{
if(!file_exists("barcode-images/".$ins['id'].".png"))
{
$barcode=imagecreatefromjpeg("http://localhost/kgg/draw.php?barcode=".$ins['id']);
$res=$conn->query("select isim from katilimcilar where id=".$ins['id'],PDO::FETCH_ASSOC);
$res=$res->fetch();
$image_width=300;
$image_height=50;
$fontsize=20;
$text_box=imagettfbbox($fontsize,0,"barcode/font/Arial.ttf",$res['isim']);
$text_width=$text_box[2]-$text_box[0];
$text_height=$text_box[5]-$text_box[1];
if($text_width>$image_width)
{
$fontsize-=5;
$text_box=imagettfbbox($fontsize,0,"barcode/font/Arial.ttf",$res['isim']);
$text_width=$text_box[2]-$text_box[0];
$text_height=$text_box[5]-$text_box[1];
}
$x=$image_width/2-$text_width/2;
$y=$image_height/2-$text_height/2;
$textim=imagecreatetruecolor($image_width, $image_height);
$background = imagecolorallocate( $textim, 255, 255, 255 );
$text_color = imagecolorallocate($textim, 0, 0, 0);
imagefill($textim,0,0,$background);
imagettftext($textim, $fontsize, 0,$x, $y, $text_color,"barcode/font/Arial.ttf",$res['isim']);
$to_printed=imagecreatetruecolor($image_width,$image_width/2);
$bg=imagecolorallocate($to_printed,255,255,255);
imagefill($to_printed,0,0,$bg);
imagecopymerge($to_printed,$textim,0,0,0,0,$image_width,$image_height,100);
imagecopymerge($to_printed,$barcode,$image_width/2-imagesx($barcode)/2,50,0,0,$image_width,95,100);
imagefilledrectangle($to_printed,0,50+imagesy($barcode),300,150,$bg);
imagefilledrectangle($to_printed,$image_width/2+imagesx($barcode)/2,50,300,150,$bg);
imagepng($to_printed,"barcode-images/".$ins['id'].".png");
}
$conn->query("DELETE FROM print_queue WHERE id=".$ins['id']);
$last.=(string)$ins['id'];
$last.=",";
}
if($last=="")echo -1;
else
echo substr($last,0,-1);
?>