Gravity PDF - Version 1.1.0

Version Description

  • Now compatible with Gravity Forms Signature Add-On
  • Moved the field data functions out side of the Gravity Forms core so users can freely style their form information (located in pdf-entry-detail.php)
  • Simplified the field data output
  • Fixed bug when using product information
Download this release

Release Info

Developer Blue Liquid Designs
Plugin Icon 128x128 Gravity PDF
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.0 to 1.1.0

Files changed (5) hide show
  1. README.txt +23 -10
  2. pdf-entry-detail.php +315 -0
  3. pdf-print-entry.php +90 -92
  4. pdf.php +114 -66
  5. template.css +9 -1
README.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: blueliquiddesigns
3
  Donate link: http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/
4
  Tags: gravity, forms, pdf, automation, attachment
5
- Requires at least: 3.4.1
6
- Tested up to: 3.4.1
7
- Stable tag: 1.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,7 +12,7 @@ Gravity Forms PDF Extended allows you to save/view/download a PDF from the front
12
 
13
  == Description ==
14
 
15
- Expanding on the good work of 'rposborne', who created the original [Gravity Forms PDF Plugin](http://wordpress.org/extend/plugins/gravity-forms-pdf/), the extended version overhauls the rendering process so developers have more control over the creation of PDFs.
16
 
17
  **Features**
18
 
@@ -21,28 +21,30 @@ Expanding on the good work of 'rposborne', who created the original [Gravity For
21
  * Create multiple PDF templates
22
  * View and download a PDF via the administrator interface
23
  * Simple function to output PDF via template / plugin
 
24
 
25
  **Tutorial**
26
  [Head to Blue Liquid Designs](http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/) - the developer of the extended Gravity Forms PDF plugin - and view everything you need to know installing, configuring and using the plugin.
27
 
28
  **Demo**
29
- [See the Gravity Forms PDF Extended Plugin in action](http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/#gf-demo).
30
 
31
  == Installation ==
32
 
33
  This section describes how to install the plugin and get it working.
34
 
35
  1. Upload this plugin to your website and activate it
36
- 2. Modify the PDF template file, *pdf-print-entry.php*, inside the gravity-forms-pdf-extended plugin folder to suit your requirements.
37
- 3. To create a PDF on form submission and add as an email attachment read the tutorial: [http://blueliquiddesigns.com.au/gravity-forms-pdf-extended-plugin/](http://blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/)
 
38
 
39
  == Frequently Asked Questions ==
40
 
41
  = I get the error message: Fatal error: Call to undefined method DOMText::getAttribute() on line ###. =
42
- This is generally caused by invalid HTML. [Read the plugin documentation](http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/#gf-the-template) for an easy method to debug the issue.
43
 
44
  = I added an image to the template file and got the error 'Image not readable or empty'. =
45
- Make sure you use an absolute path to the file e.g. http://www.your-site.com/my-image.jpg. Also, check that the 'temp' folder in *../gravity-forms-pdf-extended/dompdf/* is writable by your web server.
46
 
47
  = I want to have multiple PDF template files. =
48
  Copy the *pdf-print-entry.php* file (located in the plugin directory) and pass the new template name to the PDF_Generator() function inside the gform_pdf_create() function.
@@ -52,10 +54,21 @@ By deleting the .htaccess file in the 'output' folder you'll be able to access t
52
 
53
  == Screenshots ==
54
 
55
- 1. View a PDF from the Form List
56
  2. View or download the PDF from a form entry.
57
 
58
  == Changelog ==
59
 
 
 
 
 
 
 
60
  = 1.0.0 =
61
  * First release.
 
 
 
 
 
2
  Contributors: blueliquiddesigns
3
  Donate link: http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/
4
  Tags: gravity, forms, pdf, automation, attachment
5
+ Requires at least: 3.0
6
+ Tested up to: 3.4
7
+ Stable tag: 1.1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ Expanding on the good work of 'rposborne', who created the original [Gravity Forms PDF Plugin](http://wordpress.org/extend/plugins/gravity-forms-pdf/), the extended version overhauls the rendering process so that developers now have more control over the creation of PDFs.
16
 
17
  **Features**
18
 
21
  * Create multiple PDF templates
22
  * View and download a PDF via the administrator interface
23
  * Simple function to output PDF via template / plugin
24
+ * Works with Gravity Forms Signature Add-On
25
 
26
  **Tutorial**
27
  [Head to Blue Liquid Designs](http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/) - the developer of the extended Gravity Forms PDF plugin - and view everything you need to know installing, configuring and using the plugin.
28
 
29
  **Demo**
30
+ You can see it in action [on the Blue Liquid Designs website](http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/#gf-demo).
31
 
32
  == Installation ==
33
 
34
  This section describes how to install the plugin and get it working.
35
 
36
  1. Upload this plugin to your website and activate it
37
+ 2. Modify the PDF template file, pdf-print-entry.php, inside the gravity-forms-pdf-extended plugin folder to suit your requirements.
38
+ 3. Create a form you want to PDF and configure notifications
39
+ 4. To create the PDF on the fly and add as an email attachment read the documentation: http://blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/
40
 
41
  == Frequently Asked Questions ==
42
 
43
  = I get the error message: Fatal error: Call to undefined method DOMText::getAttribute() on line ###. =
44
+ This is generally caused by invalid HTML. [See The Template section](http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/#gf-the-template) for an easy method to debug the issue.
45
 
46
  = I added an image to the template file and got the error 'Image not readable or empty'. =
47
+ Make sure you use an absolute path to the file e.g. http://www.your-site.com/my-image.jpg. Also, check that the 'temp' folder in ../gravity-forms-pdf-extended/dompdf/ is writable by your web server.
48
 
49
  = I want to have multiple PDF template files. =
50
  Copy the *pdf-print-entry.php* file (located in the plugin directory) and pass the new template name to the PDF_Generator() function inside the gform_pdf_create() function.
54
 
55
  == Screenshots ==
56
 
57
+ 1. View PDF From the Form List
58
  2. View or download the PDF from a form entry.
59
 
60
  == Changelog ==
61
 
62
+ = 1.1.0 =
63
+ * Now compatible with Gravity Forms Signature Add-On
64
+ * Moved the field data functions out side of the Gravity Forms core so users can freely style their form information (located in pdf-entry-detail.php)
65
+ * Simplified the field data output
66
+ * Fixed bug when using product information
67
+
68
  = 1.0.0 =
69
  * First release.
70
+
71
+ == Upgrade Notice ==
72
+
73
+ = 1.1.0 =
74
+ Compatible with Gravity Forms Signature Add-On, numerous bug fixes and more control over template.
pdf-entry-detail.php ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class GFEntryDetail{
3
+
4
+ /* NEED THIS FUNCTION - BLD */
5
+ public static function notes_grid($notes, $is_editable, $emails = null, $autoresponder_subject=""){
6
+ if(sizeof($notes) > 0 && $is_editable && GFCommon::current_user_can_any("gravityforms_edit_entry_notes")){
7
+ ?>
8
+ <div class="alignleft actions" style="padding:3px 0;">
9
+ <label class="hidden" for="bulk_action"><?php _e(" Bulk action", "gravityforms") ?></label>
10
+ <select name="bulk_action" id="bulk_action">
11
+ <option value=''><?php _e(" Bulk action ", "gravityforms") ?></option>
12
+ <option value='delete'><?php _e("Delete", "gravityforms") ?></option>
13
+ </select>
14
+ <?php
15
+ $apply_button = '<input type="submit" class="button" value="' . __("Apply", "gravityforms") . '" onclick="jQuery(\'#action\').val(\'bulk\');" style="width: 50px;" />';
16
+ echo apply_filters("gform_notes_apply_button", $apply_button);
17
+ ?>
18
+ </div>
19
+ <?php
20
+ }
21
+ ?>
22
+ <table class="widefat fixed entry-detail-notes" cellspacing="0">
23
+ <?php
24
+ if(!$is_editable){
25
+ ?>
26
+ <thead>
27
+ <tr>
28
+ <th id="notes">Notes</th>
29
+ </tr>
30
+ </thead>
31
+ <?php
32
+ }
33
+ ?>
34
+ <tbody id="the-comment-list" class="list:comment">
35
+ <?php
36
+ $count = 0;
37
+ $notes_count = sizeof($notes);
38
+ foreach($notes as $note){
39
+ $count++;
40
+ $is_last = $count >= $notes_count ? true : false;
41
+ ?>
42
+ <tr valign="top">
43
+ <?php
44
+ if($is_editable && GFCommon::current_user_can_any("gravityforms_edit_entry_notes")){
45
+ ?>
46
+ <th class="check-column" scope="row" style="padding:9px 3px 0 0">
47
+ <input type="checkbox" value="<?php echo $note->id ?>" name="note[]"/>
48
+ </th>
49
+ <td colspan="2">
50
+ <?php
51
+ }
52
+ else{
53
+ ?>
54
+ <td class="entry-detail-note<?php echo $is_last ? " lastrow" : "" ?>">
55
+ <?php
56
+ }
57
+ ?>
58
+ <div style="margin-top:4px;">
59
+ <div class="note-avatar"><?php echo get_avatar($note->user_id, 48);?></div>
60
+ <h6 class="note-author"> <?php echo esc_html($note->user_name)?></h6>
61
+ <p style="line-height:130%; text-align:left; margin-top:3px;"><a href="mailto:<?php echo esc_attr($note->user_email)?>"><?php echo esc_html($note->user_email) ?></a><br />
62
+ <?php _e("added on", "gravityforms"); ?> <?php echo esc_html(GFCommon::format_date($note->date_created, false)) ?></p>
63
+ </div>
64
+ <div class="detail-note-content"><?php echo esc_html($note->value) ?></div>
65
+ </td>
66
+
67
+ </tr>
68
+ <?php
69
+ }
70
+ if($is_editable && GFCommon::current_user_can_any("gravityforms_edit_entry_notes")){
71
+ ?>
72
+ <tr>
73
+ <td colspan="3" style="padding:10px;" class="lastrow">
74
+ <textarea name="new_note" style="width:100%; height:50px; margin-bottom:4px;"></textarea>
75
+ <?php
76
+ $note_button = '<input type="submit" name="add_note" value="' . __("Add Note", "gravityforms") . '" class="button" style="width:60px;" onclick="jQuery(\'#action\').val(\'add_note\');"/>';
77
+ echo apply_filters("gform_addnote_button", $note_button);
78
+
79
+ if(!empty($emails)){ ?>
80
+ &nbsp;&nbsp;
81
+ <span>
82
+ <select name="gentry_email_notes_to" onchange="if(jQuery(this).val() != '') {jQuery('#gentry_email_subject_container').css('display', 'inline');} else{jQuery('#gentry_email_subject_container').css('display', 'none');}">
83
+ <option value=""><?php _e("Also email this note to", "gravityforms") ?></option>
84
+ <?php foreach($emails as $email){ ?>
85
+ <option value="<?php echo $email ?>"><?php echo $email ?></option>
86
+ <?php } ?>
87
+ </select>
88
+ &nbsp;&nbsp;
89
+
90
+ <span id='gentry_email_subject_container' style="display:none;">
91
+ <label for="gentry_email_subject"><?php _e("Subject:", "gravityforms") ?></label>
92
+ <input type="text" name="gentry_email_subject" id="gentry_email_subject" value="<?php echo $autoresponder_subject ?>" style="width:35%"/>
93
+ </span>
94
+ </span>
95
+ <?php } ?>
96
+ </td>
97
+ </tr>
98
+ <?php
99
+ }
100
+ ?>
101
+ </tbody>
102
+ </table>
103
+ <?php
104
+ }
105
+ /* NEED THIS FUNCTION - BLD */
106
+ public static function lead_detail_grid($form, $lead, $allow_display_empty_fields=false){
107
+ $form_id = $form["id"];
108
+ $display_empty_fields = false;
109
+ if($allow_display_empty_fields){
110
+ $display_empty_fields = rgget("gf_display_empty_fields", $_COOKIE);
111
+ }
112
+
113
+ ?>
114
+ <table cellspacing="0" class="widefat fixed entry-detail-view">
115
+ <thead>
116
+ <tr>
117
+ <th id="details">
118
+ <?php echo $form["title"]?> <!--: <?php _e("Entry # ", "gravityforms") ?> <?php echo $lead["id"] ?> -->
119
+ </th>
120
+ <th style="width:140px; font-size:10px; text-align: right;">
121
+ <?php
122
+ if($allow_display_empty_fields){
123
+ ?>
124
+ <input type="checkbox" id="gentry_display_empty_fields" <?php echo $display_empty_fields ? "checked='checked'" : "" ?> onclick="ToggleShowEmptyFields();"/>&nbsp;&nbsp;<label for="gentry_display_empty_fields"><?php _e("show empty fields", "gravityforms") ?></label>
125
+ <?php
126
+ }
127
+ ?>
128
+ </th>
129
+ </tr>
130
+ </thead>
131
+ <tbody>
132
+ <?php
133
+ $count = 0;
134
+ $field_count = sizeof($form["fields"]);
135
+ $has_product_fields = false;
136
+
137
+ foreach($form["fields"] as $field){
138
+ switch(RGFormsModel::get_input_type($field)){
139
+ case "section" :
140
+ if(!GFCommon::is_section_empty($field, $form, $lead) || $display_empty_fields){
141
+ $count++;
142
+ $is_last = $count >= $field_count ? true : false;
143
+ ?>
144
+ <tr>
145
+ <td colspan="2" class="entry-view-section-break<?php echo $is_last ? " lastrow" : ""?>"><?php echo esc_html(GFCommon::get_label($field))?></td>
146
+ </tr>
147
+ <?php
148
+ }
149
+ break;
150
+
151
+ case "captcha":
152
+ case "html":
153
+ case "password":
154
+ case "page":
155
+ //ignore captcha, html, password, page field
156
+ break;
157
+ case "signature":
158
+ $value = RGFormsModel::get_lead_field_value($lead, $field);
159
+ $folder = site_url() . "/wp-content/uploads/gravity_forms/signatures/";
160
+ $display_value = '<img src="'. $folder.$value .'" alt="Signature" width="100" height="60" />';
161
+
162
+ /*$count++;*/
163
+ $is_last = $count >= $field_count && !$has_product_fields ? true : false;
164
+ $last_row = $is_last ? " lastrow" : "";
165
+ /*$even = ($count%2) ? ' odd' : ' even';*/
166
+
167
+ $content = '
168
+ <tr>
169
+ <td colspan="2" class="entry-view-field-name"> '. esc_html(GFCommon::get_label($field)) .'</td>
170
+ </tr>
171
+ <tr>
172
+ <td colspan="2" class="entry-view-field-value' . $last_row .'">' . $display_value . '</td>
173
+ </tr>';
174
+
175
+ echo $content;
176
+ break;
177
+
178
+ default:
179
+
180
+ //ignore product fields as they will be grouped together at the end of the grid
181
+ if(GFCommon::is_product_field($field["type"])){
182
+ $has_product_fields = true;
183
+ continue;
184
+ }
185
+
186
+ $value = RGFormsModel::get_lead_field_value($lead, $field);
187
+ $display_value = GFCommon::get_lead_field_display($field, $value, $lead["currency"]);
188
+
189
+ $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $lead, $form);
190
+
191
+ if($display_empty_fields || !empty($display_value) || $display_value === "0"){
192
+ $count++;
193
+ $is_last = $count >= $field_count && !$has_product_fields ? true : false;
194
+ $last_row = $is_last ? " lastrow" : "";
195
+ $even = ($count%2) ? ' odd' : ' even';
196
+
197
+ $display_value = empty($display_value) && $display_value !== "0" ? "&nbsp;" : $display_value;
198
+
199
+ $content = '
200
+ <tr>
201
+ <td colspan="2" class="entry-view-field-value' . $last_row . $even . '"><strong>' . esc_html(GFCommon::get_label($field)) . '</strong> ' . $display_value . '</td>
202
+ </tr>';
203
+
204
+ $content = apply_filters("gform_field_content", $content, $field, $value, $lead["id"], $form["id"]);
205
+
206
+ echo $content;
207
+
208
+ }
209
+ break;
210
+ }
211
+
212
+ }
213
+ $products = array();
214
+ if($has_product_fields){
215
+ $products = GFCommon::get_product_fields($form, $lead);
216
+ if(!empty($products["products"])){
217
+ ?>
218
+ <tr>
219
+ <td colspan="2" class="entry-view-field-name"><?php echo apply_filters("gform_order_label_{$form["id"]}", apply_filters("gform_order_label", __("Order", "gravityforms"), $form["id"]), $form["id"]) ?></td>
220
+ </tr>
221
+ <tr>
222
+ <td colspan="2" class="entry-view-field-value lastrow">
223
+ <table class="entry-products" cellspacing="0" width="97%">
224
+ <colgroup>
225
+ <col class="entry-products-col1" />
226
+ <col class="entry-products-col2" />
227
+ <col class="entry-products-col3" />
228
+ <col class="entry-products-col4" />
229
+ </colgroup>
230
+ <thead>
231
+ <tr>
232
+ <th scope="col"><?php echo apply_filters("gform_product_{$form_id}", apply_filters("gform_product", __("Product", "gravityforms"), $form_id), $form_id) ?></th>
233
+ <th scope="col" class="textcenter"><?php echo apply_filters("gform_product_qty_{$form_id}", apply_filters("gform_product_qty", __("Qty", "gravityforms"), $form_id), $form_id) ?></th>
234
+ <th scope="col"><?php echo apply_filters("gform_product_unitprice_{$form_id}", apply_filters("gform_product_unitprice", __("Unit Price", "gravityforms"), $form_id), $form_id) ?></th>
235
+ <th scope="col"><?php echo apply_filters("gform_product_price_{$form_id}", apply_filters("gform_product_price", __("Price", "gravityforms"), $form_id), $form_id) ?></th>
236
+ </tr>
237
+ </thead>
238
+ <tbody>
239
+ <?php
240
+
241
+ $total = 0;
242
+ foreach($products["products"] as $product){
243
+ ?>
244
+ <tr>
245
+ <td>
246
+ <div class="product_name"><?php echo esc_html($product["name"])?></div>
247
+
248
+ <?php
249
+ $price = GFCommon::to_number($product["price"]);
250
+ if(is_array(rgar($product,"options"))){
251
+ echo '<ul class="product_options">';
252
+ $count = sizeof($product["options"]);
253
+ $index = 1;
254
+ foreach($product["options"] as $option){
255
+ $price += GFCommon::to_number($option["price"]);
256
+ $class = $index == $count ? " class='lastitem'" : "";
257
+ $index++;
258
+ ?>
259
+ <li<?php echo $class?>><?php echo $option["option_label"]?></li>
260
+ <?php
261
+ }
262
+ echo '</ul>';
263
+ }
264
+ $subtotal = floatval($product["quantity"]) * $price;
265
+ $total += $subtotal;
266
+ ?>
267
+
268
+ </td>
269
+ <td class="textcenter"><?php echo $product["quantity"] ?></td>
270
+ <td><?php echo GFCommon::to_money($price, $lead["currency"]) ?></td>
271
+ <td><?php echo GFCommon::to_money($subtotal, $lead["currency"]) ?></td>
272
+ </tr>
273
+ <?php
274
+ }
275
+ $total += floatval($products["shipping"]["price"]);
276
+ ?>
277
+ </tbody>
278
+ <tfoot>
279
+ <?php
280
+ if(!empty($products["shipping"]["name"])){
281
+ ?>
282
+ <tr>
283
+ <td colspan="2" rowspan="2" class="emptycell">&nbsp;</td>
284
+ <td class="textright shipping"><?php echo $products["shipping"]["name"] ?></td>
285
+ <td class="shipping_amount"><?php echo GFCommon::to_money($products["shipping"]["price"], $lead["currency"])?>&nbsp;</td>
286
+ </tr>
287
+ <?php
288
+ }
289
+ ?>
290
+ <tr>
291
+ <?php
292
+ if(empty($products["shipping"]["name"])){
293
+ ?>
294
+ <td colspan="2" class="emptycell">&nbsp;</td>
295
+ <?php
296
+ }
297
+ ?>
298
+ <td class="textright grandtotal"><?php _e("Total", "gravityforms") ?></td>
299
+ <td class="grandtotal_amount"><?php echo GFCommon::to_money($total, $lead["currency"])?></td>
300
+ </tr>
301
+ </tfoot>
302
+ </table>
303
+ </td>
304
+ </tr>
305
+
306
+ <?php
307
+ }
308
+ }
309
+ ?>
310
+ </tbody>
311
+ </table>
312
+ <?php
313
+ }
314
+ }
315
+ ?>
pdf-print-entry.php CHANGED
@@ -1,93 +1,91 @@
1
- <?php
2
-
3
- //For backwards compatibility, load wordpress if it hasn't been loaded yet
4
- //Will be used if this file is being called directly
5
- if(!class_exists("RGForms")){
6
- for ( $i = 0; $i < $depth = 10; $i++ ) {
7
- $wp_root_path = str_repeat( '../', $i );
8
-
9
- if ( file_exists("{$wp_root_path}wp-load.php" ) ) {
10
- require_once("{$wp_root_path}wp-load.php");
11
- require_once("{$wp_root_path}wp-admin/includes/admin.php");
12
- break;
13
- }
14
- }
15
-
16
- //redirect to the login page if user is not authenticated
17
- auth_redirect();
18
- }
19
-
20
- if(!GFCommon::current_user_can_any("gravityforms_view_entries") && !defined('GF_FORM_ID') )
21
- die(__("You don't have adequate permission to view entries.", "gravityforms"));
22
-
23
- $form_id = (defined('GF_FORM_ID')) ? GF_FORM_ID : absint(rgget("fid"));
24
- $lead_ids = (defined('GF_LEAD_ID')) ? array(GF_LEAD_ID) : explode(',', rgget("lid"));
25
- $page_break = rgget("page_break") ? 'print-page-break' : false;
26
-
27
- // sort lead IDs numerically
28
- sort($lead_ids);
29
-
30
- if(empty($form_id) || empty($lead_ids))
31
- die(__("Form Id and Lead Id are required parameters.", "gravityforms"));
32
-
33
- $form = RGFormsModel::get_form_meta($form_id);
34
-
35
- ?>
36
-
37
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
38
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
39
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
40
- <head>
41
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
42
- <meta name="keywords" content="" />
43
- <meta name="description" content="" />
44
- <meta name="MSSmartTagsPreventParsing" content="true" />
45
- <meta name="Robots" content="noindex, nofollow" />
46
- <meta http-equiv="Imagetoolbar" content="No" />
47
- <title>
48
- Print Preview :
49
- <?php echo $form["title"] ?> :
50
- <?php echo count($lead_ids) > 1 ? __("Entry # ", "gravityforms") . $lead_ids[0] : 'Bulk Print' ?>
51
- </title>
52
- <link rel='stylesheet' href='<?php echo GFCommon::get_base_url() ?>/css/print.css' type='text/css' />
53
- <link rel='stylesheet' href='<?php echo bloginfo('url') ?>/wp-content/plugins/gravity-forms-pdf-extended/template.css' type='text/css' />
54
- </head>
55
- <body>
56
-
57
- <div id="print_preview_hdr" style="display:none">
58
- <div><span class="actionlinks"><a href="javascript:;" onclick="window.print();" class="header-print-link">print this page</a> | <a href="javascript:window.close()" class="close_window"><?php _e("close window", "gravityforms") ?></a></span><?php _e("Print Preview", "gravityforms") ?></div>
59
- </div>
60
-
61
-
62
- <div id="view-container">
63
-
64
- <?php
65
- /* Add image and copy above here to show before the entry details */
66
-
67
- require_once(GFCommon::get_base_path() . "/entry_detail.php");
68
-
69
- foreach($lead_ids as $lead_id){
70
-
71
- $lead = RGFormsModel::get_lead($lead_id);
72
-
73
- do_action("gform_print_entry_header", $form, $lead);
74
-
75
- GFEntryDetail::lead_detail_grid($form, $lead);
76
-
77
- if(rgget('notes')){
78
- $notes = RGFormsModel::get_lead_notes($lead["id"]);
79
- if(!empty($notes))
80
- GFEntryDetail::notes_grid($notes, false);
81
- }
82
-
83
- // output entry divider/page break
84
- if(array_search($lead_id, $lead_ids) < count($lead_ids) - 1)
85
- echo '<div class="print-hr ' . $page_break . '"></div>';
86
-
87
- do_action("gform_print_entry_footer", $form, $lead);
88
- }
89
-
90
- ?>
91
- </div>
92
- </body>
93
  </html>
1
+ <?php
2
+
3
+ //For backwards compatibility, load wordpress if it hasn't been loaded yet
4
+ //Will be used if this file is being called directly
5
+ if(!class_exists("RGForms")){
6
+ for ( $i = 0; $i < $depth = 10; $i++ ) {
7
+ $wp_root_path = str_repeat( '../', $i );
8
+
9
+ if ( file_exists("{$wp_root_path}wp-load.php" ) ) {
10
+ require_once("{$wp_root_path}wp-load.php");
11
+ require_once("{$wp_root_path}wp-admin/includes/admin.php");
12
+ break;
13
+ }
14
+ }
15
+
16
+ //redirect to the login page if user is not authenticated
17
+ auth_redirect();
18
+ }
19
+
20
+ if(!GFCommon::current_user_can_any("gravityforms_view_entries") && !defined('GF_FORM_ID') )
21
+ die(__("You don't have adequate permission to view entries.", "gravityforms"));
22
+
23
+ $form_id = (defined('GF_FORM_ID')) ? GF_FORM_ID : absint(rgget("fid"));
24
+ $lead_ids = (defined('GF_LEAD_ID')) ? array(GF_LEAD_ID) : explode(',', rgget("lid"));
25
+ $page_break = rgget("page_break") ? 'print-page-break' : false;
26
+
27
+ // sort lead IDs numerically
28
+ sort($lead_ids);
29
+
30
+ if(empty($form_id) || empty($lead_ids))
31
+ die(__("Form Id and Lead Id are required parameters.", "gravityforms"));
32
+
33
+ $form = RGFormsModel::get_form_meta($form_id);
34
+
35
+ ?>
36
+
37
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
38
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
39
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
40
+ <head>
41
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
42
+ <meta name="keywords" content="" />
43
+ <meta name="description" content="" />
44
+ <meta name="MSSmartTagsPreventParsing" content="true" />
45
+ <meta name="Robots" content="noindex, nofollow" />
46
+ <meta http-equiv="Imagetoolbar" content="No" />
47
+ <title>
48
+ Print Preview :
49
+ <?php echo $form["title"] ?> :
50
+ <?php echo count($lead_ids) > 1 ? __("Entry # ", "gravityforms") . $lead_ids[0] : 'Bulk Print' ?>
51
+ </title>
52
+ <link rel='stylesheet' href='<?php echo GFCommon::get_base_url() ?>/css/print.css' type='text/css' />
53
+ <link rel='stylesheet' href='<?php echo bloginfo('url') ?>/wp-content/plugins/gravity-forms-pdf-extended/template.css' type='text/css' />
54
+ </head>
55
+ <body>
56
+
57
+ <div id="print_preview_hdr" style="display:none"></div>
58
+
59
+
60
+ <div id="view-container">
61
+
62
+ <?php
63
+ /* Add image and copy above here to show before the entry details */
64
+
65
+ require_once(ABSPATH. "wp-content/plugins/gravity-forms-pdf-extended/pdf-entry-detail.php");
66
+
67
+ foreach($lead_ids as $lead_id){
68
+
69
+ $lead = RGFormsModel::get_lead($lead_id);
70
+
71
+ do_action("gform_print_entry_header", $form, $lead);
72
+
73
+ GFEntryDetail::lead_detail_grid($form, $lead);
74
+
75
+ if(rgget('notes')){
76
+ $notes = RGFormsModel::get_lead_notes($lead["id"]);
77
+ if(!empty($notes))
78
+ GFEntryDetail::notes_grid($notes, false);
79
+ }
80
+
81
+ // output entry divider/page break
82
+ if(array_search($lead_id, $lead_ids) < count($lead_ids) - 1)
83
+ echo '<div class="print-hr ' . $page_break . '"></div>';
84
+
85
+ do_action("gform_print_entry_footer", $form, $lead);
86
+ }
87
+
88
+ ?>
89
+ </div>
90
+ </body>
 
 
91
  </html>
pdf.php CHANGED
@@ -1,67 +1,115 @@
1
- <?php
2
-
3
- /*
4
- Plugin Name: Gravity Forms PDF Extended
5
- Plugin URI: http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/
6
- Description: Renders PDFs so they can be easily attached to notifications, viewed and downloaded.
7
- Version: 1.0.0
8
- Author: Blue Liquid Designs
9
- Author URI: http://www.blueliquiddesigns.com.au
10
-
11
- ------------------------------------------------------------------------
12
-
13
- This program is free software; you can redistribute it and/or modify
14
- it under the terms of the GNU General Public License as published by
15
- the Free Software Foundation; either version 2 of the License, or
16
- (at your option) any later version.
17
-
18
- This program is distributed in the hope that it will be useful,
19
- but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- GNU General Public License for more details.
22
-
23
- */
24
-
25
- /*
26
- * Handles the admin area routing
27
- * See render_to_pdf.php for PDF Output Functions
28
- */
29
-
30
- add_action('gform_entries_first_column_actions', 'pdf_link', 10, 4);
31
- add_action("gform_entry_info", "detail_pdf_link", 10, 2);
32
- add_action('wp', 'process_exterior_pages');
33
-
34
- //Link for Entry Detail View (Provide both View Link and Download)
35
- function detail_pdf_link($form_id, $lead) {
36
- $lead_id = $lead['id'];
37
- echo "PDF: ";
38
- echo "<a href=\"javascript:;\" onclick=\"var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='".site_url()."/?gf_pdf=print-entry&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\" class=\"button\"> View</a>";
39
- echo " <a href=\"javascript:;\" onclick=\"var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='".site_url()."/?gf_pdf=print-entry&download=1&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\" class=\"button\"> Download</a>";
40
- }
41
-
42
- // Made this first... figured i would leave it in. View link on the Entry list view.
43
- function pdf_link($form_id, $field_id, $value, $lead) {
44
- $lead_id = $lead['id'];
45
- echo "| <a href=\"javascript:;\" onclick=\"var notes_qs = '&notes=1'; var url='".site_url()."/?gf_pdf=print-entry&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\"> View PDF</a>";
46
- }
47
-
48
- //Handle Incoming route. Look for GF_PDF namespace
49
- function process_exterior_pages(){
50
- if(rgempty("gf_pdf", $_GET))
51
- return;
52
-
53
- //ensure users are logged in
54
- if(!is_user_logged_in())
55
- auth_redirect();
56
-
57
- switch(rgget("gf_pdf")){
58
- case "print-entry" :
59
- require_once("render_to_pdf.php");
60
- /* call the creation class */
61
- $output = ($_GET['download'] == 1) ? 'download' : 'view';
62
- PDF_Generator((int) $_GET['fid'], (int) $_GET['lid'], $output);
63
- break;
64
- }
65
- exit();
66
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  ?>
1
+ <?php
2
+
3
+ /*
4
+ Plugin Name: Gravity Forms PDF Extended
5
+ Plugin URI: http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/
6
+ Description: Renders PDFs so they can be easily attached to notifications, viewed and downloaded.
7
+ Version: 1.1.0
8
+ Author: Blue Liquid Designs
9
+ Author URI: http://www.blueliquiddesigns.com.au
10
+
11
+ ------------------------------------------------------------------------
12
+
13
+ This program is free software; you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License as published by
15
+ the Free Software Foundation; either version 2 of the License, or
16
+ (at your option) any later version.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ */
24
+
25
+ /*
26
+ * Handles the admin area routing
27
+ * See render_to_pdf.php for PDF Output Functions
28
+ */
29
+
30
+ add_action('gform_entries_first_column_actions', 'pdf_link', 10, 4);
31
+ add_action("gform_entry_info", "detail_pdf_link", 10, 2);
32
+ add_action('wp', 'process_exterior_pages');
33
+
34
+
35
+ add_action('admin_init', 'gfe_init', 9);
36
+ /**
37
+ * Check to see if Gravity Forms is actually installed
38
+ */
39
+ function gfe_init()
40
+ {
41
+ if(!class_exists("RGForms"))
42
+ {
43
+ /* throw error to the admin notice bar */
44
+ add_action('admin_notices', 'gf_not_installed');
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Gravity Forms hasn't been installed so throw error.
50
+ * We make sure the user hasn't already dismissed the error
51
+ */
52
+ function gf_not_installed()
53
+ {
54
+ global $current_user;
55
+ $user_id = $current_user->ID;
56
+
57
+ /* Check that the user hasn't already clicked to ignore the message */
58
+ if ( ! get_user_meta($user_id, 'gfpdfe_ignore_notice') ) {
59
+ // Shows as an error message. You could add a link to the right page if you wanted.
60
+ echo '<div id="message" class="error"><p>';
61
+ printf(__('You need to install <a href="http://www.gravityforms.com/">Gravity Forms</a> to use the Gravity Forms PDF Extended Plugin. | <a href="%1$s">Hide Notice</a>'), '?gfpdfe_nag_ignore=1');
62
+ echo '</p></div>';
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Gravity Forms hasn't been installed and user is dismissing the error thrown
68
+ */
69
+ add_action('admin_init', 'gfpdfe_nag_ignore');
70
+ function gfpdfe_nag_ignore() {
71
+ global $current_user;
72
+ $user_id = $current_user->ID;
73
+ /* If user clicks to ignore the notice, add that to their user meta */
74
+ if ( isset($_GET['gfpdfe_nag_ignore']) && $_GET['gfpdfe_nag_ignore'] == 1 ) {
75
+ add_user_meta($user_id, 'gfpdfe_ignore_notice', 'true', true);
76
+ }
77
+ }
78
+
79
+ //Link for Entry Detail View (Provide both View Link and Download)
80
+ function detail_pdf_link($form_id, $lead) {
81
+ $lead_id = $lead['id'];
82
+ echo "PDF: ";
83
+ echo "<a href=\"javascript:;\" onclick=\"var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='".site_url()."/?gf_pdf=print-entry&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\" class=\"button\"> View</a>";
84
+ echo " <a href=\"javascript:;\" onclick=\"var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='".site_url()."/?gf_pdf=print-entry&download=1&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\" class=\"button\"> Download</a>";
85
+ }
86
+
87
+ // Made this first... figured i would leave it in. View link on the Entry list view.
88
+ function pdf_link($form_id, $field_id, $value, $lead) {
89
+ $lead_id = $lead['id'];
90
+ echo "| <a href=\"javascript:;\" onclick=\"var notes_qs = '&notes=1'; var url='".site_url()."/?gf_pdf=print-entry&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\"> View PDF</a>";
91
+ }
92
+
93
+ //Handle Incoming route. Look for GF_PDF namespace
94
+ function process_exterior_pages(){
95
+ if(rgempty("gf_pdf", $_GET))
96
+ return;
97
+
98
+ //ensure users are logged in
99
+ if(!is_user_logged_in())
100
+ auth_redirect();
101
+
102
+ switch(rgget("gf_pdf")){
103
+ case "print-entry" :
104
+ require_once("render_to_pdf.php");
105
+ /* call the creation class */
106
+ $output = ($_GET['download'] == 1) ? 'download' : 'view';
107
+ PDF_Generator((int) $_GET['fid'], (int) $_GET['lid'], $output);
108
+ break;
109
+ }
110
+ exit();
111
+ }
112
+
113
+
114
+
115
  ?>
template.css CHANGED
@@ -1 +1,9 @@
1
- /* Put your PDF stylesheet details here */
 
 
 
 
 
 
 
 
1
+ /* Put your PDF stylesheet details here */
2
+
3
+ td.entry-view-field-value {
4
+ padding-left: 9px;
5
+ }
6
+
7
+ .even {
8
+ background: #EAF2FA;
9
+ }