getting really close
[clinton/MarylandElectronicPetitionSignature.git] / admin / print.php
CommitLineData
f2f95132
PM
1<?php
2include_once('/var/www/secure.php');
2451b52f 3include_once('../slack.php');
f2f95132 4$id = intval($_GET['id']);
87fd7856 5$name=$_GET['name'];
a4622b53 6$now = date('r');
87fd7856
PM
7if ($id == 0 || $name == ''){
8 die("Error #".__LINE__);
9}
a4622b53 10$petition->query("update signatures set printed_status = '$name printed on $now' where id = '$id' ");
f2f95132
PM
11$q = "select * from signatures where id = '$id' ";
12$r = $petition->query($q);
13$d = mysqli_fetch_array($r);
f2f95132
PM
14$DOB = $d['date_of_birth'];
15$SIGNED = $d['date_time_signed'];
16$PETITION_ID = $d['petition_id'];
57085bd6
PM
17$signed_name_as = ucwords(strtolower($d['signed_name_as']));
18$signed_name_as_circulator = ucwords(strtolower($d['signed_name_as_circulator']));
913f1062 19$contact_phone = $d['contact_phone'];
c9239967 20$VoterList_table = $d['VoterList_table'];
913f1062 21
c9239967
PM
22slack_general("$name printing $VoterList_table petition $id",'md-petition');
23$q2 = "select * from $VoterList_table where VTRID = '$d[VTRID]' ";
f2f95132
PM
24$r2 = $petition->query($q2);
25$d2 = mysqli_fetch_array($r2);
26 $FIRSTNAME = $d2['FIRSTNAME'];
27 $MIDDLENAME = $d2['MIDDLENAME'];
28 $LASTNAME = $d2['LASTNAME'];
29 $ADDRESS = $d2['ADDRESS'];
30 $RESIDENTIALCITY = $d2['RESIDENTIALCITY'];
31 $COUNTY = $d2['COUNTY'];
32 $RESIDENTIALZIP5 = $d2['RESIDENTIALZIP5'];
33 $full_name = "$FIRSTNAME $MIDDLENAME $LASTNAME";
34 $address = "$ADDRESS $RESIDENTIALCITY $RESIDENTIALZIP5";
35
913f1062
PM
36$address1 = $ADDRESS;
37$address2 = "$RESIDENTIALCITY, MD $RESIDENTIALZIP5";
38
f2f95132
PM
39
40
41$qX = "select * from petitions where petition_id = '$PETITION_ID'";
42$rX = $petition->query($qX);
43$dX = mysqli_fetch_array($rX);
44
45$hide_county = $dX['hide_county_on_petition'];
46$offset_x = $dX['offset_x_cords'];
47$offset_y = $dX['offset_y_cords'];
48$offset_x_circulator = $dX['offset_x_cords_circulator'];
49$offset_y_circulator = $dX['offset_y_cords_circulator'];
50
51// imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )
52// x how far from left
53// y how far from top
54
55
56//Set the Content Type
57header('Content-type: image/jpeg');
58
59// Create Image From Existing File -- going to have to make this a reqired size??? 2550x3300
ac923cf0 60$jpg_image = imagecreatefromjpeg("../".$dX['petition_jpg']);
f2f95132
PM
61
62// Allocate A Color For The Text
63$black = imagecolorallocate($jpg_image, 0, 0, 0);
64
65// Set Path to Font File
913f1062
PM
66$font_path = '../files/coolvetica rg.ttf';
67$font_path_sig = '../files/Claston Script.ttf';
f2f95132
PM
68
69if ($hide_county == 'NO'){
913f1062 70 if ( $COUNTY == 'Baltimore City'){
f2f95132
PM
71 // City Checkbox
72 $cord = $dX['text_cord_cityX'];
73 $array = explode(",",$cord);
74 $debug = "$id : $cord : $array[0]";
75 imagettftext($jpg_image, $array[0], $array[1], $array[2], $array[3], $black, $font_path, 'X');
76 }else{
77 // County on Petition
78 $cord = $dX['text_cord_county'];
79 $array = explode(",",$cord);
913f1062 80 imagettftext($jpg_image, $array[0], $array[1], $array[2], $array[3], $black, $font_path, str_replace('County','',$COUNTY) );
f2f95132
PM
81 }
82}
83// name
84imagettftext($jpg_image, 50, 0, 350+$offset_x, 1070+$offset_y, $black, $font_path, $full_name);
85// signed
86imagettftext($jpg_image, 70, 0, 400+$offset_x, 1180+$offset_y, $black, $font_path_sig, $signed_name_as);
87// address
88imagettftext($jpg_image, 50, 0, 400+$offset_x, 1300+$offset_y, $black, $font_path, $address);
89
90// date of birth
91if($DOB != ''){
92 imagettftext($jpg_image, 50, 0, 1900+$offset_x, 1070+$offset_y, $black, $font_path, date('m d Y',strtotime($DOB)));
93}
94// date signed
95imagettftext($jpg_image, 50, 0, 1900+$offset_x, 1200+$offset_y, $black, $font_path, date('m d Y',strtotime($SIGNED)));
96
97
98// name
913f1062 99imagettftext($jpg_image, 40, 0, 100+$offset_x_circulator, 2880+$offset_y_circulator, $black, $font_path, $full_name);
f2f95132 100// address
913f1062 101imagettftext($jpg_image, 40, 0, 100+$offset_x_circulator, 2975+$offset_y_circulator, $black, $font_path, $address1);
f2f95132 102// city state zip
913f1062 103imagettftext($jpg_image, 40, 0, 100+$offset_x_circulator, 3065+$offset_y_circulator, $black, $font_path, $address2);
f2f95132 104// phone
913f1062 105imagettftext($jpg_image, 40, 0, 100+$offset_x_circulator, 3160+$offset_y_circulator, $black, $font_path, $contact_phone);
f2f95132
PM
106// signed
107imagettftext($jpg_image, 70, 0, 1290+$offset_x_circulator, 3160+$offset_y_circulator, $black, $font_path_sig, $signed_name_as_circulator);
108// date signed
109imagettftext($jpg_image, 50, 0, 2150+$offset_x_circulator, 3160+$offset_y_circulator, $black, $font_path, date('m / d / y',strtotime($SIGNED)));
110
111
112
113// Send Image to Browser
114imagejpeg($jpg_image);
115
116// Clear Memory
117imagedestroy($jpg_image);
118?>