-
Notifications
You must be signed in to change notification settings - Fork 22
/
entry_detail.php
1510 lines (1272 loc) · 56.3 KB
/
entry_detail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
if ( ! class_exists( 'GFForms' ) ) {
die();
}
use Gravity_Forms\Gravity_Forms\Orders\Summaries\GF_Order_Summary;
use Gravity_Forms\Gravity_Forms\Orders\Factories\GF_Order_Factory;
class GFEntryDetail {
/**
* The current entry array.
*
* @var null|array
*/
private static $_entry = null;
/**
* The current form object.
*
* @var null|form
*/
private static $_form = null;
/**
* The total number of entries in the current filter sent from the entry list.
*
* @var int
*/
private static $_total_count = 0;
/**
* Prepare meta boxes and screen options.
*/
public static function add_meta_boxes() {
$entry = self::get_current_entry();
if ( is_wp_error( $entry ) ) {
return;
}
$meta_boxes = array(
'submitdiv' => array(
'title' => esc_html__( 'Entry', 'gravityforms' ),
'callback' => array( 'GFEntryDetail', 'meta_box_entry_info' ),
'context' => 'side',
),
);
if ( GFCommon::current_user_can_any( 'gravityforms_edit_entry_notes' ) ) {
$meta_boxes['notifications'] = array(
'title' => esc_html__( 'Notifications', 'gravityforms' ),
'callback' => array( 'GFEntryDetail', 'meta_box_notifications' ),
'context' => 'side',
);
}
if ( GFCommon::current_user_can_any( 'gravityforms_view_entry_notes' ) ) {
$meta_boxes['notes'] = array(
'title' => esc_html__( 'Notes', 'gravityforms' ),
'callback' => array( 'GFEntryDetail', 'meta_box_notes' ),
'context' => 'normal',
);
}
if ( ! empty( $entry['payment_status'] ) ) {
$meta_boxes['payment'] = array(
'title' => $entry['transaction_type'] == 2 ? esc_html__( 'Subscription Details', 'gravityforms' ) : esc_html__( 'Payment Details', 'gravityforms' ),
'callback' => array( 'GFEntryDetail', 'meta_box_payment_details' ),
'context' => 'side',
);
}
$meta_boxes['print'] = array(
'title' => esc_html__( 'Print entry', 'gravityforms' ),
'callback' => array( 'GFEntryDetail', 'meta_box_print_entry' ),
'context' => 'side',
);
$form = self::get_current_form();
/**
* Allow custom meta boxes to be added to the entry detail page.
*
* @since 2.0-beta-3
*
* @param array $meta_boxes The properties for the meta boxes.
* @param array $entry The entry currently being viewed/edited.
* @param array $form The form object used to process the current entry.
*/
$meta_boxes = apply_filters( 'gform_entry_detail_meta_boxes', $meta_boxes, $entry, $form );
foreach ( $meta_boxes as $id => $meta_box ) {
$screen = get_current_screen();
add_meta_box(
$id,
$meta_box['title'],
$meta_box['callback'],
$screen->id,
$meta_box['context'],
isset( $meta_box['priority'] ) ? $meta_box['priority'] : 'default',
isset( $meta_box['callback_args'] ) ? $meta_box['callback_args'] : null
);
}
}
public static function get_current_form() {
if ( isset( self::$_form ) ) {
return self::$_form;
}
$form = GFFormsModel::get_form_meta( absint( $_GET['id'] ) );
$form_id = absint( $form['id'] );
$form = apply_filters( 'gform_admin_pre_render', $form );
$form = apply_filters( 'gform_admin_pre_render_' . $form_id, $form );
self::set_current_form( $form );
return $form;
}
/**
* Caches the current form.
*
* @since 2.4.4.1
*
* @param array $form The form to be cached.
*/
public static function set_current_form( $form ) {
self::$_form = $form;
}
public static function get_current_entry() {
if ( isset( self::$_entry ) ) {
return self::$_entry;
}
$form = self::get_current_form();
$form_id = absint( $form['id'] );
$lead_id = rgpost( 'entry_id' ) ? absint( rgpost( 'entry_id' ) ) : absint( rgget( 'lid' ) );
$filter = rgget( 'filter' );
$status = in_array( $filter, array( 'trash', 'spam' ) ) ? $filter : 'active';
$position = rgget( 'pos' ) ? rgget( 'pos' ) : 0;
$sort_direction = rgget( 'order' ) ? rgget( 'order' ) : 'DESC';
$sort_field = empty( $_GET['orderby'] ) ? 0 : $_GET['orderby'];
$sort_field_meta = RGFormsModel::get_field( $form, $sort_field );
$is_numeric = rgar( $sort_field_meta, 'type' ) == 'number';
$search_criteria['status'] = $status;
require_once( 'entry_list.php' );
$filter_links = GFEntryList::get_filter_links( $form, false );
foreach ( $filter_links as $filter_link ) {
if ( $filter == $filter_link['id'] ) {
$search_criteria['field_filters'] = $filter_link['field_filters'];
break;
}
}
$search_field_id = rgget( 'field_id' );
if ( isset( $_GET['field_id'] ) && $_GET['field_id'] !== '' ) {
$key = $search_field_id;
$val = rgget( 's' );
$strpos_row_key = strpos( $search_field_id, '|' );
if ( $strpos_row_key !== false ) { //multi-row likert
$key_array = explode( '|', $search_field_id );
$key = $key_array[0];
$val = $key_array[1] . ':' . $val;
}
$search_criteria['field_filters'][] = array(
'key' => $key,
'operator' => rgempty( 'operator', $_GET ) ? 'is' : rgget( 'operator' ),
'value' => $val,
);
$type = rgget( 'type' );
if ( empty( $type ) ) {
if ( rgget( 'field_id' ) == '0' ) {
$search_criteria['type'] = 'global';
}
}
}
/**
* Allow the entry list search criteria to be overridden.
*
* @since 1.9.14.30
*
* @param array $search_criteria An array containing the search criteria.
* @param int $form_id The ID of the current form.
*/
$search_criteria = gf_apply_filters( array( 'gform_search_criteria_entry_list', $form_id ), $search_criteria, $form_id );
$paging = array( 'offset' => $position, 'page_size' => 1 );
if ( ! empty( $sort_field ) ) {
$sorting = array( 'key' => $sort_field, 'direction' => $sort_direction, 'is_numeric' => $is_numeric );
} else {
$sorting = array();
}
$leads = GFAPI::get_entries( $form['id'], $search_criteria, $sorting, $paging, self::$_total_count );
if ( ! $lead_id ) {
$lead = ! empty( $leads ) ? $leads[0] : false;
} else {
$lead = GFAPI::get_entry( $lead_id );
}
self::set_current_entry( $lead );
return $lead;
}
public static function set_current_entry( $entry ) {
self::$_entry = $entry;
}
public static function get_total_count() {
return self::$_total_count;
}
public static function lead_detail_page() {
global $current_user;
if ( ! GFCommon::ensure_wp_version() ) {
return;
}
$requested_form_id = absint( $_GET['id'] );
if ( empty( $requested_form_id ) ) {
return;
}
$lead = self::get_current_entry();
if ( is_wp_error( $lead ) || ! $lead ) {
esc_html_e( "Oops! We couldn't find your entry. Please try again", 'gravityforms' );
return;
}
GFForms::admin_header();
$lead_id = $lead['id'];
$form = self::get_current_form();
$form_id = absint( $form['id'] );
/**
* Fires before the entry detail page is shown or any processing is handled.
*
* @param array $form The form object for the entry.
* @param array $lead The entry object.
*
* @since 2.3.3.9
*/
gf_do_action( array( 'gform_pre_entry_detail', $form['id'] ), $form, $lead );
$total_count = self::get_total_count();
$position = rgget( 'pos' ) ? rgget( 'pos' ) : 0;
$prev_pos = ! rgblank( $position ) && $position > 0 ? $position - 1 : false;
$next_pos = ! rgblank( $position ) && $position < self::$_total_count - 1 ? $position + 1 : false;
$filter = rgget( 'filter' );
// unread filter requires special handling for pagination since entries are filter out of the query as they are read
if ( $filter == 'unread' ) {
$next_pos = $position;
if ( $next_pos + 1 == $total_count ) {
$next_pos = false;
}
}
GFFormsModel::update_entry_property( $lead['id'], 'is_read', 1 );
switch ( RGForms::post( 'action' ) ) {
case 'update' :
check_admin_referer( 'gforms_save_entry', 'gforms_save_entry' );
$original_entry = $lead;
// Set files that have been uploaded to temp folder
GFFormsModel::set_uploaded_files( $form_id );
GFFormsModel::save_lead( $form, $lead );
/**
* Fires after the Entry is updated from the entry detail page.
*
* @param array $form The form object for the entry.
* @param integer $lead['id'] The entry ID.
* @param array $original_entry The entry object before being updated.
*/
gf_do_action( array( 'gform_after_update_entry', $form['id'] ), $form, $lead['id'], $original_entry );
$lead = GFFormsModel::get_entry( $lead['id'] );
$lead = GFFormsModel::set_entry_meta( $lead, $form );
self::set_current_entry( $lead );
// Check if there's consent field, and values updated.
if ( GFCommon::has_consent_field( $form ) ) {
$user_data = get_userdata( $current_user->ID );
$consent_update_note = '';
foreach ( $form['fields'] as $field ) {
if ( $field['type'] === 'consent' ) {
$field_obj = GFFormsModel::get_field( $form, $field['id'] );
$revision_id = GFFormsModel::get_latest_form_revisions_id( $form['id'] );
$current_description = $field_obj->get_field_description_from_revision( $revision_id );
$submitted_description = $field_obj->get_field_description_from_revision( $original_entry[ $field['id'] . '.3' ] );
if ( $lead[ $field['id'] . '.1' ] !== $original_entry[ $field['id'] . '.1' ] || $field['checkboxLabel'] !== $original_entry[ $field['id'] . '.2' ] || $current_description !== $submitted_description ) {
if ( ! empty( $consent_update_note ) ) {
$consent_update_note .= "\n";
}
$consent_update_note .= empty( $lead[ $field['id'] . '.1' ] ) ? sprintf( esc_html__( '%s: Unchecked "%s"', 'gravityforms' ), GFCommon::get_label( $field ), wp_strip_all_tags( $original_entry[ $field['id'] . '.2' ] ) ) : sprintf( esc_html__( '%s: Checked "%s"', 'gravityforms' ), GFCommon::get_label( $field ), wp_strip_all_tags( $lead[ $field['id'] . '.2' ] ) );
}
}
}
if ( ! empty( $consent_update_note ) ) {
GFFormsModel::add_note( $lead['id'], $current_user->ID, $user_data->display_name, $consent_update_note );
}
}
break;
case 'add_note' :
check_admin_referer( 'gforms_update_note', 'gforms_update_note' );
$user_data = get_userdata( $current_user->ID );
GFFormsModel::add_note( $lead['id'], $current_user->ID, $user_data->display_name, stripslashes( $_POST['new_note'] ) );
//emailing notes if configured
if ( rgpost( 'gentry_email_notes_to' ) ) {
GFCommon::log_debug( 'GFEntryDetail::lead_detail_page(): Preparing to email entry notes.' );
$email_to = $_POST['gentry_email_notes_to'];
$email_from = $current_user->user_email;
$email_subject = stripslashes( $_POST['gentry_email_subject'] );
$body = stripslashes( $_POST['new_note'] );
$headers = "From: \"$email_from\" <$email_from> \r\n";
GFCommon::log_debug( "GFEntryDetail::lead_detail_page(): Emailing notes - TO: $email_to SUBJECT: $email_subject BODY: $body HEADERS: $headers" );
$is_success = wp_mail( $email_to, $email_subject, $body, $headers );
$result = is_wp_error( $is_success ) ? $is_success->get_error_message() : $is_success;
GFCommon::log_debug( "GFEntryDetail::lead_detail_page(): Result from wp_mail(): {$result}" );
if ( ! is_wp_error( $is_success ) && $is_success ) {
GFCommon::log_debug( 'GFEntryDetail::lead_detail_page(): Mail was passed from WordPress to the mail server.' );
} else {
GFCommon::log_error( 'GFEntryDetail::lead_detail_page(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.' );
}
if ( has_filter( 'phpmailer_init' ) ) {
GFCommon::log_debug( __METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.' );
}
/**
* Fires after a note is attached to an entry and sent as an email
*
* @param string $result The Error message or success message when the entry note is sent
* @param string $email_to The email address to send the entry note to
* @param string $email_from The email address from which the email is sent from
* @param string $email_subject The subject of the email that is sent
* @param mixed $body The Full body of the email containing the message after the note is sent
* @param array $form The current form object
* @param array $lead The Current lead object
*/
do_action( 'gform_post_send_entry_note', $result, $email_to, $email_from, $email_subject, $body, $form, $lead );
}
break;
case 'add_quick_note' :
check_admin_referer( 'gforms_save_entry', 'gforms_save_entry' );
$user_data = get_userdata( $current_user->ID );
GFFormsModel::add_note( $lead['id'], $current_user->ID, $user_data->display_name, stripslashes( $_POST['quick_note'] ) );
break;
case 'bulk' :
check_admin_referer( 'gforms_update_note', 'gforms_update_note' );
if ( $_POST['bulk_action'] == 'delete' ) {
if ( ! GFCommon::current_user_can_any( 'gravityforms_edit_entry_notes' ) ) {
wp_die( esc_html__( "You don't have adequate permission to delete notes.", 'gravityforms' ) );
}
GFFormsModel::delete_notes( $_POST['note'] );
}
break;
case 'trash' :
check_admin_referer( 'gforms_save_entry', 'gforms_save_entry' );
if ( ! GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) {
wp_die( esc_html__( "You don't have adequate permission to trash entries.", 'gravityforms' ) );
}
GFFormsModel::update_entry_property( $lead['id'], 'status', 'trash' );
$admin_url = admin_url( 'admin.php?page=gf_entries&view=entries&id=' . absint( $form['id'] ) . '&trashed_entry=' . absint( $lead['id'] ) );
?>
<script type="text/javascript">
document.location.href = <?php echo json_encode( $admin_url ); ?>;
</script>
<?php
break;
case 'restore' :
check_admin_referer( 'gforms_save_entry', 'gforms_save_entry' );
if ( ! GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) {
wp_die( esc_html__( "You don't have adequate permission to restore entries.", 'gravityforms' ) );
}
GFFormsModel::update_entry_property( $lead['id'], 'status', 'active' );
$lead = RGFormsModel::get_lead( $lead['id'] );
self::set_current_entry( $lead );
break;
case 'unspam' :
check_admin_referer( 'gforms_save_entry', 'gforms_save_entry' );
GFFormsModel::update_entry_property( $lead['id'], 'status', 'active' );
$lead = GFFormsModel::get_entry( $lead['id'] );
self::set_current_entry( $lead );
break;
case 'spam' :
check_admin_referer( 'gforms_save_entry', 'gforms_save_entry' );
GFFormsModel::update_entry_property( $lead['id'], 'status', 'spam' );
$lead = GFFormsModel::get_entry( $lead['id'] );
self::set_current_entry( $lead );
break;
case 'delete' :
check_admin_referer( 'gforms_save_entry', 'gforms_save_entry' );
if ( ! GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) {
wp_die( esc_html__( "You don't have adequate permission to delete entries.", 'gravityforms' ) );
}
GFFormsModel::delete_entry( $lead['id'] );
$admin_url = admin_url( 'admin.php?page=gf_entries&view=entries&id=' . absint( $form['id'] ) . '&deleted=' . absint( $lead['id'] ) );
?>
<script type="text/javascript">
document.location.href = <?php echo json_encode( $admin_url ); ?>;
</script>
<?php
break;
} // End switch().
$mode = empty( $_POST['screen_mode'] ) ? 'view' : $_POST['screen_mode'];
if ( $mode === 'edit' ) {
wp_print_styles( 'gform_admin_theme' );
}
$screen = get_current_screen();
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || isset( $_GET['gform_debug'] ) ? '' : '.min';
?>
<script type="text/javascript">
jQuery(document).ready(function () {
toggleNotificationOverride(true);
jQuery('#gform_update_button').prop('disabled', false);
if(typeof postboxes != 'undefined'){
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
postboxes.add_postbox_toggles( <?php echo json_encode( $screen->id ); ?>);
}
});
function DeleteFile(leadId, fieldId, deleteButton) {
if (confirm(<?php echo json_encode( __( "Would you like to delete this file? 'Cancel' to stop. 'OK' to delete", 'gravityforms' ) ); ?>)) {
var fileIndex = jQuery(deleteButton).parent().index();
var mysack = new sack("<?php echo admin_url( 'admin-ajax.php' )?>");
mysack.execute = 1;
mysack.method = 'POST';
mysack.setVar("action", "rg_delete_file");
mysack.setVar("rg_delete_file", "<?php echo wp_create_nonce( 'rg_delete_file' ) ?>");
mysack.setVar("lead_id", leadId);
mysack.setVar("field_id", fieldId);
mysack.setVar("file_index", fileIndex);
mysack.onError = function () {
alert(<?php echo json_encode( __( 'Ajax error while deleting field.', 'gravityforms' ) ); ?>)
};
mysack.runAJAX();
return true;
}
}
function EndDeleteFile(fieldId, fileIndex) {
var previewFileSelector = "#preview_existing_files_" + fieldId + " .ginput_preview";
var $previewFiles = jQuery(previewFileSelector);
var rr = $previewFiles.eq(fileIndex);
$previewFiles.eq(fileIndex).remove();
var $visiblePreviewFields = jQuery(previewFileSelector);
if ($visiblePreviewFields.length == 0) {
jQuery('#preview_' + fieldId).hide();
jQuery('#upload_' + fieldId).show('slow');
}
var $input = jQuery( 'input[name="input_' + fieldId + '"]' );
var rawFiles = JSON.parse( $input.val() );
var files = rawFiles.filter( function( url ) { return url !== null; } );
// remove file from array
if ( fileIndex > -1 ) {
files.splice( fileIndex, 1 );
}
$input.val( jQuery.toJSON( files ) );
}
function ToggleShowEmptyFields() {
if (jQuery("#gentry_display_empty_fields").is(":checked")) {
createCookie("gf_display_empty_fields", true, 10000);
document.location = document.location.href;
}
else {
eraseCookie("gf_display_empty_fields");
document.location = document.location.href;
}
}
function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
}
function eraseCookie(name) {
createCookie(name, "", -1);
}
function ResendNotifications() {
var selectedNotifications = new Array();
jQuery(".gform_notifications:checked").each(function () {
selectedNotifications.push(jQuery(this).val());
});
var sendTo = jQuery('#notification_override_email').val();
if (selectedNotifications.length <= 0) {
displayMessage(<?php echo json_encode( __( 'You must select at least one type of notification to resend.', 'gravityforms' ) ); ?>, 'error', '#notifications');
return;
}
jQuery('#please_wait_container').fadeIn();
jQuery.post(ajaxurl, {
action : "gf_resend_notifications",
gf_resend_notifications: '<?php echo wp_create_nonce( 'gf_resend_notifications' ); ?>',
notifications : jQuery.toJSON(selectedNotifications),
sendTo : sendTo,
leadIds : '<?php echo absint( $lead['id'] ); ?>',
formId : '<?php echo absint( $form['id'] ); ?>'
},
function (response) {
if (response) {
displayMessage(response, "error", "#notifications");
} else {
displayMessage(<?php echo json_encode( esc_html__( 'Notifications were resent successfully.', 'gravityforms' ) ); ?>, "success", "#notifications" );
// reset UI
jQuery(".gform_notifications").attr( 'checked', false );
jQuery('#notification_override_email').val('');
toggleNotificationOverride();
}
jQuery('#please_wait_container').hide();
setTimeout(function () {
jQuery('#notifications_container').find('.message').slideUp();
}, 5000);
}
);
}
function displayMessage( message, messageClass, container ) {
jQuery( container ).find( '.message' ).hide().html( message ).attr( 'class', 'message alert ' + messageClass ).slideDown();
}
function toggleNotificationOverride(isInit) {
if (isInit)
jQuery('#notification_override_email').val('');
if (jQuery(".gform_notifications:checked").length > 0) {
jQuery('#notifications_override_settings').slideDown();
}
else {
jQuery('#notifications_override_settings').slideUp(function () {
jQuery('#notification_override_email').val('');
});
}
}
</script>
<?php
if ( rgpost( 'action' ) == 'update' ) {
?>
<div class="alert success">
<p><?php esc_html_e( 'Entry Updated.', 'gravityforms' ); ?></p>
</div>
<?php
}
?>
<form method="post" id="entry_form" enctype='multipart/form-data'>
<?php wp_nonce_field( 'gforms_save_entry', 'gforms_save_entry' ) ?>
<input type="hidden" name="action" id="action" value="" />
<input type="hidden" name="screen_mode" id="screen_mode" value="<?php echo esc_attr( rgpost( 'screen_mode' ) ) ?>" />
<input type="hidden" name="entry_id" id="entry_id" value="<?php echo absint( $lead['id'] ) ?>" />
<div class="wrap gf_entry_wrap">
<?php
$gf_entry_locking = new GFEntryLocking();
$gf_entry_locking->lock_info( $lead_id ); ?>
<?php if ( isset( $_GET['pos'] ) ) { ?>
<div class="gf_entry_detail_pagination">
<div class="gf_entry_count">
<?php esc_html_e('Entry', 'gravityforms' );?> <strong><?php echo $position + 1; ?></strong> of <strong><?php echo $total_count; ?></strong>
</div>
<div class="gf_entry_prev gf_entry_pagination"><?php echo GFEntryDetail::entry_detail_pagination_link( $prev_pos, 'Previous Entry', 'gf_entry_prev_link', 'dashicons-arrow-left-alt' ); ?></div>
<div class="gf_entry_next gf_entry_pagination"><?php echo GFEntryDetail::entry_detail_pagination_link( $next_pos, 'Next Entry', 'gf_entry_next_link', 'dashicons-arrow-right-alt' ); ?></div>
</div>
<?php } ?>
<div id="poststuff">
<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
<div id="post-body" class="metabox-holder columns-2 gform-settings-panel__content">
<div id="post-body-content" >
<?php
/**
* Fires before the entry detail content is displayed
*
* @param array $form The Form object
* @param array $lead The Entry object
*/
do_action( 'gform_entry_detail_content_before', $form, $lead );
if ( 'edit' === $mode && GFCommon::current_user_can_any( 'gravityforms_edit_entries' ) ) {
self::lead_detail_edit( $form, $lead );
} else {
self::lead_detail_grid( $form, $lead, true );
}
/**
* Fires when entry details are displayed
*
* @param array $form The Form object
* @param array $lead The Entry object
*/
do_action( 'gform_entry_detail', $form, $lead );
?>
</div>
<div id="postbox-container-1" class="postbox-container">
<?php
/**
* Fires before the entry detail sidebar is generated
*
* @param array $form The Form object
* @param array $lead The Entry object
*/
do_action( 'gform_entry_detail_sidebar_before', $form, $lead );
?>
<?php
do_meta_boxes( $screen->id, 'side', array( 'form' => $form, 'entry' => $lead, 'mode' => $mode ) ); ?>
<?php
/**
* Inserts information into the middle of the entry detail sidebar
*
* @param array $form The Form object
* @param array $lead The Entry object
*/
do_action( 'gform_entry_detail_sidebar_middle', $form, $lead );
/**
* Fires after the entry detail sidebar information.
*
* @param array $form The Form object
* @param array $lead The Entry object
*/
do_action( 'gform_entry_detail_sidebar_after', $form, $lead );
?>
</div>
<div id="postbox-container-2" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'normal', array( 'form' => $form, 'entry' => $lead, 'mode' => $mode ) ); ?>
<?php
/**
* Fires after the entry detail content is displayed
*
* @param array $form The Form object
* @param array $lead The Entry object
*/
do_action( 'gform_entry_detail_content_after', $form, $lead );
?>
</div>
</div>
</div>
</div>
</form>
<?php
}
public static function lead_detail_edit( $form, $lead ) {
$form_id = absint( $form['id'] );
if ( empty( $form_id ) ) {
return;
}
?>
<div class="postbox">
<h3>
<label for="name"><?php esc_html_e( 'Details', 'gravityforms' ); ?></label>
</h3>
<div class="inside gform_wrapper gravity-theme">
<table class="form-table entry-details">
<tbody>
<?php
foreach ( $form['fields'] as $field ) {
$field_id = $field->id;
$content = $value = '';
switch ( $field->get_input_type() ) {
case 'section' :
$content = '
<tr valign="top">
<td class="detail-view">
<div style="margin-bottom:10px; border-bottom:1px dotted #ccc;">
<h2 class="detail_gsection_title">' . esc_html( GFCommon::get_label( $field ) ) . '</h2>
</div>
</td>
</tr>';
break;
case 'captcha':
case 'html':
case 'password':
//ignore certain fields
break;
default :
$value = RGFormsModel::get_lead_field_value( $lead, $field );
$td_id = 'field_' . $form_id . '_' . $field_id;
$td_id = esc_attr( $td_id );
if ( is_array( $field->fields ) ) {
// Ensure the top level repeater has the right nesting level so the label is not duplicated.
$field->nestingLevel = 0;
$field_label = '';
} else {
$field_label = "<label class='detail-label'>" . esc_html( GFCommon::get_label( $field ) ) . '</label>';
}
$content = "<tr valign='top'><td class='detail-view' id='{$td_id}'>" .
$field_label .
GFCommon::get_field_input( $field, $value, $lead['id'], $form_id, $form ) .
'</td></tr>';
break;
}
/**
* Filters the field content.
*
* @since 2.1.2.14 Added form and field ID modifiers.
*
* @param string $content The field content.
* @param array $field The Field Object.
* @param string $value The field value.
* @param int $lead['id'] The entry ID.
* @param int $form['id'] The form ID.
*/
$content = gf_apply_filters( array( 'gform_field_content', $form['id'], $field->id ), $content, $field, $value, $lead['id'], $form['id'] );
echo $content;
}
?>
</tbody>
</table>
<br />
<div class="gform_footer">
<input type="hidden" name="gform_unique_id" value="" />
<input type="hidden" name="gform_uploaded_files" id='gform_uploaded_files_<?php echo absint( $form_id ); ?>' value="" />
</div>
</div>
</div>
<?php
}
public static function notes_grid( $notes, $is_editable, $emails = null, $subject = '' ) {
if ( sizeof( $notes ) > 0 && $is_editable && GFCommon::current_user_can_any( 'gravityforms_edit_entry_notes' ) ) {
?>
<div class="actions" style="padding:3px 0;">
<label class="hidden" for="bulk_action"><?php esc_html_e( ' Bulk action', 'gravityforms' ) ?></label>
<select name="bulk_action" id="bulk_action">
<option value=''><?php esc_html_e( ' Bulk action ', 'gravityforms' ) ?></option>
<option value='delete'><?php esc_html_e( 'Delete', 'gravityforms' ) ?></option>
</select>
<?php
$apply_button = '<input type="submit" class="button" value="' . esc_attr__( 'Apply', 'gravityforms' ) . '" onclick="jQuery(\'#action\').val(\'bulk\');" />';
/**
* A filter to allow you to modify the note apply button
*
* @param string $apply_button The Apply Button HTML
*/
echo apply_filters( 'gform_notes_apply_button', $apply_button );
?>
</div>
<?php
}
?>
<div class="entry-notes">
<?php
$count = 0;
$notes_count = sizeof( $notes );
if ( $notes_count > 0 ) {
echo '<h3 class="entry-notes-print-header">' . esc_html__( 'Notes', 'gravityforms' ) . '</h3>';
}
foreach ( $notes as $note ) {
$count ++;
$is_last = $count >= $notes_count ? true : false;
// Prepare note classes.
$classes = array();
// Add base note class.
if ( $note->note_type ) {
$classes[] = sprintf( 'gforms_note_%s', $note->note_type );
}
// Add sub type note class.
if ( rgobj( $note, 'sub_type' ) ) {
$classes[] = sprintf( 'alert gforms_note_%s', $note->sub_type );
}
// Escape note classes.
$classes = array_map( 'esc_attr', $classes );
?>
<div class="note" data-id="<?php echo esc_attr( $note->id ); ?>" data-type="<?php echo esc_attr( $note->note_type ); ?>"<?php echo rgobj( $note, 'sub_type' ) ? ' data-sub-type="' . esc_attr( $note->sub_type ) . '"' : ''; ?>>
<div class="note-details">
<?php if ( $is_editable && GFCommon::current_user_can_any( 'gravityforms_edit_entry_notes' ) ) { ?>
<div class="note-check" >
<input type="checkbox" value="<?php echo $note->id ?>" name="note[]" />
</div>
<?php } ?>
<div class="author<?php echo $is_last ? ' lastrow' : '' ?>">
<div class="avatar">
<?php
if ( $note->user_id ) {
$avatar = get_avatar( $note->user_id, 48 );
} else {
$avatar = '<svg width="37" height="39" alt="' . esc_attr( $note->user_name ) . '" viewBox="0 0 43 47" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M42.8148 31.7793C42.8148 33.9193 41.2892 36.5422 39.421 37.6067L24.7956 45.9912C22.9274 47.0557 19.8763 47.0557 18.0081 45.9912L3.38273 37.6067C1.52555 36.5422 0 33.9193 0 31.7793V15.0103C0 12.8703 1.52555 10.2474 3.39379 9.18288L18.0081 0.798392C19.8763 -0.266131 22.9274 -0.266131 24.7956 0.798392L39.421 9.18288C41.2892 10.2474 42.8148 12.8703 42.8148 15.0103V31.7793Z" fill="#F15A29"/>
<path d="M17.2449 19.51H36.6238V14.0996H17.3002C14.5365 14.0996 12.2372 15.0434 10.4905 16.8981C6.26765 21.3537 6.1571 32.5916 6.1571 32.5916H36.4911V22.4292H31.0412V27.1812H11.9608C12.0824 25.4143 12.9005 22.2427 14.4481 20.6075C15.1556 19.8612 16.051 19.51 17.2449 19.51Z" fill="white"/></svg>';
}
/**
* Allows filtering of the notes avatar
*
* @param array $note The Note object that is being filtered when modifying the avatar
*/
echo apply_filters( 'gform_notes_avatar', $avatar, $note ); ?>
</div>
<div class="text">
<h6><?php echo esc_html( $note->user_name ) ?> <?php if ( $note->user_email ): ?><?php echo esc_html( $note->user_email ) ?><?php endif; ?></h6>
<time><?php esc_html_e( 'added', 'gravityforms' ); ?> <?php echo esc_html( GFCommon::format_date( $note->date_created, true ) ) ?></time>
</div>
</div>
</div>
<div class="note-content <?php echo implode( ' ', $classes ); ?>"><?php echo nl2br( wp_kses_post( $note->value ) ) ?></div>
</div>
<?php
}
if ( $is_editable && GFCommon::current_user_can_any( 'gravityforms_edit_entry_notes' ) ) {
?>
<div class="add-note">
<textarea name="new_note" ></textarea>
<div class="add-note-actions">
<?php
$note_button = '<input type="submit" name="add_note" value="' . esc_attr__( 'Add Note', 'gravityforms' ) . '" class="button" onclick="jQuery(\'#action\').val(\'add_note\');"/>';
/**
* Allows for modification of the "Add Note" button for Entry Notes
*
* @param string $note_button The HTML for the "Add Note" Button
*/
echo apply_filters( 'gform_addnote_button', $note_button );
if ( ! empty( $emails ) ) {
?>
<span class="send-to">
<select name="gentry_email_notes_to" onchange="if(jQuery(this).val() != '') {jQuery('#gentry_email_subject_container').css('display', 'inline');} else{jQuery('#gentry_email_subject_container').css('display', 'none');}">
<option value=""><?php esc_html_e( 'Also email this note to', 'gravityforms' ) ?></option>
<?php foreach ( $emails as $email ) { ?>
<option value="<?php echo esc_attr( $email ); ?>"><?php echo esc_html( $email ); ?></option>
<?php } ?>
</select>
<span id='gentry_email_subject_container' style="display:none;">
<label for="gentry_email_subject"><?php esc_html_e( 'Subject:', 'gravityforms' ) ?></label>
<input type="text" name="gentry_email_subject" id="gentry_email_subject" value="" style="width:70%" />
</span>
</span>
<?php } ?>
</div>
</div>
<?php
}
?>
</div>
<?php
}
public static function lead_detail_grid( $form, $lead, $allow_display_empty_fields = false ) {
$form_id = absint( $form['id'] );
if ( empty( $form_id ) ) {
return;
}
$display_empty_fields = self::maybe_display_empty_fields( $allow_display_empty_fields, $form, $lead );
?>
<table cellspacing="0" class="entry-details-table ">
<thead>
<tr>
<th id="details">
<?php
$title = sprintf( '%s : %s %s', esc_html( $form['title'] ), esc_html__( 'Entry # ', 'gravityforms' ), absint( $lead['id'] ) );
/**
* Filters the title displayed on the entry detail page.
*
* @since 1.9
*
* @param string $title The title used.
* @param array $form The Form Object.
* @param array $entry The Entry Object.
*/
echo apply_filters( 'gform_entry_detail_title', $title, $form, $lead );
?>
</th>
<th style="width:auto; font-size:10px; text-align: right;">
<?php
if ( $allow_display_empty_fields ) {
?>
<input type="checkbox" id="gentry_display_empty_fields" <?php echo $display_empty_fields ? "checked='checked'" : '' ?> onclick="ToggleShowEmptyFields();" />
<label for="gentry_display_empty_fields"><?php esc_html_e( 'show empty fields', 'gravityforms' ) ?></label>
<?php
}
?>
</th>
</tr>
</thead>
<tbody>
<?php
$count = 0;
$field_count = sizeof( $form['fields'] );
$has_product_fields = false;
foreach ( $form['fields'] as $field ) {
$content = $value = '';
switch ( $field->get_input_type() ) {
case 'section' :