Gravity PDF - Version 1.2.0

Version Description

  • Template files moved to the plugin's template folder
  • Sample Form installed so developers have a working example to modify
  • Fixed bug when using WordPress in another directory to the site
Download this release

Release Info

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

Code changes from version 1.1.0 to 1.2.0

README.txt CHANGED
@@ -2,13 +2,13 @@
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
 
11
- Gravity Forms PDF Extended allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission.
12
 
13
  == Description ==
14
 
@@ -18,16 +18,18 @@ Expanding on the good work of 'rposborne', who created the original [Gravity For
18
 
19
  * Save PDF File on user submission of a Gravity Form so it can be attached to a notification
20
  * Customise the PDF template without affecting the core Gravity Form Plugin
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
 
@@ -36,7 +38,7 @@ This section describes how to install the plugin and get it working.
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
 
@@ -59,6 +61,13 @@ By deleting the .htaccess file in the 'output' folder you'll be able to access t
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)
@@ -67,8 +76,3 @@ By deleting the .htaccess file in the 'output' folder you'll be able to access t
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.
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.2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Gravity Forms PDF Extended allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission.
12
 
13
  == Description ==
14
 
18
 
19
  * Save PDF File on user submission of a Gravity Form so it can be attached to a notification
20
  * Customise the PDF template without affecting the core Gravity Form Plugin
21
+ * Multiple PDF Templates
22
+ * Output individual form fields in the template - like MERGETAGS.
23
  * View and download a PDF via the administrator interface
24
  * Simple function to output PDF via template / plugin
25
  * Works with Gravity Forms Signature Add-On
26
+ * Installs a sample form using the new MERGETAGS-style template to help the setup
27
 
28
  **Tutorial**
29
  [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.
30
 
31
  **Demo**
32
+ You can see it in action [on the Blue Liquid Designs website](http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/#tab-demo).
33
 
34
  == Installation ==
35
 
38
  1. Upload this plugin to your website and activate it
39
  2. Modify the PDF template file, pdf-print-entry.php, inside the gravity-forms-pdf-extended plugin folder to suit your requirements.
40
  3. Create a form you want to PDF and configure notifications
41
+ 4. To create the PDF on the fly and add as an email attachment read the tutorial: http://blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/
42
 
43
  == Frequently Asked Questions ==
44
 
61
 
62
  == Changelog ==
63
 
64
+ Remember to always make a backup of your plugin before upgrading otherwise you'll loose your custom PDF template file.
65
+
66
+ = 1.2.0 =
67
+ * Template files moved to the plugin's template folder
68
+ * Sample Form installed so developers have a working example to modify
69
+ * Fixed bug when using WordPress in another directory to the site
70
+
71
  = 1.1.0 =
72
  * Now compatible with Gravity Forms Signature Add-On
73
  * 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)
76
 
77
  = 1.0.0 =
78
  * First release.
 
 
 
 
 
dompdf/_notes/dwsync.xml DELETED
@@ -1,21 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
2
- <dwsync>
3
- <file name="LICENSE.LGPL" server="ftp.danielmarks.com.au" local="129908529600000000" remote="129908529600000000" />
4
- <file name="changelog.txt" server="ftp.danielmarks.com.au" local="129908529600000000" remote="129908529600000000" />
5
- <file name="docblox.dist.xml" server="ftp.danielmarks.com.au" local="129908529600000000" remote="129908529600000000" />
6
- <file name="dompdf.php" server="ftp.danielmarks.com.au" local="129908529600000000" remote="129908529600000000" />
7
- <file name="dompdf_config.custom.inc.php" server="ftp.danielmarks.com.au" local="129908529600000000" remote="129908550600000000" />
8
- <file name="dompdf_config.inc.php" server="ftp.danielmarks.com.au" local="129908569017039464" remote="129908568600000000" />
9
- <file name="index.php" server="ftp.danielmarks.com.au" local="129908529600000000" remote="129908529600000000" />
10
- <file name="load_font.php" server="ftp.danielmarks.com.au" local="129908529600000000" remote="129908529600000000" />
11
- <file name="readme.html" server="ftp.danielmarks.com.au" local="129908529600000000" remote="129908529600000000" />
12
- <file name="changelog.txt" server="216.235.107.57" local="129908529600000000" remote="129913284600000000" />
13
- <file name="docblox.dist.xml" server="216.235.107.57" local="129908529600000000" remote="129913284600000000" />
14
- <file name="dompdf.php" server="216.235.107.57" local="129908529600000000" remote="129913285200000000" />
15
- <file name="dompdf_config.custom.inc.php" server="216.235.107.57" local="129914800781916146" remote="129914260800000000" />
16
- <file name="dompdf_config.inc.php" server="216.235.107.57" local="129908569017039464" remote="129913285200000000" />
17
- <file name="index.php" server="216.235.107.57" local="129908529600000000" remote="129913290600000000" />
18
- <file name="LICENSE.LGPL" server="216.235.107.57" local="129908529600000000" remote="129913312800000000" />
19
- <file name="load_font.php" server="216.235.107.57" local="129908529600000000" remote="129913312800000000" />
20
- <file name="readme.html" server="216.235.107.57" local="129908529600000000" remote="129913312800000000" />
21
- </dwsync>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
example-form.xml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <forms version="1.6.7">
3
+ <form labelPlacement="top_label" useCurrentUserAsAuthor="1">
4
+ <title><![CDATA[Gravity Forms PDF Extended Custom Template Sample]]></title>
5
+ <description><![CDATA[This form will demonstrate the new power of the PDF Extended plugin. All form data is now pulling into an array so you can display individual fields in what ever format you need.]]></description>
6
+ <confirmation type="message">
7
+ <message><![CDATA[The sample PDF has been emailed to the Wordpress Admin email.]]></message>
8
+ </confirmation>
9
+ <button type="text">
10
+ <text><![CDATA[Submit]]></text>
11
+ </button>
12
+ <fields>
13
+ <field id="1" size="medium" type="name">
14
+ <label><![CDATA[Name]]></label>
15
+ <inputs>
16
+ <input id="1.3">
17
+ <label><![CDATA[First]]></label>
18
+ </input>
19
+ <input id="1.6">
20
+ <label><![CDATA[Last]]></label>
21
+ </input>
22
+ </inputs>
23
+ </field>
24
+ <field id="2" size="medium" type="address" addressType="international">
25
+ <label><![CDATA[Address]]></label>
26
+ <inputs>
27
+ <input id="2.1">
28
+ <label><![CDATA[Street Address]]></label>
29
+ </input>
30
+ <input id="2.2">
31
+ <label><![CDATA[Address Line 2]]></label>
32
+ </input>
33
+ <input id="2.3">
34
+ <label><![CDATA[City]]></label>
35
+ </input>
36
+ <input id="2.4">
37
+ <label><![CDATA[State / Province]]></label>
38
+ </input>
39
+ <input id="2.5">
40
+ <label><![CDATA[Zip / Postal Code]]></label>
41
+ </input>
42
+ <input id="2.6">
43
+ <label><![CDATA[Country]]></label>
44
+ </input>
45
+ </inputs>
46
+ </field>
47
+ <field id="3" size="medium" type="phone" phoneFormat="international">
48
+ <label><![CDATA[Phone]]></label>
49
+ </field>
50
+ </fields>
51
+ <descriptionPlacement><![CDATA[below]]></descriptionPlacement>
52
+ <notification>
53
+ <to><![CDATA[{admin_email}]]></to>
54
+ <subject><![CDATA[New submission from {form_title}]]></subject>
55
+ <message><![CDATA[{all_fields}]]></message>
56
+ </notification>
57
+ </form>
58
+ </forms>
images/BlueLiquidDesigns.jpg ADDED
Binary file
images/signature.png ADDED
Binary file
pdf-entry-detail.php CHANGED
@@ -311,5 +311,397 @@ class GFEntryDetail{
311
  </table>
312
  <?php
313
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  }
315
  ?>
311
  </table>
312
  <?php
313
  }
