Gravity PDF - Version 3.7.2

Version Description

  • Bug - Updated $form_data['date_created'], $form_data['date_created_usa'], $form_data['misc']['date_time'], $form_data['misc']['time_24hr'] and $form_data['misc']['time_12hr'] to factor in the website's timezone settings.
Download this release

Release Info

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

Code changes from version 3.7.1 to 3.7.2

README.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://gravitypdf.com
4
  Tags: gravity, forms, pdf, automation, attachment
5
  Requires at least: 3.9
6
  Tested up to: 4.2
7
- Stable tag: 3.7.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl.txt
10
 
@@ -88,6 +88,9 @@ All FAQs can be [viewed on the Gravity PDF website](https://gravitypdf.com/#faqs
88
 
89
  == Changelog ==
90
 
 
 
 
91
  = 3.7.1 =
92
  * Housekeeping - Allow control over signature width in default template using the 'gfpdfe_signature_width' filter
93
  * Housekeeping - Add better error checking when migrating PDF template folder
4
  Tags: gravity, forms, pdf, automation, attachment
5
  Requires at least: 3.9
6
  Tested up to: 4.2
7
+ Stable tag: 3.7.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl.txt
10
 
88
 
89
  == Changelog ==
90
 
91
+ = 3.7.2 =
92
+ * Bug - Updated $form_data['date_created'], $form_data['date_created_usa'], $form_data['misc']['date_time'], $form_data['misc']['time_24hr'] and $form_data['misc']['time_12hr'] to factor in the website's timezone settings.
93
+
94
  = 3.7.1 =
95
  * Housekeeping - Allow control over signature width in default template using the 'gfpdfe_signature_width' filter
96
  * Housekeeping - Add better error checking when migrating PDF template folder
helper/pdf-entry-detail.php CHANGED
@@ -1,2046 +1,2038 @@
1
- <?php
2
-
3
- /*
4
- This file is part of Gravity PDF.
5
-
6
- Gravity PDF Copyright (C) 2015 Blue Liquid Designs
7
-
8
- This program is free software; you can redistribute it and/or modify
9
- it under the terms of the GNU General Public License as published by
10
- the Free Software Foundation; either version 2 of the License, or
11
- (at your option) any later version.
12
-
13
- This program is distributed in the hope that it will be useful,
14
- but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- GNU General Public License for more details.
17
-
18
- You should have received a copy of the GNU General Public License
19
- along with this program; if not, write to the Free Software
20
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
- */
22
-
23
- if(!class_exists('GFPDFEntryDetail'))
24
- {
25
-
26
- /*
27
- * Include Gravity Forms Currency class (it not already included)
28
- */
29
- if ( false === class_exists( 'RGCurrency' ) && class_exists('GFCommon') ) {
30
- require_once( GFCommon::get_base_path() . '/currency.php' );
31
- }
32
-
33
- add_filter('gfpdf_field_content', array('GFPDFEntryDetail', 'encode_tags'), 10, 2); /* encode shortcodes in user's response so they aren't converted later by do_shortcode */
34
- class GFPDFEntryDetail {
35
-
36
- /* holds the form fields, stored by field ID */
37
- static $fields;
38
-
39
- /* depreciated function which we will replace with a better config passing method */
40
- public static function lead_detail_grid($form, $lead, $allow_display_empty_fields=false, $show_html=false, $show_page_name=false, $return=false) {
41
-
42
- $config = array(
43
- 'empty_field' => $allow_display_empty_fields,
44
- 'html_field' => $show_html,
45
- 'page_names' => $show_page_name,
46
- 'return' => $return,
47
- );
48
-
49
- return self::do_lead_detail_grid($form, $lead, $config);
50
- }
51
-
52
-
53
- public static function do_lead_detail_grid($form, $lead, $config) {
54
- $form_id = $form['id'];
55
- $results = array();
56
-
57
- /*
58
- * Set up our defaults and merge down the user config
59
- */
60
- $defaults = array(
61
- 'empty_field' => false,
62
- 'html_field' => false,
63
- 'page_names' => false,
64
- 'return' => false,
65
- 'section_content' => false,
66
- );
67
-
68
- $config = array_merge($defaults, $config);
69
-
70
- if($config['return'] === true)
71
- {
72
- $results['title'] = '<h2 id="details" class="default">'. $form['title'] .'</h2>';
73
- }
74
- else
75
- {
76
- ?>
77
- <div id='container'>
78
- <h2 id='details' class='default'><?php echo $form['title']?></h2>
79
- <?php
80
- }
81
-
82
-
83
- $count = 0;
84
- $field_count = sizeof($form['fields']);
85
-
86
- $has_product_fields = false;
87
-
88
- $page_number = 0;
89
- foreach($form['fields'] as $field) {
90
-
91
-
92
- /*
93
- * Check if this field has been excluded from the list
94
- */
95
- if(isset($field['cssClass']) && strpos($field['cssClass'], 'exclude') !== false)
96
- {
97
- /* skip this field */
98
- continue;
99
- }
100
-
101
- /*
102
- * Skip over hidden fields
103
- */
104
- if(GFFormsModel::is_field_hidden( $form, $field, array(), $lead ))
105
- {
106
- continue;
107
- }
108
-
109
- /*
110
- * Check if we are to show the page names
111
- */
112
- if($config['page_names'] === true)
113
- {
114
- if((int) $field['pageNumber'] !== $page_number && isset($form['pagination']['pages'][$page_number]))
115
- {
116
- /*
117
- * Display the page number
118
- */
119
- if($config['return'] === true)
120
- {
121
- $results['field'][] = '<h2 id="field-'. $field['id'].'" class="default entry-view-page-break">'. $form['pagination']['pages'][$page_number] .'</h2>';
122
- }
123
- else
124
- {
125
- ?>
126
- <h2 id='field-<?php echo $field['id']; ?>' class='default entry-view-page-break'><?php echo $form['pagination']['pages'][$page_number]; ?></h2>
127
- <?php
128
- }
129
- /*
130
- * Increment the page number
131
- */
132
- $page_number++;
133
- }
134
- }
135
-
136
- $even = $odd = '';
137
-
138
- switch(RGFormsModel::get_input_type($field)){
139
- case 'section' :
140
-
141
- if(!GFCommon::is_section_empty($field, $form, $lead) || $config['empty_field'] || $config['section_content']){
142
- $count++;
143
-
144
- if($config['return'] === true)
145
- {
146
- $results['field'][] = '<h2 id="field-'.$field['id'].'" class="default entry-view-section-break">'. esc_html(GFCommon::get_label($field)) .'</h2>';
147
-
148
- if($config['section_content'])
149
- {
150
- $results['field'][] = '<div class="default entry-view-section-break entry-view-section-break-content">' . $field['description'] . '</div>';
151
- }
152
-
153
- }
154
- else
155
- {
156
- ?>
157
- <h2 id="field-<?php echo $field['id']; ?>" class="default entry-view-section-break"><?php echo esc_html(GFCommon::get_label($field))?></h2>
158
-
159
- <?php if($config['section_content']): ?>
160
- <div class="default entry-view-section-break entry-view-section-break-content"><?php echo $field['description']; ?></div>
161
- <?php endif; ?>
162
- <?php
163
- }
164
- }
165
- break;
166
-
167
- case 'captcha':
168
- case 'password':
169
- case 'page':
170
- //ignore captcha, html, password, page field
171
- break;
172
- case 'html':
173
- if($config['html_field'] == true)
174
- {
175
-
176
- $count++;
177
- $is_last = $count >= $field_count && !$has_product_fields ? true : false;
178
- $last_row = $is_last ? ' lastrow' : '';
179
- $even = ($count%2) ? ' odd' : ' even';
180
-
181
- $display_value = $field['content'];
182
- $value = '';
183
-
184
- $content = '<div id="field-'. $field['id'] .'" class="entry-view-html-value' . $last_row . $even . '"><div class="value">' . $display_value . '</div></div>';
185
- $content = apply_filters('gfpdf_field_content', $content, $field, $value, $lead['id'], $form['id']);
186
-
187
- if($config['return'] === true)
188
- {
189
- $results['field'][] = $content;
190
- }
191
- else
192
- {
193
- echo $content;
194
- }
195
- }
196
- break;
197
- case 'signature':
198
- $value = RGFormsModel::get_lead_field_value($lead, $field);
199
- $public_folder = RGFormsModel::get_upload_url_root() . 'signatures/';
200
- $server_folder = RGFormsModel::get_upload_root() . 'signatures/';
201
- $file = $server_folder.$value;
202
- $display_value = false;
203
-
204
- $is_last = $count >= $field_count ? true : false;
205
- $last_row = $is_last ? ' lastrow' : '';
206
-
207
- if(file_exists($file) && !is_dir($file))
208
- {
209
- $image_size = getimagesize($file);
210
- $width = apply_filters('gfpdfe_signature_width', $image_size[0] / 4, $image_size[0]);
211
-
212
- $display_value = '<img src="'. $file .'" alt="Signature" width=" '. $width .'" />';
213
- }
214
-
215
- if($display_value)
216
- {
217
- $content = '<div id="field-'. $field['id'] .'" class="entry-view-field-value' . $last_row . $even . '"><div class="strong">' . esc_html(GFCommon::get_label($field)) . '</div> <div class="value">' . $display_value . '</div></div> ';
218
-
219
- if($config['return'] === true)
220
- {
221
- $results['field'][] = $content;
222
- }
223
- else
224
- {
225
- echo $content;
226
- }
227
- }
228
- elseif($config['empty_field'])
229
- {
230
- if($config['return'] === true)
231
- {
232
- $results['field'][] = '<div id="field-'. $field['id'] .'" class="entry-view-field-value' . $last_row . $even . '"><div class="strong">' . esc_html(GFCommon::get_label($field)) . '</div> <div class="value">&nbsp;</div></div>';
233
- }
234
- else
235
- {
236
- print '<div id="field-'. $field['id'] .'" class="entry-view-field-value' . $last_row . $even . '"><div class="strong">' . esc_html(GFCommon::get_label($field)) . '</div><div class="value">&nbsp;</div></div>';
237
- }
238
-
239
- }
240
- break;
241
-
242
- default:
243
-
244
- //ignore product fields as they will be grouped together at the end of the grid
245
- if(GFCommon::is_product_field($field['type'])){
246
- $has_product_fields = true;
247
- continue;
248
- }
249
-
250
- $value = RGFormsModel::get_lead_field_value($lead, $field);
251
- $display_value = self::pdf_get_lead_field_display($field, $value, $lead['currency']);
252
-
253
-
254
- $display_value = apply_filters('gform_entry_field_value', $display_value, $field, $lead, $form);
255
-
256
- if( !empty($display_value) || $display_value === '0' || $config['empty_field']){
257
- $count++;
258
- $is_last = $count >= $field_count && !$has_product_fields ? true : false;
259
- $last_row = $is_last ? ' lastrow' : '';
260
- $even = ($count%2) ? ' odd' : ' even';
261
-
262
- $display_value = empty($display_value) && $display_value !== '0' ? '&nbsp;' : $display_value;
263
-
264
- $content = '<div id="field-'. $field['id'] .'" class="entry-view-field-value' . $last_row . $even . '"><div class="strong">' . esc_html(GFCommon::get_label($field)) . '</div> <div class="value">' . $display_value . '</div></div>';
265
-
266
- $content = apply_filters('gfpdf_field_content', $content, $field, $value, $lead['id'], $form['id']);
267
-
268
- if($config['return'] === true)
269
- {
270
- $results['field'][] = $content;
271
- }
272
- else
273
- {
274
- echo $content;
275
- }
276
-
277
- }
278
- break;
279
- }
280
-
281
- }
282
- $products = array();
283
- if($has_product_fields){
284
- if($config['return'] === true)
285
- {
286
- ob_start();
287
- self::product_table($form, $lead);
288
- $results['field'][] = ob_get_contents();
289
- ob_end_clean();
290
- }
291
- else
292
- {
293
- self::product_table($form, $lead);
294
- }
295
-
296
- }
297
-
298
- if($config['return'] === true)
299
- {
300
- return $results;
301
- }
302
- ?>
303
- </div>
304
- <?php
305
- }
306
-
307
- public static function product_table($form, $lead)
308
- {
309
- $products = GFCommon::get_product_fields($form, $lead, true);
310
-
311
- $form_id = $form['id'];
312
- if(!empty($products['products'])){
313
- ?>
314
-
315
- <h2 class='default entry-view-field-name'><?php echo apply_filters("gform_order_label_{$form['id']}", apply_filters('gform_order_label', __('Order', 'gravityforms'), $form['id']), $form['id']) ?></h2>
316
-
317
- <table class='entry-products' autosize='1' cellspacing='0' width='97%'>
318
- <colgroup>
319
- <col class='entry-products-col1' />
320
- <col class='entry-products-col2' />
321
- <col class='entry-products-col3' />
322
- <col class='entry-products-col4' />
323
- </colgroup>
324
- <thead>
325
- <tr>
326
- <th scope='col'><?php echo apply_filters('gform_product_{$form_id}', apply_filters('gform_product', __('Product', 'gravityforms'), $form_id), $form_id) ?></th>
327
- <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>
328
- <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>
329
- <th scope='col'><?php echo apply_filters('gform_product_price_{$form_id}', apply_filters('gform_product_price', __('Price', 'gravityforms'), $form_id), $form_id) ?></th>
330
- </tr>
331
- </thead>
332
- <tbody>
333
- <?php
334
-
335
- $total = 0;
336
- foreach($products['products'] as $product){
337
- ?>
338
- <tr>
339
- <td>
340
- <div class='product_name'><?php echo esc_html($product['name'])?></div>
341
-
342
- <?php
343
- $price = GFCommon::to_number($product['price']);
344
- if(is_array(rgar($product,'options'))){
345
- echo '<ul class="product_options">';
346
- $count = sizeof($product['options']);
347
- $index = 1;
348
- foreach($product['options'] as $option){
349
- $price += GFCommon::to_number($option['price']);
350
- $class = $index == $count ? ' class="lastitem"' : '';
351
- $index++;
352
- ?>
353
- <li<?php echo $class?>><?php echo $option['option_label']?></li>
354
- <?php
355
- }
356
- echo '</ul>';
357
- }
358
- $subtotal = floatval($product['quantity']) * $price;
359
- $total += $subtotal;
360
- ?>
361
-
362
- </td>
363
- <td class='textcenter'><?php echo $product['quantity'] ?></td>
364
- <td><?php echo GFCommon::to_money($price, $lead['currency']) ?></td>
365
- <td><?php echo GFCommon::to_money($subtotal, $lead['currency']) ?></td>
366
- </tr>
367
- <?php
368
- }
369
- $total += floatval($products['shipping']['price']);
370
- ?>
371
-
372
-
373
- <?php
374
- if(!empty($products['shipping']['name'])){
375
- ?>
376
- <tr>
377
- <td colspan='2' rowspan='2' class='emptycell'>&nbsp;</td>
378
- <td class='textright shipping'><?php echo $products['shipping']['name'] ?></td>
379
- <td class='shipping_amount'><?php echo GFCommon::to_money($products['shipping']['price'], $lead['currency'])?>&nbsp;</td>
380
- </tr>
381
- <?php
382
- }
383
- ?>
384
- <tr>
385
- <?php
386
- if(empty($products['shipping']['name'])){
387
- ?>
388
- <td colspan='2' class='emptycell'>&nbsp;</td>
389
- <?php
390
- }
391
- ?>
392
- <td class='textright grandtotal'><?php _e('Total', 'gravityforms') ?></td>
393
- <td class='grandtotal_amount'><?php echo GFCommon::to_money($total, $lead['currency'])?></td>
394
- </tr>
395
- </tbody>
396
-
397
- </table>
398
-
399
- <?php
400
- }
401
- }
402
-
403
- /*
404
- * Public method for outputting likert (survey addon field)
405
- */
406
- public static function get_likert($form, $lead, $field_id)
407
- {
408
- $fields = self::$fields;
409
- $field = $fields[$field_id];
410
- $value = RGFormsModel::get_lead_field_value($lead, $field);
411
-
412
- $display_value = apply_filters('gform_entry_field_value', self::pdf_get_lead_field_display($field, $value, ''), $field, $lead, $form);
413
- $content = $display_value;
414
-
415
- $results = apply_filters('gfpdf_field_content', $content, $field, $value, $lead['id'], $form['id']);
416
-
417
- return $results;
418
- }
419
-
420
- public static function format_date($date, $usa = false)
421
- {
422
- $timestamp = strtotime($date);
423
- $new_date = (!$usa) ? date('j/n/Y', $timestamp) : date('n/j/Y', $timestamp);
424
- return $new_date;
425
- }
426
-
427
-
428
- /* returns the form values as an array instead of pre-formated html */
429
- public static function lead_detail_grid_array($form, $lead){
430
-
431
- $form_id = $form['id'];
432
- $form_array = self::set_form_array_common($form, $lead, $form_id);
433
-
434
- $has_product_fields = false;
435
-
436
- foreach($form['fields'] as $field) {
437
-
438
-
439
- /*
440
- * Add field descriptions to the $form_data array
441
- */
442
- if(isset($field['description']))
443
- {
444
- $form_array['field_descriptions'][$field['id']] = $field['description'];
445
- }
446
-
447
- switch(RGFormsModel::get_input_type($field)) {
448
- case 'section' :
449
- case 'html':
450
- $form_array = self::get_html($field, $form_array);
451
- break;
452
-
453
- case 'captcha':
454
- case 'password':
455
- case 'page':
456
- //ignore captcha, password and page
457
- break;
458
- case 'signature':
459
- $form_array = self::get_signature($form, $lead, $field, $form_array);
460
-
461
- break;
462
- case 'fileupload':
463
- $form_array = self::get_fileupload($form, $lead, $field, $form_array);
464
- break;
465
- case 'list':
466
- /*
467
- * We want list to run both this and the deafult so don't call break.
468
- * Get the list array and store it outside of [field] in a new key called ['list']
469
- */
470
- $form_array = self::get_default_list($lead, $field, $form_array);
471
-
472
- case 'select':
473
- case 'multiselect':
474
- case 'radio':
475
-
476
- if($field['type'] == 'quiz')
477
- {
478
- $form_array = self::get_quiz_radios($form, $lead, $field, $form_array);
479
- }
480
- elseif($field['type'] == 'poll' || $field['type'] == 'survey')
481
- {
482
- $form_array = self::get_poll_radios($form, $lead, $field, $form_array);
483
- }
484
- else
485
- {
486
- /* store values in regular [field] array */
487
- $form_array = self::get_the_list($lead, $field, $form_array);
488
- }
489
- break;
490
-
491
- case 'likert':
492
- $form_array['survey']['likert'][$field['id']] = self::get_the_likert($form, $lead, $field, $form_array);
493
- break;
494
-
495
- case 'rank':
496
- $form_array['survey']['rank'][$field['id']] = self::get_the_rank($form, $lead, $field, $form_array);
497
- break;
498
-
499
- case 'rating':
500
- $form_array['survey']['rating'][$field['id']] = self::get_the_rank($form, $lead, $field, $form_array);
501
- break;
502
-
503
- case 'checkbox':
504
- /* Only process non-survey checkbox fields */
505
- if($field['type'] == 'checkbox') {
506
- $form_array = self::get_the_list($lead, $field, $form_array);
507
- break;
508
- }
509
-
510
- default:
511
-
512
-
513
- //ignore product fields as they will be grouped together at the end of the grid
514
- if(GFCommon::is_product_field($field['type'])){
515
- $has_product_fields = true;
516
- continue;
517
- }
518
-
519
- $form_array = self::get_defaults($lead, $field, $form_array);
520
-
521
- break;
522
- }
523
-
524
- }
525
-
526
- $form_array = self::get_product_array($form, $lead, $has_product_fields, $form_array);
527
-
528
- return $form_array;
529
- }
530
-
531
- private static function get_quiz_radios($form, $lead, $field, $form_array)
532
- {
533
- $id = $field['id'];
534
- $results = $lead[$id];
535
- $return = array();
536
-
537
- foreach($field['choices'] as $choice)
538
- {
539
- if(trim($choice['value']) == trim($results))
540
- {
541
- $return = array('text' => $choice['text'], 'isCorrect' => $choice['gquizIsCorrect']);
542
- break;
543
- }
544
- }
545
-
546
- /* add data to field tag correctly */
547
- $form_array['field'][$field['id'].'.'.$field['label'].'_name'] = $return;
548
-
549
- /* add ID incase want to use template on multiple duplicate forms with different field names */
550
- $form_array['field'][$field['id']] = $return;
551
-
552
- return $form_array;
553
-
554
- }
555
-
556
- private static function get_poll_radios($form, $lead, $field, $form_array)
557
- {
558
-
559
- $id = $field['id'];
560
- $results = $lead[$id];
561
- $return = array();
562
-
563
- $return = self::get_poll_data($results, $field['choices']);
564
-
565
- /* add data to field tag correctly */
566
- $form_array['field'][$field['id'].'.'.$field['label'].'_name'] = $return;
567
-
568
- /* add ID incase want to use template on multiple duplicate forms with different field names */
569
- $form_array['field'][$field['id']] = $return;
570
-
571
- return $form_array;
572
-
573
- }
574
-
575
- private static function get_poll_checkbox($field, $values)
576
- {
577
- foreach($values as $id => $item)
578
- {
579
- $values[$id] = self::get_poll_data($item, $field['choices']);
580
- }
581
- return $values;
582
- }
583
-
584
- private static function get_poll_data($lookup, $options)
585
- {
586
- $return = '';
587
-
588
- foreach($options as $choice)
589
- {
590
- if(trim($choice['value']) == trim($lookup))
591
- {
592
- $return = $choice['text'];
593
- break;
594
- }
595
- }
596
-
597
- return $return;
598
- }
599
-
600
- private static function get_the_rank($form, $lead, $field, $form_array)
601
- {
602
- $id = $field['id'];
603
- $results = explode(',', $lead[$id]);
604
- $return = array();
605
-
606
- foreach($results as $rank)
607
- {
608
- foreach($field['choices'] as $choice)
609
- {
610
- if(trim($choice['value']) == trim($rank))
611
- {
612
- $return[] = $choice['text'];
613
- break;
614
- }
615
- }
616
- }
617
-
618
- return $return;
619
- }
620
-
621
- private static function get_the_likert($form, $lead, $field, $form_array)
622
- {
623
- $id = $field['id'];
624
- $multiple_rows = rgar($field, "gsurveyLikertEnableMultipleRows");
625
-
626
- if(!$multiple_rows)
627
- {
628
- $results = $lead[$id];
629
- }
630
-
631
- $likert = array();
632
-
633
- /* store the column names */
634
- foreach($field['choices'] as $col)
635
- {
636
- $likert['col'][$col['value']] = $col['text'];
637
- }
638
-
639
- if(is_array($field['inputs']) && sizeof($field['inputs']) > 0)
640
- {
641
- /* do our multi-row likert */
642
- foreach($field['inputs'] as $row)
643
- {
644
- /* pad the array with the number of columns */
645
-
646
- foreach($likert['col'] as $col_id => $text)
647
- {
648
- /*
649
- * Results for multi row is stored with ID.ROW# (eg $lead['1.2'])
650
- * The number is stored in $row['id']
651
- */
652
- $results = $lead[$row['id']];
653
-
654
- /* user data in the $lead comes in as ROW ID:COL ID */
655
- $comparison = $row['name'] . ':' . $col_id;
656
-
657
- /* do our comparison and update the output */
658
- $output = ($comparison == $results) ? 'selected' : '';
659
-
660
- /* assign our results to the array */
661
- $likert['rows'][$row['label']][$text] = $output;
662
-
663
- }
664
- }
665
- }
666
- else
667
- {
668
- /* do our single row likert */
669
- foreach($likert['col'] as $col_id => $text)
670
- {
671
- /* single row data comes in with col value */
672
- /* do our comparison and update the output */
673
- $output = ($col_id == $results) ? 'selected' : '';
674
-
675
- $likert['row'][$text] = $output;
676
-
677
- }
678
- }
679
-
680
- /*
681
- * Check if scoring is enabled and calculate
682
- */
683
- if($field['gsurveyLikertEnableScoring'] && class_exists('GFSurvey'))
684
- {
685
- $survey = GFSurvey::get_instance();
686
- $likert['score'] = $survey->get_field_score($field, $lead);
687
- }
688
-
689
- return $likert;
690
-
691
- }
692
-
693
- private static function get_form_fields($form)
694
- {
695
- $fields = array();
696
- foreach($form['fields'] as $field)
697
- {
698
- $fields[$field['id']] = $field;
699
- }
700
-
701
- self::$fields = $fields;
702
- }
703
-
704
- private static function set_form_array_common($form, $lead, $form_id)
705
- {
706
- /*
707
- * Reorder the $form array as we can access the info by Field ID
708
- */
709
- self::get_form_fields($form);
710
-
711
- $form_array = array();
712
-
713
- /*
714
- * Add form_id and lead_id
715
- */
716
- $form_array['form_id'] = $form_id;
717
- $form_array['entry_id'] = $lead['id'];
718
-
719
- /*
720
- * Set title and dates (both US and international)
721
- */
722
- $form_array['form_title'] = $form['title'];
723
- $form_array['form_description'] = (isset($form['description'])) ? $form['description'] : '';
724
- $form_array['date_created'] = self::format_date($lead['date_created']);
725
- $form_array['date_created_usa'] = self::format_date($lead['date_created'], true);
726
-
727
- /*
728
- * Include page names
729
- */
730
- $form_array['pages'] = $form['pagination']['pages'];
731
-
732
- /*
733
- * Add misc fields
734
- */
735
- $form_array['misc']['date_time'] = $lead['date_created'];
736
- $form_array['misc']['time_24hr'] = date('H:i', strtotime($lead['date_created']));
737
- $form_array['misc']['time_12hr'] = date('g:ia', strtotime($lead['date_created']));
738
- $form_array['misc']['is_starred'] = $lead['is_starred'];
739
- $form_array['misc']['is_read'] = $lead['is_read'];
740
- $form_array['misc']['ip'] = $lead['ip'];
741
- $form_array['misc']['source_url'] = $lead['source_url'];
742
- $form_array['misc']['post_id'] = $lead['post_id'];
743
- $form_array['misc']['currency'] = $lead['currency'];
744
- $form_array['misc']['payment_status'] = $lead['payment_status'];
745
- $form_array['misc']['payment_date'] = $lead['payment_date'];
746
- $form_array['misc']['transaction_id'] = $lead['transaction_id'];
747
- $form_array['misc']['payment_amount'] = $lead['payment_amount'];
748
- $form_array['misc']['is_fulfilled'] = $lead['is_fulfilled'];
749
- $form_array['misc']['created_by'] = $lead['created_by'];
750
- $form_array['misc']['transaction_type'] = $lead['transaction_type'];
751
- $form_array['misc']['user_agent'] = $lead['user_agent'];
752
- $form_array['misc']['status'] = $lead['status'];
753
-
754
-
755
-
756
- /*
757
- * Add quiz/survey/poll results
758
- */
759
-
760
- if(class_exists('GFQuiz'))
761
- {
762
- $form_array = self::get_quiz_results($form_array, $form, $lead);
763
- }
764
-
765
- if(class_exists('GFSurvey'))
766
- {
767
- $form_array = self::get_survey_results($form_array, $form, $lead);
768
- }
769
-
770
- if(class_exists('GFPolls'))
771
- {
772
- $form_array = self::get_poll_results($form_array, $form, $lead);
773
- }
774
-
775
- return $form_array;
776
- }
777
-
778
- /**
779
- * Sniff the form fields and determine if there are any of the $type avaluable
780
- * @param string $type the field type we are looking for
781
- * @param array $form the form array
782
- * @return boolean Whether there is a match or not
783
- */
784
- private static function check_for_fields($type, $form)
785
- {
786
- foreach($form['fields'] as $field)
787
- {
788
- if($field['type'] == $type)
789
- {
790
- return true;
791
- }
792
- }
793
- return false;
794
- }
795
-
796
- private static function get_poll_results($form_array, $form, $lead)
797
- {
798
- if(self::check_for_fields('poll', $form) === false)
799
- {
800
- return $form_array;
801
- }
802
-
803
- $fields = self::get_related_fields($form["fields"], 'poll');
804
- $poll_results = self::get_addon_global_data($form, array(), $fields);
805
-
806
- $form_fields = self::$fields;
807
-
808
- /*
809
- * Convert the array keys into their text counterparts
810
- * Loop through the global poll data
811
- */
812
- foreach($poll_results['field_data'] as $id => &$choices)
813
- {
814
- /* get the $field */
815
- $field = $form_fields[$id];
816
-
817
- /* add the field name to the ['misc'] key */
818
- $choices['misc']['label'] = $field['label'];
819
-
820
- /* loop through the field choices */
821
- foreach($field['choices'] as $choice)
822
- {
823
- $choices = self::replace_key($choices, $choice['value'], $choice['text']);
824
- }
825
- }
826
-
827
- $form_array['poll']['global'] = $poll_results;
828
-
829
- return $form_array;
830
- }
831
-
832
- private static function get_survey_results($form_array, $form, $lead)
833
- {
834
- if(self::check_for_fields('survey', $form) === false)
835
- {
836
- return $form_array;
837
- }
838
-
839
- /*
840
- * If there are any survey results
841
- * add them to the 'survey' key
842
- */
843
- $fields = GFCommon::get_fields_by_type($form, array('survey'));
844
- $count_survey_fields = count($fields);
845
-
846
- if ($count_survey_fields > 0 && isset($lead['gsurvey_score']))
847
- {
848
- $form_array['survey']['score'] = $lead['gsurvey_score'];
849
- }
850
-
851
- $fields = self::get_related_fields($form["fields"], 'survey');
852
- $form_array['survey']['global'] = self::get_addon_global_data($form, array(), $fields);
853
- $form_fields = self::$fields;
854
-
855
- /*
856
- * Convert the array keys into their text counterparts
857
- * Loop through the global survey data
858
- */
859
- foreach($form_array['survey']['global']['field_data'] as $id => &$choices)
860
- {
861
- /* get the $field */
862
- $field = $form_fields[$id];
863
-
864
- /*
865
- * Check if we have a multifield likert and replace the row key
866
- */
867
- if(isset($field['gsurveyLikertEnableMultipleRows']) && $field['gsurveyLikertEnableMultipleRows'] == 1)
868
- {
869
- foreach($field['gsurveyLikertRows'] as $row)
870
- {
871
- $choices = self::replace_key($choices, $row['value'], $row['text']);
872
- }
873
-
874
- foreach($choices as $multi_id => &$multi_choices)
875
- {
876
- foreach($field['choices'] as $choice)
877
- {
878
- $multi_choices = self::replace_key($multi_choices, $choice['value'], $choice['text']);
879
- }
880
- }
881
- }
882
-
883
-
884
- /* replace the standard row data */
885
- if(isset($field['choices']) && is_array($field['choices']))
886
- {
887
- foreach($field['choices'] as $choice)
888
- {
889
- $choices = self::replace_key($choices, $choice['value'], $choice['text']);
890
- }
891
- }
892
- }
893
-
894
- return $form_array;
895
-
896
- }
897
-
898
- private static function replace_key($array, $key, $text)
899
- {
900
- if($key != $text && isset($array[$key]))
901
- {
902
- /* replace the array key with the actual field name */
903
- $array[$text] = $array[$key];
904
- unset($array[$key]);
905
- }
906
- return $array;
907
- }
908
-
909
- private static function get_quiz_results($form_array, $form, $lead)
910
- {
911
-
912
- if(self::check_for_fields('quiz', $form) === false)
913
- {
914
- return $form_array;
915
- }
916
-
917
- /*
918
- * If there are any quiz results
919
- * add them to the 'quiz' key
920
- */
921
- $fields = GFCommon::get_fields_by_type($form, array('quiz'));
922
- $count_quiz_fields = count($fields);
923
-
924
- if ($count_quiz_fields > 0)
925
- {
926
- $form_array['quiz']['config']['grading'] = (isset($form['gravityformsquiz']['grading'])) ? $form['gravityformsquiz']['grading'] : '';
927
- $form_array['quiz']['config']['passPercent'] = (isset($form['gravityformsquiz']['passPercent'])) ? $form['gravityformsquiz']['passPercent'] : '';
928
- $form_array['quiz']['config']['grades'] = (isset($form['gravityformsquiz']['grades'])) ? $form['gravityformsquiz']['grades'] : '';
929
-
930
- $form_array['quiz']['results']['score'] = rgar($lead, 'gquiz_score');
931
- $form_array['quiz']['results']['percent'] = rgar($lead, 'gquiz_percent');
932
- $form_array['quiz']['results']['is_pass'] = rgar($lead, 'gquiz_is_pass');
933
- $form_array['quiz']['results']['grade'] = rgar($lead, 'gquiz_grade');
934
-
935
- /*
936
- * Get the overall results
937
- */
938
-
939
- $quiz_global = self::get_quiz_overalls($form);
940
-
941
- $form_fields = self::$fields;
942
- /*
943
- * Convert the array keys into their text counterparts
944
- * Loop through the global quiz data
945
- */
946
- if(empty($quiz_global['field_data']))
947
- {
948
- $quiz_global['field_data'] = array();
949
- }
950
-
951
- foreach($quiz_global['field_data'] as $id => &$choices)
952
- {
953
- /* get the $field */
954
- $field = $form_fields[$id];
955
-
956
- /* replace ['totals'] key with ['misc'] key */
957
- $choices = self::replace_key($choices, 'totals', 'misc');
958
-
959
- /* add the field name to the ['misc'] key */
960
- $choices['misc']['label'] = $field['label'];
961
-
962
- /* loop through the field choices */
963
- foreach($field['choices'] as $choice)
964
- {
965
- $choices = self::replace_key($choices, $choice['value'], $choice['text']);
966
-
967
- /* check if this is the correct field */
968
- if(isset($choice['gquizIsCorrect']) && $choice['gquizIsCorrect'] == 1)
969
- {
970
- $choices['misc']['correct_option_name'][] = $choice['text'];
971
- }
972
-
973
- }
974
- }
975
-
976
- $form_array['quiz']['global'] = $quiz_global;
977
- //$form_array['quiz']['global'] = self::get_quiz_overalls($form);
978
-
979
- }
980
-
981
- return $form_array;
982
- }
983
-
984
- private static function get_addon_global_data($form, $options, $fields)
985
- {
986
- /* if the results class isn't loaded, load it */
987
- if (!class_exists("GFResults"))
988
- {
989
- require_once(GFCommon::get_base_path() . "/includes/addon/class-gf-results.php");
990
- }
991
-
992
- $form_id = $form['id'];
993
-
994
- /* add form filter to keep in line with GF standard */
995
- $form = apply_filters( "gform_form_pre_results_$form_id", apply_filters( 'gform_form_pre_results', $form ) );
996
-
997
- /* initiat the results class */
998
- $gf_results = new GFResults('', $options);
999
-
1000
- /* ensure that only active leads are queried */
1001
- $search = array(
1002
- 'field_filters' => array('mode' => ''),
1003
- 'status' => 'active'
1004
- );
1005
-
1006
- /* get the results */
1007
- $data = $gf_results->get_results_data($form, $fields, $search);
1008
-
1009
- /* unset some array keys we don't need */
1010
- unset($data['status']);
1011
- unset($data['timestamp']);
1012
-
1013
- return $data;
1014
-
1015
- }
1016
-
1017
- /**
1018
- * Gravity Forms is throwing notices when accessing get_results_data()
1019
- * due to poor validation. To fix this we'll unset the 'choices' array key
1020
- * if it is not an array (the expected input for this function)
1021
- * @param Array $fields The fields array
1022
- * @return Array The processed fields array
1023
- */
1024
- private static function get_related_fields($fields, $type)
1025
- {
1026
- foreach($fields as $id => $field)
1027
- {
1028
- if($field['type'] !== $type)
1029
- {
1030
- unset($fields[$id]);
1031
- continue;
1032
- }
1033
- }
1034
-
1035
- return $fields;
1036
- }
1037
-
1038
- private static function get_quiz_overalls($form)
1039
- {
1040
- /* we need to tap into functions GF Quiz has so only run if it is active */
1041
- if(class_exists('GFQuiz'))
1042
- {
1043
- /* GFQuiz is a singleton. Get the instance */
1044
- $quiz = GFQuiz::get_instance();
1045
-
1046
- /* create our callback to add additional data to the array specific to the quiz plugin */
1047
- $options['callbacks']['calculation'] = array(
1048
- $quiz,
1049
- 'results_calculation'
1050
- );
1051
-
1052
- $fields = self::get_related_fields($form["fields"], 'quiz');
1053
-
1054
- $quiz_results = self::get_addon_global_data($form, $options, $fields);
1055
-
1056
- return $quiz_results;
1057
- }
1058
-
1059
- return array(__('Activate Gravity Forms Quiz Add On to see global quiz statistics for this form', 'pdfextended'));
1060
- }
1061
-
1062
- private static function get_html($field, $form_array)
1063
- {
1064
- if(isset($field['content']))
1065
- {
1066
- $form_array['html'][] = wpautop($field['content']);
1067
- $form_array['html_id'][$field['id']] = wpautop($field['content']);
1068
- }
1069
-
1070
- return $form_array;
1071
- }
1072
-
1073
- private static function get_signature($form, $lead, $field, $form_array)
1074
- {
1075
- $value = RGFormsModel::get_lead_field_value($lead, $field);
1076
- $http_folder = RGFormsModel::get_upload_url_root(). 'signatures/';
1077
- $server_folder = RGFormsModel::get_upload_root() . 'signatures/';
1078
- $file = $server_folder.$value;
1079
- $sig_html = '';
1080
-
1081
- /*
1082
- * Set defaults is we cannot find the images
1083
- */
1084
- $width = 75;
1085
- $height = 45;
1086
-
1087
- /*
1088
- * Only get sane defaults specific to the image if we can find it.
1089
- */
1090
- if(file_exists($file) !== false && is_dir($file) !== true)
1091
- {
1092
- $image_size = getimagesize($file);
1093
- $width = $image_size[0] / 4;
1094
- $height = $image_size[1] / 4;
1095
- $sig_html = '<img src="'. $server_folder.$value .'" alt="Signature" width="'. $width .'" height="'. $height .'" />';
1096
- }
1097
-
1098
- /*
1099
- * Include the image details
1100
- */
1101
-
1102
-
1103
- $form_array['signature'][] = $sig_html;
1104
- $form_array['signature_details'][] = array(
1105
- 'img' => $sig_html,
1106
- 'path' => $file,
1107
- 'url' => $http_folder.$value,
1108
- 'width' => $width,
1109
- 'height' => $height,
1110
- );
1111
-
1112
- $form_array['signature_details_id'][$field['id']] = array(
1113
- 'img' => $sig_html,
1114
- 'path' => $file,
1115
- 'url' => $http_folder.$value,
1116
- 'width' => $width,
1117
- 'height' => $height,
1118
- );
1119
-
1120
-
1121
- return $form_array;
1122
- }
1123
-
1124
- private static function get_fileupload($form, $lead, $field, $form_array)
1125
- {
1126
- $value = RGFormsModel::get_lead_field_value($lead, $field);
1127
- $display = self::get_lead_field_display($field, $value, $lead['currency']);
1128
-
1129
- /*
1130
- * Get the absolute path to the upload
1131
- */
1132
- $path = str_replace(home_url().'/', ABSPATH, $display);
1133
-
1134
- /* add path */
1135
- $form_array['field'][$field['id'].'_path'] = $path;
1136
- $form_array['field'][$field['id'].'.'.$field['label'].'_path'] = $path;
1137
-
1138
- return self::assign_form($field, $display, $form_array);
1139
- }
1140
-
1141
- private static function get_default_list($lead, $field, $form_array)
1142
- {
1143
- $value = self::remove_empty_list_rows(unserialize(RGFormsModel::get_lead_field_value($lead, $field)));
1144
- $form_array['list'][$field['id']] = $value;
1145
-
1146
- return $form_array;
1147
- }
1148
-
1149
- private static function remove_empty_list_rows($list)
1150
- {
1151
- /*
1152
- * Check if there are any values in the list
1153
- */
1154
- if(!is_array($list) || sizeof($list) == 0)
1155
- {
1156
- return $list;
1157
- }
1158
-
1159
- /*
1160
- * Check if it's a multi column list
1161
- */
1162
- if(!is_array($list[0]))
1163
- {
1164
- $list = array_filter($list);
1165
- }
1166
- else
1167
- {
1168
- $list = self::remove_empty_multi_col_list($list);
1169
- }
1170
-
1171
- return $list;
1172
- }
1173
-
1174
- private static function remove_empty_multi_col_list($list)
1175
- {
1176
- foreach($list as $id => $row)
1177
- {
1178
-
1179
- $empty = true;
1180
- foreach($row as &$col)
1181
- {
1182
- /* check if there is data and if so break the loop */
1183
- if(trim(strlen($col) > 0))
1184
- {
1185
- $empty = false;
1186
- break;
1187
- }
1188
- }
1189
-
1190
- /* remove row from list */
1191
- if($empty)
1192
- {
1193
- unset($list[$id]);
1194
- }
1195
- }
1196
-
1197
- return $list;
1198
- }
1199
-
1200
- private static function get_the_list($lead, $field, $form_array)
1201
- {
1202
- $value = RGFormsModel::get_lead_field_value($lead, $field);
1203
- $display = self::get_lead_field_display($field, $value, $lead['currency']);
1204
-
1205
- $form_array = self::assign_form($field, $display, $form_array);
1206
-
1207
- /*
1208
- * Include these items correct names
1209
- */
1210
- $display = self::get_lead_field_display($field, $value, $lead['currency'], true);
1211
- /* add data to field tag correctly */
1212
- $form_array['field'][$field['id'].'.'.$field['label'].'_name'] = $display;
1213
-
1214
- /* add ID incase want to use template on multiple duplicate forms with different field names */
1215
- $form_array['field'][$field['id'].'_name'] = $display;
1216
-
1217
- /* keep backwards compatibility */
1218
- $form_array['field'][$field['label'].'_name'] = $display;
1219
-
1220
- return $form_array;
1221
- }
1222
-
1223
- private static function get_defaults($lead, $field, $form_array)
1224
- {
1225
- $value = RGFormsModel::get_lead_field_value($lead, $field);
1226
- $display = self::get_lead_field_display($field, $value, $lead['currency']);
1227
-
1228
- return self::assign_form($field, $display, $form_array);
1229
- }
1230
-
1231
- private static function assign_form($field, $display, $form_array)
1232
- {
1233
- /* add data to field tag correctly */
1234
- $form_array['field'][$field['id'].'.'.$field['label']] = $display;
1235
-
1236
- /* add ID incase want to use template on multiple duplicate forms with different field names */
1237
- $form_array['field'][$field['id']] = $display;
1238
-
1239
- /* keep backwards compatibility */
1240
- $form_array['field'][$field['label']] = $display;
1241
-
1242
- return $form_array;
1243
- }
1244
-
1245
- private static function get_product_array($form, $lead, $has_product_fields, $form_array)
1246
- {
1247
- $currency_type = (method_exists('GFCommon', 'is_currency_decimal_dot')) ? GFCommon::is_currency_decimal_dot() : PDF_Common::is_currency_decimal_dot();
1248
- $currency_format = $currency_type ? 'decimal_dot' : 'decimal_comma';
1249
-
1250
- if($has_product_fields) {
1251
- $products = GFCommon::get_product_fields($form, $lead, true);
1252
-
1253
- /* check that there are actual product fields */
1254
- if(sizeof($products['products']) > 0 )
1255
- {
1256
-
1257
- /*
1258
- * Set up our variables
1259
- */
1260
- $total = 0;
1261
- $subtotal = 0;
1262
-
1263
- foreach($products['products'] as $id => $product) {
1264
- $price = GFCommon::to_number($product['price']);
1265
-
1266
- /* add all options to total price */
1267
- if(is_array(rgar($product,'options')))
1268
- {
1269
- foreach($product['options'] as $option){
1270
- $price += GFCommon::to_number($option['price']);
1271
- }
1272
- }
1273
-
1274
- /* calculate subtotal */
1275
- $subtotal = floatval($product['quantity']) * $price;
1276
- $total += $subtotal;
1277
-
1278
- /*
1279
- * Check if we should include options
1280
- */
1281
- $options = isset($product['options']) ? $product['options'] : array();
1282
-
1283
- /*
1284
- * Add formated price for each product option
1285
- */
1286
- foreach($options as &$o)
1287
- {
1288
- if(is_numeric($o['price']))
1289
- {
1290
- $o['price_formatted'] = GFCommon::format_number($o['price'], 'currency');
1291
- }
1292
- }
1293
-
1294
- /*
1295
- * Store product in $form_array array
1296
- */
1297
- $form_array['products'][$id] = array(
1298
- 'name' => esc_html($product['name']),
1299
- 'price' => esc_html($product['price']),
1300
- 'price_unformatted' => GFCommon::clean_number($product['price'], $currency_format),
1301
- 'options' => $options,
1302
- 'quantity' => $product['quantity'],
1303
- 'subtotal' => $subtotal,
1304
- 'subtotal_formatted' => GFCommon::format_number($subtotal, 'currency'));
1305
- }
1306
-
1307
- /* Increment total */
1308
- $total += floatval($products['shipping']['price']);
1309
- $subtotal = $total - floatval($products['shipping']['price']);
1310
-
1311
- /* add totals to form data */
1312
- $form_array['products_totals'] = array(
1313
- 'subtotal' => $subtotal,
1314
- 'shipping' => $products['shipping']['price'],
1315
- 'total' => $total,
1316
- 'shipping_formatted' => GFCommon::format_number($products['shipping']['price'], 'currency'),
1317
- 'subtotal_formatted' => GFCommon::format_number($subtotal, 'currency'),
1318
- 'total_formatted' => GFCommon::format_number($total, 'currency'),
1319
- );
1320
- }
1321
- }
1322
-
1323
- return $form_array;
1324
- }
1325
-
1326
- public static function get_lead_field_display($field, $value, $currency='', $use_text=false, $format='html', $media='screen'){
1327
-
1328
- if($field['type'] == 'post_category')
1329
- $value = GFCommon::prepare_post_category_value($value, $field);
1330
-
1331
- switch(RGFormsModel::get_input_type($field)){
1332
- case 'name' :
1333
- if(is_array($value)){
1334
- $prefix = trim(rgget($field['id'] . '.2', $value));
1335
- $first = trim(rgget($field['id'] . '.3', $value));
1336
- $middle = trim(rgget($field['id'] . '.4', $value));
1337
- $last = trim(rgget($field['id'] . '.6', $value));
1338
- $suffix = trim(rgget($field['id'] . '.8', $value));
1339
-
1340
- return array('prefix' => $prefix, 'first' => $first, 'middle' => $middle, 'last' => $last, 'suffix' => $suffix);
1341
- }
1342
- else{
1343
- return $value;
1344
- }
1345
-
1346
- break;
1347
- case 'creditcard' :
1348
- if(is_array($value)){
1349
- $card_number = trim(rgget($field['id'] . '.1', $value));
1350
- $card_type = trim(rgget($field['id'] . '.4', $value));
1351
- return array('card_number' => $card_number, 'card_type' => $card_type);
1352
- }
1353
- else{
1354
- return '';
1355
- }
1356
- break;
1357
-
1358
- case 'address' :
1359
- if(is_array($value)){
1360
- $street_value = trim(rgget($field['id'] . '.1', $value));
1361
- $street2_value = trim(rgget($field['id'] . '.2', $value));
1362
- $city_value = trim(rgget($field['id'] . '.3', $value));
1363
- $state_value = trim(rgget($field['id'] . '.4', $value));
1364
- $zip_value = trim(rgget($field['id'] . '.5', $value));
1365
- $country_value = trim(rgget($field['id'] . '.6', $value));
1366
-
1367
- $line_break = $format == 'html' ? '<br />' : '\n';
1368
-
1369
- $address_display_format = apply_filters('gform_address_display_format', 'default');
1370
-
1371
- $address['street'] = $street_value;
1372
- $address['street2'] = $street2_value;
1373
- $address['city'] = $city_value;
1374
- $address['state'] = $state_value;
1375
- $address['zip'] = $zip_value;
1376
- $address['country'] = $country_value;
1377
-
1378
- return $address;
1379
- }
1380
- else{
1381
- return '';
1382
- }
1383
- break;
1384
-
1385
- case 'email' :
1386
- return GFCommon::is_valid_email($value) && $format == 'html' ? $value : $value;
1387
- break;
1388
-
1389
- case 'website' :
1390
- return GFCommon::is_valid_url($value) && $format == 'html' ? $value : $value;
1391
- break;
1392
-
1393
- case 'checkbox' :
1394
- if(is_array($value)){
1395
-
1396
- $items = array();
1397
-
1398
- foreach($value as $key => $item){
1399
- if(!empty($item)) {
1400
- if($field['type'] == 'poll' || $field['type'] == 'survey')
1401
- {
1402
- /*
1403
- * Convert our poll type
1404
- */
1405
- $items[] = self::get_poll_checkbox($field, $value);
1406
- return $items;
1407
- }
1408
-
1409
- switch($format){
1410
- case 'text' :
1411
- $items[] = GFCommon::selection_display($item, $field, $currency, $use_text);
1412
- break;
1413
-
1414
- default:
1415
- $items[] = GFCommon::selection_display($item, $field, $currency, $use_text);
1416
- break;
1417
- }
1418
- }
1419
- }
1420
- if(empty($items)){
1421
- return '';
1422
- }
1423
- else if($format == 'text'){
1424
- /*return substr($items, 0, strlen($items)-2); //removing last comma*/
1425
- }
1426
- else{
1427
- return $items;
1428
- }
1429
- }
1430
- else{
1431
- return $value;
1432
- }
1433
- break;
1434
-
1435
- case 'post_image' :
1436
- $ary = explode('|:|', $value);
1437
- $url = count($ary) > 0 ? $ary[0] : '';
1438
- $title = count($ary) > 1 ? $ary[1] : '';
1439
- $caption = count($ary) > 2 ? $ary[2] : '';
1440
- $description = count($ary) > 3 ? $ary[3] : '';
1441
-
1442
- if(!empty($url)){
1443
- $url = str_replace(' ', '%20', $url);
1444
-
1445
- $value = array('url' => $url,
1446
- 'path' => str_replace(site_url().'/', ABSPATH, $url),
1447
- 'title' => $title,
1448
- 'caption' => $caption,
1449
- 'description' => $description);
1450
- }
1451
- return $value;
1452
-
1453
- case 'fileupload' :
1454
- $output_arr = array();
1455
- if(!empty($value)){
1456
- $file_paths = rgar($field,'multipleFiles') ? json_decode($value) : array($value);
1457
- foreach($file_paths as $file_path){
1458
- $info = pathinfo($file_path);
1459
- $file_path = esc_attr(str_replace(' ', '%20', $file_path));
1460
- $output_arr[] = $file_path;
1461
- }
1462
- $output = join(PHP_EOL, $output_arr);
1463
- }
1464
- return $output_arr;
1465
- break;
1466
-
1467
- case 'date' :
1468
- return GFCommon::date_display($value, rgar($field, 'dateFormat'));
1469
- break;
1470
-
1471
- case 'radio' :
1472
- case 'select' :
1473
- return GFCommon::selection_display($value, $field, $currency, $use_text);
1474
- break;
1475
-
1476
- case 'multiselect' :
1477
- if(empty($value) || $format == 'text')
1478
- return $value;
1479
-
1480
- if(!is_array($value))
1481
- {
1482
- $value = explode(',', $value);
1483
- }
1484
-
1485
- $items = '';
1486
- foreach($value as $item){
1487
- $items[] = GFCommon::selection_display($item, $field, $currency, $use_text);
1488
- }
1489
-
1490
- if(sizeof($items) == 1)
1491
- {
1492
- return $items[0];
1493
- }
1494
- return $items;
1495
-
1496
-
1497
- break;
1498
-
1499
- case 'calculation' :
1500
- case 'singleproduct' :
1501
- if(is_array($value)){
1502
- $product_name = trim($value[$field['id'] . '.1']);
1503
- $price = trim($value[$field['id'] . '.2']);
1504
- $quantity = trim($value[$field['id'] . '.3']);
1505
-
1506
- $product = $product_name . ', ' . __('Qty: ', 'gravityforms') . $quantity . ', ' . __('Price: ', 'gravityforms') . $price;
1507
-
1508
- return $product;
1509
- }
1510
- else{
1511
- return '';
1512
- }
1513
- break;
1514
-
1515
- case 'number' :
1516
- return GFCommon::format_number($value, rgar($field, 'numberFormat'));
1517
- break;
1518
-
1519
- case 'singleshipping' :
1520
- case 'donation' :
1521
- case 'total' :
1522
- case 'price' :
1523
- return GFCommon::to_money($value, $currency);
1524
-
1525
- case 'list' :
1526
- if(empty($value))
1527
- return '';
1528
- $value = unserialize($value);
1529
-
1530
- $has_columns = is_array($value[0]);
1531
-
1532
- if(!$has_columns){
1533
- $items = array();
1534
- foreach($value as $key => $item){
1535
- if(!empty($item)){
1536
- switch($format){
1537
- case 'text' :
1538
- $items[] = $item;
1539
- break;
1540
- case 'url' :
1541
- $items[] = $item;
1542
- break;
1543
- default :
1544
- if($media == 'email'){
1545
- $items[] = $item;
1546
- }
1547
- else{
1548
- $items[] = $item;
1549
- }
1550
- break;
1551
- }
1552
- }
1553
- }
1554
-
1555
- if(empty($items)){
1556
- return '';
1557
- }
1558
- else if($format == 'text'){
1559
- /* return substr($items, 0, strlen($items)-2); //removing last comma*/
1560
- return $items;
1561
- }
1562
- else if($format == 'url'){
1563
- /*return substr($items, 0, strlen($items)-1); //removing last comma*/
1564
- return $items;
1565
- }
1566
- else if($media == 'email'){
1567
- return $items;
1568
- }
1569
- else {
1570
- $list = '<table autosize="1" 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%">';
1571
- foreach($items as $i)
1572
- {
1573
- $list .= '<tr><td>' . $i .'</td></tr>';
1574
- }
1575
- $list .= '</table>';
1576
-
1577
- return $list;
1578
- }
1579
- }
1580
- else if(is_array($value)){
1581
- $columns = array_keys($value[0]);
1582
-
1583
- $list = '';
1584
-
1585
- switch($format){
1586
- case 'text' :
1587
- $is_first_row = true;
1588
- foreach($value as $item){
1589
- if(!$is_first_row)
1590
- $list .= '\n\n' . $field['label'] . ': ';
1591
- $list .= implode(',', array_values($item));
1592
-
1593
- $is_first_row = false;
1594
- }
1595
- break;
1596
-
1597
- case 'url' :
1598
- foreach($value as $item){
1599
- $list .= implode('|', array_values($item)) . ',';
1600
- }
1601
- if(!empty($list))
1602
- $list = substr($list, 0, strlen($list)-1);
1603
- break;
1604
-
1605
- default :
1606
-
1607
- if($media == 'email'){
1608
- $list = '<table autosize="1" 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>';
1609
-
1610
- //reading columns from entry data
1611
- foreach($columns as $column){
1612
- $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>';
1613
- }
1614
- $list .= '</tr></thead>';
1615
-
1616
- $list .= '<tbody style="background-color: #F9F9F9">';
1617
- foreach($value as $item){
1618
- $list .= '<tr>';
1619
- foreach($columns as $column){
1620
- $val = rgar($item, $column);
1621
- $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>';
1622
- }
1623
-
1624
- $list .='</tr>';
1625
- }
1626
-
1627
- $list .='</tbody></table>';
1628
- }
1629
- else{
1630
- $list = '<table class="gfield_list" autosize="1"><thead><tr>';
1631
-
1632
- //reading columns from entry data
1633
- foreach($columns as $column){
1634
- $list .= '<th>' . esc_html($column) . '</th>';
1635
- }
1636
- $list .= '</tr></thead>';
1637
-
1638
- $list .= '<tbody>';
1639
- foreach($value as $item){
1640
- $list .= '<tr>';
1641
- foreach($columns as $column){
1642
- $val = rgar($item, $column);
1643
- $list .= '<td>'.htmlspecialchars($val).'</td>';
1644
- }
1645
-
1646
- $list .='</tr>';
1647
- }
1648
-
1649
- $list .='</tbody></table>';
1650
- }
1651
- break;
1652
- }
1653
-
1654
- return $list;
1655
- }
1656
- return '';
1657
- break;
1658
-
1659
- default :
1660
- if (!is_array($value))
1661
- {
1662
- return nl2br($value);
1663
- }
1664
- break;
1665
- }
1666
- }
1667
-
1668
- public static function pdf_get_lead_field_display($field, $value, $currency='', $use_text=false, $format='html', $media='screen'){
1669
-
1670
- if($field['type'] == 'post_category')
1671
- $value = GFCommon::prepare_post_category_value($value, $field);
1672
-
1673
- switch(RGFormsModel::get_input_type($field)){
1674
- case 'name' :
1675
- if(is_array($value)){
1676
- $prefix = trim(rgget($field['id'] . '.2', $value));
1677
- $first = trim(rgget($field['id'] . '.3', $value));
1678
- $middle = trim(rgget($field['id'] . '.4', $value));
1679
- $last = trim(rgget($field['id'] . '.6', $value));
1680
- $suffix = trim(rgget($field['id'] . '.8', $value));
1681
-
1682
- $name = $prefix;
1683
- $name .= !empty($name) && !empty($first) ? " $first" : $first;
1684
- $name .= !empty($name) && !empty($middle) ? " $middle" : $middle;
1685
- $name .= !empty($name) && !empty($last) ? " $last" : $last;
1686
- $name .= !empty($name) && !empty($suffix) ? " $suffix" : $suffix;
1687
-
1688
- return $name;
1689
- }
1690
- else{
1691
- return $value;
1692
- }
1693
-
1694
- break;
1695
- case 'creditcard' :
1696
- if(is_array($value)){
1697
- $card_number = trim(rgget($field['id'] . '.1', $value));
1698
- $card_type = trim(rgget($field['id'] . '.4', $value));
1699
- $separator = $format == 'html' ? '<br/>' : '\n';
1700
- return empty($card_number) ? '' : $card_type . $separator . $card_number;
1701
- }
1702
- else{
1703
- return '';
1704
- }
1705
- break;
1706
-
1707
- case 'address' :
1708
- if(is_array($value)){
1709
- $street_value = trim(rgget($field['id'] . '.1', $value));
1710
- $street2_value = trim(rgget($field['id'] . '.2', $value));
1711
- $city_value = trim(rgget($field['id'] . '.3', $value));
1712
- $state_value = trim(rgget($field['id'] . '.4', $value));
1713
- $zip_value = trim(rgget($field['id'] . '.5', $value));
1714
- $country_value = trim(rgget($field['id'] . '.6', $value));
1715
-
1716
- $line_break = $format == 'html' ? '<br />' : '\n';
1717
-
1718
- $address_display_format = apply_filters('gform_address_display_format', 'default');
1719
- if($address_display_format == 'zip_before_city'){
1720
- /*
1721
- Sample:
1722
- 3333 Some Street
1723
- suite 16
1724
- 2344 City, State
1725
- Country
1726
- */
1727
-
1728
- $addr_ary = array();
1729
- $addr_ary[] = $street_value;
1730
-
1731
- if(!empty($street2_value))
1732
- $addr_ary[] = $street2_value;
1733
-
1734
- $zip_line = trim($zip_value . ' ' . $city_value);
1735
- $zip_line .= !empty($zip_line) && !empty($state_value) ? ", {$state_value}" : $state_value;
1736
- $zip_line = trim($zip_line);
1737
- if(!empty($zip_line))
1738
- $addr_ary[] = $zip_line;
1739
-
1740
- if(!empty($country_value))
1741
- $addr_ary[] = $country_value;
1742
-
1743
- $address = implode('<br />', $addr_ary);
1744
-
1745
- }
1746
- else{
1747
- $address = $street_value;
1748
- $address .= !empty($address) && !empty($street2_value) ? $line_break . $street2_value : $street2_value;
1749
- $address .= !empty($address) && (!empty($city_value) || !empty($state_value)) ? $line_break. $city_value : $city_value;
1750
- $address .= !empty($address) && !empty($city_value) && !empty($state_value) ? ", $state_value" : $state_value;
1751
- $address .= !empty($address) && !empty($zip_value) ? " $zip_value" : $zip_value;
1752
- $address .= !empty($address) && !empty($country_value) ? $line_break . $country_value : $country_value;
1753
- }
1754
-
1755
- return $address;
1756
- }
1757
- else{
1758
- return '';
1759
- }
1760
- break;
1761
-
1762
- case 'email' :
1763
- return GFCommon::is_valid_email($value) && $format == 'html' ? '<a href="mailto:'. $value .'">'. $value .'</a>' : $value;
1764
- break;
1765
-
1766
- case 'website' :
1767
- return GFCommon::is_valid_url($value) && $format == 'html' ? '<a href="'. $value .'" target="_blank">'. $value .'</a>' : $value;
1768
- break;
1769
-
1770
- case 'checkbox' :
1771
- if(is_array($value)){
1772
-
1773
- $items = '';
1774
-
1775
- foreach($value as $key => $item){
1776
- if(!empty($item)){
1777
- switch($format){
1778
- case 'text' :
1779
- $items .= GFCommon::selection_display($item, $field, $currency, true) . ', ';
1780
- break;
1781
-
1782
- default:
1783
- $items .= '<li>' . GFCommon::selection_display($item, $field, $currency, true) . '</li>';
1784
- break;
1785
- }
1786
- }
1787
- }
1788
- if(empty($items)){
1789
- return '';
1790
- }
1791
- else if($format == 'text'){
1792
- return substr($items, 0, strlen($items)-2); //removing last comma
1793
- }
1794
- else{
1795
- return '<ul class="bulleted">' . $items . '</ul>';
1796
- }
1797
- }
1798
- else{
1799
- return $value;
1800
- }
1801
- break;
1802
-
1803
- case 'post_image' :
1804
- $ary = explode('|:|', $value);
1805
- $url = count($ary) > 0 ? $ary[0] : '';
1806
- $title = count($ary) > 1 ? $ary[1] : '';
1807
- $caption = count($ary) > 2 ? $ary[2] : '';
1808
- $description = count($ary) > 3 ? $ary[3] : '';
1809
-
1810
- if(!empty($url)){
1811
- $url = str_replace(' ', '%20', $url);
1812
- switch($format){
1813
- case 'text' :
1814
- $value = $url;
1815
- $value .= !empty($title) ? '\n\n' . $field['label'] . ' (' . __('Title', 'gravityforms') . '): ' . $title : '';
1816
- $value .= !empty($caption) ? '\n\n' . $field['label'] . ' (' . __('Caption', 'gravityforms') . '): ' . $caption : '';
1817
- $value .= !empty($description) ? '\n\n' . $field['label'] . ' (' . __('Description', 'gravityforms') . '): ' . $description : '';
1818
- break;
1819
-
1820
- default :
1821
- $path = str_replace(site_url().'/', ABSPATH, $url);
1822
- $value = "<a href='$url' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='$path' width='100' /></a>";
1823
- $value .= !empty($title) ? "<div>Title: $title</div>" : "";
1824
- $value .= !empty($caption) ? "<div>Caption: $caption</div>" : "";
1825
- $value .= !empty($description) ? "<div>Description: $description</div>": "";
1826
-
1827
- break;
1828
- }
1829
- }
1830
- return $value;
1831
-
1832
- case 'fileupload' :
1833
- $output = '';
1834
- $output_arr = array();
1835
- if(!empty($value)){
1836
- $output .= '<ul>';
1837
- $file_paths = rgar($field,'multipleFiles') ? json_decode($value) : array($value);
1838
- foreach($file_paths as $file_path){
1839
- $info = pathinfo($file_path);
1840
- $file_path = esc_attr(str_replace(' ', '%20', $file_path));
1841
- $output_arr[] = '<li><a href="'. $file_path .'" target="_blank" title="' . __('Click to view', 'gravityforms') . '">' . $info['basename'] . '</a></li>';
1842
- }
1843
- $output .= join(PHP_EOL, $output_arr);
1844
- $output .= '</ul>';
1845
- }
1846
-
1847
- return $output;
1848
- break;
1849
-
1850
- case 'date' :
1851
- return GFCommon::date_display($value, rgar($field, 'dateFormat'));
1852
- break;
1853
-
1854
- case 'radio' :
1855
- case 'select' :
1856
- return GFCommon::selection_display($value, $field, $currency, true);
1857
- break;
1858
-
1859
- case 'multiselect' :
1860
- if(empty($value) || $format == 'text')
1861
- return $value;
1862
-
1863
- if(!is_array($value))
1864
- {
1865
- $value = explode(',', $value);
1866
- }
1867
-
1868
- $items = '';
1869
- foreach($value as $item){
1870
- $items .= '<li>' . GFCommon::selection_display($item, $field, $currency, true) . '</li>';
1871
- }
1872
-
1873
- return '<ul class="bulleted">' . $items . '</ul>';
1874
-
1875
- break;
1876
-
1877
- case 'calculation' :
1878
- case 'singleproduct' :
1879
- if(is_array($value)){
1880
- $product_name = trim($value[$field['id'] . '.1']);
1881
- $price = trim($value[$field['id'] . '.2']);
1882
- $quantity = trim($value[$field['id'] . '.3']);
1883
-
1884
- $product = $product_name . ', ' . __('Qty: ', 'gravityforms') . $quantity . ', ' . __('Price: ', 'gravityforms') . $price;
1885
- return $product;
1886
- }
1887
- else{
1888
- return '';
1889
- }
1890
- break;
1891
-
1892
- case 'number' :
1893
- return GFCommon::format_number($value, rgar($field, 'numberFormat'));
1894
- break;
1895
-
1896
- case 'singleshipping' :
1897
- case 'donation' :
1898
- case 'total' :
1899
- case 'price' :
1900
- return GFCommon::to_money($value, $currency);
1901
-
1902
- case 'list' :
1903
- if(empty($value))
1904
- return '';
1905
- $value = unserialize($value);
1906
-
1907
- $has_columns = is_array($value[0]);
1908
-
1909
- if(!$has_columns){
1910
- $items = '';
1911
- foreach($value as $key => $item){
1912
- if(!empty($item)){
1913
- switch($format){
1914
- case 'text' :
1915
- $items .= $item . ', ';
1916
- break;
1917
- case 'url' :
1918
- $items .= $item . ',';
1919
- break;
1920
- default :
1921
- if($media == 'email'){
1922
- $items .= '<li>'.htmlspecialchars($item).'</li>';
1923
- }
1924
- else{
1925
- $items .= '<li>'.htmlspecialchars($item).'</li>';
1926
- }
1927
- break;
1928
- }
1929
- }
1930
- }
1931
-
1932
- if(empty($items)){
1933
- return '';
1934
- }
1935
- else if($format == 'text'){
1936
- return substr($items, 0, strlen($items)-2); //removing last comma
1937
- }
1938
- else if($format == 'url'){
1939
- return substr($items, 0, strlen($items)-1); //removing last comma
1940
- }
1941
- else{
1942
- return '<ul class="bulleted">' . $items . '</ul>';
1943
- }
1944
- }
1945
- else if(is_array($value)){
1946
- $columns = array_keys($value[0]);
1947
-
1948
- $list = '';
1949
-
1950
- switch($format){
1951
- case 'text' :
1952
- $is_first_row = true;
1953
- foreach($value as $item){
1954
- if(!$is_first_row)
1955
- $list .= '\n\n' . $field['label'] . ': ';
1956
- $list .= implode(',', array_values($item));
1957
-
1958
- $is_first_row = false;
1959
- }
1960
- break;
1961
-
1962
- case 'url' :
1963
- foreach($value as $item){
1964
- $list .= implode('|', array_values($item)) . ',';
1965
- }
1966
- if(!empty($list))
1967
- $list = substr($list, 0, strlen($list)-1);
1968
- break;
1969
-
1970
- default :
1971
- if($media == 'email'){
1972
- $list = '<table autosize="1" 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>';
1973
-
1974
- //reading columns from entry data
1975
- foreach($columns as $column){
1976
- $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>';
1977
- }
1978
- $list .= '</tr></thead>';
1979
-
1980
- $list .= '<tbody style="background-color: #F9F9F9">';
1981
- foreach($value as $item){
1982
- $list .= '<tr>';
1983
- foreach($columns as $column){
1984
- $val = rgar($item, $column);
1985
- $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>';
1986
- }
1987
-
1988
- $list .='</tr>';
1989
- }
1990
-
1991
- $list .='</tbody></table>';
1992
- }
1993
- else{
1994
- $list = '<table autosize="1" class="gfield_list"><thead><tr>';
1995
-
1996
- //reading columns from entry data
1997
- foreach($columns as $column){
1998
- $list .= '<th>' . esc_html($column) . '</th>';
1999
- }
2000
- $list .= '</tr></thead>';
2001
-
2002
- $list .= '<tbody>';
2003
- foreach($value as $item){
2004
- $list .= '<tr>';
2005
- foreach($columns as $column){
2006
- $val = rgar($item, $column);
2007
- $list .= '<td>'.htmlspecialchars($val).'</td>';
2008
- }
2009
-
2010
- $list .='</tr>';
2011
- }
2012
-
2013
- $list .='</tbody></table>';
2014
- }
2015
- break;
2016
- }
2017
-
2018
- return $list;
2019
- }
2020
- return '';
2021
- break;
2022
-
2023
- default :
2024
- if (!is_array($value))
2025
- {
2026
- return nl2br($value);
2027
- }
2028
- break;
2029
- }
2030
- }
2031
-
2032
-
2033
- public static function encode_tags($content, $field)
2034
- {
2035
- if(RGFormsModel::get_input_type($field) != 'html' || RGFormsModel::get_input_type($field) != 'signature')
2036
- {
2037
- $content = str_replace('[', '&#91;', $content);
2038
- $content = str_replace(']', '&#93;', $content);
2039
- $content = str_replace('{', '&#123;', $content);
2040
- $content = str_replace('}', '&#125;', $content);
2041
- }
2042
-
2043
- return $content;
2044
- }
2045
- }
2046
  }
1
+ <?php
2
+
3
+ /*
4
+ This file is part of Gravity PDF.
5
+
6
+ Gravity PDF Copyright (C) 2015 Blue Liquid Designs
7
+
8
+ This program is free software; you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation; either version 2 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program; if not, write to the Free Software
20
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+ */
22
+
23
+ if(!class_exists('GFPDFEntryDetail'))
24
+ {
25
+
26
+ /*
27
+ * Include Gravity Forms Currency class (it not already included)
28
+ */
29
+ if ( false === class_exists( 'RGCurrency' ) && class_exists('GFCommon') ) {
30
+ require_once( GFCommon::get_base_path() . '/currency.php' );
31
+ }
32
+
33
+ add_filter('gfpdf_field_content', array('GFPDFEntryDetail', 'encode_tags'), 10, 2); /* encode shortcodes in user's response so they aren't converted later by do_shortcode */
34
+ class GFPDFEntryDetail {
35
+
36
+ /* holds the form fields, stored by field ID */
37
+ static $fields;
38
+
39
+ /* depreciated function which we will replace with a better config passing method */
40
+ public static function lead_detail_grid($form, $lead, $allow_display_empty_fields=false, $show_html=false, $show_page_name=false, $return=false) {
41
+
42
+ $config = array(
43
+ 'empty_field' => $allow_display_empty_fields,
44
+ 'html_field' => $show_html,
45
+ 'page_names' => $show_page_name,
46
+ 'return' => $return,
47
+ );
48
+
49
+ return self::do_lead_detail_grid($form, $lead, $config);
50
+ }
51
+
52
+
53
+ public static function do_lead_detail_grid($form, $lead, $config) {
54
+ $form_id = $form['id'];
55
+ $results = array();
56
+
57
+ /*
58
+ * Set up our defaults and merge down the user config
59
+ */
60
+ $defaults = array(
61
+ 'empty_field' => false,
62
+ 'html_field' => false,
63
+ 'page_names' => false,
64
+ 'return' => false,
65
+ 'section_content' => false,
66
+ );
67
+
68
+ $config = array_merge($defaults, $config);
69
+
70
+ if($config['return'] === true)
71
+ {
72
+ $results['title'] = '<h2 id="details" class="default">'. $form['title'] .'</h2>';
73
+ }
74
+ else
75
+ {
76
+ ?>
77
+ <div id='container'>
78
+ <h2 id='details' class='default'><?php echo $form['title']?></h2>
79
+ <?php
80
+ }
81
+
82
+
83
+ $count = 0;
84
+ $field_count = sizeof($form['fields']);
85
+
86
+ $has_product_fields = false;
87
+
88
+ $page_number = 0;
89
+ foreach($form['fields'] as $field) {
90
+
91
+
92
+ /*
93
+ * Check if this field has been excluded from the list
94
+ */
95
+ if(isset($field['cssClass']) && strpos($field['cssClass'], 'exclude') !== false)
96
+ {
97
+ /* skip this field */
98
+ continue;
99
+ }
100
+
101
+ /*
102
+ * Skip over hidden fields
103
+ */
104
+ if(GFFormsModel::is_field_hidden( $form, $field, array(), $lead ))
105
+ {
106
+ continue;
107
+ }
108
+
109
+ /*
110
+ * Check if we are to show the page names
111
+ */
112
+ if($config['page_names'] === true)
113
+ {
114
+ if((int) $field['pageNumber'] !== $page_number && isset($form['pagination']['pages'][$page_number]))
115
+ {
116
+ /*
117
+ * Display the page number
118
+ */
119
+ if($config['return'] === true)
120
+ {
121
+ $results['field'][] = '<h2 id="field-'. $field['id'].'" class="default entry-view-page-break">'. $form['pagination']['pages'][$page_number] .'</h2>';
122
+ }
123
+ else
124
+ {
125
+ ?>
126
+ <h2 id='field-<?php echo $field['id']; ?>' class='default entry-view-page-break'><?php echo $form['pagination']['pages'][$page_number]; ?></h2>
127
+ <?php
128
+ }
129
+ /*
130
+ * Increment the page number
131
+ */
132
+ $page_number++;
133
+ }
134
+ }
135
+
136
+ $even = $odd = '';
137
+
138
+ switch(RGFormsModel::get_input_type($field)){
139
+ case 'section' :
140
+
141
+ if(!GFCommon::is_section_empty($field, $form, $lead) || $config['empty_field'] || $config['section_content']){
142
+ $count++;
143
+
144
+ if($config['return'] === true)
145
+ {
146
+ $results['field'][] = '<h2 id="field-'.$field['id'].'" class="default entry-view-section-break">'. esc_html(GFCommon::get_label($field)) .'</h2>';
147
+
148
+ if($config['section_content'])
149
+ {
150
+ $results['field'][] = '<div class="default entry-view-section-break entry-view-section-break-content">' . $field['description'] . '</div>';
151
+ }
152
+
153
+ }
154
+ else
155
+ {
156
+ ?>
157
+ <h2 id="field-<?php echo $field['id']; ?>" class="default entry-view-section-break"><?php echo esc_html(GFCommon::get_label($field))?></h2>
158
+
159
+ <?php if($config['section_content']): ?>
160
+ <div class="default entry-view-section-break entry-view-section-break-content"><?php echo $field['description']; ?></div>
161
+ <?php endif; ?>
162
+ <?php
163
+ }
164
+ }
165
+ break;
166
+
167
+ case 'captcha':
168
+ case 'password':
169
+ case 'page':
170
+ //ignore captcha, html, password, page field
171
+ break;
172
+ case 'html':
173
+ if($config['html_field'] == true)
174
+ {
175
+
176
+ $count++;
177
+ $is_last = $count >= $field_count && !$has_product_fields ? true : false;
178
+ $last_row = $is_last ? ' lastrow' : '';
179
+ $even = ($count%2) ? ' odd' : ' even';
180
+
181
+ $display_value = $field['content'];
182
+ $value = '';
183
+
184
+ $content = '<div id="field-'. $field['id'] .'" class="entry-view-html-value' . $last_row . $even . '"><div class="value">' . $display_value . '</div></div>';
185
+ $content = apply_filters('gfpdf_field_content', $content, $field, $value, $lead['id'], $form['id']);
186
+
187
+ if($config['return'] === true)
188
+ {
189
+ $results['field'][] = $content;
190
+ }
191
+ else
192
+ {
193
+ echo $content;
194
+ }
195
+ }
196
+ break;
197
+ case 'signature':
198
+ $value = RGFormsModel::get_lead_field_value($lead, $field);
199
+ $public_folder = RGFormsModel::get_upload_url_root() . 'signatures/';
200
+ $server_folder = RGFormsModel::get_upload_root() . 'signatures/';
201
+ $file = $server_folder.$value;
202
+ $display_value = false;
203
+
204
+ $is_last = $count >= $field_count ? true : false;
205
+ $last_row = $is_last ? ' lastrow' : '';
206
+
207
+ if(file_exists($file) && !is_dir($file))
208
+ {
209
+ $image_size = getimagesize($file);
210
+ $width = apply_filters('gfpdfe_signature_width', $image_size[0] / 4, $image_size[0]);
211
+
212
+ $display_value = '<img src="'. $file .'" alt="Signature" width=" '. $width .'" />';
213
+ }
214
+
215
+ if($display_value)
216
+ {
217
+ $content = '<div id="field-'. $field['id'] .'" class="entry-view-field-value' . $last_row . $even . '"><div class="strong">' . esc_html(GFCommon::get_label($field)) . '</div> <div class="value">' . $display_value . '</div></div> ';
218
+
219
+ if($config['return'] === true)
220
+ {
221
+ $results['field'][] = $content;
222
+ }
223
+ else
224
+ {
225
+ echo $content;
226
+ }
227
+ }
228
+ elseif($config['empty_field'])
229
+ {
230
+ if($config['return'] === true)
231
+ {
232
+ $results['field'][] = '<div id="field-'. $field['id'] .'" class="entry-view-field-value' . $last_row . $even . '"><div class="strong">' . esc_html(GFCommon::get_label($field)) . '</div> <div class="value">&nbsp;</div></div>';
233
+ }
234
+ else
235
+ {
236
+ print '<div id="field-'. $field['id'] .'" class="entry-view-field-value' . $last_row . $even . '"><div class="strong">' . esc_html(GFCommon::get_label($field)) . '</div><div class="value">&nbsp;</div></div>';
237
+ }
238
+
239
+ }
240
+ break;
241
+
242
+ default:
243
+
244
+ //ignore product fields as they will be grouped together at the end of the grid
245
+ if(GFCommon::is_product_field($field['type'])){
246
+ $has_product_fields = true;
247
+ continue;
248
+ }
249
+
250
+ $value = RGFormsModel::get_lead_field_value($lead, $field);
251
+ $display_value = self::pdf_get_lead_field_display($field, $value, $lead['currency']);
252
+
253
+
254
+ $display_value = apply_filters('gform_entry_field_value', $display_value, $field, $lead, $form);
255
+
256
+ if( !empty($display_value) || $display_value === '0' || $config['empty_field']){
257
+ $count++;
258
+ $is_last = $count >= $field_count && !$has_product_fields ? true : false;
259
+ $last_row = $is_last ? ' lastrow' : '';
260
+ $even = ($count%2) ? ' odd' : ' even';
261
+
262
+ $display_value = empty($display_value) && $display_value !== '0' ? '&nbsp;' : $display_value;
263
+
264
+ $content = '<div id="field-'. $field['id'] .'" class="entry-view-field-value' . $last_row . $even . '"><div class="strong">' . esc_html(GFCommon::get_label($field)) . '</div> <div class="value">' . $display_value . '</div></div>';
265
+
266
+ $content = apply_filters('gfpdf_field_content', $content, $field, $value, $lead['id'], $form['id']);
267
+
268
+ if($config['return'] === true)
269
+ {
270
+ $results['field'][] = $content;
271
+ }
272
+ else
273
+ {
274
+ echo $content;
275
+ }
276
+
277
+ }
278
+ break;
279
+ }
280
+
281
+ }
282
+ $products = array();
283
+ if($has_product_fields){
284
+ if($config['return'] === true)
285
+ {
286
+ ob_start();
287
+ self::product_table($form, $lead);
288
+ $results['field'][] = ob_get_contents();
289
+ ob_end_clean();
290
+ }
291
+ else
292
+ {
293
+ self::product_table($form, $lead);
294
+ }
295
+
296
+ }
297
+
298
+ if($config['return'] === true)
299
+ {
300
+ return $results;
301
+ }
302
+ ?>
303
+ </div>
304
+ <?php
305
+ }
306
+
307
+ public static function product_table($form, $lead)
308
+ {
309
+ $products = GFCommon::get_product_fields($form, $lead, true);
310
+
311
+ $form_id = $form['id'];
312
+ if(!empty($products['products'])){
313
+ ?>
314
+
315
+ <h2 class='default entry-view-field-name'><?php echo apply_filters("gform_order_label_{$form['id']}", apply_filters('gform_order_label', __('Order', 'gravityforms'), $form['id']), $form['id']) ?></h2>
316
+
317
+ <table class='entry-products' autosize='1' cellspacing='0' width='97%'>
318
+ <colgroup>
319
+ <col class='entry-products-col1' />
320
+ <col class='entry-products-col2' />
321
+ <col class='entry-products-col3' />
322
+ <col class='entry-products-col4' />
323
+ </colgroup>
324
+ <thead>
325
+ <tr>
326
+ <th scope='col'><?php echo apply_filters('gform_product_{$form_id}', apply_filters('gform_product', __('Product', 'gravityforms'), $form_id), $form_id) ?></th>
327
+ <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>
328
+ <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>
329
+ <th scope='col'><?php echo apply_filters('gform_product_price_{$form_id}', apply_filters('gform_product_price', __('Price', 'gravityforms'), $form_id), $form_id) ?></th>
330
+ </tr>
331
+ </thead>
332
+ <tbody>
333
+ <?php
334
+
335
+ $total = 0;
336
+ foreach($products['products'] as $product){
337
+ ?>
338
+ <tr>
339
+ <td>
340
+ <div class='product_name'><?php echo esc_html($product['name'])?></div>
341
+
342
+ <?php
343
+ $price = GFCommon::to_number($product['price']);
344
+ if(is_array(rgar($product,'options'))){
345
+ echo '<ul class="product_options">';
346
+ $count = sizeof($product['options']);
347
+ $index = 1;
348
+ foreach($product['options'] as $option){
349
+ $price += GFCommon::to_number($option['price']);
350
+ $class = $index == $count ? ' class="lastitem"' : '';
351
+ $index++;
352
+ ?>
353
+ <li<?php echo $class?>><?php echo $option['option_label']?></li>
354
+ <?php
355
+ }
356
+ echo '</ul>';
357
+ }
358
+ $subtotal = floatval($product['quantity']) * $price;
359
+ $total += $subtotal;
360
+ ?>
361
+
362
+ </td>
363
+ <td class='textcenter'><?php echo $product['quantity'] ?></td>
364
+ <td><?php echo GFCommon::to_money($price, $lead['currency']) ?></td>
365
+ <td><?php echo GFCommon::to_money($subtotal, $lead['currency']) ?></td>
366
+ </tr>
367
+ <?php
368
+ }
369
+ $total += floatval($products['shipping']['price']);
370
+ ?>
371
+
372
+
373
+ <?php
374
+ if(!empty($products['shipping']['name'])){
375
+ ?>
376
+ <tr>
377
+ <td colspan='2' rowspan='2' class='emptycell'>&nbsp;</td>
378
+ <td class='textright shipping'><?php echo $products['shipping']['name'] ?></td>
379
+ <td class='shipping_amount'><?php echo GFCommon::to_money($products['shipping']['price'], $lead['currency'])?>&nbsp;</td>
380
+ </tr>
381
+ <?php
382
+ }
383
+ ?>
384
+ <tr>
385
+ <?php
386
+ if(empty($products['shipping']['name'])){
387
+ ?>
388
+ <td colspan='2' class='emptycell'>&nbsp;</td>
389
+ <?php
390
+ }
391
+ ?>
392
+ <td class='textright grandtotal'><?php _e('Total', 'gravityforms') ?></td>
393
+ <td class='grandtotal_amount'><?php echo GFCommon::to_money($total, $lead['currency'])?></td>
394
+ </tr>
395
+ </tbody>
396
+
397
+ </table>
398
+
399
+ <?php
400
+ }
401
+ }
402
+
403
+ /*
404
+ * Public method for outputting likert (survey addon field)
405
+ */
406
+ public static function get_likert($form, $lead, $field_id)
407
+ {
408
+ $fields = self::$fields;
409
+ $field = $fields[$field_id];
410
+ $value = RGFormsModel::get_lead_field_value($lead, $field);
411
+
412
+ $display_value = apply_filters('gform_entry_field_value', self::pdf_get_lead_field_display($field, $value, ''), $field, $lead, $form);
413
+ $content = $display_value;
414
+
415
+ $results = apply_filters('gfpdf_field_content', $content, $field, $value, $lead['id'], $form['id']);
416
+
417
+ return $results;
418
+ }
419
+
420
+ /* returns the form values as an array instead of pre-formated html */
421
+ public static function lead_detail_grid_array($form, $lead){
422
+
423
+ $form_id = $form['id'];
424
+ $form_array = self::set_form_array_common($form, $lead, $form_id);
425
+
426
+ $has_product_fields = false;
427
+
428
+ foreach($form['fields'] as $field) {
429
+
430
+
431
+ /*
432
+ * Add field descriptions to the $form_data array
433
+ */
434
+ if(isset($field['description']))
435
+ {
436
+ $form_array['field_descriptions'][$field['id']] = $field['description'];
437
+ }
438
+
439
+ switch(RGFormsModel::get_input_type($field)) {
440
+ case 'section' :
441
+ case 'html':
442
+ $form_array = self::get_html($field, $form_array);
443
+ break;
444
+
445
+ case 'captcha':
446
+ case 'password':
447
+ case 'page':
448
+ //ignore captcha, password and page
449
+ break;
450
+ case 'signature':
451
+ $form_array = self::get_signature($form, $lead, $field, $form_array);
452
+
453
+ break;
454
+ case 'fileupload':
455
+ $form_array = self::get_fileupload($form, $lead, $field, $form_array);
456
+ break;
457
+ case 'list':
458
+ /*
459
+ * We want list to run both this and the deafult so don't call break.
460
+ * Get the list array and store it outside of [field] in a new key called ['list']
461
+ */
462
+ $form_array = self::get_default_list($lead, $field, $form_array);
463
+
464
+ case 'select':
465
+ case 'multiselect':
466
+ case 'radio':
467
+
468
+ if($field['type'] == 'quiz')
469
+ {
470
+ $form_array = self::get_quiz_radios($form, $lead, $field, $form_array);
471
+ }
472
+ elseif($field['type'] == 'poll' || $field['type'] == 'survey')
473
+ {
474
+ $form_array = self::get_poll_radios($form, $lead, $field, $form_array);
475
+ }
476
+ else
477
+ {
478
+ /* store values in regular [field] array */
479
+ $form_array = self::get_the_list($lead, $field, $form_array);
480
+ }
481
+ break;
482
+
483
+ case 'likert':
484
+ $form_array['survey']['likert'][$field['id']] = self::get_the_likert($form, $lead, $field, $form_array);
485
+ break;
486
+
487
+ case 'rank':
488
+ $form_array['survey']['rank'][$field['id']] = self::get_the_rank($form, $lead, $field, $form_array);
489
+ break;
490
+
491
+ case 'rating':
492
+ $form_array['survey']['rating'][$field['id']] = self::get_the_rank($form, $lead, $field, $form_array);
493
+ break;
494
+
495
+ case 'checkbox':
496
+ /* Only process non-survey checkbox fields */
497
+ if($field['type'] == 'checkbox') {
498
+ $form_array = self::get_the_list($lead, $field, $form_array);
499
+ break;
500
+ }
501
+
502
+ default:
503
+
504
+
505
+ //ignore product fields as they will be grouped together at the end of the grid
506
+ if(GFCommon::is_product_field($field['type'])){
507
+ $has_product_fields = true;
508
+ continue;
509
+ }
510
+
511
+ $form_array = self::get_defaults($lead, $field, $form_array);
512
+
513
+ break;
514
+ }
515
+
516
+ }
517
+
518
+ $form_array = self::get_product_array($form, $lead, $has_product_fields, $form_array);
519
+
520
+ return $form_array;
521
+ }
522
+
523
+ private static function get_quiz_radios($form, $lead, $field, $form_array)
524
+ {
525
+ $id = $field['id'];
526
+ $results = $lead[$id];
527
+ $return = array();
528
+
529
+ foreach($field['choices'] as $choice)
530
+ {
531
+ if(trim($choice['value']) == trim($results))
532
+ {
533
+ $return = array('text' => $choice['text'], 'isCorrect' => $choice['gquizIsCorrect']);
534
+ break;
535
+ }
536
+ }
537
+
538
+ /* add data to field tag correctly */
539
+ $form_array['field'][$field['id'].'.'.$field['label'].'_name'] = $return;
540
+
541
+ /* add ID incase want to use template on multiple duplicate forms with different field names */
542
+ $form_array['field'][$field['id']] = $return;
543
+
544
+ return $form_array;
545
+
546
+ }
547
+
548
+ private static function get_poll_radios($form, $lead, $field, $form_array)
549
+ {
550
+
551
+ $id = $field['id'];
552
+ $results = $lead[$id];
553
+ $return = array();
554
+
555
+ $return = self::get_poll_data($results, $field['choices']);
556
+
557
+ /* add data to field tag correctly */
558
+ $form_array['field'][$field['id'].'.'.$field['label'].'_name'] = $return;
559
+
560
+ /* add ID incase want to use template on multiple duplicate forms with different field names */
561
+ $form_array['field'][$field['id']] = $return;
562
+
563
+ return $form_array;
564
+
565
+ }
566
+
567
+ private static function get_poll_checkbox($field, $values)
568
+ {
569
+ foreach($values as $id => $item)
570
+ {
571
+ $values[$id] = self::get_poll_data($item, $field['choices']);
572
+ }
573
+ return $values;
574
+ }
575
+
576
+ private static function get_poll_data($lookup, $options)
577
+ {
578
+ $return = '';
579
+
580
+ foreach($options as $choice)
581
+ {
582
+ if(trim($choice['value']) == trim($lookup))
583
+ {
584
+ $return = $choice['text'];
585
+ break;
586
+ }
587
+ }
588
+
589
+ return $return;
590
+ }
591
+
592
+ private static function get_the_rank($form, $lead, $field, $form_array)
593
+ {
594
+ $id = $field['id'];
595
+ $results = explode(',', $lead[$id]);
596
+ $return = array();
597
+
598
+ foreach($results as $rank)
599
+ {
600
+ foreach($field['choices'] as $choice)
601
+ {
602
+ if(trim($choice['value']) == trim($rank))
603
+ {
604
+ $return[] = $choice['text'];
605
+ break;
606
+ }
607
+ }
608
+ }
609
+
610
+ return $return;
611
+ }
612
+
613
+ private static function get_the_likert($form, $lead, $field, $form_array)
614
+ {
615
+ $id = $field['id'];
616
+ $multiple_rows = rgar($field, "gsurveyLikertEnableMultipleRows");
617
+
618
+ if(!$multiple_rows)
619
+ {
620
+ $results = $lead[$id];
621
+ }
622
+
623
+ $likert = array();
624
+
625
+ /* store the column names */
626
+ foreach($field['choices'] as $col)
627
+ {
628
+ $likert['col'][$col['value']] = $col['text'];
629
+ }
630
+
631
+ if(is_array($field['inputs']) && sizeof($field['inputs']) > 0)
632
+ {
633
+ /* do our multi-row likert */
634
+ foreach($field['inputs'] as $row)
635
+ {
636
+ /* pad the array with the number of columns */
637
+
638
+ foreach($likert['col'] as $col_id => $text)
639
+ {
640
+ /*
641
+ * Results for multi row is stored with ID.ROW# (eg $lead['1.2'])
642
+ * The number is stored in $row['id']
643
+ */
644
+ $results = $lead[$row['id']];
645
+
646
+ /* user data in the $lead comes in as ROW ID:COL ID */
647
+ $comparison = $row['name'] . ':' . $col_id;
648
+
649
+ /* do our comparison and update the output */
650
+ $output = ($comparison == $results) ? 'selected' : '';
651
+
652
+ /* assign our results to the array */
653
+ $likert['rows'][$row['label']][$text] = $output;
654
+
655
+ }
656
+ }
657
+ }
658
+ else
659
+ {
660
+ /* do our single row likert */
661
+ foreach($likert['col'] as $col_id => $text)
662
+ {
663
+ /* single row data comes in with col value */
664
+ /* do our comparison and update the output */
665
+ $output = ($col_id == $results) ? 'selected' : '';
666
+
667
+ $likert['row'][$text] = $output;
668
+
669
+ }
670
+ }
671
+
672
+ /*
673
+ * Check if scoring is enabled and calculate
674
+ */
675
+ if($field['gsurveyLikertEnableScoring'] && class_exists('GFSurvey'))
676
+ {
677
+ $survey = GFSurvey::get_instance();
678
+ $likert['score'] = $survey->get_field_score($field, $lead);
679
+ }
680
+
681
+ return $likert;
682
+
683
+ }
684
+
685
+ private static function get_form_fields($form)
686
+ {
687
+ $fields = array();
688
+ foreach($form['fields'] as $field)
689
+ {
690
+ $fields[$field['id']] = $field;
691
+ }
692
+
693
+ self::$fields = $fields;
694
+ }
695
+
696
+ private static function set_form_array_common($form, $lead, $form_id)
697
+ {
698
+ /*
699
+ * Reorder the $form array as we can access the info by Field ID
700
+ */
701
+ self::get_form_fields($form);
702
+
703
+ $form_array = array();
704
+
705
+ /*
706
+ * Add form_id and lead_id
707
+ */
708
+ $form_array['form_id'] = $form_id;
709
+ $form_array['entry_id'] = $lead['id'];
710
+
711
+ /*
712
+ * Set title and dates (both US and international)
713
+ */
714
+ $form_array['form_title'] = $form['title'];
715
+ $form_array['form_description'] = (isset($form['description'])) ? $form['description'] : '';
716
+ $form_array['date_created'] = GFCommon::format_date( $lead['date_created'], false, 'j/n/Y', false);
717
+ $form_array['date_created_usa'] = GFCommon::format_date( $lead['date_created'], false, 'n/j/Y', false);
718
+
719
+ /*
720
+ * Include page names
721
+ */
722
+ $form_array['pages'] = $form['pagination']['pages'];
723
+
724
+ /*
725
+ * Add misc fields
726
+ */
727
+ $form_array['misc']['date_time'] = GFCommon::format_date( $lead['date_created'], false, 'Y-m-d H:i:s', false);
728
+ $form_array['misc']['time_24hr'] = GFCommon::format_date( $lead['date_created'], false, 'H:i', false);
729
+ $form_array['misc']['time_12hr'] = GFCommon::format_date( $lead['date_created'], false, 'g:ia', false);
730
+ $form_array['misc']['is_starred'] = $lead['is_starred'];
731
+ $form_array['misc']['is_read'] = $lead['is_read'];
732
+ $form_array['misc']['ip'] = $lead['ip'];
733
+ $form_array['misc']['source_url'] = $lead['source_url'];
734
+ $form_array['misc']['post_id'] = $lead['post_id'];
735
+ $form_array['misc']['currency'] = $lead['currency'];
736
+ $form_array['misc']['payment_status'] = $lead['payment_status'];
737
+ $form_array['misc']['payment_date'] = $lead['payment_date'];
738
+ $form_array['misc']['transaction_id'] = $lead['transaction_id'];
739
+ $form_array['misc']['payment_amount'] = $lead['payment_amount'];
740
+ $form_array['misc']['is_fulfilled'] = $lead['is_fulfilled'];
741
+ $form_array['misc']['created_by'] = $lead['created_by'];
742
+ $form_array['misc']['transaction_type'] = $lead['transaction_type'];
743
+ $form_array['misc']['user_agent'] = $lead['user_agent'];
744
+ $form_array['misc']['status'] = $lead['status'];
745
+
746
+
747
+
748
+ /*
749
+ * Add quiz/survey/poll results
750
+ */
751
+
752
+ if(class_exists('GFQuiz'))
753
+ {
754
+ $form_array = self::get_quiz_results($form_array, $form, $lead);
755
+ }
756
+
757
+ if(class_exists('GFSurvey'))
758
+ {
759
+ $form_array = self::get_survey_results($form_array, $form, $lead);
760
+ }
761
+
762
+ if(class_exists('GFPolls'))
763
+ {
764
+ $form_array = self::get_poll_results($form_array, $form, $lead);
765
+ }
766
+
767
+ return $form_array;
768
+ }
769
+
770
+ /**
771
+ * Sniff the form fields and determine if there are any of the $type avaluable
772
+ * @param string $type the field type we are looking for
773
+ * @param array $form the form array
774
+ * @return boolean Whether there is a match or not
775
+ */
776
+ private static function check_for_fields($type, $form)
777
+ {
778
+ foreach($form['fields'] as $field)
779
+ {
780
+ if($field['type'] == $type)
781
+ {
782
+ return true;
783
+ }
784
+ }
785
+ return false;
786
+ }
787
+
788
+ private static function get_poll_results($form_array, $form, $lead)
789
+ {
790
+ if(self::check_for_fields('poll', $form) === false)
791
+ {
792
+ return $form_array;
793
+ }
794
+
795
+ $fields = self::get_related_fields($form["fields"], 'poll');
796
+ $poll_results = self::get_addon_global_data($form, array(), $fields);
797
+
798
+ $form_fields = self::$fields;
799
+
800
+ /*
801
+ * Convert the array keys into their text counterparts
802
+ * Loop through the global poll data
803
+ */
804
+ foreach($poll_results['field_data'] as $id => &$choices)
805
+ {
806
+ /* get the $field */
807
+ $field = $form_fields[$id];
808
+
809
+ /* add the field name to the ['misc'] key */
810
+ $choices['misc']['label'] = $field['label'];
811
+
812
+ /* loop through the field choices */
813
+ foreach($field['choices'] as $choice)
814
+ {
815
+ $choices = self::replace_key($choices, $choice['value'], $choice['text']);
816
+ }
817
+ }
818
+
819
+ $form_array['poll']['global'] = $poll_results;
820
+
821
+ return $form_array;
822
+ }
823
+
824
+ private static function get_survey_results($form_array, $form, $lead)
825
+ {
826
+ if(self::check_for_fields('survey', $form) === false)
827
+ {
828
+ return $form_array;
829
+ }
830
+
831
+ /*
832
+ * If there are any survey results
833
+ * add them to the 'survey' key
834
+ */
835
+ $fields = GFCommon::get_fields_by_type($form, array('survey'));
836
+ $count_survey_fields = count($fields);
837
+
838
+ if ($count_survey_fields > 0 && isset($lead['gsurvey_score']))
839
+ {
840
+ $form_array['survey']['score'] = $lead['gsurvey_score'];
841
+ }
842
+
843
+ $fields = self::get_related_fields($form["fields"], 'survey');
844
+ $form_array['survey']['global'] = self::get_addon_global_data($form, array(), $fields);
845
+ $form_fields = self::$fields;
846
+
847
+ /*
848
+ * Convert the array keys into their text counterparts
849
+ * Loop through the global survey data
850
+ */
851
+ foreach($form_array['survey']['global']['field_data'] as $id => &$choices)
852
+ {
853
+ /* get the $field */
854
+ $field = $form_fields[$id];
855
+
856
+ /*
857
+ * Check if we have a multifield likert and replace the row key
858
+ */
859
+ if(isset($field['gsurveyLikertEnableMultipleRows']) && $field['gsurveyLikertEnableMultipleRows'] == 1)
860
+ {
861
+ foreach($field['gsurveyLikertRows'] as $row)
862
+ {
863
+ $choices = self::replace_key($choices, $row['value'], $row['text']);
864
+ }
865
+
866
+ foreach($choices as $multi_id => &$multi_choices)
867
+ {
868
+ foreach($field['choices'] as $choice)
869
+ {
870
+ $multi_choices = self::replace_key($multi_choices, $choice['value'], $choice['text']);
871
+ }
872
+ }
873
+ }
874
+
875
+
876
+ /* replace the standard row data */
877
+ if(isset($field['choices']) && is_array($field['choices']))
878
+ {
879
+ foreach($field['choices'] as $choice)
880
+ {
881
+ $choices = self::replace_key($choices, $choice['value'], $choice['text']);
882
+ }
883
+ }
884
+ }
885
+
886
+ return $form_array;
887
+
888
+ }
889
+
890
+ private static function replace_key($array, $key, $text)
891
+ {
892
+ if($key != $text && isset($array[$key]))
893
+ {
894
+ /* replace the array key with the actual field name */
895
+ $array[$text] = $array[$key];
896
+ unset($array[$key]);
897
+ }
898
+ return $array;
899
+ }
900
+
901
+ private static function get_quiz_results($form_array, $form, $lead)
902
+ {
903
+
904
+ if(self::check_for_fields('quiz', $form) === false)
905
+ {
906
+ return $form_array;
907
+ }
908
+
909
+ /*
910
+ * If there are any quiz results
911
+ * add them to the 'quiz' key
912
+ */
913
+ $fields = GFCommon::get_fields_by_type($form, array('quiz'));
914
+ $count_quiz_fields = count($fields);
915
+
916
+ if ($count_quiz_fields > 0)
917
+ {
918
+ $form_array['quiz']['config']['grading'] = (isset($form['gravityformsquiz']['grading'])) ? $form['gravityformsquiz']['grading'] : '';
919
+ $form_array['quiz']['config']['passPercent'] = (isset($form['gravityformsquiz']['passPercent'])) ? $form['gravityformsquiz']['passPercent'] : '';
920
+ $form_array['quiz']['config']['grades'] = (isset($form['gravityformsquiz']['grades'])) ? $form['gravityformsquiz']['grades'] : '';
921
+
922
+ $form_array['quiz']['results']['score'] = rgar($lead, 'gquiz_score');
923
+ $form_array['quiz']['results']['percent'] = rgar($lead, 'gquiz_percent');
924
+ $form_array['quiz']['results']['is_pass'] = rgar($lead, 'gquiz_is_pass');
925
+ $form_array['quiz']['results']['grade'] = rgar($lead, 'gquiz_grade');
926
+
927
+ /*
928
+ * Get the overall results
929
+ */
930
+
931
+ $quiz_global = self::get_quiz_overalls($form);
932
+
933
+ $form_fields = self::$fields;
934
+ /*
935
+ * Convert the array keys into their text counterparts
936
+ * Loop through the global quiz data
937
+ */
938
+ if(empty($quiz_global['field_data']))
939
+ {
940
+ $quiz_global['field_data'] = array();
941
+ }
942
+
943
+ foreach($quiz_global['field_data'] as $id => &$choices)
944
+ {
945
+ /* get the $field */
946
+ $field = $form_fields[$id];
947
+
948
+ /* replace ['totals'] key with ['misc'] key */
949
+ $choices = self::replace_key($choices, 'totals', 'misc');
950
+
951
+ /* add the field name to the ['misc'] key */
952
+ $choices['misc']['label'] = $field['label'];
953
+
954
+ /* loop through the field choices */
955
+ foreach($field['choices'] as $choice)
956
+ {
957
+ $choices = self::replace_key($choices, $choice['value'], $choice['text']);
958
+
959
+ /* check if this is the correct field */
960
+ if(isset($choice['gquizIsCorrect']) && $choice['gquizIsCorrect'] == 1)
961
+ {
962
+ $choices['misc']['correct_option_name'][] = $choice['text'];
963
+ }
964
+
965
+ }
966
+ }
967
+
968
+ $form_array['quiz']['global'] = $quiz_global;
969
+ //$form_array['quiz']['global'] = self::get_quiz_overalls($form);
970
+
971
+ }
972
+
973
+ return $form_array;
974
+ }
975
+
976
+ private static function get_addon_global_data($form, $options, $fields)
977
+ {
978
+ /* if the results class isn't loaded, load it */
979
+ if (!class_exists("GFResults"))
980
+ {
981
+ require_once(GFCommon::get_base_path() . "/includes/addon/class-gf-results.php");
982
+ }
983
+
984
+ $form_id = $form['id'];
985
+
986
+ /* add form filter to keep in line with GF standard */
987
+ $form = apply_filters( "gform_form_pre_results_$form_id", apply_filters( 'gform_form_pre_results', $form ) );
988
+
989
+ /* initiat the results class */
990
+ $gf_results = new GFResults('', $options);
991
+
992
+ /* ensure that only active leads are queried */
993
+ $search = array(
994
+ 'field_filters' => array('mode' => ''),
995
+ 'status' => 'active'
996
+ );
997
+
998
+ /* get the results */
999
+ $data = $gf_results->get_results_data($form, $fields, $search);
1000
+
1001
+ /* unset some array keys we don't need */
1002
+ unset($data['status']);
1003
+ unset($data['timestamp']);
1004
+
1005
+ return $data;
1006
+
1007
+ }
1008
+
1009
+ /**
1010
+ * Gravity Forms is throwing notices when accessing get_results_data()
1011
+ * due to poor validation. To fix this we'll unset the 'choices' array key
1012
+ * if it is not an array (the expected input for this function)
1013
+ * @param Array $fields The fields array
1014
+ * @return Array The processed fields array
1015
+ */
1016
+ private static function get_related_fields($fields, $type)
1017
+ {
1018
+ foreach($fields as $id => $field)
1019
+ {
1020
+ if($field['type'] !== $type)
1021
+ {
1022
+ unset($fields[$id]);
1023
+ continue;
1024
+ }
1025
+ }
1026
+
1027
+ return $fields;
1028
+ }
1029
+
1030
+ private static function get_quiz_overalls($form)
1031
+ {
1032
+ /* we need to tap into functions GF Quiz has so only run if it is active */
1033
+ if(class_exists('GFQuiz'))
1034
+ {
1035
+ /* GFQuiz is a singleton. Get the instance */
1036
+ $quiz = GFQuiz::get_instance();
1037
+
1038
+ /* create our callback to add additional data to the array specific to the quiz plugin */
1039
+ $options['callbacks']['calculation'] = array(
1040
+ $quiz,
1041
+ 'results_calculation'
1042
+ );
1043
+
1044
+ $fields = self::get_related_fields($form["fields"], 'quiz');
1045
+
1046
+ $quiz_results = self::get_addon_global_data($form, $options, $fields);
1047
+
1048
+ return $quiz_results;
1049
+ }
1050
+
1051
+ return array(__('Activate Gravity Forms Quiz Add On to see global quiz statistics for this form', 'pdfextended'));
1052
+ }
1053
+
1054
+ private static function get_html($field, $form_array)
1055
+ {
1056
+ if(isset($field['content']))
1057
+ {
1058
+ $form_array['html'][] = wpautop($field['content']);
1059
+ $form_array['html_id'][$field['id']] = wpautop($field['content']);
1060
+ }
1061
+
1062
+ return $form_array;
1063
+ }
1064
+
1065
+ private static function get_signature($form, $lead, $field, $form_array)
1066
+ {
1067
+ $value = RGFormsModel::get_lead_field_value($lead, $field);
1068
+ $http_folder = RGFormsModel::get_upload_url_root(). 'signatures/';
1069
+ $server_folder = RGFormsModel::get_upload_root() . 'signatures/';
1070
+ $file = $server_folder.$value;
1071
+ $sig_html = '';
1072
+
1073
+ /*
1074
+ * Set defaults is we cannot find the images
1075
+ */
1076
+ $width = 75;
1077
+ $height = 45;
1078
+
1079
+ /*
1080
+ * Only get sane defaults specific to the image if we can find it.
1081
+ */
1082
+ if(file_exists($file) !== false && is_dir($file) !== true)
1083
+ {
1084
+ $image_size = getimagesize($file);
1085
+ $width = $image_size[0] / 4;
1086
+ $height = $image_size[1] / 4;
1087
+ $sig_html = '<img src="'. $server_folder.$value .'" alt="Signature" width="'. $width .'" height="'. $height .'" />';
1088
+ }
1089
+
1090
+ /*
1091
+ * Include the image details
1092
+ */
1093
+
1094
+
1095
+ $form_array['signature'][] = $sig_html;
1096
+ $form_array['signature_details'][] = array(
1097
+ 'img' => $sig_html,
1098
+ 'path' => $file,
1099
+ 'url' => $http_folder.$value,
1100
+ 'width' => $width,
1101
+ 'height' => $height,
1102
+ );
1103
+
1104
+ $form_array['signature_details_id'][$field['id']] = array(
1105
+ 'img' => $sig_html,
1106
+ 'path' => $file,
1107
+ 'url' => $http_folder.$value,
1108
+ 'width' => $width,
1109
+ 'height' => $height,
1110
+ );
1111
+
1112
+
1113
+ return $form_array;
1114
+ }
1115
+
1116
+ private static function get_fileupload($form, $lead, $field, $form_array)
1117
+ {
1118
+ $value = RGFormsModel::get_lead_field_value($lead, $field);
1119
+ $display = self::get_lead_field_display($field, $value, $lead['currency']);
1120
+
1121
+ /*
1122
+ * Get the absolute path to the upload
1123
+ */
1124
+ $path = str_replace(home_url().'/', ABSPATH, $display);
1125
+
1126
+ /* add path */
1127
+ $form_array['field'][$field['id'].'_path'] = $path;
1128
+ $form_array['field'][$field['id'].'.'.$field['label'].'_path'] = $path;
1129
+
1130
+ return self::assign_form($field, $display, $form_array);
1131
+ }
1132
+
1133
+ private static function get_default_list($lead, $field, $form_array)
1134
+ {
1135
+ $value = self::remove_empty_list_rows(unserialize(RGFormsModel::get_lead_field_value($lead, $field)));
1136
+ $form_array['list'][$field['id']] = $value;
1137
+
1138
+ return $form_array;
1139
+ }
1140
+
1141
+ private static function remove_empty_list_rows($list)
1142
+ {
1143
+ /*
1144
+ * Check if there are any values in the list
1145
+ */
1146
+ if(!is_array($list) || sizeof($list) == 0)
1147
+ {
1148
+ return $list;
1149
+ }
1150
+
1151
+ /*
1152
+ * Check if it's a multi column list
1153
+ */
1154
+ if(!is_array($list[0]))
1155
+ {
1156
+ $list = array_filter($list);
1157
+ }
1158
+ else
1159
+ {
1160
+ $list = self::remove_empty_multi_col_list($list);
1161
+ }
1162
+
1163
+ return $list;
1164
+ }
1165
+
1166
+ private static function remove_empty_multi_col_list($list)
1167
+ {
1168
+ foreach($list as $id => $row)
1169
+ {
1170
+
1171
+ $empty = true;
1172
+ foreach($row as &$col)
1173
+ {
1174
+ /* check if there is data and if so break the loop */
1175
+ if(trim(strlen($col) > 0))
1176
+ {
1177
+ $empty = false;
1178
+ break;
1179
+ }
1180
+ }
1181
+
1182
+ /* remove row from list */
1183
+ if($empty)
1184
+ {
1185
+ unset($list[$id]);
1186
+ }
1187
+ }
1188
+
1189
+ return $list;
1190
+ }
1191
+
1192
+ private static function get_the_list($lead, $field, $form_array)
1193
+ {
1194
+ $value = RGFormsModel::get_lead_field_value($lead, $field);
1195
+ $display = self::get_lead_field_display($field, $value, $lead['currency']);
1196
+
1197
+ $form_array = self::assign_form($field, $display, $form_array);
1198
+
1199
+ /*
1200
+ * Include these items correct names
1201
+ */
1202
+ $display = self::get_lead_field_display($field, $value, $lead['currency'], true);
1203
+ /* add data to field tag correctly */
1204
+ $form_array['field'][$field['id'].'.'.$field['label'].'_name'] = $display;
1205
+
1206
+ /* add ID incase want to use template on multiple duplicate forms with different field names */
1207
+ $form_array['field'][$field['id'].'_name'] = $display;
1208
+
1209
+ /* keep backwards compatibility */
1210
+ $form_array['field'][$field['label'].'_name'] = $display;
1211
+
1212
+ return $form_array;
1213
+ }
1214
+
1215
+ private static function get_defaults($lead, $field, $form_array)
1216
+ {
1217
+ $value = RGFormsModel::get_lead_field_value($lead, $field);
1218
+ $display = self::get_lead_field_display($field, $value, $lead['currency']);
1219
+
1220
+ return self::assign_form($field, $display, $form_array);
1221
+ }
1222
+
1223
+ private static function assign_form($field, $display, $form_array)
1224
+ {
1225
+ /* add data to field tag correctly */
1226
+ $form_array['field'][$field['id'].'.'.$field['label']] = $display;
1227
+
1228
+ /* add ID incase want to use template on multiple duplicate forms with different field names */
1229
+ $form_array['field'][$field['id']] = $display;
1230
+
1231
+ /* keep backwards compatibility */
1232
+ $form_array['field'][$field['label']] = $display;
1233
+
1234
+ return $form_array;
1235
+ }
1236
+
1237
+ private static function get_product_array($form, $lead, $has_product_fields, $form_array)
1238
+ {
1239
+ $currency_type = (method_exists('GFCommon', 'is_currency_decimal_dot')) ? GFCommon::is_currency_decimal_dot() : PDF_Common::is_currency_decimal_dot();
1240
+ $currency_format = $currency_type ? 'decimal_dot' : 'decimal_comma';
1241
+
1242
+ if($has_product_fields) {
1243
+ $products = GFCommon::get_product_fields($form, $lead, true);
1244
+
1245
+ /* check that there are actual product fields */
1246
+ if(sizeof($products['products']) > 0 )
1247
+ {
1248
+
1249
+ /*
1250
+ * Set up our variables
1251
+ */
1252
+ $total = 0;
1253
+ $subtotal = 0;
1254
+
1255
+ foreach($products['products'] as $id => $product) {
1256
+ $price = GFCommon::to_number($product['price']);
1257
+
1258
+ /* add all options to total price */
1259
+ if(is_array(rgar($product,'options')))
1260
+ {
1261
+ foreach($product['options'] as $option){
1262
+ $price += GFCommon::to_number($option['price']);
1263
+ }
1264
+ }
1265
+
1266
+ /* calculate subtotal */
1267
+ $subtotal = floatval($product['quantity']) * $price;
1268
+ $total += $subtotal;
1269
+
1270
+ /*
1271
+ * Check if we should include options
1272
+ */
1273
+ $options = isset($product['options']) ? $product['options'] : array();
1274
+
1275
+ /*
1276
+ * Add formated price for each product option
1277
+ */
1278
+ foreach($options as &$o)
1279
+ {
1280
+ if(is_numeric($o['price']))
1281
+ {
1282
+ $o['price_formatted'] = GFCommon::format_number($o['price'], 'currency');
1283
+ }
1284
+ }
1285
+
1286
+ /*
1287
+ * Store product in $form_array array
1288
+ */
1289
+ $form_array['products'][$id] = array(
1290
+ 'name' => esc_html($product['name']),
1291
+ 'price' => esc_html($product['price']),
1292
+ 'price_unformatted' => GFCommon::clean_number($product['price'], $currency_format),
1293
+ 'options' => $options,
1294
+ 'quantity' => $product['quantity'],
1295
+ 'subtotal' => $subtotal,
1296
+ 'subtotal_formatted' => GFCommon::format_number($subtotal, 'currency'));
1297
+ }
1298
+
1299
+ /* Increment total */
1300
+ $total += floatval($products['shipping']['price']);
1301
+ $subtotal = $total - floatval($products['shipping']['price']);
1302
+
1303
+ /* add totals to form data */
1304
+ $form_array['products_totals'] = array(
1305
+ 'subtotal' => $subtotal,
1306
+ 'shipping' => $products['shipping']['price'],
1307
+ 'total' => $total,
1308
+ 'shipping_formatted' => GFCommon::format_number($products['shipping']['price'], 'currency'),
1309
+ 'subtotal_formatted' => GFCommon::format_number($subtotal, 'currency'),
1310
+ 'total_formatted' => GFCommon::format_number($total, 'currency'),
1311
+ );
1312
+ }
1313
+ }
1314
+
1315
+ return $form_array;
1316
+ }
1317
+
1318
+ public static function get_lead_field_display($field, $value, $currency='', $use_text=false, $format='html', $media='screen'){
1319
+
1320
+ if($field['type'] == 'post_category')
1321
+ $value = GFCommon::prepare_post_category_value($value, $field);
1322
+
1323
+ switch(RGFormsModel::get_input_type($field)){
1324
+ case 'name' :
1325
+ if(is_array($value)){
1326
+ $prefix = trim(rgget($field['id'] . '.2', $value));
1327
+ $first = trim(rgget($field['id'] . '.3', $value));
1328
+ $middle = trim(rgget($field['id'] . '.4', $value));
1329
+ $last = trim(rgget($field['id'] . '.6', $value));
1330
+ $suffix = trim(rgget($field['id'] . '.8', $value));
1331
+
1332
+ return array('prefix' => $prefix, 'first' => $first, 'middle' => $middle, 'last' => $last, 'suffix' => $suffix);
1333
+ }
1334
+ else{
1335
+ return $value;
1336
+ }
1337
+
1338
+ break;
1339
+ case 'creditcard' :
1340
+ if(is_array($value)){
1341
+ $card_number = trim(rgget($field['id'] . '.1', $value));
1342
+ $card_type = trim(rgget($field['id'] . '.4', $value));
1343
+ return array('card_number' => $card_number, 'card_type' => $card_type);
1344
+ }
1345
+ else{
1346
+ return '';
1347
+ }
1348
+ break;
1349
+
1350
+ case 'address' :
1351
+ if(is_array($value)){
1352
+ $street_value = trim(rgget($field['id'] . '.1', $value));
1353
+ $street2_value = trim(rgget($field['id'] . '.2', $value));
1354
+ $city_value = trim(rgget($field['id'] . '.3', $value));
1355
+ $state_value = trim(rgget($field['id'] . '.4', $value));
1356
+ $zip_value = trim(rgget($field['id'] . '.5', $value));
1357
+ $country_value = trim(rgget($field['id'] . '.6', $value));
1358
+
1359
+ $line_break = $format == 'html' ? '<br />' : '\n';
1360
+
1361
+ $address_display_format = apply_filters('gform_address_display_format', 'default');
1362
+
1363
+ $address['street'] = $street_value;
1364
+ $address['street2'] = $street2_value;
1365
+ $address['city'] = $city_value;
1366
+ $address['state'] = $state_value;
1367
+ $address['zip'] = $zip_value;
1368
+ $address['country'] = $country_value;
1369
+
1370
+ return $address;
1371
+ }
1372
+ else{
1373
+ return '';
1374
+ }
1375
+ break;
1376
+
1377
+ case 'email' :
1378
+ return GFCommon::is_valid_email($value) && $format == 'html' ? $value : $value;
1379
+ break;
1380
+
1381
+ case 'website' :
1382
+ return GFCommon::is_valid_url($value) && $format == 'html' ? $value : $value;
1383
+ break;
1384
+
1385
+ case 'checkbox' :
1386
+ if(is_array($value)){
1387
+
1388
+ $items = array();
1389
+
1390
+ foreach($value as $key => $item){
1391
+ if(!empty($item)) {
1392
+ if($field['type'] == 'poll' || $field['type'] == 'survey')
1393
+ {
1394
+ /*
1395
+ * Convert our poll type
1396
+ */
1397
+ $items[] = self::get_poll_checkbox($field, $value);
1398
+ return $items;
1399
+ }
1400
+
1401
+ switch($format){
1402
+ case 'text' :
1403
+ $items[] = GFCommon::selection_display($item, $field, $currency, $use_text);
1404
+ break;
1405
+
1406
+ default:
1407
+ $items[] = GFCommon::selection_display($item, $field, $currency, $use_text);
1408
+ break;
1409
+ }
1410
+ }
1411
+ }
1412
+ if(empty($items)){
1413
+ return '';
1414
+ }
1415
+ else if($format == 'text'){
1416
+ /*return substr($items, 0, strlen($items)-2); //removing last comma*/
1417
+ }
1418
+ else{
1419
+ return $items;
1420
+ }
1421
+ }
1422
+ else{
1423
+ return $value;
1424
+ }
1425
+ break;
1426
+
1427
+ case 'post_image' :
1428
+ $ary = explode('|:|', $value);
1429
+ $url = count($ary) > 0 ? $ary[0] : '';
1430
+ $title = count($ary) > 1 ? $ary[1] : '';
1431
+ $caption = count($ary) > 2 ? $ary[2] : '';
1432
+ $description = count($ary) > 3 ? $ary[3] : '';
1433
+
1434
+ if(!empty($url)){
1435
+ $url = str_replace(' ', '%20', $url);
1436
+
1437
+ $value = array('url' => $url,
1438
+ 'path' => str_replace(site_url().'/', ABSPATH, $url),
1439
+ 'title' => $title,
1440
+ 'caption' => $caption,
1441
+ 'description' => $description);
1442
+ }
1443
+ return $value;
1444
+
1445
+ case 'fileupload' :
1446
+ $output_arr = array();
1447
+ if(!empty($value)){
1448
+ $file_paths = rgar($field,'multipleFiles') ? json_decode($value) : array($value);
1449
+ foreach($file_paths as $file_path){
1450
+ $info = pathinfo($file_path);
1451
+ $file_path = esc_attr(str_replace(' ', '%20', $file_path));
1452
+ $output_arr[] = $file_path;
1453
+ }
1454
+ $output = join(PHP_EOL, $output_arr);
1455
+ }
1456
+ return $output_arr;
1457
+ break;
1458
+
1459
+ case 'date' :
1460
+ return GFCommon::date_display($value, rgar($field, 'dateFormat'));
1461
+ break;
1462
+
1463
+ case 'radio' :
1464
+ case 'select' :
1465
+ return GFCommon::selection_display($value, $field, $currency, $use_text);
1466
+ break;
1467
+
1468
+ case 'multiselect' :
1469
+ if(empty($value) || $format == 'text')
1470
+ return $value;
1471
+
1472
+ if(!is_array($value))
1473
+ {
1474
+ $value = explode(',', $value);
1475
+ }
1476
+
1477
+ $items = '';
1478
+ foreach($value as $item){
1479
+ $items[] = GFCommon::selection_display($item, $field, $currency, $use_text);
1480
+ }
1481
+
1482
+ if(sizeof($items) == 1)
1483
+ {
1484
+ return $items[0];
1485
+ }
1486
+ return $items;
1487
+
1488
+
1489
+ break;
1490
+
1491
+ case 'calculation' :
1492
+ case 'singleproduct' :
1493
+ if(is_array($value)){
1494
+ $product_name = trim($value[$field['id'] . '.1']);
1495
+ $price = trim($value[$field['id'] . '.2']);
1496
+ $quantity = trim($value[$field['id'] . '.3']);
1497
+
1498
+ $product = $product_name . ', ' . __('Qty: ', 'gravityforms') . $quantity . ', ' . __('Price: ', 'gravityforms') . $price;
1499
+
1500
+ return $product;
1501
+ }
1502
+ else{
1503
+ return '';
1504
+ }
1505
+ break;
1506
+
1507
+ case 'number' :
1508
+ return GFCommon::format_number($value, rgar($field, 'numberFormat'));
1509
+ break;
1510
+
1511
+ case 'singleshipping' :
1512
+ case 'donation' :
1513
+ case 'total' :
1514
+ case 'price' :
1515
+ return GFCommon::to_money($value, $currency);
1516
+
1517
+ case 'list' :
1518
+ if(empty($value))
1519
+ return '';
1520
+ $value = unserialize($value);
1521
+
1522
+ $has_columns = is_array($value[0]);
1523
+
1524
+ if(!$has_columns){
1525
+ $items = array();
1526
+ foreach($value as $key => $item){
1527
+ if(!empty($item)){
1528
+ switch($format){
1529
+ case 'text' :
1530
+ $items[] = $item;
1531
+ break;
1532
+ case 'url' :
1533
+ $items[] = $item;
1534
+ break;
1535
+ default :
1536
+ if($media == 'email'){
1537
+ $items[] = $item;
1538
+ }
1539
+ else{
1540
+ $items[] = $item;
1541
+ }
1542
+ break;
1543
+ }
1544
+ }
1545
+ }
1546
+
1547
+ if(empty($items)){
1548
+ return '';
1549
+ }
1550
+ else if($format == 'text'){
1551
+ /* return substr($items, 0, strlen($items)-2); //removing last comma*/
1552
+ return $items;
1553
+ }
1554
+ else if($format == 'url'){
1555
+ /*return substr($items, 0, strlen($items)-1); //removing last comma*/
1556
+ return $items;
1557
+ }
1558
+ else if($media == 'email'){
1559
+ return $items;
1560
+ }
1561
+ else {
1562
+ $list = '<table autosize="1" 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%">';
1563
+ foreach($items as $i)
1564
+ {
1565
+ $list .= '<tr><td>' . $i .'</td></tr>';
1566
+ }
1567
+ $list .= '</table>';
1568
+
1569
+ return $list;
1570
+ }
1571
+ }
1572
+ else if(is_array($value)){
1573
+ $columns = array_keys($value[0]);
1574
+
1575
+ $list = '';
1576
+
1577
+ switch($format){
1578
+ case 'text' :
1579
+ $is_first_row = true;
1580
+ foreach($value as $item){
1581
+ if(!$is_first_row)
1582
+ $list .= '\n\n' . $field['label'] . ': ';
1583
+ $list .= implode(',', array_values($item));
1584
+
1585
+ $is_first_row = false;
1586
+ }
1587
+ break;
1588
+
1589
+ case 'url' :
1590
+ foreach($value as $item){
1591
+ $list .= implode('|', array_values($item)) . ',';
1592
+ }
1593
+ if(!empty($list))
1594
+ $list = substr($list, 0, strlen($list)-1);
1595
+ break;
1596
+
1597
+ default :
1598
+
1599
+ if($media == 'email'){
1600
+ $list = '<table autosize="1" 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>';
1601
+
1602
+ //reading columns from entry data
1603
+ foreach($columns as $column){
1604
+ $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>';
1605
+ }
1606
+ $list .= '</tr></thead>';
1607
+
1608
+ $list .= '<tbody style="background-color: #F9F9F9">';
1609
+ foreach($value as $item){
1610
+ $list .= '<tr>';
1611
+ foreach($columns as $column){
1612
+ $val = rgar($item, $column);
1613
+ $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>';
1614
+ }
1615
+
1616
+ $list .='</tr>';
1617
+ }
1618
+
1619
+ $list .='</tbody></table>';
1620
+ }
1621
+ else{
1622
+ $list = '<table class="gfield_list" autosize="1"><thead><tr>';
1623
+
1624
+ //reading columns from entry data
1625
+ foreach($columns as $column){
1626
+ $list .= '<th>' . esc_html($column) . '</th>';
1627
+ }
1628
+ $list .= '</tr></thead>';
1629
+
1630
+ $list .= '<tbody>';
1631
+ foreach($value as $item){
1632
+ $list .= '<tr>';
1633
+ foreach($columns as $column){
1634
+ $val = rgar($item, $column);
1635
+ $list .= '<td>'.htmlspecialchars($val).'</td>';
1636
+ }
1637
+
1638
+ $list .='</tr>';
1639
+ }
1640
+
1641
+ $list .='</tbody></table>';
1642
+ }
1643
+ break;
1644
+ }
1645
+
1646
+ return $list;
1647
+ }
1648
+ return '';
1649
+ break;
1650
+
1651
+ default :
1652
+ if (!is_array($value))
1653
+ {
1654
+ return nl2br($value);
1655
+ }
1656
+ break;
1657
+ }
1658
+ }
1659
+
1660
+ public static function pdf_get_lead_field_display($field, $value, $currency='', $use_text=false, $format='html', $media='screen'){
1661
+
1662
+ if($field['type'] == 'post_category')
1663
+ $value = GFCommon::prepare_post_category_value($value, $field);
1664
+
1665
+ switch(RGFormsModel::get_input_type($field)){
1666
+ case 'name' :
1667
+ if(is_array($value)){
1668
+ $prefix = trim(rgget($field['id'] . '.2', $value));
1669
+ $first = trim(rgget($field['id'] . '.3', $value));
1670
+ $middle = trim(rgget($field['id'] . '.4', $value));
1671
+ $last = trim(rgget($field['id'] . '.6', $value));
1672
+ $suffix = trim(rgget($field['id'] . '.8', $value));
1673
+
1674
+ $name = $prefix;
1675
+ $name .= !empty($name) && !empty($first) ? " $first" : $first;
1676
+ $name .= !empty($name) && !empty($middle) ? " $middle" : $middle;
1677
+ $name .= !empty($name) && !empty($last) ? " $last" : $last;
1678
+ $name .= !empty($name) && !empty($suffix) ? " $suffix" : $suffix;
1679
+
1680
+ return $name;
1681
+ }
1682
+ else{
1683
+ return $value;
1684
+ }
1685
+
1686
+ break;
1687
+ case 'creditcard' :
1688
+ if(is_array($value)){
1689
+ $card_number = trim(rgget($field['id'] . '.1', $value));
1690
+ $card_type = trim(rgget($field['id'] . '.4', $value));
1691
+ $separator = $format == 'html' ? '<br/>' : '\n';
1692
+ return empty($card_number) ? '' : $card_type . $separator . $card_number;
1693
+ }
1694
+ else{
1695
+ return '';
1696
+ }
1697
+ break;
1698
+
1699
+ case 'address' :
1700
+ if(is_array($value)){
1701
+ $street_value = trim(rgget($field['id'] . '.1', $value));
1702
+ $street2_value = trim(rgget($field['id'] . '.2', $value));
1703
+ $city_value = trim(rgget($field['id'] . '.3', $value));
1704
+ $state_value = trim(rgget($field['id'] . '.4', $value));
1705
+ $zip_value = trim(rgget($field['id'] . '.5', $value));
1706
+ $country_value = trim(rgget($field['id'] . '.6', $value));
1707
+
1708
+ $line_break = $format == 'html' ? '<br />' : '\n';
1709
+
1710
+ $address_display_format = apply_filters('gform_address_display_format', 'default');
1711
+ if($address_display_format == 'zip_before_city'){
1712
+ /*
1713
+ Sample:
1714
+ 3333 Some Street
1715
+ suite 16
1716
+ 2344 City, State
1717
+ Country
1718
+ */
1719
+
1720
+ $addr_ary = array();
1721
+ $addr_ary[] = $street_value;
1722
+
1723
+ if(!empty($street2_value))
1724
+ $addr_ary[] = $street2_value;
1725
+
1726
+ $zip_line = trim($zip_value . ' ' . $city_value);
1727
+ $zip_line .= !empty($zip_line) && !empty($state_value) ? ", {$state_value}" : $state_value;
1728
+ $zip_line = trim($zip_line);
1729
+ if(!empty($zip_line))
1730
+ $addr_ary[] = $zip_line;
1731
+
1732
+ if(!empty($country_value))
1733
+ $addr_ary[] = $country_value;
1734
+
1735
+ $address = implode('<br />', $addr_ary);
1736
+
1737
+ }
1738
+ else{
1739
+ $address = $street_value;
1740
+ $address .= !empty($address) && !empty($street2_value) ? $line_break . $street2_value : $street2_value;
1741
+ $address .= !empty($address) && (!empty($city_value) || !empty($state_value)) ? $line_break. $city_value : $city_value;
1742
+ $address .= !empty($address) && !empty($city_value) && !empty($state_value) ? ", $state_value" : $state_value;
1743
+ $address .= !empty($address) && !empty($zip_value) ? " $zip_value" : $zip_value;
1744
+ $address .= !empty($address) && !empty($country_value) ? $line_break . $country_value : $country_value;
1745
+ }
1746
+
1747
+ return $address;
1748
+ }
1749
+ else{
1750
+ return '';
1751
+ }
1752
+ break;
1753
+
1754
+ case 'email' :
1755
+ return GFCommon::is_valid_email($value) && $format == 'html' ? '<a href="mailto:'. $value .'">'. $value .'</a>' : $value;
1756
+ break;
1757
+
1758
+ case 'website' :
1759
+ return GFCommon::is_valid_url($value) && $format == 'html' ? '<a href="'. $value .'" target="_blank">'. $value .'</a>' : $value;
1760
+ break;
1761
+
1762
+ case 'checkbox' :
1763
+ if(is_array($value)){
1764
+
1765
+ $items = '';
1766
+
1767
+ foreach($value as $key => $item){
1768
+ if(!empty($item)){
1769
+ switch($format){
1770
+ case 'text' :
1771
+ $items .= GFCommon::selection_display($item, $field, $currency, true) . ', ';
1772
+ break;
1773
+
1774
+ default:
1775
+ $items .= '<li>' . GFCommon::selection_display($item, $field, $currency, true) . '</li>';
1776
+ break;
1777
+ }
1778
+ }
1779
+ }
1780
+ if(empty($items)){
1781
+ return '';
1782
+ }
1783
+ else if($format == 'text'){
1784
+ return substr($items, 0, strlen($items)-2); //removing last comma
1785
+ }
1786
+ else{
1787
+ return '<ul class="bulleted">' . $items . '</ul>';
1788
+ }
1789
+ }
1790
+ else{
1791
+ return $value;
1792
+ }
1793
+ break;
1794
+
1795
+ case 'post_image' :
1796
+ $ary = explode('|:|', $value);
1797
+ $url = count($ary) > 0 ? $ary[0] : '';
1798
+ $title = count($ary) > 1 ? $ary[1] : '';
1799
+ $caption = count($ary) > 2 ? $ary[2] : '';
1800
+ $description = count($ary) > 3 ? $ary[3] : '';
1801
+
1802
+ if(!empty($url)){
1803
+ $url = str_replace(' ', '%20', $url);
1804
+ switch($format){
1805
+ case 'text' :
1806
+ $value = $url;
1807
+ $value .= !empty($title) ? '\n\n' . $field['label'] . ' (' . __('Title', 'gravityforms') . '): ' . $title : '';
1808
+ $value .= !empty($caption) ? '\n\n' . $field['label'] . ' (' . __('Caption', 'gravityforms') . '): ' . $caption : '';
1809
+ $value .= !empty($description) ? '\n\n' . $field['label'] . ' (' . __('Description', 'gravityforms') . '): ' . $description : '';
1810
+ break;
1811
+
1812
+ default :
1813
+ $path = str_replace(site_url().'/', ABSPATH, $url);
1814
+ $value = "<a href='$url' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='$path' width='100' /></a>";
1815
+ $value .= !empty($title) ? "<div>Title: $title</div>" : "";
1816
+ $value .= !empty($caption) ? "<div>Caption: $caption</div>" : "";
1817
+ $value .= !empty($description) ? "<div>Description: $description</div>": "";
1818
+
1819
+ break;
1820
+ }
1821
+ }
1822
+ return $value;
1823
+
1824
+ case 'fileupload' :
1825
+ $output = '';
1826
+ $output_arr = array();
1827
+ if(!empty($value)){
1828
+ $output .= '<ul>';
1829
+ $file_paths = rgar($field,'multipleFiles') ? json_decode($value) : array($value);
1830
+ foreach($file_paths as $file_path){
1831
+ $info = pathinfo($file_path);
1832
+ $file_path = esc_attr(str_replace(' ', '%20', $file_path));
1833
+ $output_arr[] = '<li><a href="'. $file_path .'" target="_blank" title="' . __('Click to view', 'gravityforms') . '">' . $info['basename'] . '</a></li>';
1834
+ }
1835
+ $output .= join(PHP_EOL, $output_arr);
1836
+ $output .= '</ul>';
1837
+ }
1838
+
1839
+ return $output;
1840
+ break;
1841
+
1842
+ case 'date' :
1843
+ return GFCommon::date_display($value, rgar($field, 'dateFormat'));
1844
+ break;
1845
+
1846
+ case 'radio' :
1847
+ case 'select' :
1848
+ return GFCommon::selection_display($value, $field, $currency, true);
1849
+ break;
1850
+
1851
+ case 'multiselect' :
1852
+ if(empty($value) || $format == 'text')
1853
+ return $value;
1854
+
1855
+ if(!is_array($value))
1856
+ {
1857
+ $value = explode(',', $value);
1858
+ }
1859
+
1860
+ $items = '';
1861
+ foreach($value as $item){
1862
+ $items .= '<li>' . GFCommon::selection_display($item, $field, $currency, true) . '</li>';
1863
+ }
1864
+
1865
+ return '<ul class="bulleted">' . $items . '</ul>';
1866
+
1867
+ break;
1868
+
1869
+ case 'calculation' :
1870
+ case 'singleproduct' :
1871
+ if(is_array($value)){
1872
+ $product_name = trim($value[$field['id'] . '.1']);
1873
+ $price = trim($value[$field['id'] . '.2']);
1874
+ $quantity = trim($value[$field['id'] . '.3']);
1875
+
1876
+ $product = $product_name . ', ' . __('Qty: ', 'gravityforms') . $quantity . ', ' . __('Price: ', 'gravityforms') . $price;
1877
+ return $product;
1878
+ }
1879
+ else{
1880
+ return '';
1881
+ }
1882
+ break;
1883
+
1884
+ case 'number' :
1885
+ return GFCommon::format_number($value, rgar($field, 'numberFormat'));
1886
+ break;
1887
+
1888
+ case 'singleshipping' :
1889
+ case 'donation' :
1890
+ case 'total' :
1891
+ case 'price' :
1892
+ return GFCommon::to_money($value, $currency);
1893
+
1894
+ case 'list' :
1895
+ if(empty($value))
1896
+ return '';
1897
+ $value = unserialize($value);
1898
+
1899
+ $has_columns = is_array($value[0]);
1900
+
1901
+ if(!$has_columns){
1902
+ $items = '';
1903
+ foreach($value as $key => $item){
1904
+ if(!empty($item)){
1905
+ switch($format){
1906
+ case 'text' :
1907
+ $items .= $item . ', ';
1908
+ break;
1909
+ case 'url' :
1910
+ $items .= $item . ',';
1911
+ break;
1912
+ default :
1913
+ if($media == 'email'){
1914
+ $items .= '<li>'.htmlspecialchars($item).'</li>';
1915
+ }
1916
+ else{
1917
+ $items .= '<li>'.htmlspecialchars($item).'</li>';
1918
+ }
1919
+ break;
1920
+ }
1921
+ }
1922
+ }
1923
+
1924
+ if(empty($items)){
1925
+ return '';
1926
+ }
1927
+ else if($format == 'text'){
1928
+ return substr($items, 0, strlen($items)-2); //removing last comma
1929
+ }
1930
+ else if($format == 'url'){
1931
+ return substr($items, 0, strlen($items)-1); //removing last comma
1932
+ }
1933
+ else{
1934
+ return '<ul class="bulleted">' . $items . '</ul>';
1935
+ }
1936
+ }
1937
+ else if(is_array($value)){
1938
+ $columns = array_keys($value[0]);
1939
+
1940
+ $list = '';
1941
+
1942
+ switch($format){
1943
+ case 'text' :
1944
+ $is_first_row = true;
1945
+ foreach($value as $item){
1946
+ if(!$is_first_row)
1947
+ $list .= '\n\n' . $field['label'] . ': ';
1948
+ $list .= implode(',', array_values($item));
1949
+
1950
+ $is_first_row = false;
1951
+ }
1952
+ break;
1953
+
1954
+ case 'url' :
1955
+ foreach($value as $item){
1956
+ $list .= implode('|', array_values($item)) . ',';
1957
+ }
1958
+ if(!empty($list))
1959
+ $list = substr($list, 0, strlen($list)-1);
1960
+ break;
1961
+
1962
+ default :
1963
+ if($media == 'email'){
1964
+ $list = '<table autosize="1" 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>';
1965
+
1966
+ //reading columns from entry data
1967
+ foreach($columns as $column){
1968
+ $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>';
1969
+ }
1970
+ $list .= '</tr></thead>';
1971
+
1972
+ $list .= '<tbody style="background-color: #F9F9F9">';
1973
+ foreach($value as $item){
1974
+ $list .= '<tr>';
1975
+ foreach($columns as $column){
1976
+ $val = rgar($item, $column);
1977
+ $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>';
1978
+ }
1979
+
1980
+ $list .='</tr>';
1981
+ }
1982
+
1983
+ $list .='</tbody></table>';
1984
+ }
1985
+ else{
1986
+ $list = '<table autosize="1" class="gfield_list"><thead><tr>';
1987
+
1988
+ //reading columns from entry data
1989
+ foreach($columns as $column){
1990
+ $list .= '<th>' . esc_html($column) . '</th>';
1991
+ }
1992
+ $list .= '</tr></thead>';
1993
+
1994
+ $list .= '<tbody>';
1995
+ foreach($value as $item){
1996
+ $list .= '<tr>';
1997
+ foreach($columns as $column){
1998
+ $val = rgar($item, $column);
1999
+ $list .= '<td>'.htmlspecialchars($val).'</td>';
2000
+ }
2001
+
2002
+ $list .='</tr>';
2003
+ }
2004
+
2005
+ $list .='</tbody></table>';
2006
+ }
2007
+ break;
2008
+ }
2009
+
2010
+ return $list;
2011
+ }
2012
+ return '';
2013
+ break;
2014
+
2015
+ default :
2016
+ if (!is_array($value))
2017
+ {
2018
+ return nl2br($value);
2019
+ }
2020
+ break;
2021
+ }
2022
+ }
2023
+
2024
+
2025
+ public static function encode_tags($content, $field)
2026
+ {
2027
+ if(RGFormsModel::get_input_type($field) != 'html' || RGFormsModel::get_input_type($field) != 'signature')
2028
+ {
2029
+ $content = str_replace('[', '&#91;', $content);
2030
+ $content = str_replace(']', '&#93;', $content);
2031
+ $content = str_replace('{', '&#123;', $content);
2032
+ $content = str_replace('}', '&#125;', $content);
2033
+ }
2034
+
2035
+ return $content;
2036
+ }
2037
+ }
 
 
 
 
 
 
 
 
2038
  }
pdf.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Gravity PDF
5
  * Plugin URI: https://gravitypdf.com
6
  * Description: Gravity PDF allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission. Our Business Plus package also allows you to overlay field onto an existing PDF.
7
- * Version: 3.7.1
8
  * Author: Blue Liquid Designs
9
  * Author URI: http://www.blueliquiddesigns.com.au
10
  */
@@ -41,7 +41,7 @@
41
  /*
42
  * Define our constants
43
  */
44
- define('PDF_EXTENDED_VERSION', '3.7.1');
45
  define('GF_PDF_EXTENDED_SUPPORTED_VERSION', '1.8');
46
  define('GF_PDF_EXTENDED_WP_SUPPORTED_VERSION', '3.9');
47
  define('GF_PDF_EXTENDED_PHP_SUPPORTED_VERSION', '5');
4
  * Plugin Name: Gravity PDF
5
  * Plugin URI: https://gravitypdf.com
6
  * Description: Gravity PDF allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission. Our Business Plus package also allows you to overlay field onto an existing PDF.
7
+ * Version: 3.7.2
8
  * Author: Blue Liquid Designs
9
  * Author URI: http://www.blueliquiddesigns.com.au
10
  */
41
  /*
42
  * Define our constants
43
  */
44
+ define('PDF_EXTENDED_VERSION', '3.7.2');
45
  define('GF_PDF_EXTENDED_SUPPORTED_VERSION', '1.8');
46
  define('GF_PDF_EXTENDED_WP_SUPPORTED_VERSION', '3.9');
47
  define('GF_PDF_EXTENDED_PHP_SUPPORTED_VERSION', '5');
view/templates/settings/changelog.php CHANGED
@@ -40,6 +40,12 @@
40
  <p><strong>Current Version: <?php echo PDF_EXTENDED_VERSION; ?></strong></p>
41
 
42
  <h3><?php echo PDF_EXTENDED_VERSION; ?></h3>
 
 
 
 
 
 
43
  <ul>
44
  <li>Housekeeping - Allow control over signature width in default template using the 'gfpdfe_signature_width' filter</li>
45
  <li>Housekeeping - Add better error checking when migrating PDF template folder</li>
40
  <p><strong>Current Version: <?php echo PDF_EXTENDED_VERSION; ?></strong></p>
41
 
42
  <h3><?php echo PDF_EXTENDED_VERSION; ?></h3>
43
+ <ul>
44
+ <li>Bug - Updated $form_data['date_created'], $form_data['date_created_usa'], $form_data['misc']['date_time'], $form_data['misc']['time_24hr'] and $form_data['misc']['time_12hr'] to factor in the website's timezone settings. </li>
45
+ </ul>
46
+
47
+
48
+ <h3>3.7.1</h3>
49
  <ul>
50
  <li>Housekeeping - Allow control over signature width in default template using the 'gfpdfe_signature_width' filter</li>
51
  <li>Housekeeping - Add better error checking when migrating PDF template folder</li>