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