314
+
315
+ /* returns the form values as an array instead of pre-formated html */
316
+ public static function lead_detail_grid_array($form, $lead, $allow_display_empty_fields=false){
317
+ $form_id = $form["id"];
318
+ $display_empty_fields = false;
319
+ if($allow_display_empty_fields){
320
+ $display_empty_fields = rgget("gf_display_empty_fields", $_COOKIE);
321
+ }
322
+
323
+ $form_array['form_title'] = $form['title'];
324
+
325
+ $count = 0;
326
+ $field_count = sizeof($form["fields"]);
327
+ $has_product_fields = false;
328
+
329
+ foreach($form["fields"] as $field){
330
+ switch(RGFormsModel::get_input_type($field)){
331
+ case "section" :
332
+ break;
333
+
334
+ case "captcha":
335
+ case "html":
336
+ $form_array['html'][] = RGFormsModel::get_lead_field_value($lead, $field);
337
+ case "password":
338
+ case "page":
339
+ //ignore captcha, html, password, page field
340
+ break;
341
+ case "signature":
342
+ $value = RGFormsModel::get_lead_field_value($lead, $field);
343
+ $folder = site_url() . "/wp-content/uploads/gravity_forms/signatures/";
344
+ $form_array['signature'][] = '<img src="'. $folder.$value .'" alt="Signature" width="100" height="60" />';
345
+
346
+ /*$count++;*/
347
+ $is_last = $count >= $field_count && !$has_product_fields ? true : false;
348
+ $last_row = $is_last ? " lastrow" : "";
349
+ break;
350
+
351
+ default:
352
+ //ignore product fields as they will be grouped together at the end of the grid
353
+ if(GFCommon::is_product_field($field["type"])){
354
+ $has_product_fields = true;
355
+ continue;
356
+ }
357
+
358
+ $value = RGFormsModel::get_lead_field_value($lead, $field);
359
+ $form_array['field'][$field['label']] = GFEntryDetail::get_lead_field_display($field, $value, $lead["currency"]);
360
+
361
+ break;
362
+ }
363
+
364
+ }
365
+
366
+ $products = array();
367
+ if($has_product_fields){
368
+ $products = GFCommon::get_product_fields($form, $lead);
369
+ if(!empty($products["products"])){
370
+ foreach($products["products"] as $product){
371
+ $form_array['products'][] = array(
372
+ 'name' => esc_html($product['name']),
373
+ 'price' => esc_html($product["name"]),
374
+ 'options' => $product['options'],
375
+ 'quantity' => $product["quantity"],
376
+ 'shipping' => $products['shopping']);
377
+ }
378
+ }
379
+ }
380
+ return $form_array;
381
+ }
382
+
383
+
384
+
385
+ public static function get_lead_field_display($field, $value, $currency="", $use_text=false, $format="html", $media="screen"){
386
+
387
+ if($field['type'] == 'post_category')
388
+ $value = self::prepare_post_category_value($value, $field);
389
+
390
+ switch(RGFormsModel::get_input_type($field)){
391
+ case "name" :
392
+ if(is_array($value)){
393
+ $prefix = trim(rgget($field["id"] . ".2", $value));
394
+ $first = trim(rgget($field["id"] . ".3", $value));
395
+ $last = trim(rgget($field["id"] . ".6", $value));
396
+ $suffix = trim(rgget($field["id"] . ".8", $value));
397
+
398
+ return array('prefix' => $prefix, 'first' => $first, 'last' => $last, 'suffix' => $suffix);
399
+ }
400
+ else{
401
+ return $value;
402
+ }
403
+
404
+ break;
405
+ case "creditcard" :
406
+ if(is_array($value)){
407
+ $card_number = trim(rgget($field["id"] . ".1", $value));
408
+ $card_type = trim(rgget($field["id"] . ".4", $value));
409
+ $separator = $format == "html" ? "<br/>" : "\n";
410
+ return empty($card_number) ? "" : $card_type . $separator . $card_number;
411
+ }
412
+ else{
413
+ return "";
414
+ }
415
+ break;
416
+
417
+ case "address" :
418
+ if(is_array($value)){
419
+ $street_value = trim(rgget($field["id"] . ".1", $value));
420
+ $street2_value = trim(rgget($field["id"] . ".2", $value));
421
+ $city_value = trim(rgget($field["id"] . ".3", $value));
422
+ $state_value = trim(rgget($field["id"] . ".4", $value));
423
+ $zip_value = trim(rgget($field["id"] . ".5", $value));
424
+ $country_value = trim(rgget($field["id"] . ".6", $value));
425
+
426
+ $line_break = $format == "html" ? "<br />" : "\n";
427
+
428
+ $address_display_format = apply_filters("gform_address_display_format", "default");
429
+
430
+ $address['street'] = $street_value;
431
+ $address['street2'] = $street2_value;
432
+ $address['city'] = $city_value;
433
+ $address['state'] = $state_value;
434
+ $address['zip'] = $zip_value;
435
+ $address['country'] = $country_value;
436
+
437
+ return $address;
438
+ }
439
+ else{
440
+ return "";
441
+ }
442
+ break;
443
+
444
+ case "email" :
445
+ return GFCommon::is_valid_email($value) && $format == "html" ? $value : $value;
446
+ break;
447
+
448
+ case "website" :
449
+ return GFCommon::is_valid_url($value) && $format == "html" ? $value : $value;
450
+ break;
451
+
452
+ case "checkbox" :
453
+ if(is_array($value)){
454
+
455
+ $items = '';
456
+
457
+ foreach($value as $key => $item){
458
+ if(!empty($item)){
459
+ switch($format){
460
+ case "text" :
461
+ $items .= GFCommon::selection_display($item, $field, $currency, $use_text) . ", ";
462
+ break;
463
+
464
+ default:
465
+ $items .= "<li>" . GFCommon::selection_display($item, $field, $currency, $use_text) . "</li>";
466
+ break;
467
+ }
468
+ }
469
+ }
470
+ if(empty($items)){
471
+ return "";
472
+ }
473
+ else if($format == "text"){
474
+ return substr($items, 0, strlen($items)-2); //removing last comma
475
+ }
476
+ else{
477
+ return "<ul class='bulleted'>$items</ul>";
478
+ }
479
+ }
480
+ else{
481
+ return $value;
482
+ }
483
+ break;
484
+
485
+ case "post_image" :
486
+ $ary = explode("|:|", $value);
487
+ $url = count($ary) > 0 ? $ary[0] : "";
488
+ $title = count($ary) > 1 ? $ary[1] : "";
489
+ $caption = count($ary) > 2 ? $ary[2] : "";
490
+ $description = count($ary) > 3 ? $ary[3] : "";
491
+
492
+ if(!empty($url)){
493
+ $url = str_replace(" ", "%20", $url);
494
+
495
+ switch($format){
496
+ case "text" :
497
+ $value = $url;
498
+ $value .= !empty($title) ? "\n\n" . $field["label"] . " (" . __("Title", "gravityforms") . "): " . $title : "";
499
+ $value .= !empty($caption) ? "\n\n" . $field["label"] . " (" . __("Caption", "gravityforms") . "): " . $caption : "";
500
+ $value .= !empty($description) ? "\n\n" . $field["label"] . " (" . __("Description", "gravityforms") . "): " . $description : "";
501
+ break;
502
+
503
+ default :
504
+ $value = "<a href='$url' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='$url' width='100' /></a>";
505
+ $value .= !empty($title) ? "<div>Title: $title</div>" : "";
506
+ $value .= !empty($caption) ? "<div>Caption: $caption</div>" : "";
507
+ $value .= !empty($description) ? "<div>Description: $description</div>": "";
508
+
509
+ break;
510
+ }
511
+ }
512
+ return $value;
513
+
514
+ case "fileupload" :
515
+ $file_path = $value;
516
+ if(!empty($file_path)){
517
+ $info = pathinfo($file_path);
518
+ $file_path = esc_attr(str_replace(" ", "%20", $file_path));
519
+ $value = $format == "text" ? $file_path : "<a href='$file_path' target='_blank' title='" . __("Click to view", "gravityforms") . "'>" . $info["basename"] . "</a>";
520
+ }
521
+ return $value;
522
+ break;
523
+
524
+ case "date" :
525
+ return GFCommon::date_display($value, rgar($field, "dateFormat"));
526
+ break;
527
+
528
+ case "radio" :
529
+ case "select" :
530
+ return GFCommon::selection_display($value, $field, $currency, $use_text);
531
+ break;
532
+
533
+ case "multiselect" :
534
+ if(empty($value) || $format == "text")
535
+ return $value;
536
+
537
+ $value = explode(",", $value);
538
+
539
+ $items = '';
540
+ foreach($value as $item){
541
+ $items .= "<li>" . GFCommon::selection_display($item, $field, $currency, $use_text) . "</li>";
542
+ }
543
+
544
+ return "<ul class='bulleted'>{$items}</ul>";
545
+
546
+ break;
547
+
548
+ case "calculation" :
549
+ case "singleproduct" :
550
+ if(is_array($value)){
551
+ $product_name = trim($value[$field["id"] . ".1"]);
552
+ $price = trim($value[$field["id"] . ".2"]);
553
+ $quantity = trim($value[$field["id"] . ".3"]);
554
+
555
+ $product = $product_name . ", " . __("Qty: ", "gravityforms") . $quantity . ", " . __("Price: ", "gravityforms") . $price;
556
+ return $product;
557
+ }
558
+ else{
559
+ return "";
560
+ }
561
+ break;
562
+
563
+ case "number" :
564
+ return GFCommon::format_number($value, rgar($field, "numberFormat"));
565
+ break;
566
+
567
+ case "singleshipping" :
568
+ case "donation" :
569
+ case "total" :
570
+ case "price" :
571
+ return GFCommon::to_money($value, $currency);
572
+
573
+ case "list" :
574
+ if(empty($value))
575
+ return "";
576
+ $value = unserialize($value);
577
+
578
+ $has_columns = is_array($value[0]);
579
+
580
+ if(!$has_columns){
581
+ $items = '';
582
+ foreach($value as $key => $item){
583
+ if(!empty($item)){
584
+ switch($format){
585
+ case "text" :
586
+ $items .= $item . ", ";
587
+ break;
588
+ case "url" :
589
+ $items .= $item . ",";
590
+ break;
591
+ default :
592
+ if($media == "email"){
593
+ $items .= "<li>{$item}</li>";
594
+ }
595
+ else{
596
+ $items .= "<li>{$item}</li>";
597
+ }
598
+ break;
599
+ }
600
+ }
601
+ }
602
+
603
+ if(empty($items)){
604
+ return "";
605
+ }
606
+ else if($format == "text"){
607
+ return substr($items, 0, strlen($items)-2); //removing last comma
608
+ }
609
+ else if($format == "url"){
610
+ return substr($items, 0, strlen($items)-1); //removing last comma
611
+ }
612
+ else if($media == "email"){
613
+ return "<ul class='bulleted'>{$items}</ul>";
614
+ }
615
+ else{
616
+ return "<ul class='bulleted'>{$items}</ul>";
617
+ }
618
+ }
619
+ else if(is_array($value)){
620
+ $columns = array_keys($value[0]);
621
+
622
+ $list = "";
623
+
624
+ switch($format){
625
+ case "text" :
626
+ $is_first_row = true;
627
+ foreach($value as $item){
628
+ if(!$is_first_row)
629
+ $list .= "\n\n" . $field["label"] . ": ";
630
+ $list .= implode(",", array_values($item));
631
+
632
+ $is_first_row = false;
633
+ }
634
+ break;
635
+
636
+ case "url" :
637
+ foreach($value as $item){
638
+ $list .= implode("|", array_values($item)) . ",";
639
+ }
640
+ if(!empty($list))
641
+ $list = substr($list, 0, strlen($list)-1);
642
+ break;
643
+
644
+ default :
645
+ if($media == "email"){
646
+ $list = "<table class='gfield_list' style='border-top: 1px solid #DFDFDF; border-left: 1px solid #DFDFDF; border-spacing: 0; padding: 0; margin: 2px 0 6px; width: 100%'><thead><tr>";
647
+
648
+ //reading columns from entry data
649
+ foreach($columns as $column){
650
+ $list .= "<th style='background-image: none; border-right: 1px solid #DFDFDF; border-bottom: 1px solid #DFDFDF; padding: 6px 10px; font-family: sans-serif; font-size: 12px; font-weight: bold; background-color: #F1F1F1; color:#333; text-align:left'>" . esc_html($column) . "</th>";
651
+ }
652
+ $list .= "</tr></thead>";
653
+
654
+ $list .= "<tbody style='background-color: #F9F9F9'>";
655
+ foreach($value as $item){
656
+ $list .= "<tr>";
657
+ foreach($columns as $column){
658
+ $val = rgar($item, $column);
659
+ $list .= "<td style='padding: 6px 10px; border-right: 1px solid #DFDFDF; border-bottom: 1px solid #DFDFDF; border-top: 1px solid #FFF; font-family: sans-serif; font-size:12px;'>{$val}</td>";
660
+ }
661
+
662
+ $list .="</tr>";
663
+ }
664
+
665
+ $list .="<tbody></table>";
666
+ }
667
+ else{
668
+ $list = "<table class='gfield_list'><thead><tr>";
669
+
670
+ //reading columns from entry data
671
+ foreach($columns as $column){
672
+ $list .= "<th>" . esc_html($column) . "</th>";
673
+ }
674
+ $list .= "</tr></thead>";
675
+
676
+ $list .= "<tbody>";
677
+ foreach($value as $item){
678
+ $list .= "<tr>";
679
+ foreach($columns as $column){
680
+ $val = rgar($item, $column);
681
+ $list .= "<td>{$val}</td>";
682
+ }
683
+
684
+ $list .="</tr>";
685
+ }
686
+
687
+ $list .="<tbody></table>";
688
+ }
689
+ break;
690
+ }
691
+
692
+ return $list;
693
+ }
694
+ return "";
695
+ break;
696
+
697
+ default :
698
+ if (!is_array($value))
699
+ {
700
+ return nl2br($value);
701
+ }
702
+ break;
703
+ }
704
+ }
705
+
706
  }
