forked from wp-premium/gravityforms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
print-entry.php
133 lines (107 loc) · 4.57 KB
/
print-entry.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
<?php
//For backwards compatibility, load wordpress if it hasn't been loaded yet
//Will be used if this file is being called directly
if(!class_exists("RGForms")){
for ( $i = 0; $i < $depth = 10; $i++ ) {
$wp_root_path = str_repeat( '../', $i );
if ( file_exists("{$wp_root_path}wp-load.php" ) ) {
require_once("{$wp_root_path}wp-load.php");
require_once("{$wp_root_path}wp-admin/includes/admin.php");
break;
}
}
//redirect to the login page if user is not authenticated
auth_redirect();
}
if(!GFCommon::current_user_can_any("gravityforms_view_entries"))
die(__("You don't have adequate permission to view entries.", "gravityforms"));
$form_id = absint(rgget("fid"));
$leads = rgget("lid");
if(0 == $leads){
// get all the lead ids for the current filter / search
$filter = rgget("filter");
$search = rgget("search");
$star = $filter == "star" ? 1 : null;
$read = $filter == "unread" ? 0 : null;
$status = in_array($filter, array("trash", "spam")) ? $filter : "active";
$search_criteria["status"] = $status;
if($star)
$search_criteria["field_filters"][] = array("key" => "is_starred", "value" => (bool) $star );
if(!is_null($read))
$search_criteria["field_filters"][] = array("key" => "is_read", "value" => (bool) $read );
$search_field_id = rgget("field_id");
$search_operator = rgget("operator");
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
$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
);
}
$lead_ids = GFFormsModel::search_lead_ids($form_id, $search_criteria);
} else {
$lead_ids = explode(',', $leads);
}
$page_break = rgget("page_break") ? 'print-page-break' : false;
// sort lead IDs numerically
sort($lead_ids);
if(empty($form_id) || empty($lead_ids))
die(__("Form Id and Lead Id are required parameters.", "gravityforms"));
$form = RGFormsModel::get_form_meta($form_id);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="Robots" content="noindex, nofollow" />
<meta http-equiv="Imagetoolbar" content="No" />
<title>
Print Preview :
<?php echo $form["title"] ?> :
<?php echo count($lead_ids) > 1 ? __("Entry # ", "gravityforms") . $lead_ids[0] : 'Bulk Print' ?>
</title>
<link rel='stylesheet' href='<?php echo GFCommon::get_base_url() ?>/css/print.css' type='text/css' />
<?php
$styles = apply_filters("gform_print_styles", false, $form);
if(!empty($styles)){
wp_print_styles($styles);
}
?>
</head>
<body onload="window.print();">
<div id="print_preview_hdr" style="display:none">
<div><span class="actionlinks"><a href="javascript:;" onclick="window.print();" class="header-print-link">print this page</a> | <a href="javascript:window.close()" class="close_window"><?php _e("close window", "gravityforms") ?></a></span><?php _e("Print Preview", "gravityforms") ?></div>
</div>
<div id="view-container">
<?php
require_once(GFCommon::get_base_path() . "/entry_detail.php");
foreach($lead_ids as $lead_id){
$lead = RGFormsModel::get_lead($lead_id);
do_action("gform_print_entry_header", $form, $lead);
GFEntryDetail::lead_detail_grid($form, $lead);
if(rgget('notes')){
$notes = RGFormsModel::get_lead_notes($lead["id"]);
if(!empty($notes))
GFEntryDetail::notes_grid($notes, false);
}
// output entry divider/page break
if(array_search($lead_id, $lead_ids) < count($lead_ids) - 1)
echo '<div class="print-hr ' . $page_break . '"></div>';
do_action("gform_print_entry_footer", $form, $lead);
}
?>
</div>
</body>
</html>