Add files via upload
[clinton/MarylandElectronicPetitionSignature.git] / admin / print.php
1 <?php
2 include_once('/var/www/secure.php');
3 include_once('../slack.php');
4 $id = intval($_GET['id']);
5 $name=$_GET['name'];
6 $now = date('r');
7 if ($id == 0 || $name == ''){
8 die("Error #".__LINE__);
9 }
10 $petition->query("update signatures set printed_status = '$name printed on $now' where id = '$id' ");
11 $q = "select * from signatures where id = '$id' ";
12 $r = $petition->query($q);
13 $d = mysqli_fetch_array($r);
14 $DOB = $d['date_of_birth'];
15 $SIGNED = $d['date_time_signed'];
16 $PETITION_ID = $d['petition_id'];
17 $signed_name_as = ucwords(strtolower($d['signed_name_as']));
18 $signed_name_as_circulator = ucwords(strtolower($d['signed_name_as_circulator']));
19 $contact_phone = $d['contact_phone'];
20 $VoterList_table = $d['VoterList_table'];
21
22 slack_general("$name printing $VoterList_table petition $id",'md-petition');
23 $q2 = "select * from $VoterList_table where VTRID = '$d[VTRID]' ";
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
36 $address1 = $ADDRESS;
37 $address2 = "$RESIDENTIALCITY, MD $RESIDENTIALZIP5";
38
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 $petition_party_line1 = $dX['petition_party_line1'];
52 $petition_party_line2 = $dX['petition_party_line2'];
53 $petition_party_line3 = $dX['petition_party_line3'];
54 $petition_party_line4 = $dX['petition_party_line4'];
55
56 // imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )
57 // x how far from left
58 // y how far from top
59
60
61 //Set the Content Type
62 header('Content-type: image/jpeg');
63
64 // Create Image From Existing File -- going to have to make this a reqired size??? 2550x3300
65 $jpg_image = imagecreatefromjpeg("../".$dX['petition_jpg']);
66
67 // Allocate A Color For The Text
68 $black = imagecolorallocate($jpg_image, 0, 0, 0);
69
70 // Set Path to Font File
71 $font_path = '../files/coolvetica rg.ttf';
72 $font_path_sig = '../files/Claston Script.ttf';
73
74 if ($hide_county == 'NO'){
75 if ( $COUNTY == 'Baltimore City'){
76 // City Checkbox
77 $cord = $dX['text_cord_cityX'];
78 $array = explode(",",$cord);
79 $debug = "$id : $cord : $array[0]";
80 imagettftext($jpg_image, $array[0], $array[1], $array[2], $array[3], $black, $font_path, 'X');
81 }else{
82 // County on Petition
83 $cord = $dX['text_cord_county'];
84 $array = explode(",",$cord);
85 imagettftext($jpg_image, $array[0], $array[1], $array[2], $array[3], $black, $font_path, str_replace('County','',$COUNTY) );
86 }
87 }
88 // Party Information
89 imagettftext($jpg_image, 50, 0, 200, 580, $black, $font_path, $petition_party_line1 );
90 imagettftext($jpg_image, 50, 0, 700, 700, $black, $font_path, $petition_party_line2 );
91 imagettftext($jpg_image, 50, 0, 340, 790, $black, $font_path, $petition_party_line3 );
92 imagettftext($jpg_image, 50, 0, 340, 870, $black, $font_path, $petition_party_line4 );
93
94 // name
95 imagettftext($jpg_image, 50, 0, 350+$offset_x, 1070+$offset_y, $black, $font_path, $full_name);
96 // signed
97 imagettftext($jpg_image, 70, 0, 400+$offset_x, 1180+$offset_y, $black, $font_path_sig, $signed_name_as);
98 // address
99 imagettftext($jpg_image, 50, 0, 400+$offset_x, 1300+$offset_y, $black, $font_path, $address);
100
101 // date of birth
102 if($DOB != ''){
103 imagettftext($jpg_image, 50, 0, 1900+$offset_x, 1070+$offset_y, $black, $font_path, date('m d Y',strtotime($DOB)));
104 }
105 // date signed
106 imagettftext($jpg_image, 50, 0, 1900+$offset_x, 1200+$offset_y, $black, $font_path, date('m d Y',strtotime($SIGNED)));
107
108
109 // name
110 imagettftext($jpg_image, 40, 0, 100+$offset_x_circulator, 2880+$offset_y_circulator, $black, $font_path, $full_name);
111 // address
112 imagettftext($jpg_image, 40, 0, 100+$offset_x_circulator, 2975+$offset_y_circulator, $black, $font_path, $address1);
113 // city state zip
114 imagettftext($jpg_image, 40, 0, 100+$offset_x_circulator, 3065+$offset_y_circulator, $black, $font_path, $address2);
115 // phone
116 imagettftext($jpg_image, 40, 0, 100+$offset_x_circulator, 3160+$offset_y_circulator, $black, $font_path, $contact_phone);
117 // signed
118 imagettftext($jpg_image, 70, 0, 1290+$offset_x_circulator, 3160+$offset_y_circulator, $black, $font_path_sig, $signed_name_as_circulator);
119 // date signed
120 imagettftext($jpg_image, 50, 0, 2150+$offset_x_circulator, 3160+$offset_y_circulator, $black, $font_path, date('m / d / y',strtotime($SIGNED)));
121
122
123
124 // Send Image to Browser
125 imagejpeg($jpg_image);
126
127 // Clear Memory
128 imagedestroy($jpg_image);
129 ?>