707
  ?>
pdf.php CHANGED
@@ -3,8 +3,8 @@
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
 
@@ -30,19 +30,73 @@ GNU General Public License for more details.
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
  /**
@@ -80,23 +134,33 @@ function gfpdfe_nag_ignore() {
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")){
@@ -104,7 +168,7 @@ function process_exterior_pages(){
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();
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: Gravity Forms PDF Extended allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission. Note: If you're upgrading, backup your plugin files beforehand as your custom template will be overridden.
7
+ Version: 1.2.0
8
  Author: Blue Liquid Designs
9
  Author URI: http://www.blueliquiddesigns.com.au
10
 
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
+ register_activation_hook( __FILE__, 'pdf_extended_activate' );
34
 
35
 
36
+ add_action('admin_init', 'gfe_admin_init', 9);
37
+ add_action("gform_entry_created", "gform_pdf_example_create", 10, 2);
38
+ add_filter("gform_admin_notification_attachments", 'gform_add_example_attachment', 10, 3);
39
+
40
+
41
+ /*
42
+ * Generate our Sample PDF for our Sample Form
43
+ */
44
+ function gform_pdf_example_create($entry, $form)
45
+ {
46
+ $user_id = $entry['id'];
47
+ $form_id = $entry['form_id'];
48
+
49
+ if($form['title'] == 'Gravity Forms PDF Extended Custom Template Sample')
50
+ {
51
+ /* include the pdf processing file */
52
+ require ABSPATH. 'wp-content/plugins/gravity-forms-pdf-extended/render_to_pdf.php';
53
+ /* generate and save the PDF file*/
54
+ $filename = PDF_Generator($form_id, $user_id, 'save', true, 'example-template.php');
55
+ }
56
+ }
57
+
58
+ /* Emails our sample PDF to the site administrator */
59
+ function gform_add_example_attachment($attachments, $lead, $form){
60
+
61
+ $form_id = $lead['form_id'];
62
+ $user_id = $lead['id'];
63
+ $attachments = array();
64
+
65
+ if($form['title'] == 'Gravity Forms PDF Extended Custom Template Sample')
66
+ {
67
+ /* include PDF converter plugin */
68
+ include ABSPATH. 'wp-content/plugins/gravity-forms-pdf-extended/render_to_pdf.php';
69
+ $attachment_file = PDF_SAVE_LOCATION. get_pdf_filename($form_id, $user_id);
70
+ $attachments[] = $attachment_file;
71
+ }
72
+
73
+ return $attachments;
74
+ }
75
+
76
  /**
77
  * Check to see if Gravity Forms is actually installed
78
  */
79
+ function gfe_admin_init()
80
  {
81
  if(!class_exists("RGForms"))
82
  {
83
  /* throw error to the admin notice bar */
84
  add_action('admin_notices', 'gf_not_installed');
85
  }
86
+
87
+ if(get_option('gf_pdf_extended_sample') != 'installed')
88
+ {
89
+ pdf_extended_activate();
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Install an example form to show off the new template system
95
+ */
96
+ function pdf_extended_activate()
97
+ {
98
+ GFExport::import_file(ABSPATH .'/wp-content/plugins/gravity-forms-pdf-extended/example-form.xml');
99
+ update_option('gf_pdf_extended_sample', 'installed');
100
  }
101
 
102
  /**
134
  function detail_pdf_link($form_id, $lead) {
135
  $lead_id = $lead['id'];
136
  echo "PDF: ";
137
+ echo "<a href=\"javascript:;\" onclick=\"var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='".home_url()."/?gf_pdf=print-entry&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\" class=\"button\"> View</a>";
138
+ echo " <a href=\"javascript:;\" onclick=\"var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='".home_url()."/?gf_pdf=print-entry&download=1&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\" class=\"button\"> Download</a>";
139
  }
140
 
141
  // Made this first... figured i would leave it in. View link on the Entry list view.
142
  function pdf_link($form_id, $field_id, $value, $lead) {
143
  $lead_id = $lead['id'];
144
+ echo "| <a href=\"javascript:;\" onclick=\"var notes_qs = '&notes=1'; var url='".home_url()."/?gf_pdf=print-entry&fid=".$form_id."&lid=".$lead_id."' + notes_qs; window.open (url,'printwindow');\"> View PDF</a>";
145
  }
146
 
147
  //Handle Incoming route. Look for GF_PDF namespace
148
  function process_exterior_pages(){
149
+ global $wpdb;
150
+
151
  if(rgempty("gf_pdf", $_GET))
152
  return;
153
 
154
+ $form_id = $_GET['fid'];
155
+ $lead_id = $_GET['lid'];
156
+ $ip = $_GET['ip'];
157
+ $template = (rgempty('template', $_GET)) ? 'pdf-print-entry.php' : rgget('template');
158
+
159
+ /* check the lead is in the database and the IP address matches (little security booster) */
160
+ $form_entries = $wpdb->get_var( $wpdb->prepare("SELECT count(*) FROM `".$wpdb->prefix."rg_lead` WHERE form_id = ".$form_id." AND status = 'active' AND id = ".$lead_id." AND ip = '".$ip."'" ) ) ;
161
+
162
  //ensure users are logged in
163
+ if(!is_user_logged_in() && !rgempty('template', $_GET) && $form_entries == 0)
164
  auth_redirect();
165
 
166
  switch(rgget("gf_pdf")){
168
  require_once("render_to_pdf.php");
169
  /* call the creation class */
170
  $output = ($_GET['download'] == 1) ? 'download' : 'view';
171
+ PDF_Generator((int) $_GET['fid'], (int) $_GET['lid'], $output, false, $template);
172
  break;
173
  }
174
  exit();
render_to_pdf.php CHANGED
@@ -1,141 +1,144 @@
1
- <?php
2
- // Handy trick to let us run the default print view and give us the processed string... it's all we want really.
3
- if (!function_exists('GetRequire')) {
4
- function GetRequire($sFilename) {
5
- ob_start();
6
- require($sFilename);
7
- $sResult = ob_get_contents();
8
- ob_end_clean();
9
- return $sResult;
10
- return ob_get_clean();
11
- }
12
- }
13
-
14
- define('PDF_SAVE_LOCATION', dirname(__FILE__)."/output/");
15
-
16
- /**
17
- * Outputs a PDF entry from a Gravity Form
18
- * var $form_id integer: The form id
19
- * var $lead_id integer: The entry id
20
- * var $output string: either view, save or download
21
- * save will save a copy of the PDF to the server using the PDF_SAVE_LOCATION constant
22
- * var $return boolean: if set to true it will return the path of the saved PDF
23
- * var $template string: if you want to use multiple PDF templates - name of the template file
24
- */
25
- if (!function_exists('PDF_Generator')) {
26
- function PDF_Generator($form_id, $lead_id, $output = 'view', $return = false, $template = 'pdf-print-entry.php')
27
- {
28
- $filename = get_pdf_filename($form_id, $lead_id);
29
- $entry = load_entry_data($form_id, $lead_id, $template);
30
- PDF_processing($entry, $filename, $output);
31
- /* return the filename so we can use it */
32
- if($return)
33
- {
34
- return PDF_SAVE_LOCATION. $filename;
35
- }
36
- }
37
- }
38
-
39
- /**
40
- * Get the name of the PDF based on the Form and the submission
41
- */
42
- if (!function_exists('get_pdf_filename')) {
43
- function get_pdf_filename($form_id, $lead_id)
44
- {
45
- return "form-$form_id-entry-$lead_id.pdf";
46
- }
47
- }
48
-
49
- /**
50
- * Loads the Gravity Form output script (actually the print preview)
51
- */
52
- if (!function_exists('load_entry_data')) {
53
- function load_entry_data($form_id, $lead_id, $template)
54
- {
55
- /* set up contstants for gravity forms to use so we can override the security on the printed version */
56
- define('GF_FORM_ID', $form_id);
57
- define('GF_LEAD_ID', $lead_id);
58
- return GetRequire(dirname(__FILE__)."/" . $template);
59
- }
60
- }
61
-
62
- /**
63
- * Creates the PDF and does a specific output (see PDF_Generator function above for $output variable types)
64
- */
65
- if (!function_exists('PDF_processing')) {
66
- function PDF_processing($entry, $filename, $output = 'view')
67
- {
68
- //Parse the default print view from Gravity forms so we can play with it.
69
- $DOM = new DOMDocument;
70
- $DOM->loadHTML($entry);
71
-
72
- //Make Stylesheets/Images Absolute
73
- /*$stylesheets = $DOM->getElementsByTagName('link');
74
-
75
- foreach($stylesheets as $stylesheet){
76
- $href = $stylesheet->getAttribute('href');
77
- if(strpos($src, site_url()) !== 0){
78
- $stylesheet->setAttribute('href', site_url()."$href");
79
- }
80
- }*/
81
-
82
- /* Problem pulling the site style so manually set */
83
-
84
- $imgs = $DOM->getElementsByTagName('img');
85
- foreach($imgs as $img){
86
- $src = $img->getAttribute('src');
87
- if(strpos($src, site_url()) !== 0){
88
- $img->setAttribute('src', site_url()."$src");
89
- }
90
- }
91
-
92
- //Remove Ugly Header
93
- $xpath = new DOMXPath($DOM);
94
- $nlist = $xpath->query("//div[@id='print_preview_hdr']");
95
- $node = $nlist->item(0);
96
- $node->parentNode->removeChild($node);
97
- $entry = $DOM->saveHTML();
98
-
99
- //Load the DOMPDF Engine to render the PDF
100
- require_once("dompdf/dompdf_config.inc.php");
101
- $dompdf = new DOMPDF();
102
- $dompdf -> load_html($entry);
103
- $dompdf -> set_base_path(site_url());
104
- $dompdf -> render();
105
-
106
- switch($output)
107
- {
108
- case 'download':
109
- $dompdf -> stream($filename, array("Attachment" => true));
110
- exit(0);
111
- break;
112
-
113
- case 'view':
114
- $dompdf -> stream($filename, array("Attachment" => false));
115
- exit(0);
116
- break;
117
-
118
- case 'save':
119
- savePDF($dompdf, $filename);
120
- break;
121
- }
122
- }
123
- }
124
-
125
- /**
126
- * Creates the PDF and does a specific output (see PDF_Generator function above for $output variable types)
127
- * var $dompdf Object
128
- */
129
- if (!function_exists('savePDF')) {
130
- function savePDF($dompdf, $filename)
131
- {
132
- $pdf = $dompdf->output();
133
- if(!file_put_contents(PDF_SAVE_LOCATION. $filename, $pdf))
134
- {
135
- print 'Could not save PDF';
136
- }
137
- }
138
- }
139
-
140
-
 
 
 
141
  ?>
1
+ <?php
2
+ // Handy trick to let us run the default print view and give us the processed string... it's all we want really.
3
+ if (!function_exists('GetRequire')) {
4
+ function GetRequire($sFilename) {
5
+ ob_start();
6
+ require($sFilename);
7
+ $sResult = ob_get_contents();
8
+ ob_end_clean();
9
+ return $sResult;
10
+ return ob_get_clean();
11
+ }
12
+ }
13
+
14
+ if(!defined('PDF_SAVE_LOCATION'))
15
+ {
16
+ define('PDF_SAVE_LOCATION', dirname(__FILE__)."/output/");
17
+ }
18
+
19
+ /**
20
+ * Outputs a PDF entry from a Gravity Form
21
+ * var $form_id integer: The form id
22
+ * var $lead_id integer: The entry id
23
+ * var $output string: either view, save or download
24
+ * save will save a copy of the PDF to the server using the PDF_SAVE_LOCATION constant
25
+ * var $return boolean: if set to true it will return the path of the saved PDF
26
+ * var $template string: if you want to use multiple PDF templates - name of the template file
27
+ */
28
+ if (!function_exists('PDF_Generator')) {
29
+ function PDF_Generator($form_id, $lead_id, $output = 'view', $return = false, $template = 'pdf-print-entry.php')
30
+ {
31
+ $filename = get_pdf_filename($form_id, $lead_id);
32
+ $entry = load_entry_data($form_id, $lead_id, $template);
33
+ PDF_processing($entry, $filename, $output);
34
+ /* return the filename so we can use it */
35
+ if($return)
36
+ {
37
+ return PDF_SAVE_LOCATION. $filename;
38
+ }
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Get the name of the PDF based on the Form and the submission
44
+ */
45
+ if (!function_exists('get_pdf_filename')) {
46
+ function get_pdf_filename($form_id, $lead_id)
47
+ {
48
+ return "form-$form_id-entry-$lead_id.pdf";
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Loads the Gravity Form output script (actually the print preview)
54
+ */
55
+ if (!function_exists('load_entry_data')) {
56
+ function load_entry_data($form_id, $lead_id, $template)
57
+ {
58
+ /* set up contstants for gravity forms to use so we can override the security on the printed version */
59
+ define('GF_FORM_ID', $form_id);
60
+ define('GF_LEAD_ID', $lead_id);
61
+ return GetRequire(dirname(__FILE__)."/templates/" . $template);
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Creates the PDF and does a specific output (see PDF_Generator function above for $output variable types)
67
+ */
68
+ if (!function_exists('PDF_processing')) {
69
+ function PDF_processing($entry, $filename, $output = 'view')
70
+ {
71
+ //Parse the default print view from Gravity forms so we can play with it.
72
+ $DOM = new DOMDocument;
73
+ $DOM->loadHTML($entry);
74
+
75
+ //Make Stylesheets/Images Absolute
76
+ /*$stylesheets = $DOM->getElementsByTagName('link');
77
+
78
+ foreach($stylesheets as $stylesheet){
79
+ $href = $stylesheet->getAttribute('href');
80
+ if(strpos($src, site_url()) !== 0){
81
+ $stylesheet->setAttribute('href', site_url()."$href");
82
+ }
83
+ }*/
84
+
85
+ /* Problem pulling the site style so manually set */
86
+
87
+ $imgs = $DOM->getElementsByTagName('img');
88
+ foreach($imgs as $img){
89
+ $src = $img->getAttribute('src');
90
+ if(strpos($src, site_url()) !== 0){
91
+ $img->setAttribute('src', site_url()."$src");
92
+ }
93
+ }
94
+
95
+ //Remove Ugly Header
96
+ $xpath = new DOMXPath($DOM);
97
+ $nlist = $xpath->query("//div[@id='print_preview_hdr']");
98
+ $node = $nlist->item(0);
99
+ $node->parentNode->removeChild($node);
100
+ $entry = $DOM->saveHTML();
101
+
102
+ //Load the DOMPDF Engine to render the PDF
103
+ require_once("dompdf/dompdf_config.inc.php");
104
+ $dompdf = new DOMPDF();
105
+ $dompdf -> load_html($entry);
106
+ $dompdf -> set_base_path(site_url());
107
+ $dompdf -> render();
108
+
109
+ switch($output)
110
+ {
111
+ case 'download':
112
+ $dompdf -> stream($filename, array("Attachment" => true));
113
+ exit(0);
114
+ break;
115
+
116
+ case 'view':
117
+ $dompdf -> stream($filename, array("Attachment" => false));
118
+ exit(0);
119
+ break;
120
+
121
+ case 'save':
122
+ savePDF($dompdf, $filename);
123
+ break;
124
+ }
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Creates the PDF and does a specific output (see PDF_Generator function above for $output variable types)
130
+ * var $dompdf Object
131
+ */
132
+ if (!function_exists('savePDF')) {
133
+ function savePDF($dompdf, $filename)
134
+ {
135
+ $pdf = $dompdf->output();
136
+ if(!file_put_contents(PDF_SAVE_LOCATION. $filename, $pdf))
137
+ {
138
+ print 'Could not save PDF';
139
+ }
140
+ }
141
+ }
142
+
143
+
144
  ?>
template.css CHANGED
@@ -6,4 +6,13 @@ padding-left: 9px;
6
 
7
  .even {
8
  background: #EAF2FA;
 
 
 
 
 
 
 
 
 
9
  }
6
 
7
  .even {
8
  background: #EAF2FA;
9
+ }
10
+
11
+ .body_copy {
12
+ padding-top: 50px;
13
+ }
14
+
15
+ .pdf_logo_area {
16
+ text-align: center;
17
+ margin: 0 auto;
18
  }
templates/example-template.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ error_reporting(E_ALL);
3
+ ini_set("display_errors", 1);
4
+ //For backwards compatibility, load wordpress if it hasn't been loaded yet
5
+ //Will be used if this file is being called directly
6
+ if(!class_exists("RGForms")){
7
+ for ( $i = 0; $i < $depth = 10; $i++ ) {
8
+ $wp_root_path = str_repeat( '../', $i );
9
+
10
+ if ( file_exists("{$wp_root_path}wp-load.php" ) ) {
11
+ require_once("{$wp_root_path}wp-load.php");
12
+ require_once("{$wp_root_path}wp-admin/includes/admin.php");
13
+ break;
14
+ }
15
+ }
16
+
17
+ //redirect to the login page if user is not authenticated
18
+ auth_redirect();
19
+ }
20
+
21
+ if(!GFCommon::current_user_can_any("gravityforms_view_entries") && !defined('GF_FORM_ID') )
22
+ die(__("You don't have adequate permission to view entries.", "gravityforms"));
23
+
24
+ $form_id = (defined('GF_FORM_ID')) ? GF_FORM_ID : absint(rgget("fid"));
25
+ $lead_ids = (defined('GF_LEAD_ID')) ? array(GF_LEAD_ID) : explode(',', rgget("lid"));
26
+ $page_break = rgget("page_break") ? 'print-page-break' : false;
27
+
28
+ // sort lead IDs numerically
29
+ sort($lead_ids);
30
+
31
+ if(empty($form_id) || empty($lead_ids))
32
+ die(__("Form Id and Lead Id are required parameters.", "gravityforms"));
33
+
34
+ $form = RGFormsModel::get_form_meta($form_id);
35
+
36
+ ?>
37
+
38
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
39
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
40
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
41
+ <head>
42
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
43
+ <meta name="keywords" content="" />
44
+ <meta name="description" content="" />
45
+ <meta name="MSSmartTagsPreventParsing" content="true" />
46
+ <meta name="Robots" content="noindex, nofollow" />
47
+ <meta http-equiv="Imagetoolbar" content="No" />
48
+ <title>
49
+ Print Preview :
50
+ <?php echo $form["title"] ?> :
51
+ <?php echo count($lead_ids) > 1 ? __("Entry # ", "gravityforms") . $lead_ids[0] : 'Bulk Print' ?>
52
+ </title>
53
+ <link rel='stylesheet' href='<?php echo GFCommon::get_base_url() ?>/css/print.css' type='text/css' />
54
+ <link rel='stylesheet' href='<?php echo bloginfo('wurl') ?>/wp-content/plugins/gravity-forms-pdf-extended/template.css' type='text/css' />
55
+ </head>
56
+ <body>
57
+
58
+ <div id="print_preview_hdr" style="display:none"></div>
59
+
60
+
61
+ <div id="view-container">
62
+
63
+ <?php
64
+ /* Add image and copy above here to show before the entry details */
65
+
66
+ require_once(ABSPATH. "wp-content/plugins/gravity-forms-pdf-extended/pdf-entry-detail.php");
67
+
68
+ foreach($lead_ids as $lead_id){
69
+
70
+ $lead = RGFormsModel::get_lead($lead_id);
71
+ do_action("gform_print_entry_header", $form, $lead);
72
+ $form_data = GFEntryDetail::lead_detail_grid_array($form, $lead);
73
+
74
+ /** Uncomment the following line when figuring out how to access the $form_data array */
75
+ // print_r($form_data); exit();
76
+
77
+ /* get all the form values */
78
+ $first_name = $form_data['field']['Name']['first'];
79
+ $last_name = $form_data['field']['Name']['last'];
80
+
81
+ $address_street = $form_data['field']['Address']['street'];
82
+ $address_city = $form_data['field']['Address']['city'];
83
+ $address_state = $form_data['field']['Address']['state'];
84
+ $address_zip = $form_data['field']['Address']['zip'];
85
+ $address_country = $form_data['field']['Address']['country'];
86
+
87
+ $phone = $form_data['field']['Phone'];
88
+ /* format the template */
89
+ ?>
90
+
91
+
92
+ <img src="<?php echo home_url() ?>/wp-content/plugins/gravity-forms-pdf-extended/images/BlueLiquidDesigns.jpg" width="265" height="72" />
93
+
94
+
95
+ <div class="body_copy">
96
+
97
+ <p class="date"><?php echo date('d/m/Y'); ?></p>
98
+
99
+ <p class="client_address">
100
+ <?php echo $first_name .' '. $last_name; ?><br />
101
+ <?php echo $address_street; ?><br />
102
+ <?php echo $address_city .', '. $address_state .' '. $address_zip; ?><br />
103
+ <?php echo $address_country; ?>
104
+ </p>
105
+
106
+ <p class="whom_concern_intro">Dear User,</p>
107
+
108
+ <p class="body_text">The Gravity Forms PDF Extended plugin now allows you to directly access field data so you can create custom PDFs like this one. You'll need to copy the <em>example-template.php</em> file now located in the gravity-forms-pdf-extended/template/ directory and style it appropriatly. There's a <strong>print_r()</strong> statement you can uncomment that will help you access the $form_data array when customising the PDF template.</p>
109
+
110
+ <p>To create a PDF with the new template file you'll need to change the <em>PDF_Generator</em> call in your <em>gform_pdf_create()</em> function, which should be inside your theme's functions.php file, otherwise the standard template will be called. </p>
111
+
112
+ <p><strong>$filename = PDF_Generator($form_id, $user_id, 'save', true, 'your-new-template.php');</strong></p>
113
+
114
+ <p>When testing your new template file you can use the <em>View PDF</em> button on an entry in the admin area and tack <strong>&amp;template=your-new-template.php</strong> onto the end of the url.</p>
115
+
116
+ <p><strong>Example:</strong> http://www.yourdomain.com/?gf_pdf=print-entry&amp;fid=5&amp;lid=142&amp;notes=1&amp;template=example-template.php</p>
117
+
118
+ <p>As always, all documentation can be found via the <a href="http://www.blueliquiddesigns.com.au/index.php/gravity-forms-pdf-extended-plugin/">Plugin's official website.</a></p>
119
+
120
+ <br /><br />
121
+
122
+ <p class="signature">
123
+ Jake Jackson<br />
124
+ <img src="<?php echo home_url(); ?>/wp-content/plugins/gravity-forms-pdf-extended/images/signature.png" alt="Signature" width="100" height="60" /><br />
125
+ Developer, Blue Liquid Designs<br />
126
+ <a href="http://www.blueliquiddesigns.com.au">www.blueliquiddesigns.com.au</a>
127
+ </p>
128
+
129
+
130
+
131
+ </div>
132
+
133
+ <?php
134
+
135
+ if(rgget('notes')){
136
+ $notes = RGFormsModel::get_lead_notes($lead["id"]);
137
+ if(!empty($notes))
138
+ {
139
+ GFEntryDetail::notes_grid($notes, false);
140
+ }
141
+ }
142
+
143
+ // output entry divider/page break
144
+ if(array_search($lead_id, $lead_ids) < count($lead_ids) - 1)
145
+ echo '<div class="print-hr ' . $page_break . '"></div>';
146
+
147
+ do_action("gform_print_entry_footer", $form, $lead);
148
+
149
+ ?>
150
+
151
+
152
+ <?php
153
+ }
154
+
155
+ ?>
156
+ </div>
157
+ </body>
158
+ </html>
pdf-print-entry.php → templates/pdf-print-entry.php RENAMED
@@ -50,7 +50,7 @@ $form = RGFormsModel::get_form_meta($form_id);
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
 
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('wurl') ?>/wp-content/plugins/gravity-forms-pdf-extended/template.css' type='text/css' />
54
  </head>
55
  <body>
56