예제 #1
5
    public static function leads_page($form_id)
    {
        global $wpdb;
        //quit if version of wp is not supported
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        $form_id = absint($form_id);
        echo GFCommon::get_remote_message();
        $action = RGForms::post('action');
        $filter = rgget('filter');
        $search = stripslashes(rgget('s'));
        $page_index = empty($_GET['paged']) ? 0 : intval($_GET['paged']) - 1;
        $star = $filter == 'star' ? 1 : null;
        $read = $filter == 'unread' ? 0 : null;
        $status = in_array($filter, array('trash', 'spam')) ? $filter : 'active';
        $form = RGFormsModel::get_form_meta($form_id);
        $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 = stripslashes(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;
            }
            if ('entry_id' == $key) {
                $key = 'id';
            }
            $filter_operator = empty($search_operator) ? 'is' : $search_operator;
            $field = GFFormsModel::get_field($form, $key);
            if ($field) {
                $input_type = GFFormsModel::get_input_type($field);
                if ($field->type == 'product' && in_array($input_type, array('radio', 'select'))) {
                    $filter_operator = 'contains';
                }
            }
            $search_criteria['field_filters'][] = array('key' => $key, 'operator' => $filter_operator, 'value' => $val);
        }
        $update_message = '';
        switch ($action) {
            case 'delete':
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $lead_id = $_POST['action_argument'];
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    RGFormsModel::delete_lead($lead_id);
                    $update_message = esc_html__('Entry deleted.', 'gravityforms');
                } else {
                    $update_message = esc_html__("You don't have adequate permission to delete entries.", 'gravityforms');
                }
                break;
            case 'bulk':
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $bulk_action = !empty($_POST['bulk_action']) ? $_POST['bulk_action'] : $_POST['bulk_action2'];
                $select_all = rgpost('all_entries');
                $leads = empty($select_all) ? $_POST['lead'] : GFFormsModel::search_lead_ids($form_id, $search_criteria);
                $entry_count = count($leads) > 1 ? sprintf(esc_html__('%d entries', 'gravityforms'), count($leads)) : esc_html__('1 entry', 'gravityforms');
                switch ($bulk_action) {
                    case 'delete':
                        if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                            RGFormsModel::delete_leads($leads);
                            $update_message = sprintf(esc_html__('%s deleted.', 'gravityforms'), $entry_count);
                        } else {
                            $update_message = esc_html__("You don't have adequate permission to delete entries.", 'gravityforms');
                        }
                        break;
                    case 'trash':
                        RGFormsModel::update_leads_property($leads, 'status', 'trash');
                        $update_message = sprintf(esc_html__('%s moved to Trash.', 'gravityforms'), $entry_count);
                        break;
                    case 'restore':
                        RGFormsModel::update_leads_property($leads, 'status', 'active');
                        $update_message = sprintf(esc_html__('%s restored from the Trash.', 'gravityforms'), $entry_count);
                        break;
                    case 'unspam':
                        RGFormsModel::update_leads_property($leads, 'status', 'active');
                        $update_message = sprintf(esc_html__('%s restored from the spam.', 'gravityforms'), $entry_count);
                        break;
                    case 'spam':
                        RGFormsModel::update_leads_property($leads, 'status', 'spam');
                        $update_message = sprintf(esc_html__('%s marked as spam.', 'gravityforms'), $entry_count);
                        break;
                    case 'mark_read':
                        RGFormsModel::update_leads_property($leads, 'is_read', 1);
                        $update_message = sprintf(esc_html__('%s marked as read.', 'gravityforms'), $entry_count);
                        break;
                    case 'mark_unread':
                        RGFormsModel::update_leads_property($leads, 'is_read', 0);
                        $update_message = sprintf(esc_html__('%s marked as unread.', 'gravityforms'), $entry_count);
                        break;
                    case 'add_star':
                        RGFormsModel::update_leads_property($leads, 'is_starred', 1);
                        $update_message = sprintf(esc_html__('%s starred.', 'gravityforms'), $entry_count);
                        break;
                    case 'remove_star':
                        RGFormsModel::update_leads_property($leads, 'is_starred', 0);
                        $update_message = sprintf(esc_html__('%s unstarred.', 'gravityforms'), $entry_count);
                        break;
                }
                break;
            case 'change_columns':
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $columns = GFCommon::json_decode(stripslashes($_POST['grid_columns']), true);
                RGFormsModel::update_grid_column_meta($form_id, $columns);
                break;
        }
        if (rgpost('button_delete_permanently')) {
            if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                RGFormsModel::delete_leads_by_form($form_id, $filter);
            }
        }
        $sort_field = empty($_GET['sort']) ? 0 : $_GET['sort'];
        $sort_direction = empty($_GET['dir']) ? 'DESC' : $_GET['dir'];
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta['type'] == 'number';
        $page_size = gf_apply_filters('gform_entry_page_size', $form_id, 20, $form_id);
        $first_item_index = $page_index * $page_size;
        if (!empty($sort_field)) {
            $sorting = array('key' => $_GET['sort'], 'direction' => $sort_direction, 'is_numeric' => $is_numeric);
        } else {
            $sorting = array();
        }
        $paging = array('offset' => $first_item_index, 'page_size' => $page_size);
        $total_count = 0;
        $leads = GFAPI::get_entries($form_id, $search_criteria, $sorting, $paging, $total_count);
        $summary = RGFormsModel::get_form_counts($form_id);
        $active_lead_count = $summary['total'];
        $unread_count = $summary['unread'];
        $starred_count = $summary['starred'];
        $spam_count = $summary['spam'];
        $trash_count = $summary['trash'];
        $columns = RGFormsModel::get_grid_columns($form_id, true);
        $search_qs = empty($search) ? '' : '&s=' . esc_attr(urlencode($search));
        $sort_qs = empty($sort_field) ? '' : '&sort=' . esc_attr($sort_field);
        $dir_qs = empty($sort_direction) ? '' : '&dir=' . esc_attr($sort_direction);
        $star_qs = $star !== null ? '&star=' . esc_attr($star) : '';
        $read_qs = $read !== null ? '&read=' . esc_attr($read) : '';
        $filter_qs = '&filter=' . esc_attr($filter);
        $search_field_id_qs = !isset($_GET['field_id']) ? '' : '&field_id=' . esc_attr($search_field_id);
        $search_operator_urlencoded = urlencode($search_operator);
        $search_operator_qs = empty($search_operator_urlencoded) ? '' : '&operator=' . esc_attr($search_operator_urlencoded);
        $display_total = ceil($total_count / $page_size);
        $page_links = paginate_links(array('base' => admin_url('admin.php') . "?page=gf_entries&view=entries&id={$form_id}&%_%" . $search_qs . $sort_qs . $dir_qs . $star_qs . $read_qs . $filter_qs . $search_field_id_qs . $search_operator_qs, 'format' => 'paged=%#%', 'prev_text' => esc_html__('«', 'gravityforms'), 'next_text' => esc_html__('»', 'gravityforms'), 'total' => $display_total, 'current' => $page_index + 1, 'show_all' => false));
        wp_print_styles(array('thickbox'));
        $field_filters = GFCommon::get_field_filter_settings($form);
        $init_field_id = empty($search_field_id) ? 0 : $search_field_id;
        $init_field_operator = empty($search_operator) ? 'contains' : $search_operator;
        $init_filter_vars = array('mode' => 'off', 'filters' => array(array('field' => $init_field_id, 'operator' => $init_field_operator, 'value' => $search)));
        $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || isset($_GET['gform_debug']) ? '' : '.min';
        ?>

		<script type="text/javascript">

		var messageTimeout = false,
			gformFieldFilters = <?php 
        echo json_encode($field_filters);
        ?>
,
			gformInitFilter = <?php 
        echo json_encode($init_filter_vars);
        ?>

				function ChangeColumns(columns) {
					jQuery("#action").val("change_columns");
					jQuery("#grid_columns").val(jQuery.toJSON(columns));
					tb_remove();
					jQuery("#lead_form")[0].submit();
				}

		function Search(sort_field_id, sort_direction, form_id, search, star, read, filter, field_id, operator) {
			var search_qs = search == "" ? "" : "&s=" + encodeURIComponent(search);
			var star_qs = star == "" ? "" : "&star=" + star;
			var read_qs = read == "" ? "" : "&read=" + read;
			var filter_qs = filter == "" ? "" : "&filter=" + filter;
			var field_id_qs = field_id == "" ? "" : "&field_id=" + field_id;
			var operator_qs = operator == "" ? "" : "&operator=" + operator;

			var location = "?page=gf_entries&view=entries&id=" + form_id + "&sort=" + sort_field_id + "&dir=" + sort_direction + search_qs + star_qs + read_qs + filter_qs + field_id_qs + operator_qs;
			document.location = location;
		}

		function ToggleStar(img, lead_id, filter) {
			var is_starred = img.src.indexOf("star1.png") >= 0;
			if (is_starred)
				img.src = img.src.replace("star1.png", "star0.png");
			else
				img.src = img.src.replace("star0.png", "star1.png");

			jQuery("#lead_row_" + lead_id).toggleClass("lead_starred");
			//if viewing the starred entries, hide the row and adjust the paging counts
			if (filter == "star") {
				var title = jQuery("#lead_row_" + lead_id);
				title.css("display", 'none');
				UpdatePagingCounts(1);
			}

			UpdateCount("star_count", is_starred ? -1 : 1);

			UpdateLeadProperty(lead_id, "is_starred", is_starred ? 0 : 1);
		}

		function ToggleRead(lead_id, filter) {
			var title = jQuery("#lead_row_" + lead_id);
			var marking_read = title.hasClass("lead_unread");

			jQuery("#mark_read_" + lead_id).css("display", marking_read ? "none" : "inline");
			jQuery("#mark_unread_" + lead_id).css("display", marking_read ? "inline" : "none");
			jQuery("#is_unread_" + lead_id).css("display", marking_read ? "inline" : "none");
			title.toggleClass("lead_unread");
			//if viewing the unread entries, hide the row and adjust the paging counts
			if (filter == "unread") {
				title.css("display", "none");
				UpdatePagingCounts(1);
			}

			UpdateCount("unread_count", marking_read ? -1 : 1);
			UpdateLeadProperty(lead_id, "is_read", marking_read ? 1 : 0);
		}

		function UpdateLeadProperty(lead_id, name, value) {
			var mysack = new sack("<?php 
        echo admin_url('admin-ajax.php');
        ?>
");
			mysack.execute = 1;
			mysack.method = 'POST';
			mysack.setVar("action", "rg_update_lead_property");
			mysack.setVar("rg_update_lead_property", "<?php 
        echo wp_create_nonce('rg_update_lead_property');
        ?>
");
			mysack.setVar("lead_id", lead_id);
			mysack.setVar("name", name);
			mysack.setVar("value", value);
			mysack.onError = function () {
				alert(<?php 
        echo json_encode(__('Ajax error while setting lead property', 'gravityforms'));
        ?>
)
			};
			mysack.runAJAX();

			return true;
		}

		function UpdateCount(element_id, change) {
			var element = jQuery("#" + element_id);
			var count = parseInt(element.html()) + change
			element.html(count + "");
		}

		function UpdatePagingCounts(change) {
			//update paging header/footer Displaying # - # of #, use counts from header, no need to use footer since they are the same, just update footer paging with header info
			var paging_range_max_header = jQuery("#paging_range_max_header");
			var paging_range_max_footer = jQuery("#paging_range_max_footer");
			var range_change_max = parseInt(paging_range_max_header.html()) - change;
			var paging_total_header = jQuery("#paging_total_header");
			var paging_total_footer = jQuery("#paging_total_footer");
			var total_change = parseInt(paging_total_header.html()) - change;
			var paging_range_min_header = jQuery("#paging_range_min_header");
			var paging_range_min_footer = jQuery("#paging_range_min_footer");
			//if min and max are the same, this is the last entry item on the page, clear out the displaying # - # of # text
			if (parseInt(paging_range_min_header.html()) == parseInt(paging_range_max_header.html())) {
				var paging_header = jQuery("#paging_header");
				paging_header.html("");
				var paging_footer = jQuery("#paging_footer");
				paging_footer.html("");
			}
			else {
				paging_range_max_header.html(range_change_max + "");
				paging_range_max_footer.html(range_change_max + "");
				paging_total_header.html(total_change + "");
				paging_total_footer.html(total_change + "");
			}
			gformVars.countAllEntries = gformVars.countAllEntries - change;
			setSelectAllText();
		}

		function DeleteLead(lead_id) {
			jQuery("#action").val("delete");
			jQuery("#action_argument").val(lead_id);
			jQuery("#lead_form")[0].submit();
			return true;
		}

		function handleBulkApply(actionElement) {

			var action = jQuery("#" + actionElement).val();
			var defaultModalOptions = '';
			var leadIds = getLeadIds();

			if (leadIds.length == 0) {
				alert(<?php 
        echo json_encode(__('Please select at least one entry.', 'gravityforms'));
        ?>
);
				return false;
			}

			switch (action) {

				case 'resend_notifications':
					resetResendNotificationsUI();
					tb_show(<?php 
        echo json_encode(esc_html__('Resend Notifications', 'gravityforms'));
        ?>
, '#TB_inline?width=350&amp;inlineId=notifications_modal_container', '');
					return false;
					break;

				case 'print':
					resetPrintUI();
					tb_show(<?php 
        echo json_encode(esc_html__('Print Entries', 'gravityforms'));
        ?>
, '#TB_inline?width=350&amp;height=250&amp;inlineId=print_modal_container', '');
					return false;
					break;

				default:
					jQuery('#action').val('bulk');
			}

		}

		function getLeadIds() {
			var all = jQuery("#all_entries").val();
			//compare string, the boolean isn't correct, even when casting to a boolean the 0 is set to true
			if (all == "1")
				return 0;

			var leads = jQuery(".check-column input[name='lead[]']:checked");
			var leadIds = new Array();

			jQuery(leads).each(function (i) {
				leadIds[i] = jQuery(leads[i]).val();
			});

			return leadIds;
		}

		function BulkResendNotifications() {


			var selectedNotifications = new Array();
			jQuery(".gform_notifications:checked").each(function () {
				selectedNotifications.push(jQuery(this).val());
			});
			var leadIds = getLeadIds();

			var sendTo = jQuery('#notification_override_email').val();

			if (selectedNotifications.length <= 0) {
				displayMessage(<?php 
        echo json_encode(esc_html__('You must select at least one type of notification to resend.', 'gravityforms'));
        ?>
, "error", "#notifications_container");
				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                : leadIds,
					filter                 : <?php 
        echo json_encode(rgget('filter'));
        ?>
,
					search                 : <?php 
        echo json_encode(rgget('s'));
        ?>
,
					operator               : <?php 
        echo json_encode(rgget('operator'));
        ?>
,
					fieldId                : <?php 
        echo json_encode(rgget('field_id'));
        ?>
,
					formId                 : <?php 
        echo json_encode($form['id']);
        ?>
				},
				function (response) {

					jQuery('#please_wait_container').hide();

					if (response) {
						displayMessage(response, 'error', '#notifications_container');
					} else {
						var message = <?php 
        echo json_encode(__('Notifications for %s were resent successfully.', 'gravityforms'));
        ?>
;
						var c = leadIds == 0 ? gformVars.countAllEntries : leadIds.length;
						displayMessage(message.replace('%s', c + ' ' + getPlural(c, <?php 
        echo json_encode(__('entry', 'gravityforms'));
        ?>
, <?php 
        echo json_encode(__('entries', 'gravityforms'));
        ?>
)), "updated", "#lead_form");
						closeModal(true);
					}

				}
			);

		}

		function resetResendNotificationsUI() {

			jQuery(".gform_notifications").attr('checked', false);
			jQuery('#notifications_container .message, #notifications_override_settings').hide();

		}

		function BulkPrint() {

			var leadIds = getLeadIds();
			if (leadIds != 0)
				leadIds = leadIds.join(',');
			var leadsQS = '&lid=' + leadIds;
			var notesQS = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : '';
			var pageBreakQS = jQuery('#gform_print_page_break').is(':checked') ? '&page_break=1' : '';
			var filterQS = '&filter=' + <?php 
        echo json_encode(rgget('filter'));
        ?>
;
			var searchQS = '&s=' + <?php 
        echo json_encode(rgget('s'));
        ?>
;
			var searchFieldIdQS = '&field_id=' + <?php 
        echo json_encode(rgget('field_id'));
        ?>
;
			var searchOperatorQS = '&operator=' + <?php 
        echo json_encode(rgget('operator'));
        ?>
;

			var url = '<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=print-entry&fid=<?php 
        echo absint($form['id']);
        ?>
' + leadsQS + notesQS + pageBreakQS + filterQS + searchQS + searchFieldIdQS + searchOperatorQS;
			window.open(url, 'printwindow');

			closeModal(true);
			hideMessage('#lead_form', false);
		}

		function resetPrintUI() {

			jQuery('#print_options input[type="checkbox"]').attr('checked', false);

		}

		function displayMessage(message, messageClass, container) {

			hideMessage(container, true);

			var messageBox = jQuery('<div class="message ' + messageClass + '" style="display:none;"><p>' + message + '</p></div>');
			jQuery(messageBox).prependTo(container).slideDown();

			if (messageClass == 'updated')
				messageTimeout = setTimeout(function () {
					hideMessage(container, false);
				}, 10000);

		}

		function hideMessage(container, messageQueued) {

			if (messageTimeout)
				clearTimeout(messageTimeout);

			var messageBox = jQuery(container).find('.message');

			if (messageQueued)
				jQuery(messageBox).remove();
			else
				jQuery(messageBox).slideUp(function () {
					jQuery(this).remove();
				});

		}

		function closeModal(isSuccess) {

			if (isSuccess)
				jQuery('.check-column input[type="checkbox"]').attr('checked', false);

			tb_remove();

		}

		function getPlural(count, singular, plural) {
			return count > 1 ? plural : singular;
		}

		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('');
				});
			}

		}

		// Select All

		var gformStrings = {
			"allEntriesOnPageAreSelected": <?php 
        echo json_encode(sprintf(esc_html__('All %s{0}%s entries on this page are selected.', 'gravityforms'), '<strong>', '</strong>'));
        ?>
,
			"selectAll"                  : <?php 
        echo json_encode(sprintf(esc_html__('Select all %s{0}%s entries.', 'gravityforms'), '<strong>', '</strong>'));
        ?>
,
			"allEntriesSelected"         : <?php 
        echo json_encode(sprintf(esc_html__('All %s{0}%s entries have been selected.', 'gravityforms'), '<strong>', '</strong>'));
        ?>
,
			"clearSelection"             : <?php 
        echo json_encode(__('Clear selection', 'gravityforms'));
        ?>
		}

		var gformVars = {
			"countAllEntries": <?php 
        echo intval($total_count);
        ?>
,
			"perPage"        : <?php 
        echo intval($page_size);
        ?>
		}

		function setSelectAllText() {
			var tr = getSelectAllText();
			jQuery("#gform-select-all-message td").html(tr);
		}

		function getSelectAllText() {
			var count;
			count = jQuery("#gf_entry_list tr:visible:not('#gform-select-all-message')").length;
			return gformStrings.allEntriesOnPageAreSelected.format(count) + " <a href='javascript:void(0)' onclick='selectAllEntriesOnAllPages();'>" + gformStrings.selectAll.format(gformVars.countAllEntries) + "</a>";
		}

		function getSelectAllTr() {
			var t = getSelectAllText();
			var colspan = jQuery("#gf_entry_list").find("tr:first td").length + 1;
			return "<tr id='gform-select-all-message' style='display:none;background-color:lightyellow;text-align:center;'><td colspan='{0}'>{1}</td></tr>".format(colspan, t);
		}
		function toggleSelectAll(visible) {
			if (gformVars.countAllEntries <= gformVars.perPage) {
				jQuery('#gform-select-all-message').hide();
				return;
			}

			if (visible)
				setSelectAllText();
			jQuery('#gform-select-all-message').toggle(visible);
		}


		function clearSelectAllEntries() {
			jQuery(".check-column input[type=checkbox]").prop('checked', false);
			clearSelectAllMessage();
		}

		function clearSelectAllMessage() {
			jQuery("#all_entries").val("0");
			jQuery("#gform-select-all-message").hide();
			jQuery("#gform-select-all-message td").html('');
		}

		function selectAllEntriesOnAllPages() {
			var trHtmlClearSelection;
			trHtmlClearSelection = gformStrings.allEntriesSelected.format(gformVars.countAllEntries) + " <a href='javascript:void(0);' onclick='clearSelectAllEntries();'>" + gformStrings.clearSelection + "</a>";
			jQuery("#all_entries").val("1");
			jQuery("#gform-select-all-message td").html(trHtmlClearSelection);
		}

		function initSelectAllEntries() {

			if (gformVars.countAllEntries > gformVars.perPage) {
				var tr = getSelectAllTr();
				jQuery("#gf_entry_list").prepend(tr);
				jQuery(".headercb").click(function () {
					toggleSelectAll(jQuery(this).prop('checked'));
				});
				jQuery("#gf_entry_list .check-column input[type=checkbox]").click(function () {
					clearSelectAllMessage();
				})
			}
		}

		String.prototype.format = function () {
			var args = arguments;
			return this.replace(/{(\d+)}/g, function (match, number) {
				return typeof args[number] != 'undefined' ? args[number] : match;
			});
		};

		// end Select All

		jQuery(document).ready(function () {


			var action = <?php 
        echo json_encode($action);
        ?>
;
			var message = <?php 
        echo json_encode($update_message);
        ?>
;
			if (action && message)
				displayMessage(message, 'updated', '#lead_form');

			var list = jQuery("#gf_entry_list").wpList({ alt: <?php 
        echo json_encode(esc_html__('Entry List', 'gravityforms'));
        ?>
});
			list.bind('wpListDelEnd', function (e, s, list) {

				var currentStatus = <?php 
        echo json_encode($filter == 'trash' || $filter == 'spam' ? $filter : 'active');
        ?>
;
				var filter = <?php 
        echo json_encode($filter);
        ?>
;
				var movingTo = "active";
				if (s.data.status == "trash")
					movingTo = "trash";
				else if (s.data.status == "spam")
					movingTo = "spam";
				else if (s.data.status == "delete")
					movingTo = "delete";

				var id = s.data.entry;
				var title = jQuery("#lead_row_" + id);
				var isUnread = title.hasClass("lead_unread");
				var isStarred = title.hasClass("lead_starred");

				if (movingTo != "delete") {
					//Updating All count
					var allCount = currentStatus == "active" ? -1 : 1;
					UpdateCount("all_count", allCount);

					//Updating Unread count
					if (isUnread) {
						var unreadCount = currentStatus == "active" ? -1 : 1;
						UpdateCount("unread_count", unreadCount);
					}

					//Updating Starred count
					if (isStarred) {
						var starCount = currentStatus == "active" ? -1 : 1;
						UpdateCount("star_count", starCount);
					}
				}

				//Updating Spam count
				if (currentStatus == "spam" || movingTo == "spam") {
					var spamCount = movingTo == "spam" ? 1 : -1;
					UpdateCount("spam_count", spamCount);
					//adjust paging counts
					if (filter == "spam") {
						UpdatePagingCounts(1);
					}
					else {
						UpdatePagingCounts(spamCount);
					}
				}

				//Updating trash count
				if (currentStatus == "trash" || movingTo == "trash") {
					var trashCount = movingTo == "trash" ? 1 : -1;
					UpdateCount("trash_count", trashCount);
					//adjust paging counts
					if (filter == "trash") {
						UpdatePagingCounts(1);
					}
					else {
						UpdatePagingCounts(trashCount);
					}
				}

			});

			initSelectAllEntries();

			jQuery('#entry_filters').gfFilterUI(gformFieldFilters, gformInitFilter, false);
			jQuery("#entry_filters").on("keypress", ".gform-filter-value", (function (event) {
				if (event.keyCode == 13) {
					Search(<?php 
        echo json_encode($sort_field);
        ?>
, <?php 
        echo json_encode($sort_direction);
        ?>
, <?php 
        echo absint($form_id);
        ?>
, jQuery('.gform-filter-value').val(), <?php 
        echo json_encode($star);
        ?>
, <?php 
        echo json_encode($read);
        ?>
, <?php 
        echo json_encode($filter);
        ?>
, jQuery('.gform-filter-field').val(), jQuery('.gform-filter-operator').val());
					event.preventDefault();
				}
			}));
		});


		</script>
		<link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin<?php 
        echo $min;
        ?>
.css" type="text/css" />
		<style>
			/*#TB_window { height: 400px !important; }
			#TB_ajaxContent[style] { height: 370px !important; }*/
			.lead_unread a, .lead_unread td {
				font-weight: bold;
			}

			.lead_spam_trash a, .lead_spam_trash td {
				font-weight: normal;
			}

			.row-actions a {
				font-weight: normal;
			}

			.entry_nowrap {
				overflow: hidden;
				white-space: nowrap;
			}
			.gform-filter-operator {
				width: 100px
			}
		</style>


		<div class="wrap <?php 
        echo GFCommon::get_browser_class();
        ?>
">
		<h2 class="gf_admin_page_title">
			<span><?php 
        esc_html_e('Entries', 'gravityforms');
        ?>
</span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php 
        echo absint($form['id']);
        ?>
</span><span class="gf_admin_page_formname"><?php 
        esc_html_e('Form Name', 'gravityforms');
        ?>
: <?php 
        echo esc_html($form['title']);
        ?>
</span></span>
		</h2>

		<?php 
        RGForms::top_toolbar();
        ?>

		<form id="lead_form" method="post">
		<?php 
        wp_nonce_field('gforms_entry_list', 'gforms_entry_list');
        ?>

		<input type="hidden" value="" name="grid_columns" id="grid_columns" />
		<input type="hidden" value="" name="action" id="action" />
		<input type="hidden" value="" name="action_argument" id="action_argument" />
		<input type="hidden" value="" name="all_entries" id="all_entries" />

		<ul class="subsubsub">
			<li>
				<a class="<?php 
        echo empty($filter) ? 'current' : '';
        ?>
" href="?page=gf_entries&view=entries&id=<?php 
        echo absint($form_id);
        ?>
"><?php 
        _ex('All', 'Entry List', 'gravityforms');
        ?>
					<span class="count">(<span id="all_count"><?php 
        echo $active_lead_count;
        ?>
</span>)</span></a> |
			</li>
			<li>
				<a class="<?php 
        echo $read !== null ? 'current' : '';
        ?>
" href="?page=gf_entries&view=entries&id=<?php 
        echo absint($form_id);
        ?>
&filter=unread"><?php 
        _ex('Unread', 'Entry List', 'gravityforms');
        ?>
					<span class="count">(<span id="unread_count"><?php 
        echo $unread_count;
        ?>
</span>)</span></a> |
			</li>
			<li>
				<a class="<?php 
        echo $star !== null ? 'current' : '';
        ?>
" href="?page=gf_entries&view=entries&id=<?php 
        echo absint($form_id);
        ?>
&filter=star"><?php 
        _ex('Starred', 'Entry List', 'gravityforms');
        ?>
					<span class="count">(<span id="star_count"><?php 
        echo $starred_count;
        ?>
</span>)</span></a> |
			</li>
			<?php 
        if (GFCommon::spam_enabled($form_id)) {
            ?>
				<li>
					<a class="<?php 
            echo $filter == 'spam' ? 'current' : '';
            ?>
" href="?page=gf_entries&view=entries&id=<?php 
            echo absint($form_id);
            ?>
&filter=spam"><?php 
            esc_html_e('Spam', 'gravityforms');
            ?>
						<span class="count">(<span id="spam_count"><?php 
            echo esc_html($spam_count);
            ?>
</span>)</span></a> |
				</li>
			<?php 
        }
        ?>
			<li>
				<a class="<?php 
        echo $filter == 'trash' ? 'current' : '';
        ?>
" href="?page=gf_entries&view=entries&id=<?php 
        echo absint($form_id);
        ?>
&filter=trash"><?php 
        esc_html_e('Trash', 'gravityforms');
        ?>
					<span class="count">(<span id="trash_count"><?php 
        echo esc_html($trash_count);
        ?>
</span>)</span></a></li>
		</ul>
		<div style="margin-top:12px;float:right;">
			<a style="float:right;" class="button" id="lead_search_button" href="javascript:Search('<?php 
        echo esc_js($sort_field);
        ?>
', '<?php 
        echo esc_js($sort_direction);
        ?>
', <?php 
        echo absint($form_id);
        ?>
, jQuery('.gform-filter-value').val(), '<?php 
        echo esc_js($star);
        ?>
', '<?php 
        echo esc_js($read);
        ?>
', '<?php 
        echo esc_js($filter);
        ?>
', jQuery('.gform-filter-field').val(), jQuery('.gform-filter-operator').val());"><?php 
        esc_html_e('Search', 'gravityforms');
        ?>
</a>

			<div id="entry_filters" style="float:right"></div>
		</div>
		<div class="tablenav">

			<div class="alignleft actions" style="padding:8px 0 7px 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>
					<?php 
        switch ($filter) {
            case 'trash':
                ?>
							<option value='restore'><?php 
                esc_html_e('Restore', 'gravityforms');
                ?>
</option>
							<?php 
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
								<option value='delete'><?php 
                    esc_html_e('Delete Permanently', 'gravityforms');
                    ?>
</option>
							<?php 
                }
                break;
            case 'spam':
                ?>
							<option value='unspam'><?php 
                esc_html_e('Not Spam', 'gravityforms');
                ?>
</option>
							<?php 
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
								<option value='delete'><?php 
                    esc_html_e('Delete Permanently', 'gravityforms');
                    ?>
</option>
							<?php 
                }
                break;
            default:
                ?>
								<option value='mark_read'><?php 
                esc_html_e('Mark as Read', 'gravityforms');
                ?>
</option>
								<option value='mark_unread'><?php 
                esc_html_e('Mark as Unread', 'gravityforms');
                ?>
</option>
								<option value='add_star'><?php 
                esc_html_e('Add Star', 'gravityforms');
                ?>
</option>
								<option value='remove_star'><?php 
                esc_html_e('Remove Star', 'gravityforms');
                ?>
</option>
								<option value='resend_notifications'><?php 
                esc_html_e('Resend Notifications', 'gravityforms');
                ?>
</option>
								<option value='print'><?php 
                esc_html_e('Print', 'gravityforms');
                ?>
</option>

							<?php 
                if (GFCommon::spam_enabled($form_id)) {
                    ?>
								<option value='spam'><?php 
                    esc_html_e('Spam', 'gravityforms');
                    ?>
</option>
							<?php 
                }
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
								<option value='trash'><?php 
                    esc_html_e('Trash', 'gravityforms');
                    ?>
</option>
							<?php 
                }
        }
        ?>
				</select>
				<?php 
        $apply_button = '<input type="submit" class="button" value="' . esc_attr__('Apply', 'gravityforms') . '" onclick="return handleBulkApply(\'bulk_action\');" />';
        /**
         * Allows for the modification of the Entry apply button HTML (When modifying entries)
         *
         * @param string $apply_button The Entry apply button HTML
         */
        echo apply_filters('gform_entry_apply_button', $apply_button);
        if (in_array($filter, array('trash', 'spam'))) {
            $message = $filter == 'trash' ? esc_html__("WARNING! This operation cannot be undone. Empty trash? 'Ok' to empty trash. 'Cancel' to abort.", 'gravityforms') : esc_html__("WARNING! This operation cannot be undone. Permanently delete all spam? 'Ok' to delete. 'Cancel' to abort.", 'gravityforms');
            $button_label = $filter == 'trash' ? __('Empty Trash', 'gravityforms') : __('Delete All Spam', 'gravityforms');
            ?>
					<input type="submit" class="button" name="button_delete_permanently" value="<?php 
            echo esc_attr($button_label);
            ?>
" onclick="return confirm('<?php 
            echo esc_js($message);
            ?>
');" />
				<?php 
        }
        ?>
				<div id="notifications_modal_container" style="display:none;">
					<div id="notifications_container">

						<div id="post_tag" class="tagsdiv">
							<div id="resend_notifications_options">

								<?php 
        $notifications = GFCommon::get_notifications('resend_notifications', $form);
        if (!is_array($notifications) || count($form['notifications']) <= 0) {
            ?>
									<p class="description"><?php 
            esc_html_e('You cannot resend notifications for these entries because this form does not currently have any notifications configured.', 'gravityforms');
            ?>
</p>

									<a href="<?php 
            echo esc_url(admin_url("admin.php?page=gf_edit_forms&view=settings&subview=notification&id={$form['id']}"));
            ?>
" class="button"><?php 
            esc_html_e('Configure Notifications', 'gravityforms');
            ?>
</a>
								<?php 
        } else {
            ?>
									<p class="description"><?php 
            esc_html_e('Specify which notifications you would like to resend for the selected entries.', 'gravityforms');
            ?>
</p>
									<?php 
            foreach ($notifications as $notification) {
                ?>
										<input type="checkbox" class="gform_notifications" value="<?php 
                echo esc_attr($notification['id']);
                ?>
" id="notification_<?php 
                echo esc_attr($notification['id']);
                ?>
" onclick="toggleNotificationOverride();" />
										<label for="notification_<?php 
                echo esc_attr($notification['id']);
                ?>
"><?php 
                echo esc_html($notification['name']);
                ?>
</label>
										<br /><br />
									<?php 
            }
            ?>
									<div id="notifications_override_settings" style="display:none;">

										<p class="description" style="padding-top:0; margin-top:0;">
											<?php 
            esc_html_e('You may override the default notification settings by entering a comma delimited list of emails to which the selected notifications should be sent.', 'gravityforms');
            ?>
										</p>
										<label for="notification_override_email"><?php 
            esc_html_e('Send To', 'gravityforms');
            ?>
 <?php 
            gform_tooltip('notification_override_email');
            ?>
</label><br />
										<input type="text" name="notification_override_email" id="notification_override_email" style="width:99%;" /><br /><br />

									</div>

									<input type="button" name="notification_resend" id="notification_resend" value="<?php 
            esc_attr_e('Resend Notifications', 'gravityforms');
            ?>
" class="button" style="" onclick="BulkResendNotifications();" />
									<span id="please_wait_container" style="display:none; margin-left: 5px;">
                                                <i class='gficon-gravityforms-spinner-icon gficon-spin'></i> <?php 
            esc_html_e('Resending...', 'gravityforms');
            ?>
                                            </span>
								<?php 
        }
        ?>

							</div>

							<div id="resend_notifications_close" style="display:none;margin:10px 0 0;">
								<input type="button" name="resend_notifications_close_button" value="<?php 
        esc_attr_e('Close Window', 'gravityforms');
        ?>
" class="button" style="" onclick="closeModal(true);" />
							</div>

						</div>

					</div>
				</div>
				<!-- / Resend Notifications -->

				<div id="print_modal_container" style="display:none;">
					<div id="print_container">

						<div class="tagsdiv">
							<div id="print_options">

								<p class="description"><?php 
        esc_html_e('Print all of the selected entries at once.', 'gravityforms');
        ?>
</p>

								<?php 
        if (GFCommon::current_user_can_any('gravityforms_view_entry_notes')) {
            ?>
									<input type="checkbox" name="gform_print_notes" value="print_notes" checked="checked" id="gform_print_notes" />
									<label for="gform_print_notes"><?php 
            esc_html_e('Include notes', 'gravityforms');
            ?>
</label>
									<br /><br />
								<?php 
        }
        ?>

								<input type="checkbox" name="gform_print_page_break" value="print_notes" checked="checked" id="gform_print_page_break" />
								<label for="gform_print_page_break"><?php 
        esc_html_e('Add page break between entries', 'gravityforms');
        ?>
</label>
								<br /><br />

								<input type="button" value="<?php 
        esc_attr_e('Print', 'gravityforms');
        ?>
" class="button" onclick="BulkPrint();" />

							</div>
						</div>

					</div>
				</div>
				<!-- / Print -->

			</div>

			<?php 
        echo self::display_paging_links('header', $page_links, $first_item_index, $page_size, $total_count);
        ?>

			<div class="clear"></div>
		</div>

		<table class="widefat fixed" cellspacing="0">
		<thead>
		<tr>
			<th scope="col" id="cb" class="manage-column column-cb check-column">
				<input type="checkbox" class="headercb" /></th>
			<?php 
        if (!in_array($filter, array('spam', 'trash'))) {
            ?>
				<th scope="col" id="cb" class="manage-column column-cb check-column">&nbsp;</th>
			<?php 
        }
        foreach ($columns as $field_id => $field_info) {
            $dir = $field_id == 0 ? 'DESC' : 'ASC';
            //default every field so ascending sorting except date_created (id=0)
            if ($field_id == $sort_field) {
                //reverting direction if clicking on the currently sorted field
                $dir = $sort_direction == 'ASC' ? 'DESC' : 'ASC';
            }
            ?>
				<th scope="col" class="manage-column entry_nowrap" onclick="Search('<?php 
            echo esc_js($field_id);
            ?>
', '<?php 
            echo esc_js($dir);
            ?>
', <?php 
            echo absint($form_id);
            ?>
, '<?php 
            echo esc_js($search);
            ?>
', '<?php 
            echo esc_js($star);
            ?>
', '<?php 
            echo esc_js($read);
            ?>
', '<?php 
            echo esc_js($filter);
            ?>
', '<?php 
            echo esc_js($search_field_id);
            ?>
', '<?php 
            echo esc_js($search_operator);
            ?>
');" style="cursor:pointer;"><?php 
            echo esc_html($field_info['label']);
            ?>
</th>
			<?php 
        }
        ?>
			<th scope="col" align="right" width="50">
				<a title="<?php 
        esc_attr_e('click to select columns to display', 'gravityforms');
        ?>
" href="<?php 
        echo trailingslashit(site_url(null, 'admin'));
        ?>
?gf_page=select_columns&id=<?php 
        echo absint($form_id);
        ?>
&TB_iframe=true&height=365&width=600" class="thickbox entries_edit_icon"><i class="fa fa-cog"></i></a>
			</th>
		</tr>
		</thead>
		<tfoot>
		<tr>
			<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
			<?php 
        if (!in_array($filter, array('spam', 'trash'))) {
            ?>
				<th scope="col" id="cb" class="manage-column column-cb check-column">&nbsp;</th>
			<?php 
        }
        foreach ($columns as $field_id => $field_info) {
            $dir = $field_id == 0 ? 'DESC' : 'ASC';
            //default every field so ascending sorting except date_created (id=0)
            if ($field_id == $sort_field) {
                //reverting direction if clicking on the currently sorted field
                $dir = $sort_direction == 'ASC' ? 'DESC' : 'ASC';
            }
            ?>
				<th scope="col" class="manage-column entry_nowrap" onclick="Search('<?php 
            echo esc_js($field_id);
            ?>
', '<?php 
            echo esc_js($dir);
            ?>
', <?php 
            echo absint($form_id);
            ?>
, '<?php 
            echo esc_js($search);
            ?>
', '<?php 
            echo esc_js($star);
            ?>
', '<?php 
            echo esc_js($read);
            ?>
', '<?php 
            echo esc_js($filter);
            ?>
', '<?php 
            echo esc_js($search_field_id);
            ?>
', '<?php 
            echo esc_js($search_operator);
            ?>
');" style="cursor:pointer;"><?php 
            echo esc_html($field_info['label']);
            ?>
</th>
			<?php 
        }
        ?>
			<th scope="col" style="width:15px;">
				<a title="<?php 
        esc_attr_e('click to select columns to display', 'gravityforms');
        ?>
" href="<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=select_columns&id=<?php 
        echo absint($form_id);
        ?>
&TB_iframe=true&height=365&width=600" class="thickbox entries_edit_icon"><i class=fa-cog"></i></a>
			</th>
		</tr>
		</tfoot>

		<tbody data-wp-lists="list:gf_entry" class="user-list" id="gf_entry_list">
		<?php 
        if (sizeof($leads) > 0) {
            $field_ids = array_keys($columns);
            $gf_entry_locking = new GFEntryLocking();
            $alternate_row = false;
            foreach ($leads as $position => $lead) {
                $position = $page_size * $page_index + $position;
                ?>
				<tr id="lead_row_<?php 
                echo esc_attr($lead['id']);
                ?>
" class='author-self status-inherit <?php 
                echo $lead['is_read'] ? '' : 'lead_unread';
                ?>
 <?php 
                echo $lead['is_starred'] ? 'lead_starred' : '';
                ?>
 <?php 
                echo in_array($filter, array('trash', 'spam')) ? 'lead_spam_trash' : '';
                ?>
 <?php 
                $gf_entry_locking->list_row_class($lead['id']);
                ?>
 <?php 
                echo ($alternate_row = !$alternate_row) ? 'alternate' : '';
                ?>
' valign="top" data-id="<?php 
                echo esc_attr($lead['id']);
                ?>
">
				<th scope="row" class="check-column">
					<input type="checkbox" name="lead[]" value="<?php 
                echo esc_attr($lead['id']);
                ?>
" />
					<?php 
                $gf_entry_locking->lock_indicator();
                ?>
				</th>
				<?php 
                if (!in_array($filter, array('spam', 'trash'))) {
                    ?>
					<td>
						<img id="star_image_<?php 
                    echo esc_attr($lead['id']);
                    ?>
" src="<?php 
                    echo GFCommon::get_base_url();
                    ?>
/images/star<?php 
                    echo intval($lead['is_starred']);
                    ?>
.png" onclick="ToggleStar(this, '<?php 
                    echo esc_js($lead['id']);
                    ?>
','<?php 
                    echo esc_js($filter);
                    ?>
');" />
					</td>
				<?php 
                }
                $is_first_column = true;
                $nowrap_class = 'entry_nowrap';
                foreach ($field_ids as $field_id) {
                    $field = RGFormsModel::get_field($form, $field_id);
                    $value = rgar($lead, $field_id);
                    if (!empty($field) && $field->type == 'post_category') {
                        $value = GFCommon::prepare_post_category_value($value, $field, 'entry_list');
                    }
                    //filtering lead value
                    $value = apply_filters('gform_get_field_value', $value, $lead, $field);
                    $input_type = !empty($columns[$field_id]['inputType']) ? $columns[$field_id]['inputType'] : $columns[$field_id]['type'];
                    switch ($input_type) {
                        case 'source_url':
                            $value = "<a href='" . esc_attr($lead['source_url']) . "' target='_blank' alt='" . esc_attr($lead['source_url']) . "' title='" . esc_attr($lead['source_url']) . "'>.../" . esc_attr(GFCommon::truncate_url($lead['source_url'])) . '</a>';
                            break;
                        case 'date_created':
                        case 'payment_date':
                            $value = GFCommon::format_date($value, false);
                            break;
                        case 'payment_amount':
                            $value = GFCommon::to_money($value, $lead['currency']);
                            break;
                        case 'created_by':
                            if (!empty($value)) {
                                $userdata = get_userdata($value);
                                if (!empty($userdata)) {
                                    $value = $userdata->user_login;
                                }
                            }
                            break;
                        default:
                            if ($field !== null) {
                                $value = $field->get_value_entry_list($value, $lead, $field_id, $columns, $form);
                            } else {
                                $value = esc_html($value);
                            }
                    }
                    $value = apply_filters('gform_entries_field_value', $value, $form_id, $field_id, $lead);
                    /* ^ maybe move to function */
                    $query_string = "gf_entries&view=entry&id={$form_id}&lid={$lead['id']}{$search_qs}{$sort_qs}{$dir_qs}{$filter_qs}&paged=" . ($page_index + 1);
                    if ($is_first_column) {
                        ?>
						<td class="column-title">
							<a href="admin.php?page=gf_entries&view=entry&id=<?php 
                        echo absint($form_id);
                        ?>
&lid=<?php 
                        echo esc_attr($lead['id'] . $search_qs . $sort_qs . $dir_qs . $filter_qs);
                        ?>
&paged=<?php 
                        echo $page_index + 1;
                        ?>
&pos=<?php 
                        echo $position;
                        ?>
&field_id=<?php 
                        echo esc_attr($search_field_id);
                        ?>
&operator=<?php 
                        echo esc_attr($search_operator);
                        ?>
"><?php 
                        echo $value;
                        ?>
</a>

							<?php 
                        $gf_entry_locking->lock_info($lead['id']);
                        ?>

							<div class="row-actions">
								<?php 
                        switch ($filter) {
                            case 'trash':
                                ?>
										<span class="edit">
                                            <a title="<?php 
                                esc_attr_e('View this entry', 'gravityforms');
                                ?>
" href="admin.php?page=gf_entries&view=entry&id=<?php 
                                echo absint($form_id);
                                ?>
&lid=<?php 
                                echo esc_attr($lead['id'] . $search_qs . $sort_qs . $dir_qs . $filter_qs);
                                ?>
&paged=<?php 
                                echo $page_index + 1;
                                ?>
&pos=<?php 
                                echo $position;
                                ?>
&field_id=<?php 
                                echo esc_attr($search_field_id);
                                ?>
&operator=<?php 
                                echo esc_attr($search_operator);
                                ?>
"><?php 
                                esc_html_e('View', 'gravityforms');
                                ?>
</a>
                                            |
                                        </span>

										<span class="edit">
                                            <a data-wp-lists='delete:gf_entry_list:lead_row_<?php 
                                echo esc_attr($lead['id']);
                                ?>
::status=active&entry=<?php 
                                echo esc_attr($lead['id']);
                                ?>
' title="<?php 
                                esc_attr_e('Restore this entry', 'gravityforms');
                                ?>
" href="<?php 
                                echo wp_nonce_url('?page=gf_entries', 'gf_delete_entry');
                                ?>
"><?php 
                                esc_html_e('Restore', 'gravityforms');
                                ?>
</a>
											<?php 
                                echo GFCommon::current_user_can_any('gravityforms_delete_entries') ? '|' : '';
                                ?>
                                        </span>

										<?php 
                                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                                    ?>
											<span class="delete">
                                                <?php 
                                    $delete_link = '<a data-wp-lists="delete:gf_entry_list:lead_row_' . esc_attr($lead['id']) . '::status=delete&entry=' . esc_attr($lead['id']) . '" title="' . esc_attr__('Delete this entry permanently', 'gravityforms') . '"  href="' . wp_nonce_url('?page=gf_entries', 'gf_delete_entry') . '">' . esc_html__('Delete Permanently', 'gravityforms') . '</a>';
                                    /**
                                     * Allows for modification of a Form entry "delete" link
                                     *
                                     * @param string $delete_link The Entry Delete Link (Formatted in HTML)
                                     */
                                    echo apply_filters('gform_delete_entry_link', $delete_link);
                                    ?>
                                            </span>
										<?php 
                                }
                                break;
                            case 'spam':
                                ?>
										<span class="edit">
                                            <a title="<?php 
                                esc_attr_e('View this entry', 'gravityforms');
                                ?>
" href="admin.php?page=gf_entries&view=entry&id=<?php 
                                echo absint($form_id);
                                ?>
&lid=<?php 
                                echo esc_attr($lead['id'] . $search_qs . $sort_qs . $dir_qs . $filter_qs);
                                ?>
&paged=<?php 
                                echo $page_index + 1;
                                ?>
&pos=<?php 
                                echo $position;
                                ?>
"><?php 
                                esc_html_e('View', 'gravityforms');
                                ?>
</a>
                                            |
                                        </span>

										<span class="unspam">
                                            <a data-wp-lists='delete:gf_entry_list:lead_row_<?php 
                                echo esc_attr($lead['id']);
                                ?>
::status=unspam&entry=<?php 
                                echo esc_attr($lead['id']);
                                ?>
' title="<?php 
                                esc_attr_e('Mark this entry as not spam', 'gravityforms');
                                ?>
" href="<?php 
                                echo wp_nonce_url('?page=gf_entries', 'gf_delete_entry');
                                ?>
"><?php 
                                esc_html_e('Not Spam', 'gravityforms');
                                ?>
</a>
											<?php 
                                echo GFCommon::current_user_can_any('gravityforms_delete_entries') ? '|' : '';
                                ?>
                                        </span>

										<?php 
                                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                                    ?>
											<span class="delete">
                                                <?php 
                                    $delete_link = '<a data-wp-lists="delete:gf_entry_list:lead_row_' . esc_attr($lead['id']) . '::status=delete&entry=' . esc_attr($lead['id']) . '" title="' . esc_attr__('Delete this entry permanently', 'gravityforms') . '"  href="' . wp_nonce_url('?page=gf_entries', 'gf_delete_entry') . '">' . esc_html__('Delete Permanently', 'gravityforms') . '</a>';
                                    /**
                                     * Allows for modification of a Form entry "delete" link
                                     *
                                     * @param string $delete_link The Entry Delete Link (Formatted in HTML)
                                     */
                                    echo apply_filters('gform_delete_entry_link', $delete_link);
                                    ?>
                                            </span>
										<?php 
                                }
                                break;
                            default:
                                ?>
											<span class="edit">
                                                <a title="<?php 
                                esc_attr_e('View this entry', 'gravityforms');
                                ?>
" href="admin.php?page=gf_entries&view=entry&id=<?php 
                                echo absint($form_id);
                                ?>
&lid=<?php 
                                echo esc_attr($lead['id'] . $search_qs . $sort_qs . $dir_qs . $filter_qs);
                                ?>
&paged=<?php 
                                echo $page_index + 1;
                                ?>
&pos=<?php 
                                echo $position;
                                ?>
&field_id=<?php 
                                echo esc_attr($search_field_id);
                                ?>
&operator=<?php 
                                echo esc_attr($search_operator);
                                ?>
"><?php 
                                esc_html_e('View', 'gravityforms');
                                ?>
</a>
                                                |
                                            </span>
											<span class="edit">
                                                <a id="mark_read_<?php 
                                echo esc_attr($lead['id']);
                                ?>
" title="Mark this entry as read" href="javascript:ToggleRead('<?php 
                                echo esc_js($lead['id']);
                                ?>
', '<?php 
                                echo esc_js($filter);
                                ?>
');" style="display:<?php 
                                echo $lead['is_read'] ? 'none' : 'inline';
                                ?>
;"><?php 
                                esc_html_e('Mark read', 'gravityforms');
                                ?>
</a><a id="mark_unread_<?php 
                                echo absint($lead['id']);
                                ?>
" title="<?php 
                                esc_attr_e('Mark this entry as unread', 'gravityforms');
                                ?>
" href="javascript:ToggleRead('<?php 
                                echo esc_js($lead['id']);
                                ?>
', '<?php 
                                echo esc_js($filter);
                                ?>
');" style="display:<?php 
                                echo $lead['is_read'] ? 'inline' : 'none';
                                ?>
;"><?php 
                                esc_html_e('Mark unread', 'gravityforms');
                                ?>
</a>
											<?php 
                                echo GFCommon::current_user_can_any('gravityforms_delete_entries') || GFCommon::akismet_enabled($form_id) ? '|' : '';
                                ?>
                                            </span>
										<?php 
                                if (GFCommon::spam_enabled($form_id)) {
                                    ?>
											<span class="spam">
                                                <a data-wp-lists='delete:gf_entry_list:lead_row_<?php 
                                    echo esc_attr($lead['id']);
                                    ?>
::status=spam&entry=<?php 
                                    echo esc_attr($lead['id']);
                                    ?>
' title="<?php 
                                    esc_attr_e('Mark this entry as spam', 'gravityforms');
                                    ?>
" href="<?php 
                                    echo wp_nonce_url('?page=gf_entries', 'gf_delete_entry');
                                    ?>
"><?php 
                                    esc_html_e('Spam', 'gravityforms');
                                    ?>
</a>
												<?php 
                                    echo GFCommon::current_user_can_any('gravityforms_delete_entries') ? '|' : '';
                                    ?>
                                            </span>

										<?php 
                                }
                                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                                    ?>
											<span class="trash">
                                                <a data-wp-lists='delete:gf_entry_list:lead_row_<?php 
                                    echo esc_attr($lead['id']);
                                    ?>
::status=trash&entry=<?php 
                                    echo esc_attr($lead['id']);
                                    ?>
' title="<?php 
                                    esc_attr_e('Move this entry to the trash', 'gravityforms');
                                    ?>
" href="<?php 
                                    echo wp_nonce_url('?page=gf_entries', 'gf_delete_entry');
                                    ?>
"><?php 
                                    esc_html_e('Trash', 'gravityforms');
                                    ?>
</a>
                                            </span>
										<?php 
                                }
                                break;
                        }
                        do_action('gform_entries_first_column_actions', $form_id, $field_id, $value, $lead, $query_string);
                        ?>

							</div>
							<?php 
                        do_action('gform_entries_first_column', $form_id, $field_id, $value, $lead, $query_string);
                        ?>
						</td>
					<?php 
                    } else {
                        ?>
						<td class="<?php 
                        echo $nowrap_class;
                        ?>
">
							<?php 
                        echo apply_filters('gform_entries_column_filter', $value, $form_id, $field_id, $lead, $query_string);
                        ?>
&nbsp;
							<?php 
                        do_action('gform_entries_column', $form_id, $field_id, $value, $lead, $query_string);
                        ?>
						</td>
					<?php 
                    }
                    $is_first_column = false;
                }
                ?>
				<td>&nbsp;</td>
				</tr>
			<?php 
            }
        } else {
            $column_count = sizeof($columns) + 3;
            switch ($filter) {
                case 'unread':
                    $message = isset($_GET['field_id']) ? esc_html__('This form does not have any unread entries matching the search criteria.', 'gravityforms') : esc_html__('This form does not have any unread entries.', 'gravityforms');
                    break;
                case 'star':
                    $message = isset($_GET['field_id']) ? esc_html__('This form does not have any starred entries matching the search criteria.', 'gravityforms') : esc_html__('This form does not have any starred entries.', 'gravityforms');
                    break;
                case 'spam':
                    $message = esc_html__('This form does not have any spam.', 'gravityforms');
                    $column_count = sizeof($columns) + 2;
                    break;
                case 'trash':
                    $message = isset($_GET['field_id']) ? esc_html__('This form does not have any entries in the trash matching the search criteria.', 'gravityforms') : esc_html__('This form does not have any entries in the trash.', 'gravityforms');
                    $column_count = sizeof($columns) + 2;
                    break;
                default:
                    $message = isset($_GET['field_id']) ? esc_html__('This form does not have any entries matching the search criteria.', 'gravityforms') : esc_html__('This form does not have any entries yet.', 'gravityforms');
            }
            ?>
			<tr>
				<td colspan="<?php 
            echo esc_attr($column_count);
            ?>
" style="padding:20px;"><?php 
            echo esc_html($message);
            ?>
</td>
			</tr>
		<?php 
        }
        ?>
		</tbody>
		</table>

		<div class="clear"></div>

		<div class="tablenav">

			<div class="alignleft actions" style="padding:8px 0 7px 0;">
				<label class="hidden" for="bulk_action2"> <?php 
        esc_html_e('Bulk action', 'gravityforms');
        ?>
</label>
				<select name="bulk_action2" id="bulk_action2">
					<option value=''><?php 
        esc_html_e(' Bulk action ', 'gravityforms');
        ?>
</option>
					<?php 
        switch ($filter) {
            case 'trash':
                ?>
							<option value='restore'><?php 
                esc_html_e('Restore', 'gravityforms');
                ?>
</option>
							<?php 
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
								<option value='delete'><?php 
                    esc_html_e('Delete Permanently', 'gravityforms');
                    ?>
</option>
							<?php 
                }
                break;
            case 'spam':
                ?>
							<option value='unspam'><?php 
                esc_html_e('Not Spam', 'gravityforms');
                ?>
</option>
							<?php 
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
								<option value='delete'><?php 
                    esc_html_e('Delete Permanently', 'gravityforms');
                    ?>
</option>
							<?php 
                }
                break;
            default:
                ?>
								<option value='mark_read'><?php 
                esc_html_e('Mark as Read', 'gravityforms');
                ?>
</option>
								<option value='mark_unread'><?php 
                esc_html_e('Mark as Unread', 'gravityforms');
                ?>
</option>
								<option value='add_star'><?php 
                esc_html_e('Add Star', 'gravityforms');
                ?>
</option>
								<option value='remove_star'><?php 
                esc_html_e('Remove Star', 'gravityforms');
                ?>
</option>
								<option value='resend_notifications'><?php 
                esc_html_e('Resend Notifications', 'gravityforms');
                ?>
</option>
								<option value='print'><?php 
                esc_html_e('Print Entries', 'gravityforms');
                ?>
</option>
							<?php 
                if (GFCommon::spam_enabled($form_id)) {
                    ?>
								<option value='spam'><?php 
                    esc_html_e('Spam', 'gravityforms');
                    ?>
</option>
							<?php 
                }
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
								<option value='trash'><?php 
                    esc_html_e('Move to Trash', 'gravityforms');
                    ?>
</option>
							<?php 
                }
        }
        ?>
				</select>
				<?php 
        $apply_button = '<input type="submit" class="button" value="' . esc_attr__('Apply', 'gravityforms') . '" onclick="return handleBulkApply(\'bulk_action2\');" />';
        /**
         * Allows for the modification of the Entry apply button HTML (When modifying entries)
         *
         * @param string $apply_button The Entry apply button HTML
         */
        echo apply_filters('gform_entry_apply_button', $apply_button);
        ?>
			</div>

			<?php 
        echo self::display_paging_links('footer', $page_links, $first_item_index, $page_size, $total_count);
        ?>

			<div class="clear"></div>
		</div>

		</form>
		</div>
	<?php 
    }
예제 #2
1
 /**
  * Fetch Field Label
  *
  * @access public
  * @static
  * @param array $field GravityView field array
  * @param array $entry Gravity Forms entry array
  * @param boolean $force_show_label Whether to always show the label, regardless of field settings
  * @return string
  */
 public static function field_label($field, $entry = array(), $force_show_label = false)
 {
     $gravityview_view = GravityView_View::getInstance();
     $form = $gravityview_view->getForm();
     $label = '';
     if (!empty($field['show_label']) || $force_show_label) {
         $label = $field['label'];
         // Support Gravity Forms 1.9+
         if (class_exists('GF_Field')) {
             $field_object = RGFormsModel::get_field($form, $field['id']);
             if ($field_object) {
                 $input = GFFormsModel::get_input($field_object, $field['id']);
                 // This is a complex field, with lables on a per-input basis
                 if ($input) {
                     // Does the input have a custom label on a per-input basis? Otherwise, default label.
                     $label = !empty($input['customLabel']) ? $input['customLabel'] : $input['label'];
                 } else {
                     // This is a field with one label
                     $label = $field_object->get_field_label(true, $field['label']);
                 }
             }
         }
         // Use Gravity Forms label by default, but if a custom label is defined in GV, use it.
         if (!empty($field['custom_label'])) {
             $label = self::replace_variables($field['custom_label'], $form, $entry);
         }
         $label .= apply_filters('gravityview_render_after_label', '', $field);
     }
     // End $field['show_label']
     /**
      * @since 1.7
      */
     $label = apply_filters('gravityview/template/field_label', $label, $field, $form, $entry);
     return $label;
 }
예제 #3
0
 /**
  * Check if the iDEAL condition is true
  *
  * @param mixed $form
  * @param mixed $feed
  */
 public static function is_condition_true($form, $feed)
 {
     if (!$feed->condition_enabled) {
         return true;
     }
     $field = RGFormsModel::get_field($form, $feed->condition_field_id);
     // Unknown field
     if (empty($field)) {
         return true;
     }
     $is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
     // Ignore condition if the field is hidden
     if ($is_hidden) {
         return false;
     }
     $value = RGFormsModel::get_field_value($field, array());
     $is_match = RGFormsModel::is_value_match($value, $feed->condition_value);
     switch ($feed->condition_operator) {
         case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS:
             $result = $is_match;
             break;
         case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS_NOT:
             $result = !$is_match;
             break;
         default:
             $result = true;
     }
     return $result;
 }
예제 #4
0
파일: list.php 프로젝트: kidaak/GravityView
 /**
  * When showing a single column values, display the label of the column instead of the field
  *
  * @since 1.14
  *
  * @param string $label Existing label string
  * @param array $field GV field settings array, with `id`, `show_label`, `label`, `custom_label`, etc. keys
  * @param array $form Gravity Forms form array
  * @param array $entry Gravity Forms entry array
  *
  * @return string Existing label if the field isn't
  */
 public function _filter_field_label($label, $field, $form, $entry)
 {
     $field_object = RGFormsModel::get_field($form, $field['id']);
     // Not a list field
     if (!$field_object || 'list' !== $field_object->type) {
         return $label;
     }
     // Custom label is defined, so use it
     if (!empty($field['custom_label'])) {
         return $label;
     }
     $field_id_array = explode('.', $field['id']);
     // Parent field, not column field
     if (!isset($field_id_array[1])) {
         return $label;
     }
     $column_id = intval($field_id_array[1]);
     return self::get_column_label($field_object, $column_id, $label);
 }
예제 #5
0
 /**
  * Check if the iDEAL condition is true
  *
  * @param mixed $form
  * @param mixed $feed
  */
 public static function is_condition_true($form, $feed)
 {
     $result = true;
     if ($feed->condition_enabled) {
         $field = RGFormsModel::get_field($form, $feed->condition_field_id);
         if (empty($field)) {
             // unknown field
             $result = true;
         } else {
             $is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
             if ($is_hidden) {
                 // if conditional is enabled, but the field is hidden, ignore conditional
                 $result = false;
             } else {
                 $value = RGFormsModel::get_field_value($field, array());
                 $is_match = RGFormsModel::is_value_match($value, $feed->condition_value);
                 switch ($feed->condition_operator) {
                     case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS:
                         $result = $is_match;
                         break;
                     case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS_NOT:
                         $result = !$is_match;
                         break;
                     default:
                         // unknown operator
                         $result = true;
                         break;
                 }
             }
         }
     } else {
         // condition is disabled, result is true
         $result = true;
     }
     return $result;
 }
예제 #6
0
 public static function handle_existing_images_submission($form)
 {
     global $_gf_uploaded_files;
     // get UR config
     // get all fileupload fields mapped in the UR config
     // foreach loop through and see if the image has been:
     //  - resubmitted           populate the existing image data into the $_gf_uploaded_files
     //  - deleted               do nothing
     //  - new image submitted   do nothing
     if (empty($_gf_uploaded_files)) {
         $_gf_uploaded_files = array();
     }
     $config = GFUserData::get_update_feed($form['id']);
     if (!$config) {
         return;
     }
     $meta = rgars($config, 'meta/user_meta');
     if (function_exists('xprofile_get_field_data')) {
         $bp_meta = rgars($config, 'meta/buddypress_meta');
         if (is_array($bp_meta)) {
             $bp_meta = array_map(create_function('$a', '$a["is_bp"] = true; return $a;'), $bp_meta);
             $meta = array_merge($meta, $bp_meta);
         }
     }
     foreach ($meta as $meta_item) {
         $field = RGFormsModel::get_field($form, $meta_item['meta_value']);
         $input_name = "input_{$field['id']}";
         if (RGFormsModel::get_input_type($field) != 'fileupload') {
             continue;
         }
         if (self::is_prepopulated_file_upload($form['id'], $input_name)) {
             if (rgar($meta_item, 'is_bp')) {
                 $_gf_uploaded_files[$input_name] = xprofile_get_field_data($meta_item['meta_name'], get_current_user_id());
             } else {
                 $_gf_uploaded_files[$input_name] = get_user_meta(get_current_user_id(), $meta_item['meta_name'], true);
             }
         }
     }
 }
예제 #7
0
 public static function is_optin($form, $settings)
 {
     $config = $settings["meta"];
     $operator = $config["optin_operator"];
     $field = RGFormsModel::get_field($form, $config["optin_field_id"]);
     $field_value = RGFormsModel::get_field_value($field, array());
     $is_value_match = RGFormsModel::is_value_match($field_value, $config["optin_value"]);
     return !$config["optin_enabled"] || empty($field) || $operator == "is" && $is_value_match || $operator == "isnot" && !$is_value_match;
 }
예제 #8
0
 private static function fix_checkbox_value()
 {
     global $wpdb;
     $table_name = RGFormsModel::get_lead_details_table_name();
     $sql = "select * from {$table_name} where value= '!'";
     $results = $wpdb->get_results($sql);
     foreach ($results as $result) {
         $form = RGFormsModel::get_form_meta($result->form_id);
         $field = RGFormsModel::get_field($form, $result->field_number);
         if ($field->type == 'checkbox') {
             $input = GFCommon::get_input($field, $result->field_number);
             $wpdb->update($table_name, array('value' => $input['label']), array('id' => $result->id));
         }
     }
 }
 public static function get_field_value_long($lead, $field_number, $form, $apply_filter = true)
 {
     global $wpdb;
     $detail_table_name = self::get_lead_details_table_name();
     $long_table_name = self::get_lead_details_long_table_name();
     $sql = $wpdb->prepare(" SELECT l.value FROM {$detail_table_name} d\n                                INNER JOIN {$long_table_name} l ON l.lead_detail_id = d.id\n                                WHERE lead_id=%d AND field_number BETWEEN %s AND %s", $lead['id'], doubleval($field_number) - 0.0001, doubleval($field_number) + 0.0001);
     $val = $wpdb->get_var($sql);
     //running aform_get_input_value when needed
     if ($apply_filter) {
         $field = RGFormsModel::get_field($form, $field_number);
         $input_id = (string) $field_number == (string) $field->id ? '' : $field_number;
         $val = apply_filters('gform_get_input_value', $val, $lead, $field, $input_id);
     }
     return $val;
 }
예제 #10
0
 public static function is_optin($form, $settings, $entry)
 {
     $config = $settings["meta"];
     $field = RGFormsModel::get_field($form, $config["optin_field_id"]);
     if (empty($field) || !$config["optin_enabled"]) {
         return true;
     }
     $operator = $config["optin_operator"];
     $field_value = RGFormsModel::get_lead_field_value($entry, $field);
     $is_value_match = RGFormsModel::is_value_match($field_value, $config["optin_value"]);
     $is_visible = !RGFormsModel::is_field_hidden($form, $field, array(), $entry);
     $is_match = $is_value_match && $is_visible;
     $is_optin = $operator == "is" && $is_match || $operator == "isnot" && !$is_match;
     return $is_optin;
 }
예제 #11
0
 public static function start_export($form)
 {
     $form_id = $form["id"];
     $fields = $_POST["export_field"];
     $start_date = $_POST["export_date_start"];
     $end_date = $_POST["export_date_end"];
     //adding default fields
     array_push($form["fields"], array("id" => "id", "label" => __("Entry Id", "gravityforms")));
     array_push($form["fields"], array("id" => "date_created", "label" => __("Entry Date", "gravityforms")));
     array_push($form["fields"], array("id" => "ip", "label" => __("User IP", "gravityforms")));
     array_push($form["fields"], array("id" => "source_url", "label" => __("Source Url", "gravityforms")));
     array_push($form["fields"], array("id" => "payment_status", "label" => __("Payment Status", "gravityforms")));
     array_push($form["fields"], array("id" => "payment_date", "label" => __("Payment Date", "gravityforms")));
     array_push($form["fields"], array("id" => "transaction_id", "label" => __("Transaction Id", "gravityforms")));
     $entry_count = RGFormsModel::get_lead_count($form_id, "", null, null, $start_date, $end_date);
     $page_size = 200;
     $offset = 0;
     //Adding BOM marker for UTF-8
     $lines = chr(239) . chr(187) . chr(191);
     //writing header
     foreach ($fields as $field_id) {
         $field = RGFormsModel::get_field($form, $field_id);
         $value = '"' . str_replace('"', '""', GFCommon::get_label($field, $field_id)) . '"';
         $lines .= "{$value},";
     }
     $lines = substr($lines, 0, strlen($lines) - 1) . "\n";
     //paging through results for memory issues
     while ($entry_count > 0) {
         $leads = RGFormsModel::get_leads($form_id, "date_created", "DESC", "", $offset, $page_size, null, null, false, $start_date, $end_date);
         foreach ($leads as $lead) {
             foreach ($fields as $field_id) {
                 $long_text = "";
                 if (strlen($lead[$field_id]) >= GFORMS_MAX_FIELD_LENGTH) {
                     $long_text = RGFormsModel::get_field_value_long($lead["id"], $field_id);
                 }
                 $value = !empty($long_text) ? $long_text : $lead[$field_id];
                 $lines .= '"' . str_replace('"', '""', $value) . '",';
             }
             $lines = substr($lines, 0, strlen($lines) - 1);
             $lines .= "\n";
         }
         $offset += $page_size;
         $entry_count -= $page_size;
         if (!seems_utf8($lines)) {
             $lines = utf8_encode($lines);
         }
         echo $lines;
         $lines = "";
     }
 }
 /**
  *
  * @global type $wpdb
  */
 function entries_import()
 {
     $wform = $_REQUEST['form'];
     $gform = $_REQUEST['gform'];
     $entry_index = $_REQUEST['entry_index'];
     $this->init();
     $field_map = maybe_unserialize(get_site_option('rt_wufoo_' . $wform . '_field_map'));
     $f = new RGFormsModel();
     $c = new GFCommon();
     $gform_meta = RGFormsModel::get_form_meta($gform);
     try {
         $entries = $this->wufoo->getEntries($wform, 'forms', 'pageStart=' . $entry_index . '&pageSize=' . RT_WUFOO_IMPORT_PAGE_SIZE);
     } catch (Exception $rt_importer_e) {
         $this->error($rt_importer_e);
     }
     $this->op = array();
     foreach ($entries as $index => $entry) {
         $lead_exists_id = $this->is_imported($entry->EntryId);
         print_r($lead_exists_id);
         if (!$lead_exists_id) {
             foreach ($field_map as $g_id => $w_id) {
                 if (isset($w_id) && $w_id != '') {
                     $this->op[$g_id] = '';
                     $field_meta = RGFormsModel::get_field($gform_meta, $g_id);
                     if ($field_meta['type'] == 'fileupload') {
                         $this->op[$g_id] = $this->import_file_upload($entry, $w_id);
                     } else {
                         $this->import_regular_field($wform, $entry, $g_id, $w_id, $field_meta);
                     }
                 }
             }
             $currency = $c->get_currency();
             $ip = $f->get_ip();
             $page = $f->get_current_page_url();
             $lead_table = $f->get_lead_table_name();
             $lead_id = $this->insert_lead($entry, $lead_table, $ip, $currency, $page, $wform, $gform);
         }
         if ($lead_id) {
             foreach ($this->op as $inputid => $value) {
                 $this->insert_fields($lead_id, $gform, $inputid, $value);
             }
             //Insert comments as notes for the corresponding user map
             $comments = $this->get_comments_by_entry($wform, $entry->EntryId);
             if (isset($comments) && !empty($comments)) {
                 foreach ($comments as $comment) {
                     $this->move_comments_for_entry($comment, $f->get_lead_notes_table_name(), $lead_id, $wform);
                 }
             }
         } else {
             $lead_id = $lead_exists_id;
         }
         gform_update_meta($lead_id, 'rt_wufoo_entry_id', $entry->EntryId);
     }
     //update_site_option('rt_wufoo_' . $wform . '_entry_complete_count','0');
     echo count($entries) + $entry_index;
     die;
 }
 /**
  * Loop through the fields being edited and if they include Post fields, update the Entry's post object
  *
  * @param array $form Gravity Forms form
  *
  * @return void
  */
 function maybe_update_post_fields($form)
 {
     $post_id = $this->entry['post_id'];
     // Security check
     if (false === GVCommon::has_cap('edit_post', $post_id)) {
         do_action('gravityview_log_error', 'The current user does not have the ability to edit Post #' . $post_id);
         return;
     }
     $update_entry = false;
     $updated_post = $original_post = get_post($post_id);
     foreach ($this->entry as $field_id => $value) {
         //todo: only run through the edit entry configured fields
         $field = RGFormsModel::get_field($form, $field_id);
         if (class_exists('GF_Fields')) {
             $field = GF_Fields::create($field);
         }
         if (GFCommon::is_post_field($field)) {
             // Get the value of the field, including $_POSTed value
             $value = RGFormsModel::get_field_value($field);
             // Convert the field object in 1.9 to an array for backward compatibility
             $field_array = GVCommon::get_field_array($field);
             switch ($field_array['type']) {
                 case 'post_title':
                 case 'post_content':
                 case 'post_excerpt':
                     $updated_post->{$field_array['type']} = $value;
                     break;
                 case 'post_tags':
                     wp_set_post_tags($post_id, $value, false);
                     break;
                 case 'post_category':
                     $categories = is_array($value) ? array_values($value) : (array) $value;
                     $categories = array_filter($categories);
                     wp_set_post_categories($post_id, $categories, false);
                     // prepare value to be saved in the entry
                     $field = GFCommon::add_categories_as_choices($field, '');
                     // if post_category is type checkbox, then value is an array of inputs
                     if (isset($value[strval($field_id)])) {
                         foreach ($value as $input_id => $val) {
                             $input_name = 'input_' . str_replace('.', '_', $input_id);
                             $this->entry[strval($input_id)] = RGFormsModel::prepare_value($form, $field, $val, $input_name, $this->entry['id']);
                         }
                     } else {
                         $input_name = 'input_' . str_replace('.', '_', $field_id);
                         $this->entry[strval($field_id)] = RGFormsModel::prepare_value($form, $field, $value, $input_name, $this->entry['id']);
                     }
                     break;
                 case 'post_custom_field':
                     $input_type = RGFormsModel::get_input_type($field);
                     $custom_field_name = $field_array['postCustomFieldName'];
                     // Only certain custom field types are supported
                     if (!in_array($input_type, array('list', 'fileupload'))) {
                         update_post_meta($post_id, $custom_field_name, $value);
                     }
                     break;
                 case 'post_image':
                     $value = '';
                     break;
             }
             //ignore fields that have not changed
             if ($value === rgget((string) $field_id, $this->entry)) {
                 continue;
             }
             // update entry
             if ('post_category' !== $field->type) {
                 $this->entry[strval($field_id)] = $value;
             }
             $update_entry = true;
         }
     }
     if ($update_entry) {
         $return_entry = GFAPI::update_entry($this->entry);
         if (is_wp_error($return_entry)) {
             do_action('gravityview_log_error', 'Updating the entry post fields failed', $return_entry);
         } else {
             do_action('gravityview_log_debug', 'Updating the entry post fields for post #' . $post_id . ' succeeded');
         }
     }
     $return_post = wp_update_post($updated_post, true);
     if (is_wp_error($return_post)) {
         do_action('gravityview_log_error', 'Updating the post content failed', $return_post);
     } else {
         do_action('gravityview_log_debug', 'Updating the post content for post #' . $post_id . ' succeeded');
     }
 }
 public static function ajax_get_more_results()
 {
     $form_id = rgpost("form_id");
     $field_id = rgpost("field_id");
     $offset = rgpost("offset");
     $search_criteria = rgpost("search_criteria");
     if (empty($search_criteria)) {
         $search_criteria = array();
     }
     $page_size = 10;
     $form = RGFormsModel::get_form_meta($form_id);
     $form_id = $form["id"];
     $field = RGFormsModel::get_field($form, $field_id);
     $entry_count = GFFormsModel::count_search_leads($form_id, $search_criteria);
     $html = self::get_default_field_results($form_id, $field, $search_criteria, $offset, $page_size);
     $remaining = $entry_count - ($page_size + $offset);
     $remaining = $remaining < 0 ? 0 : $remaining;
     $response = array();
     $response["remaining"] = $remaining;
     $response['html'] = $html;
     echo json_encode($response);
     die;
 }
예제 #15
0
 public static function send_notification($notification, $form, $lead)
 {
     $notification = apply_filters("gform_notification_{$form["id"]}", apply_filters("gform_notification", $notification, $form, $lead), $form, $lead);
     $to_field = "";
     if (rgar($notification, "toType") == "field") {
         if (rgempty("toField", $notification)) {
             $to_field = rgar($notification, "to");
         } else {
             if (rgempty("to", $notification)) {
                 $to_field = rgar($notification, "toField");
             }
         }
     }
     $email_to = rgar($notification, "to");
     //do routing logic if "to" field doesn't have a value (to support legacy notifications what will run routing prior to this method
     if (empty($email_to) && rgar($notification, "toType") == "routing") {
         $email_to = array();
         foreach ($notification["routing"] as $routing) {
             $source_field = RGFormsModel::get_field($form, $routing["fieldId"]);
             $field_value = RGFormsModel::get_lead_field_value($lead, $source_field);
             $is_value_match = RGFormsModel::is_value_match($field_value, $routing["value"], $routing["operator"], $source_field) && !RGFormsModel::is_field_hidden($form, $source_field, array(), $lead);
             if ($is_value_match) {
                 $email_to[] = $routing["email"];
             }
         }
         $email_to = join(",", $email_to);
     } else {
         if (!empty($to_field)) {
             $source_field = RGFormsModel::get_field($form, $to_field);
             $email_to = RGFormsModel::get_lead_field_value($lead, $source_field);
         }
     }
     //Running through variable replacement
     $to = GFCommon::replace_variables($email_to, $form, $lead, false, false);
     $subject = GFCommon::replace_variables(rgar($notification, "subject"), $form, $lead, false, false);
     $from = GFCommon::replace_variables(rgar($notification, "from"), $form, $lead, false, false);
     $from_name = GFCommon::replace_variables(rgar($notification, "fromName"), $form, $lead, false, false);
     $bcc = GFCommon::replace_variables(rgar($notification, "bcc"), $form, $lead, false, false);
     $replyTo = GFCommon::replace_variables(rgar($notification, "replyTo"), $form, $lead, false, false);
     $message_format = rgempty("message_format", $notification) ? "html" : rgar($notification, "message_format");
     $message = GFCommon::replace_variables(rgar($notification, "message"), $form, $lead, false, false, !rgar($notification, "disableAutoformat"), $message_format);
     $message = do_shortcode($message);
     // allow attachments to be passed as a single path (string) or an array of paths, if string provided, add to array
     $attachments = rgar($notification, "attachments");
     if (!empty($attachments)) {
         $attachments = is_array($attachments) ? $attachments : array($attachments);
     } else {
         $attachments = array();
     }
     self::send_email($from, $to, $bcc, $replyTo, $subject, $message, $from_name, $message_format, $attachments);
     return compact("to", "from", "bcc", "replyTo", "subject", "message", "from_name", "message_format", "attachments");
 }
예제 #16
0
파일: common.php 프로젝트: novuscory/ACH
 public static function send_admin_notification($form, $lead)
 {
     $form_id = $form["id"];
     //handling admin notification email
     $subject = GFCommon::replace_variables($form["notification"]["subject"], $form, $lead, false, false);
     $message = GFCommon::replace_variables($form["notification"]["message"], $form, $lead, false, false, !$form["notification"]["disableAutoformat"]);
     $message = do_shortcode($message);
     $from = empty($form["notification"]["fromField"]) ? $form["notification"]["from"] : $lead[$form["notification"]["fromField"]];
     if (empty($form["notification"]["fromNameField"])) {
         $from_name = $form["notification"]["fromName"];
     } else {
         $field = RGFormsModel::get_field($form, $form["notification"]["fromNameField"]);
         $value = RGFormsModel::get_lead_field_value($lead, $field);
         $from_name = GFCommon::get_lead_field_display($field, $value);
     }
     $replyTo = empty($form["notification"]["replyToField"]) ? $form["notification"]["replyTo"] : $lead[$form["notification"]["replyToField"]];
     if (empty($form["notification"]["routing"])) {
         $email_to = $form["notification"]["to"];
     } else {
         $email_to = array();
         foreach ($form["notification"]["routing"] as $routing) {
             $source_field = RGFormsModel::get_field($form, $routing["fieldId"]);
             $field_value = RGFormsModel::get_field_value($source_field, array());
             $is_value_match = is_array($field_value) ? in_array($routing["value"], $field_value) : $field_value == $routing["value"];
             if ($routing["operator"] == "is" && $is_value_match || $routing["operator"] == "isnot" && !$is_value_match) {
                 $email_to[] = $routing["email"];
             }
         }
         $email_to = join(",", $email_to);
     }
     //Running through variable replacement
     $email_to = GFCommon::replace_variables($email_to, $form, $lead, false, false);
     $from = GFCommon::replace_variables($from, $form, $lead, false, false);
     $bcc = GFCommon::replace_variables($form["notification"]["bcc"], $form, $lead, false, false);
     $reply_to = GFCommon::replace_variables($replyTo, $form, $lead, false, false);
     $from_name = GFCommon::replace_variables($from_name, $form, $lead, false, false);
     //Filters the admin notification email to address. Allows users to change email address before notification is sent
     $to = apply_filters("gform_notification_email_{$form_id}", apply_filters("gform_notification_email", $email_to, $lead), $lead);
     self::send_email($from, $to, $bcc, $replyTo, $subject, $message, $from_name);
 }
 public function export_feed($entry, $form, $feed)
 {
     //$email       = $entry[ $feed['meta']['listFields_email'] ];
     //$name        = '';
     if (!empty($feed['meta']['listFields_first_name'])) {
         $name = $this->get_name($entry, $feed['meta']['listFields_first_name']);
     }
     $merge_vars = array();
     $field_maps = $this->get_field_map_fields($feed, 'listFields');
     foreach ($field_maps as $var_key => $field_id) {
         $field = RGFormsModel::get_field($form, $field_id);
         if (GFCommon::is_product_field($field['type']) && rgar($field, 'enablePrice')) {
             $ary = explode('|', $entry[$field_id]);
             $product_name = count($ary) > 0 ? $ary[0] : '';
             $merge_vars[] = array('name' => $var_key, 'value' => $product_name);
         } else {
             if (RGFormsModel::get_input_type($field) == 'checkbox') {
                 foreach ($field['inputs'] as $input) {
                     $index = (string) $input['id'];
                     $merge_vars[] = array('name' => $var_key, 'value' => apply_filters('gform_crm_field_value', rgar($entry, $index), $form['id'], $field_id, $entry));
                 }
             } else {
                 $merge_vars[] = array('name' => $var_key, 'value' => apply_filters('gform_crm_field_value', rgar($entry, $field_id), $form['id'], $field_id, $entry));
             }
         }
     }
     $override_custom_fields = apply_filters('gform_crm_override_blank_custom_fields', false, $entry, $form, $feed);
     if (!$override_custom_fields) {
         $merge_vars = $this->remove_blank_custom_fields($merge_vars);
     }
     $settings = $this->get_plugin_settings();
     if (isset($settings['gf_fd_accountname'])) {
         $accountname = $settings['gf_fd_accountname'];
     } else {
         $accountname = "";
     }
     if (isset($settings['gf_fd_apipassword'])) {
         $apipassword = $settings['gf_fd_apipassword'];
     } else {
         $apipassword = "";
     }
     $id = $this->facturadirecta_createlead($accountname, $apipassword, $merge_vars);
     //Sends email if it does not create a lead
     //if ($id == false)
     //    $this->send_emailerrorlead($crm_type);
     $this->debugcrm($id);
 }
 /**
  * When showing a single column values, display the label of the column instead of the field
  *
  * @since 1.14
  *
  * @param string $label Existing label string
  * @param array $field GV field settings array, with `id`, `show_label`, `label`, `custom_label`, etc. keys
  * @param array $form Gravity Forms form array
  * @param array $entry Gravity Forms entry array
  *
  * @return string Existing label if the field isn't
  */
 public function _filter_field_label($label, $field, $form, $entry)
 {
     $field_object = RGFormsModel::get_field($form, $field['id']);
     // Not a list field
     if (!$field_object || 'list' !== $field_object->type) {
         return $label;
     }
     // Custom label is defined, so use it
     if (!empty($field['custom_label'])) {
         return $label;
     }
     $column_id = gravityview_get_input_id_from_id($field['id']);
     // Parent field, not column field
     if (false === $column_id) {
         return $label;
     }
     return self::get_column_label($field_object, $column_id, $label);
 }
예제 #19
0
    public static function lead_detail_page()
    {
        global $wpdb;
        global $current_user;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $form = RGFormsModel::get_form_meta($_GET["id"]);
        $form_id = $form["id"];
        $form = apply_filters("gform_admin_pre_render_" . $form["id"], apply_filters("gform_admin_pre_render", $form));
        $lead_id = rgget('lid');
        $filter = rgget("filter");
        $status = in_array($filter, array("trash", "spam")) ? $filter : "active";
        $position = rgget('pos') ? rgget('pos') : 0;
        $sort_direction = rgget('dir') ? rgget('dir') : 'DESC';
        $sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"];
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta["type"] == "number";
        $star = $filter == "star" ? 1 : null;
        $read = $filter == "unread" ? 0 : null;
        $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");
        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;
            }
            $type = rgget("type");
            if (empty($type)) {
                $type = rgget("field_id") == "0" ? "global" : "field";
            }
            $search_criteria["field_filters"][] = array("key" => $key, "type" => $type, "operator" => rgempty("operator", $_GET) ? "is" : rgget("operator"), "value" => $val);
        }
        $paging = array('offset' => $position, 'page_size' => 1);
        if (!empty($sort_field)) {
            $sorting = array('key' => $_GET["sort"], 'direction' => $sort_direction, 'is_numeric' => $is_numeric);
        } else {
            $sorting = array();
        }
        $total_count = 0;
        $leads = GFAPI::get_entries($form['id'], $search_criteria, $sorting, $paging, $total_count);
        $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
        $next_pos = !rgblank($position) && $position < $total_count - 1 ? $position + 1 : false;
        // 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;
            }
        }
        if (!$lead_id) {
            $lead = !empty($leads) ? $leads[0] : false;
        } else {
            $lead = GFAPI::get_entry($lead_id);
        }
        if (!$lead) {
            _e("Oops! We couldn't find your entry. Please try again", "gravityforms");
            return;
        }
        RGFormsModel::update_lead_property($lead["id"], "is_read", 1);
        switch (RGForms::post("action")) {
            case "update":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                //Loading files that have been uploaded to temp folder
                $files = GFCommon::json_decode(stripslashes(RGForms::post("gform_uploaded_files")));
                if (!is_array($files)) {
                    $files = array();
                }
                GFFormsModel::$uploaded_files[$form_id] = $files;
                GFFormsModel::save_lead($form, $lead);
                do_action("gform_after_update_entry", $form, $lead["id"]);
                do_action("gform_after_update_entry_{$form["id"]}", $form, $lead["id"]);
                $lead = RGFormsModel::get_lead($lead["id"]);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                break;
            case "add_note":
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::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")) {
                    $email_to = $_POST["gentry_email_notes_to"];
                    $email_from = $current_user->user_email;
                    $email_subject = stripslashes($_POST["gentry_email_subject"]);
                    $headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
                    $result = wp_mail($email_to, $email_subject, stripslashes($_POST["new_note"]), $headers);
                }
                break;
            case "add_quick_note":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::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") {
                    RGFormsModel::delete_notes($_POST["note"]);
                }
                break;
            case "trash":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "trash");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "restore":
            case "unspam":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "active");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "spam":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "spam");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "delete":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                if (!GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    die(__("You don't have adequate permissions to delete entries.", "gravityforms"));
                }
                RGFormsModel::delete_lead($lead["id"]);
                ?>
                <script type="text/javascript">
                    document.location.href='<?php 
                echo "admin.php?page=gf_entries&view=entries&id=" . absint($form["id"]);
                ?>
';
                </script>
                <?php 
                break;
        }
        $mode = empty($_POST["screen_mode"]) ? "view" : $_POST["screen_mode"];
        ?>
        <link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin.css" />
         <script type="text/javascript">

            jQuery(document).ready(function(){
                toggleNotificationOverride(true);
            });

            function DeleteFile(leadId, fieldId, deleteButton){
                if(confirm(<?php 
        _e("'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 esc_js(__("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');
                }
            }

            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 
        _e("You must select at least one type of notification to resend.", "gravityforms");
        ?>
", "error", "#notifications_container");
                    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 $lead['id'];
        ?>
',
                        formId : '<?php 
        echo $form['id'];
        ?>
'
                    },
                    function(response) {
                        if(response) {
                            displayMessage(response, "error", "#notifications_container");
                        } else {
                            displayMessage("<?php 
        _e("Notifications were resent successfully.", "gravityforms");
        ?>
", "updated", "#notifications_container");

                            // reset UI
                            jQuery(".gform_notifications").attr('checked', false);
                            jQuery('#notification_override_email').val('');
                        }

                        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 ' + 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>

        <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"));
        ?>
" />

            <div class="wrap gf_entry_wrap">
            <h2 class="gf_admin_page_title"><span><?php 
        echo __("Entry #", "gravityforms") . absint($lead["id"]);
        ?>
</span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php 
        echo $form['id'];
        ?>
</span><?php 
        echo $form['title'];
        $gf_entry_locking = new GFEntryLocking();
        $gf_entry_locking->lock_info($lead_id);
        ?>
</span></h2>

            <?php 
        if (isset($_GET["pos"])) {
            ?>
            <div class="gf_entry_detail_pagination">
                <ul>
                    <li class="gf_entry_count"><span>entry <strong><?php 
            echo $position + 1;
            ?>
</strong> of <strong><?php 
            echo $total_count;
            ?>
</strong></span></li>
                    <li class="gf_entry_prev gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($prev_pos, 'Previous Entry', 'gf_entry_prev_link', "fa fa-arrow-circle-o-left");
            ?>
</li>
                    <li class="gf_entry_next gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($next_pos, 'Next Entry', 'gf_entry_next_link', "fa fa-arrow-circle-o-right");
            ?>
</li>
                </ul>
            </div>
            <?php 
        }
        ?>

            <?php 
        RGForms::top_toolbar();
        ?>

            <div id="poststuff" class="metabox-holder has-right-sidebar">
                <div id="side-info-column" class="inner-sidebar">
                	<?php 
        do_action("gform_entry_detail_sidebar_before", $form, $lead);
        ?>

                    <!-- INFO BOX -->
                    <div id="submitdiv" class="stuffbox">
                        <h3>
                            <span class="hndle"><?php 
        _e("Entry", "gravityforms");
        ?>
</span>
                        </h3>
                        <div class="inside">
                            <div id="submitcomment" class="submitbox">
                                <div id="minor-publishing" style="padding:10px;">
                                    <br/>
                                    <?php 
        _e("Entry Id", "gravityforms");
        ?>
: <?php 
        echo absint($lead["id"]);
        ?>
<br/><br/>
                                    <?php 
        _e("Submitted on", "gravityforms");
        ?>
: <?php 
        echo esc_html(GFCommon::format_date($lead["date_created"], false, "Y/m/d"));
        ?>
                                    <br/><br/>
                                    <?php 
        _e("User IP", "gravityforms");
        ?>
: <?php 
        echo $lead["ip"];
        ?>
                                    <br/><br/>
                                    <?php 
        if (!empty($lead["created_by"]) && ($usermeta = get_userdata($lead["created_by"]))) {
            ?>
                                        <?php 
            _e("User", "gravityforms");
            ?>
: <a href="user-edit.php?user_id=<?php 
            echo absint($lead["created_by"]);
            ?>
" alt="<?php 
            _e("View user profile", "gravityforms");
            ?>
" title="<?php 
            _e("View user profile", "gravityforms");
            ?>
"><?php 
            echo esc_html($usermeta->user_login);
            ?>
</a>
                                        <br/><br/>
                                        <?php 
        }
        ?>

                                    <?php 
        _e("Embed Url", "gravityforms");
        ?>
: <a href="<?php 
        echo esc_url($lead["source_url"]);
        ?>
" target="_blank" alt="<?php 
        echo esc_url($lead["source_url"]);
        ?>
" title="<?php 
        echo esc_url($lead["source_url"]);
        ?>
">.../<?php 
        echo esc_html(GFCommon::truncate_url($lead["source_url"]));
        ?>
</a>
                                    <br/><br/>
                                    <?php 
        if (!empty($lead["post_id"])) {
            $post = get_post($lead["post_id"]);
            ?>
                                        <?php 
            _e("Edit Post", "gravityforms");
            ?>
: <a href="post.php?action=edit&post=<?php 
            echo absint($post->ID);
            ?>
" alt="<?php 
            _e("Click to edit post", "gravityforms");
            ?>
" title="<?php 
            _e("Click to edit post", "gravityforms");
            ?>
"><?php 
            echo esc_html($post->post_title);
            ?>
</a>
                                        <br/><br/>
                                        <?php 
        }
        if (apply_filters("gform_enable_entry_info_payment_details", true, $lead)) {
            if (!empty($lead["payment_status"])) {
                echo $lead["transaction_type"] == 2 ? __("Subscription Status", "gravityforms") : __("Payment Status", "gravityforms");
                ?>
: <span id="gform_payment_status"><?php 
                echo apply_filters("gform_payment_status", $lead["payment_status"], $form, $lead);
                ?>
</span>
                                            <br/><br/>
                                            <?php 
                if (!empty($lead["payment_date"])) {
                    echo $lead["transaction_type"] == 2 ? __("Start Date", "gravityforms") : __("Payment Date", "gravityforms");
                    ?>
: <?php 
                    echo GFCommon::format_date($lead["payment_date"], false, "Y/m/d", $lead["transaction_type"] != 2);
                    ?>
                                                <br/><br/>
                                                <?php 
                }
                if (!empty($lead["transaction_id"])) {
                    echo $lead["transaction_type"] == 2 ? __("Subscriber Id", "gravityforms") : __("Transaction Id", "gravityforms");
                    ?>
: <?php 
                    echo $lead["transaction_id"];
                    ?>
                                                <br/><br/>
                                                <?php 
                }
                if (!rgblank($lead["payment_amount"])) {
                    echo $lead["transaction_type"] == 2 ? __("Subscription Amount", "gravityforms") : __("Payment Amount", "gravityforms");
                    ?>
: <?php 
                    echo GFCommon::to_money($lead["payment_amount"], $lead["currency"]);
                    ?>
                                                <br/><br/>
                                                <?php 
                }
            }
        }
        do_action("gform_entry_info", $form["id"], $lead);
        ?>
                                </div>
                                <div id="major-publishing-actions">
                                    <div id="delete-action">
                                        <?php 
        switch ($lead["status"]) {
            case "spam":
                if (GFCommon::akismet_enabled($form['id'])) {
                    ?>
                                                    <a onclick="jQuery('#action').val('unspam'); jQuery('#entry_form').submit()" href="#"><?php 
                    _e("Not Spam", "gravityforms");
                    ?>
</a>
                                                    <?php 
                    echo GFCommon::current_user_can_any("gravityforms_delete_entries") ? "|" : "";
                }
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                                    <a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    _e("You are about to delete this entry. \\'Cancel\\' to stop, \\'OK\\' to delete.", "gravityforms");
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</a>
                                                    <?php 
                }
                break;
            case "trash":
                ?>
                                                <a onclick="jQuery('#action').val('restore'); jQuery('#entry_form').submit()" href="#"><?php 
                _e("Restore", "gravityforms");
                ?>
</a>
                                                <?php 
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                                    |
                                                    <a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    _e("You are about to delete this entry. \\'Cancel\\' to stop, \\'OK\\' to delete.", "gravityforms");
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</a>
                                                    <?php 
                }
                break;
            default:
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                                    <a class="submitdelete deletion" onclick="jQuery('#action').val('trash'); jQuery('#entry_form').submit()" href="#"><?php 
                    _e("Move to Trash", "gravityforms");
                    ?>
</a>
                                                    <?php 
                    echo GFCommon::akismet_enabled($form['id']) ? "|" : "";
                }
                if (GFCommon::akismet_enabled($form['id'])) {
                    ?>
                                                    <a class="submitdelete deletion" onclick="jQuery('#action').val('spam'); jQuery('#entry_form').submit()" href="#"><?php 
                    _e("Mark as Spam", "gravityforms");
                    ?>
</a>
                                                <?php 
                }
        }
        ?>
                                    </div>
                                    <div id="publishing-action">
                                        <?php 
        if (GFCommon::current_user_can_any("gravityforms_edit_entries") && $lead["status"] != "trash") {
            $button_text = $mode == "view" ? __("Edit", "gravityforms") : __("Update", "gravityforms");
            $button_click = $mode == "view" ? "jQuery('#screen_mode').val('edit');" : "jQuery('#action').val('update'); jQuery('#screen_mode').val('view');";
            $update_button = '<input class="button button-large button-primary" type="submit" tabindex="4" value="' . $button_text . '" name="save" onclick="' . $button_click . '"/>';
            echo apply_filters("gform_entrydetail_update_button", $update_button);
            if ($mode == "edit") {
                echo '&nbsp;&nbsp;<input class="button button-large" type="submit" tabindex="5" value="' . __("Cancel", "gravityforms") . '" name="cancel" onclick="jQuery(\'#screen_mode\').val(\'view\');"/>';
            }
        }
        ?>
                                    </div>
                                    <div class="clear"></div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <?php 
        if (!empty($lead["payment_status"]) && !apply_filters("gform_enable_entry_info_payment_details", true, $lead)) {
            self::payment_details_box($lead, $form);
        }
        ?>

                    <?php 
        do_action("gform_entry_detail_sidebar_middle", $form, $lead);
        ?>

                    <?php 
        if (GFCommon::current_user_can_any("gravityforms_edit_entry_notes")) {
            ?>
                        <!-- start notifications -->
                        <div class="postbox" id="notifications_container">
                            <h3 style="cursor:default;"><span><?php 
            _e("Notifications", "gravityforms");
            ?>
</span></h3>
                            <div class="inside">
                                <div class="message" style="display:none; padding:10px; margin:10px 0px;"></div>
                                <div>
                                    <?php 
            if (!is_array($form["notifications"]) || count($form["notifications"]) <= 0) {
                ?>
                                        <p class="description"><?php 
                _e("You cannot resend notifications for this entry because this form does not currently have any notifications configured.", "gravityforms");
                ?>
</p>

                                        <a href="<?php 
                echo admin_url("admin.php?page=gf_edit_forms&view=settings&subview=notification&id={$form["id"]}");
                ?>
" class="button"><?php 
                _e("Configure Notifications", "gravityforms");
                ?>
</a>
                                    <?php 
            } else {
                foreach ($form["notifications"] as $notification) {
                    ?>
                                            <input type="checkbox" class="gform_notifications" value="<?php 
                    echo $notification["id"];
                    ?>
" id="notification_<?php 
                    echo $notification["id"];
                    ?>
" onclick="toggleNotificationOverride();" />
                                            <label for="notification_<?php 
                    echo $notification["id"];
                    ?>
"><?php 
                    echo $notification["name"];
                    ?>
</label> <br /><br />
                                        <?php 
                }
                ?>

                                        <div id="notifications_override_settings" style="display:none;">

                                            <p class="description" style="padding-top:0; margin-top:0; width:99%;">You may override the default notification settings
                                                by entering a comma delimited list of emails to which the selected notifications should be sent.</p>
                                            <label for="notification_override_email"><?php 
                _e("Send To", "gravityforms");
                ?>
 <?php 
                gform_tooltip("notification_override_email");
                ?>
</label><br />
                                            <input type="text" name="notification_override_email" id="notification_override_email" style="width:99%;" />
                                            <br /><br />

                                        </div>

                                        <input type="button" name="notification_resend" value="<?php 
                _e("Resend Notifications", "gravityforms");
                ?>
" class="button" style="" onclick="ResendNotifications();"/>
                                        <span id="please_wait_container" style="display:none; margin-left: 5px;">
                                            <img src="<?php 
                echo GFCommon::get_base_url();
                ?>
/images/loading.gif"> <?php 
                _e("Resending...", "gravityforms");
                ?>
                                        </span>
                                    <?php 
            }
            ?>

                                </div>
                            </div>
                        </div>
                       <!-- / end notifications -->
                   <?php 
        }
        ?>

                   <!-- begin print button -->
                   <div class="detail-view-print">
                       <a href="javascript:;" onclick="var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=print-entry&fid=<?php 
        echo $form['id'];
        ?>
&lid=<?php 
        echo $lead['id'];
        ?>
' + notes_qs; window.open (url,'printwindow');" class="button"><?php 
        _e("Print", "gravityforms");
        ?>
</a>
                       <?php 
        if (GFCommon::current_user_can_any("gravityforms_view_entry_notes")) {
            ?>
                           <input type="checkbox" name="print_notes" value="print_notes" checked="checked" id="gform_print_notes"/>
                           <label for="print_notes"><?php 
            _e("include notes", "gravityforms");
            ?>
</label>
                       <?php 
        }
        ?>
                   </div>
                   <!-- end print button -->
				   <?php 
        do_action("gform_entry_detail_sidebar_after", $form, $lead);
        ?>
                </div>

                <div id="post-body" class="has-sidebar">
                    <div id="post-body-content" class="has-sidebar-content">
                        <?php 
        do_action("gform_entry_detail_content_before", $form, $lead);
        if ($mode == "view") {
            self::lead_detail_grid($form, $lead, true);
        } else {
            self::lead_detail_edit($form, $lead);
        }
        do_action("gform_entry_detail", $form, $lead);
        if (GFCommon::current_user_can_any("gravityforms_view_entry_notes")) {
            ?>
                            <div class="postbox">
                                <h3>
                                    <label for="name"><?php 
            _e("Notes", "gravityforms");
            ?>
</label>
                                </h3>

                                <form method="post">
                                    <?php 
            wp_nonce_field('gforms_update_note', 'gforms_update_note');
            ?>
                                    <div class="inside">
                                        <?php 
            $notes = RGFormsModel::get_lead_notes($lead["id"]);
            //getting email values
            $email_fields = GFCommon::get_email_fields($form);
            $emails = array();
            foreach ($email_fields as $email_field) {
                if (!empty($lead[$email_field["id"]])) {
                    $emails[] = $lead[$email_field["id"]];
                }
            }
            //displaying notes grid
            $subject = !empty($form["autoResponder"]["subject"]) ? "RE: " . GFCommon::replace_variables($form["autoResponder"]["subject"], $form, $lead) : "";
            self::notes_grid($notes, true, $emails, $subject);
            ?>
                                    </div>
                                </form>
                            </div>
                        <?php 
        }
        do_action("gform_entry_detail_content_after", $form, $lead);
        ?>
                    </div>
                </div>
            </div>
        </div>
        </form>
        <?php 
        if (rgpost("action") == "update") {
            ?>
            <div class="updated fade" style="padding:6px;">
                <?php 
            _e("Entry Updated.", "gravityforms");
            ?>
            </div>
            <?php 
        }
    }
 public static function start_export($form)
 {
     $form_id = $form['id'];
     $fields = $_POST['export_field'];
     $start_date = empty($_POST['export_date_start']) ? '' : self::get_gmt_date($_POST['export_date_start'] . ' 00:00:00');
     $end_date = empty($_POST['export_date_end']) ? '' : self::get_gmt_date($_POST['export_date_end'] . ' 23:59:59');
     $search_criteria['status'] = 'active';
     $search_criteria['field_filters'] = GFCommon::get_field_filters_from_post($form);
     if (!empty($start_date)) {
         $search_criteria['start_date'] = $start_date;
     }
     if (!empty($end_date)) {
         $search_criteria['end_date'] = $end_date;
     }
     $sorting = array('key' => 'date_created', 'direction' => 'DESC', 'type' => 'info');
     GFCommon::log_debug("GFExport::start_export(): Start date: {$start_date}");
     GFCommon::log_debug("GFExport::start_export(): End date: {$end_date}");
     $form = self::add_default_export_fields($form);
     $entry_count = GFAPI::count_entries($form_id, $search_criteria);
     $page_size = 100;
     $offset = 0;
     //Adding BOM marker for UTF-8
     $lines = chr(239) . chr(187) . chr(191);
     // set the separater
     $separator = apply_filters('gform_export_separator_' . $form_id, apply_filters('gform_export_separator', ',', $form_id), $form_id);
     $field_rows = self::get_field_row_count($form, $fields, $entry_count);
     //writing header
     $headers = array();
     foreach ($fields as $field_id) {
         $field = RGFormsModel::get_field($form, $field_id);
         $value = str_replace('"', '""', GFCommon::get_label($field, $field_id));
         GFCommon::log_debug("GFExport::start_export(): Header for field ID {$field_id}: {$value}");
         $headers[$field_id] = $str = preg_replace('/[^a-z\\d ]/i', '', $value);
         $subrow_count = isset($field_rows[$field_id]) ? intval($field_rows[$field_id]) : 0;
         if ($subrow_count == 0) {
             $lines .= '"' . $value . '"' . $separator;
         } else {
             for ($i = 1; $i <= $subrow_count; $i++) {
                 $lines .= '"' . $value . ' ' . $i . '"' . $separator;
             }
         }
         GFCommon::log_debug("GFExport::start_export(): Lines: {$lines}");
     }
     $lines = substr($lines, 0, strlen($lines) - 1) . "\n";
     //paging through results for memory issues
     while ($entry_count > 0) {
         $paging = array('offset' => $offset, 'page_size' => $page_size);
         $leads = GFAPI::get_entries($form_id, $search_criteria, $sorting, $paging);
         $leads = apply_filters("gform_leads_before_export_{$form_id}", apply_filters('gform_leads_before_export', $leads, $form, $paging), $form, $paging);
         foreach ($leads as $lead) {
             foreach ($fields as $field_id) {
                 switch ($field_id) {
                     case 'date_created':
                         $lead_gmt_time = mysql2date('G', $lead['date_created']);
                         $lead_local_time = GFCommon::get_local_timestamp($lead_gmt_time);
                         $value = date_i18n('Y-m-d H:i:s', $lead_local_time, true);
                         break;
                     default:
                         $long_text = '';
                         if (strlen(rgar($lead, $field_id)) >= GFORMS_MAX_FIELD_LENGTH - 10) {
                             $long_text = RGFormsModel::get_field_value_long($lead, $field_id, $form);
                         }
                         $value = !empty($long_text) ? $long_text : rgar($lead, $field_id);
                         $field = RGFormsModel::get_field($form, $field_id);
                         $input_type = RGFormsModel::get_input_type($field);
                         if ($input_type == 'checkbox') {
                             //pass in label value that has not had quotes escaped so the is_checkbox_checked function compares the unchanged label value with the lead value
                             $header_label_not_escaped = GFCommon::get_label($field, $field_id);
                             $value = GFFormsModel::is_checkbox_checked($field_id, $header_label_not_escaped, $lead, $form);
                             if ($value === false) {
                                 $value = '';
                             }
                         } else {
                             if ($input_type == 'fileupload' && $field->multipleFiles) {
                                 $value = !empty($value) ? implode(' , ', json_decode($value, true)) : '';
                             }
                         }
                         $value = preg_replace('/[^a-z\\d ]/i', '', $value);
                         $value = apply_filters('gform_export_field_value', $value, $form_id, $field_id, $lead);
                         GFCommon::log_debug("GFExport::start_export(): Value for field ID {$field_id}: {$value}");
                         break;
                 }
                 if (isset($field_rows[$field_id])) {
                     $list = empty($value) ? array() : unserialize($value);
                     foreach ($list as $row) {
                         $row_values = array_values($row);
                         $row_str = implode('|', $row_values);
                         $lines .= '"' . str_replace('"', '""', $row_str) . '"' . $separator;
                     }
                     //filling missing subrow columns (if any)
                     $missing_count = intval($field_rows[$field_id]) - count($list);
                     for ($i = 0; $i < $missing_count; $i++) {
                         $lines .= '""' . $separator;
                     }
                 } else {
                     $value = maybe_unserialize($value);
                     if (is_array($value)) {
                         $value = implode('|', $value);
                     }
                     $lines .= '"' . str_replace('"', '""', $value) . '"' . $separator;
                 }
             }
             $lines = substr($lines, 0, strlen($lines) - 1);
             GFCommon::log_debug("GFExport::start_export(): Lines: {$lines}");
             $lines .= "\n";
         }
         $offset += $page_size;
         $entry_count -= $page_size;
         if (!seems_utf8($lines)) {
             $lines = utf8_encode($lines);
         }
         if (function_exists('mb_convert_encoding')) {
             // Convert the contents to UTF-16LE which has wider support than UTF-8.
             // This fixes an issue with special characters in Excel for Mac.
             $lines = mb_convert_encoding($lines, 'UTF-16LE', 'UTF-8');
         }
         echo $lines;
         $lines = '';
     }
 }
 public function signature_entry_list($value, $form_id, $field_id)
 {
     $form = RGFormsModel::get_form_meta($form_id);
     $field = RGFormsModel::get_field($form, $field_id);
     if ($field['type'] == 'signature' && !empty($value)) {
         $path_info = pathinfo($value);
         $filename = $path_info['filename'];
         $signature_path = home_url() . "?page=gf_signature&signature={$filename}";
         $thumb = GFCommon::get_base_url() . '/images/doctypes/icon_image.gif';
         $newvalue = "<a href='{$signature_path}' target='_blank' title='" . __('Click to view', 'gravityformssignature') . "'><img src='{$thumb}'/></a>";
         return $newvalue;
     } else {
         return $value;
     }
 }
예제 #22
0
 private static function get_field_values($i, $form, $field_id, $selected_value, $max_field_length = 16)
 {
     if (empty($field_id)) {
         $field_id = self::get_first_routing_field($form);
     }
     if (empty($field_id)) {
         return "";
     }
     $field = RGFormsModel::get_field($form, $field_id);
     $is_any_selected = false;
     $str = "";
     if (!$field) {
         return "";
     }
     if ($field["type"] == "post_category" && rgar($field, "displayAllCategories") == true) {
         $str .= wp_dropdown_categories(array("class" => "gfield_routing_select gfield_category_dropdown gfield_routing_value_dropdown", "orderby" => "name", "id" => "routing_value_" . $i, "selected" => $selected_value, "hierarchical" => true, "hide_empty" => 0, "echo" => false));
     } elseif (rgar($field, "choices")) {
         $str .= "<select id='routing_value_" . $i . "' class='gfield_routing_select gfield_routing_value_dropdown'>";
         foreach ($field["choices"] as $choice) {
             $is_selected = $choice["value"] == $selected_value;
             $selected = $is_selected ? "selected='selected'" : "";
             if ($is_selected) {
                 $is_any_selected = true;
             }
             $str .= "<option value='" . esc_attr($choice["value"]) . "' " . $selected . ">" . $choice["text"] . "</option>";
         }
         //adding current selected field value to the list
         if (!$is_any_selected && !empty($selected_value)) {
             $str .= "<option value='" . esc_attr($selected_value) . "' selected='selected'>" . $selected_value . "</option>";
         }
         $str .= "</select>";
     } else {
         //create a text field for fields that don't have choices (i.e text, textarea, number, email, etc...)
         $str = "<input type='text' placeholder='" . __("Enter value", "gravityforms") . "' class='gfield_routing_select' id='routing_value_" . $i . "' value='" . esc_attr($selected_value) . "' onchange='SetRouting(" . $i . ");' onkeyup='SetRouting(" . $i . ");'>";
     }
     return $str;
 }
예제 #23
0
 public static function has_paypal_condition($form, $config)
 {
     $config = $config["meta"];
     $operator = isset($config["paypal_conditional_operator"]) ? $config["paypal_conditional_operator"] : "";
     $field = RGFormsModel::get_field($form, $config["paypal_conditional_field_id"]);
     if (empty($field) || !$config["paypal_conditional_enabled"]) {
         return true;
     }
     // if conditional is enabled, but the field is hidden, ignore conditional
     $is_visible = !RGFormsModel::is_field_hidden($form, $field, array());
     $field_value = RGFormsModel::get_field_value($field, array());
     $is_value_match = RGFormsModel::is_value_match($field_value, $config["paypal_conditional_value"], $operator);
     $go_to_paypal = $is_value_match && $is_visible;
     return $go_to_paypal;
 }
    public static function leads_page($form_id)
    {
        global $wpdb;
        //quit if version of wp is not supported
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $action = RGForms::post("action");
        $filter = rgget("filter");
        $search = rgget("s");
        $page_index = empty($_GET["paged"]) ? 0 : intval($_GET["paged"]) - 1;
        $star = $filter == "star" ? 1 : null;
        // is_numeric(RGForms::get("star")) ? intval(RGForms::get("star")) : null;
        $read = $filter == "unread" ? 0 : null;
        //is_numeric(RGForms::get("read")) ? intval(RGForms::get("read")) : null;
        $status = in_array($filter, array("trash", "spam")) ? $filter : "active";
        $update_message = "";
        switch ($action) {
            case "delete":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $lead_id = $_POST["action_argument"];
                RGFormsModel::delete_lead($lead_id);
                $update_message = __("Entry deleted.", "gravityforms");
                break;
            case "bulk":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $bulk_action = !empty($_POST["bulk_action"]) ? $_POST["bulk_action"] : $_POST["bulk_action2"];
                $select_all = rgpost("all_entries");
                $leads = empty($select_all) ? $_POST["lead"] : GFFormsModel::get_lead_ids($form_id, $search, $star, $read, null, null, $status);
                $entry_count = count($leads) > 1 ? sprintf(__("%d entries", "gravityforms"), count($leads)) : __("1 entry", "gravityforms");
                switch ($bulk_action) {
                    case "delete":
                        RGFormsModel::delete_leads($leads);
                        $update_message = sprintf(__("%s deleted.", "gravityforms"), $entry_count);
                        break;
                    case "trash":
                        RGFormsModel::update_leads_property($leads, "status", "trash");
                        $update_message = sprintf(__("%s moved to Trash.", "gravityforms"), $entry_count);
                        break;
                    case "restore":
                        RGFormsModel::update_leads_property($leads, "status", "active");
                        $update_message = sprintf(__("%s restored from the Trash.", "gravityforms"), $entry_count);
                        break;
                    case "unspam":
                        RGFormsModel::update_leads_property($leads, "status", "active");
                        $update_message = sprintf(__("%s restored from the spam.", "gravityforms"), $entry_count);
                        break;
                    case "spam":
                        RGFormsModel::update_leads_property($leads, "status", "spam");
                        $update_message = sprintf(__("%s marked as spam.", "gravityforms"), $entry_count);
                        break;
                    case "mark_read":
                        RGFormsModel::update_leads_property($leads, "is_read", 1);
                        $update_message = sprintf(__("%s marked as read.", "gravityforms"), $entry_count);
                        break;
                    case "mark_unread":
                        RGFormsModel::update_leads_property($leads, "is_read", 0);
                        $update_message = sprintf(__("%s marked as unread.", "gravityforms"), $entry_count);
                        break;
                    case "add_star":
                        RGFormsModel::update_leads_property($leads, "is_starred", 1);
                        $update_message = sprintf(__("%s starred.", "gravityforms"), $entry_count);
                        break;
                    case "remove_star":
                        RGFormsModel::update_leads_property($leads, "is_starred", 0);
                        $update_message = sprintf(__("%s unstarred.", "gravityforms"), $entry_count);
                        break;
                }
                break;
            case "change_columns":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $columns = GFCommon::json_decode(stripslashes($_POST["grid_columns"]), true);
                RGFormsModel::update_grid_column_meta($form_id, $columns);
                break;
        }
        if (rgpost("button_delete_permanently")) {
            RGFormsModel::delete_leads_by_form($form_id, $filter);
        }
        $sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"];
        $sort_direction = empty($_GET["dir"]) ? "DESC" : $_GET["dir"];
        $form = RGFormsModel::get_form_meta($form_id);
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta["type"] == "number";
        $page_size = apply_filters("gform_entry_page_size", apply_filters("gform_entry_page_size_{$form_id}", 20, $form_id), $form_id);
        $first_item_index = $page_index * $page_size;
        $leads = RGFormsModel::get_leads($form_id, $sort_field, $sort_direction, $search, $first_item_index, $page_size, $star, $read, $is_numeric, null, null, $status);
        $lead_count = RGFormsModel::get_lead_count($form_id, $search, $star, $read, null, null, $status);
        $summary = RGFormsModel::get_form_counts($form_id);
        $active_lead_count = $summary["total"];
        $unread_count = $summary["unread"];
        $starred_count = $summary["starred"];
        $spam_count = $summary["spam"];
        $trash_count = $summary["trash"];
        $columns = RGFormsModel::get_grid_columns($form_id, true);
        $search_qs = empty($search) ? "" : "&s=" . urlencode($search);
        $sort_qs = empty($sort_field) ? "" : "&sort={$sort_field}";
        $dir_qs = empty($sort_field) ? "" : "&dir={$sort_direction}";
        $star_qs = $star !== null ? "&star={$star}" : "";
        $read_qs = $read !== null ? "&read={$read}" : "";
        $filter_qs = "&filter=" . $filter;
        $display_total = ceil($lead_count / $page_size);
        $page_links = paginate_links(array('base' => admin_url("admin.php") . "?page=gf_entries&view=entries&id={$form_id}&%_%" . $search_qs . $sort_qs . $dir_qs . $star_qs . $read_qs . $filter_qs, 'format' => 'paged=%#%', 'prev_text' => __('&laquo;', 'gravityforms'), 'next_text' => __('&raquo;', 'gravityforms'), 'total' => $display_total, 'current' => $page_index + 1, 'show_all' => false));
        wp_print_styles(array("thickbox"));
        ?>

        <script type="text/javascript">

            var messageTimeout = false;

            function ChangeColumns(columns){
                jQuery("#action").val("change_columns");
                jQuery("#grid_columns").val(jQuery.toJSON(columns));
                tb_remove();
                jQuery("#lead_form")[0].submit();
            }

            function Search(sort_field_id, sort_direction, form_id, search, star, read, filter){
                var search_qs = search == "" ? "" : "&s=" + search;
                var star_qs = star == "" ? "" : "&star=" + star;
                var read_qs = read == "" ? "" : "&read=" + read;
                var filter_qs = filter == "" ? "" : "&filter=" + filter;

                var location = "?page=gf_entries&view=entries&id=" + form_id + "&sort=" + sort_field_id + "&dir=" + sort_direction + search_qs + star_qs + read_qs + filter_qs;
                document.location = location;
            }

            function ToggleStar(img, lead_id, filter){
                var is_starred = img.src.indexOf("star1.png") >=0
                if(is_starred)
                    img.src = img.src.replace("star1.png", "star0.png");
                else
                    img.src = img.src.replace("star0.png", "star1.png");

                jQuery("#lead_row_" + lead_id).toggleClass("lead_starred");
                //if viewing the starred entries, hide the row and adjust the paging counts
                if (filter == "star")
                {
                	var title = jQuery("#lead_row_" + lead_id);
                	title.css("display", "none");
                	UpdatePagingCounts(1);
				}

                UpdateCount("star_count", is_starred ? -1 : 1);

                UpdateLeadProperty(lead_id, "is_starred", is_starred ? 0 : 1);
            }

            function ToggleRead(lead_id, filter){
                var title = jQuery("#lead_row_" + lead_id);
                marking_read = title.hasClass("lead_unread");

                jQuery("#mark_read_" + lead_id).css("display", marking_read ? "none" : "inline");
                jQuery("#mark_unread_" + lead_id).css("display", marking_read ? "inline" : "none");
                jQuery("#is_unread_" + lead_id).css("display", marking_read ? "inline" : "none");
                title.toggleClass("lead_unread");
                //if viewing the unread entries, hide the row and adjust the paging counts
                if (filter == "unread")
                {
                	title.css("display", "none");
                	UpdatePagingCounts(1);
				}

                UpdateCount("unread_count", marking_read ? -1 : 1);
                UpdateLeadProperty(lead_id, "is_read", marking_read ? 1 : 0);
            }

            function UpdateLeadProperty(lead_id, name, value){
                var mysack = new sack("<?php 
        echo admin_url("admin-ajax.php");
        ?>
" );
                mysack.execute = 1;
                mysack.method = 'POST';
                mysack.setVar( "action", "rg_update_lead_property" );
                mysack.setVar( "rg_update_lead_property", "<?php 
        echo wp_create_nonce("rg_update_lead_property");
        ?>
" );
                mysack.setVar( "lead_id", lead_id);
                mysack.setVar( "name", name);
                mysack.setVar( "value", value);
                mysack.onError = function() { alert('<?php 
        echo esc_js(__("Ajax error while setting lead property", "gravityforms"));
        ?>
' )};
                mysack.runAJAX();

                return true;
            }

            function UpdateCount(element_id, change){
                var element = jQuery("#" + element_id);
                var count = parseInt(element.html()) + change
                element.html(count + "");
            }

            function UpdatePagingCounts(change){
				//update paging header/footer Displaying # - # of #, use counts from header, no need to use footer since they are the same, just update footer paging with header info
                var paging_range_max_header = jQuery("#paging_range_max_header");
                var paging_range_max_footer = jQuery("#paging_range_max_footer");
                var range_change_max = parseInt(paging_range_max_header.html()) - change;
                var paging_total_header = jQuery("#paging_total_header");
                var paging_total_footer = jQuery("#paging_total_footer");
                var total_change = parseInt(paging_total_header.html()) - change;
                var paging_range_min_header = jQuery("#paging_range_min_header");
                var paging_range_min_footer = jQuery("#paging_range_min_footer");
				//if min and max are the same, this is the last entry item on the page, clear out the displaying # - # of # text
                if (parseInt(paging_range_min_header.html()) == parseInt(paging_range_max_header.html()))
                {
					var paging_header = jQuery("#paging_header");
					paging_header.html("");
					var paging_footer = jQuery("#paging_footer");
					paging_footer.html("");
                }
                else
                {
                	paging_range_max_header.html(range_change_max + "");
                	paging_range_max_footer.html(range_change_max + "");
                	paging_total_header.html(total_change + "");
                	paging_total_footer.html(total_change + "");
				}
                gformVars.countAllEntries = gformVars.countAllEntries - change;
                setSelectAllText();
            }

            function DeleteLead(lead_id){
                jQuery("#action").val("delete");
                jQuery("#action_argument").val(lead_id);
                jQuery("#lead_form")[0].submit();
                return true;
            }

            function handleBulkApply(actionElement){

                var action = jQuery("#" + actionElement).val();
                var defaultModalOptions = '';
                var leadIds = getLeadIds();

                if(leadIds.length == 0){
                    alert('<?php 
        _e('Please select at least one entry.', 'gravityforms');
        ?>
');
                    return false;
                }

                switch(action){

                case 'resend_notifications':
                    resetResendNotificationsUI();
                    tb_show('<?php 
        _e("Resend Notifications", "gravityforms");
        ?>
', '#TB_inline?width=350&amp;inlineId=notifications_modal_container', '');
                    return false;
                    break;

                case 'print':
                    resetPrintUI();
                    tb_show('<?php 
        _e("Print Entries", "gravityforms");
        ?>
', '#TB_inline?width=350&amp;height=250&amp;inlineId=print_modal_container', '');
                    return false;
                    break;

                default:
                    jQuery('#action').val('bulk');
                }

            }

            function getLeadIds(){
                var all = jQuery("#all_entries").val();
                //compare string, the boolean isn't correct, even when casting to a boolean the 0 is set to true
                if(all == "1")
                    return 0;

                var leads = jQuery(".check-column input[name='lead[]']:checked");
                var leadIds = new Array();

                jQuery(leads).each(function(i){
                    leadIds[i] = jQuery(leads[i]).val();
                });

                return leadIds;
            }

            function BulkResendNotifications(){


                var selectedNotifications = new Array();
                jQuery(".gform_notifications:checked").each(function(){
                    selectedNotifications.push(jQuery(this).val());
                });
                var leadIds = getLeadIds();

                var sendTo = jQuery('#notification_override_email').val();

                if(selectedNotifications.length <=0) {
                    displayMessage("<?php 
        _e("You must select at least one type of notification to resend.", "gravityforms");
        ?>
", "error", "#notifications_container");
                    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 : leadIds,
                    filter: '<?php 
        echo esc_attr(rgget("filter"));
        ?>
',
                    search: '<?php 
        echo esc_attr(rgget("s"));
        ?>
',
                    formId : '<?php 
        echo $form['id'];
        ?>
'
                    },
                    function(response){

                        jQuery('#please_wait_container').hide();

                        if(response) {
                            displayMessage(response, "error", "#notifications_container");
                        } else {
                            var message = '<?php 
        _e("Notifications for %s were resent successfully.", "gravityforms");
        ?>
';
                            displayMessage(message.replace('%s', leadIds.length + ' ' + getPlural(leadIds.length, '<?php 
        _e('entry', 'gravityforms');
        ?>
', '<?php 
        _e('entries', 'gravityforms');
        ?>
')), "updated", "#lead_form");
                            closeModal(true);
                        }

                    }
                );

            }

            function resetResendNotificationsUI(){

                jQuery('#notification_admin, #notification_user').attr('checked', false);
                jQuery('#notifications_container .message, #notifications_override_settings').hide();

            }

            function BulkPrint(){

                var leadIds = getLeadIds();
                if(leadIds != 0)
                    leadIds = leadIds.join(',');
                var leadsQS = '&lid=' + leadIds;
                var notesQS = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : '';
                var pageBreakQS = jQuery('#gform_print_page_break').is(':checked') ? '&page_break=1' : '';
                var filterQS = '&filter=<?php 
        echo esc_attr(rgget("filter"));
        ?>
';
                var searchQS = '&search=<?php 
        echo esc_attr(rgget("s"));
        ?>
';

                var url = '<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=print-entry&fid=<?php 
        echo $form['id'];
        ?>
' + leadsQS + notesQS + pageBreakQS + filterQS + searchQS;
                window.open (url,'printwindow');

                closeModal(true);
                hideMessage('#lead_form', false);
            }

            function resetPrintUI(){

                jQuery('#print_options input[type="checkbox"]').attr('checked', false);

            }

            function displayMessage(message, messageClass, container){

                hideMessage(container, true);

                var messageBox = jQuery('<div class="message ' + messageClass + '" style="display:none;"><p>' + message + '</p></div>');
                jQuery(messageBox).prependTo(container).slideDown();

                if(messageClass == 'updated')
                    messageTimeout = setTimeout(function(){ hideMessage(container, false); }, 10000);

            }

            function hideMessage(container, messageQueued){

                if(messageTimeout)
                    clearTimeout(messageTimeout);

                var messageBox = jQuery(container).find('.message');

                if(messageQueued)
                    jQuery(messageBox).remove();
                else
                    jQuery(messageBox).slideUp(function(){ jQuery(this).remove(); });

            }

            function closeModal(isSuccess) {

                if(isSuccess)
                    jQuery('.check-column input[type="checkbox"]').attr('checked', false);

                tb_remove();

            }

            function getPlural(count, singular, plural) {
                return count > 1 ? plural : singular;
            }

            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('');
                    });
                }

            }

            // Select All

            var gformStrings = {
                "allEntriesOnPageAreSelected" : "<?php 
        printf(__("All %s{0}%s entries on this page are selected.", "gravityforms"), "<strong>", "</strong>");
        ?>
",
                "selectAll" : "<?php 
        printf(__("Select all %s{0}%s entries.", "gravityforms"), "<strong>", "</strong>");
        ?>
",
                "allEntriesSelected" : "<?php 
        printf(__("All %s{0}%s entries have been selected.", "gravityforms"), "<strong>", "</strong>");
        ?>
",
                "clearSelection" : "<?php 
        _e("Clear selection", "gravityforms");
        ?>
"
            }

            var gformVars = {
                "countAllEntries" : <?php 
        echo intval($lead_count);
        ?>
,
                "perPage" : <?php 
        echo intval($page_size);
        ?>
            }

            function setSelectAllText(){
                var tr = getSelectAllText();
                jQuery("#gform-select-all-message td").html(tr);
            }

            function getSelectAllText(){
                var count;
                count = jQuery("#gf_entry_list tr:visible:not('#gform-select-all-message')").length;
                return gformStrings.allEntriesOnPageAreSelected.format(count) + " <a href='javascript:void(0)' onclick='selectAllEntriesOnAllPages();'>" + gformStrings.selectAll.format(gformVars.countAllEntries) + "</a>";
            }

            function getSelectAllTr(){
                var t = getSelectAllText();
                var colspan = jQuery("#gf_entry_list").find("tr:first td").length + 1;
                return "<tr id='gform-select-all-message' style='display:none;background-color:lightyellow;text-align:center;'><td colspan='{0}'>{1}</td></tr>".format(colspan, t);
            }
            function toggleSelectAll(visible){
                if(gformVars.countAllEntries <= gformVars.perPage){
                    jQuery('#gform-select-all-message').hide();
                    return;
                }

                if(visible)
                    setSelectAllText();
                jQuery('#gform-select-all-message').toggle(visible);
            }


            function clearSelectAllEntries(){
                jQuery(".check-column input[type=checkbox]").prop('checked', false);
                clearSelectAllMessage();
            }

            function clearSelectAllMessage(){
                jQuery("#all_entries").val("0");
                jQuery("#gform-select-all-message").hide();
                jQuery("#gform-select-all-message td").html('');
            }

            function selectAllEntriesOnAllPages (){
                var trHtmlClearSelection;
                trHtmlClearSelection = gformStrings.allEntriesSelected.format(gformVars.countAllEntries) + " <a href='javascript:void(0);' onclick='clearSelectAllEntries();'>" + gformStrings.clearSelection + "</a>";
                jQuery("#all_entries").val("1");
                jQuery("#gform-select-all-message td").html(trHtmlClearSelection);
            }

            function SetUpSelectAllEntries(){

                if(gformVars.countAllEntries > gformVars.perPage){
                    var tr = getSelectAllTr();
                    jQuery("#gf_entry_list").prepend(tr);
                    jQuery(".headercb").click(function(){
                        toggleSelectAll(jQuery(this).prop('checked'));
                    });
                    jQuery("#gf_entry_list .check-column input[type=checkbox]").click(function(){
                        clearSelectAllMessage();
                    })
                }
            }

            String.prototype.format = function() {
                var args = arguments;
                return this.replace(/{(\d+)}/g, function (match, number) {
                    return typeof args[number] != 'undefined' ? args[number] : match;
                });
            };

            // end Select All

            jQuery(document).ready(function(){
                jQuery("#lead_search").keypress(function(event){
                    if(event.keyCode == 13){
                        Search('<?php 
        echo $sort_field;
        ?>
', '<?php 
        echo $sort_direction;
        ?>
', <?php 
        echo $form_id;
        ?>
, this.value, '<?php 
        echo $star;
        ?>
', '<?php 
        echo $read;
        ?>
', '<?php 
        echo $filter;
        ?>
');
                        event.preventDefault();
                    }
                });

                var action = '<?php 
        echo $action;
        ?>
';
                var message = '<?php 
        echo $update_message;
        ?>
';
                if(action && message)
                    displayMessage(message, 'updated', '#lead_form');

                var list = jQuery("#gf_entry_list").wpList( { alt: '<?php 
        echo esc_js(__('Entry List', 'gravityforms'));
        ?>
'} );
                list.bind('wpListDelEnd', function(e, s, list){

                    var currentStatus = "<?php 
        echo $filter == "trash" || $filter == "spam" ? $filter : "active";
        ?>
";
                    var filter = "<?php 
        echo $filter;
        ?>
";
                    var movingTo = "active";
                    if(s.data.status == "trash")
                        movingTo = "trash";
                    else if(s.data.status == "spam")
                        movingTo = "spam";
                    else if(s.data.status == "delete")
                        movingTo = "delete";

                    var id = s.data.entry;
                    var title = jQuery("#lead_row_" + id);
                    var isUnread = title.hasClass("lead_unread");
                    var isStarred = title.hasClass("lead_starred");

                    if(movingTo != "delete"){
                        //Updating All count
                        var allCount = currentStatus == "active" ? -1 : 1;
                        UpdateCount("all_count", allCount);

                        //Updating Unread count
                        if(isUnread){
                            var unreadCount = currentStatus == "active" ? -1 : 1;
                            UpdateCount("unread_count", unreadCount);
                        }

                        //Updating Starred count
                        if(isStarred){
                            var starCount = currentStatus == "active" ? -1 : 1;
                            UpdateCount("star_count", starCount);
                        }
                    }

                    //Updating Spam count
                    if(currentStatus == "spam" || movingTo == "spam"){
                        var spamCount = movingTo == "spam" ? 1 : -1;
                        UpdateCount("spam_count", spamCount);
                        //adjust paging counts
                        if (filter == "spam")
                        {
                        	UpdatePagingCounts(1);
						}
						else
						{
							UpdatePagingCounts(spamCount);
						}
                    }

                    //Updating trash count
                    if(currentStatus == "trash" || movingTo == "trash"){
                        var trashCount = movingTo == "trash" ? 1 : -1;
                        UpdateCount("trash_count", trashCount);
                        //adjust paging counts
                        if (filter == "trash")
                        {
                        	UpdatePagingCounts(1);
						}
						else
						{
							UpdatePagingCounts(trashCount);
						}
                    }

                });

                SetUpSelectAllEntries();
            });

        </script>
        <link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin.css" type="text/css" />
        <style>
            /*#TB_window { height: 400px !important; }
            #TB_ajaxContent[style] { height: 370px !important; }*/
            .lead_unread a, .lead_unread td{font-weight: bold;}
            .lead_spam_trash a, .lead_spam_trash td{font-weight:normal;}
            .row-actions a { font-weight:normal;}
            .entry_nowrap{ overflow:hidden; white-space:nowrap; }
            .message { margin: 15px 0 0 !important; }
        </style>


        <div class="wrap">

            <div class="icon32" id="gravity-entry-icon"><br></div>
            <h2 class="gf_admin_page_title"><span><?php 
        _e("Entries", "gravityforms");
        ?>
</span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php 
        echo $form['id'];
        ?>
</span><?php 
        echo $form['title'];
        ?>
</span></h2>

            <?php 
        RGForms::top_toolbar();
        ?>

            <form id="lead_form" method="post">
                <?php 
        wp_nonce_field('gforms_entry_list', 'gforms_entry_list');
        ?>

                <input type="hidden" value="" name="grid_columns" id="grid_columns" />
                <input type="hidden" value="" name="action" id="action" />
                <input type="hidden" value="" name="action_argument" id="action_argument" />
                <input type="hidden" value="" name="all_entries" id="all_entries" />

                <ul class="subsubsub">
                    <li><a class="<?php 
        echo empty($filter) ? "current" : "";
        ?>
" href="?page=gf_entries&view=entries&id=<?php 
        echo $form_id;
        ?>
"><?php 
        _e("All", "gravityforms");
        ?>
 <span class="count">(<span id="all_count"><?php 
        echo $active_lead_count;
        ?>
</span>)</span></a> | </li>
                    <li><a class="<?php 
        echo $read !== null ? "current" : "";
        ?>
" href="?page=gf_entries&view=entries&id=<?php 
        echo $form_id;
        ?>
&filter=unread"><?php 
        _e("Unread", "gravityforms");
        ?>
 <span class="count">(<span id="unread_count"><?php 
        echo $unread_count;
        ?>
</span>)</span></a> | </li>
                    <li><a class="<?php 
        echo $star !== null ? "current" : "";
        ?>
" href="?page=gf_entries&view=entries&id=<?php 
        echo $form_id;
        ?>
&filter=star"><?php 
        _e("Starred", "gravityforms");
        ?>
 <span class="count">(<span id="star_count"><?php 
        echo $starred_count;
        ?>
</span>)</span></a> | </li>
                    <?php 
        if (GFCommon::akismet_enabled($form_id)) {
            ?>
                        <li><a class="<?php 
            echo $filter == "spam" ? "current" : "";
            ?>
" href="?page=gf_entries&view=entries&id=<?php 
            echo $form_id;
            ?>
&filter=spam"><?php 
            _e("Spam", "gravityforms");
            ?>
 <span class="count">(<span id="spam_count"><?php 
            echo $spam_count;
            ?>
</span>)</span></a> | </li>
                        <?php 
        }
        ?>
                    <li><a class="<?php 
        echo $filter == "trash" ? "current" : "";
        ?>
" href="?page=gf_entries&view=entries&id=<?php 
        echo $form_id;
        ?>
&filter=trash"><?php 
        _e("Trash", "gravityforms");
        ?>
 <span class="count">(<span id="trash_count"><?php 
        echo $trash_count;
        ?>
</span>)</span></a></li>
                </ul>
                <p class="search-box">
                    <label class="hidden" for="lead_search"><?php 
        _e("Search Entries:", "gravityforms");
        ?>
</label>
                    <input type="text" id="lead_search" value="<?php 
        echo $search;
        ?>
"><a class="button" id="lead_search_button" href="javascript:Search('<?php 
        echo $sort_field;
        ?>
', '<?php 
        echo $sort_direction;
        ?>
', <?php 
        echo $form_id;
        ?>
, jQuery('#lead_search').val(), '<?php 
        echo $star;
        ?>
', '<?php 
        echo $read;
        ?>
', '<?php 
        echo $filter;
        ?>
');"><?php 
        _e("Search", "gravityforms");
        ?>
</a>

                </p>
                <div class="tablenav">

                    <div class="alignleft actions" style="padding:8px 0 7px 0;">
                        <label class="hidden" for="bulk_action"> <?php 
        _e("Bulk action", "gravityforms");
        ?>
</label>
                        <select name="bulk_action" id="bulk_action">
                            <option value=''><?php 
        _e(" Bulk action ", "gravityforms");
        ?>
</option>
                            <?php 
        switch ($filter) {
            case "trash":
                ?>
                                    <option value='restore'><?php 
                _e("Restore", "gravityforms");
                ?>
</option>
                                    <?php 
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                        <option value='delete'><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</option>
                                        <?php 
                }
                break;
            case "spam":
                ?>
                                    <option value='unspam'><?php 
                _e("Not Spam", "gravityforms");
                ?>
</option>
                                    <?php 
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                        <option value='delete'><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</option>
                                        <?php 
                }
                break;
            default:
                ?>
                                    <option value='mark_read'><?php 
                _e("Mark as Read", "gravityforms");
                ?>
</option>
                                    <option value='mark_unread'><?php 
                _e("Mark as Unread", "gravityforms");
                ?>
</option>
                                    <option value='add_star'><?php 
                _e("Add Star", "gravityforms");
                ?>
</option>
                                    <option value='remove_star'><?php 
                _e("Remove Star", "gravityforms");
                ?>
</option>
                                    <option value='resend_notifications'><?php 
                _e("Resend Notifications", "gravityforms");
                ?>
</option>
                                    <option value='print'><?php 
                _e("Print", "gravityforms");
                ?>
</option>

                                    <?php 
                if (GFCommon::akismet_enabled($form_id)) {
                    ?>
                                        <option value='spam'><?php 
                    _e("Spam", "gravityforms");
                    ?>
</option>
                                        <?php 
                }
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                        <option value='trash'><?php 
                    _e("Trash", "gravityforms");
                    ?>
</option>
                                        <?php 
                }
        }
        ?>
                        </select>
                        <?php 
        $apply_button = '<input type="submit" class="button" value="' . __("Apply", "gravityforms") . '" onclick="return handleBulkApply(\'bulk_action\');" />';
        echo apply_filters("gform_entry_apply_button", $apply_button);
        if (in_array($filter, array("trash", "spam"))) {
            $message = $filter == "trash" ? __("WARNING! This operation cannot be undone. Empty trash? \\'Ok\\' to empty trash. \\'Cancel\\' to abort.", "gravityforms") : __("WARNING! This operation cannot be undone. Permanently delete all spam? \\'Ok\\' to delete. \\'Cancel\\' to abort.", "gravityforms");
            $button_label = $filter == "trash" ? __("Empty Trash", "gravityforms") : __("Delete All Spam", "gravityforms");
            ?>
                            <input type="submit" class="button" name="button_delete_permanently" value="<?php 
            echo $button_label;
            ?>
" onclick="return confirm('<?php 
            echo esc_attr($message);
            ?>
');" />
                            <?php 
        }
        ?>

                        <div id="notifications_modal_container" style="display:none;">
                            <div id="notifications_container">

                                <div id="post_tag" class="tagsdiv">
                                    <div id="resend_notifications_options">

                                        <?php 
        if (!is_array($form["notifications"]) || count($form["notifications"]) <= 0) {
            ?>
                                            <p class="description"><?php 
            _e("You cannot resend notifications for these entries because this form does not currently have any notifications configured.", "gravityforms");
            ?>
</p>

                                            <a href="<?php 
            echo admin_url("admin.php?page=gf_edit_forms&view=settings&subview=notification&id={$form["id"]}");
            ?>
" class="button"><?php 
            _e("Configure Notifications", "gravityforms");
            ?>
</a>
                                        <?php 
        } else {
            ?>
                                            <p class="description"><?php 
            _e("Specify which notifications you would like to resend for the selected entries.", "gravityforms");
            ?>
</p>
                                            <?php 
            foreach ($form["notifications"] as $notification) {
                ?>
                                                <input type="checkbox" class="gform_notifications" value="<?php 
                echo $notification["id"];
                ?>
" id="notification_<?php 
                echo $notification["id"];
                ?>
" onclick="toggleNotificationOverride();" />
                                                <label for="notification_<?php 
                echo $notification["id"];
                ?>
"><?php 
                echo $notification["name"];
                ?>
</label> <br /><br />
                                            <?php 
            }
            ?>
                                            <div id="notifications_override_settings" style="display:none;">

                                                <p class="description" style="padding-top:0; margin-top:0;">You may override the default notification settings
                                                    by entering a comma delimited list of emails to which the selected notifications should be sent.</p>
                                                <label for="notification_override_email"><?php 
            _e("Send To", "gravityforms");
            ?>
 <?php 
            gform_tooltip("notification_override_email");
            ?>
</label><br />
                                                <input type="text" name="notification_override_email" id="notification_override_email" style="width:99%;" /><br /><br />

                                            </div>

                                            <input type="button" name="notification_resend" id="notification_resend" value="<?php 
            _e("Resend Notifications", "gravityforms");
            ?>
" class="button" style="" onclick="BulkResendNotifications();"/>
                                            <span id="please_wait_container" style="display:none; margin-left: 5px;">
                                                <img src="<?php 
            echo GFCommon::get_base_url();
            ?>
/images/loading.gif"> <?php 
            _e("Resending...", "gravityforms");
            ?>
                                            </span>
                                        <?php 
        }
        ?>

                                    </div>

                                    <div id="resend_notifications_close" style="display:none;margin:10px 0 0;">
                                        <input type="button" name="resend_notifications_close_button" value="<?php 
        _e("Close Window", "gravityforms");
        ?>
" class="button" style="" onclick="closeModal(true);"/>
                                    </div>

                                </div>

                            </div>
                        </div> <!-- / Resend Notifications -->

                        <div id="print_modal_container" style="display:none;">
                            <div id="print_container">

                                <div class="tagsdiv">
                                    <div id="print_options">

                                        <p class="description"><?php 
        _e("Print all of the selected entries at once.", "gravityforms");
        ?>
</p>

                                        <?php 
        if (GFCommon::current_user_can_any("gravityforms_view_entry_notes")) {
            ?>
                                            <input type="checkbox" name="gform_print_notes" value="print_notes" checked="checked" id="gform_print_notes" />
                                            <label for="gform_print_notes"><?php 
            _e("Include notes", "gravityforms");
            ?>
</label>
                                            <br /><br />
                                        <?php 
        }
        ?>

                                        <input type="checkbox" name="gform_print_page_break" value="print_notes" checked="checked" id="gform_print_page_break" />
                                        <label for="gform_print_page_break"><?php 
        _e("Add page break between entries", "gravityforms");
        ?>
</label>
                                        <br /><br />

                                        <input type="button" value="<?php 
        _e("Print", "gravityforms");
        ?>
" class="button" onclick="BulkPrint();" />

                                    </div>
                                </div>

                            </div>
                        </div> <!-- / Print -->

                    </div>

                    <?php 
        echo self::display_paging_links("header", $page_links, $first_item_index, $page_size, $lead_count);
        ?>

                    <div class="clear"></div>
                </div>

                <table class="widefat fixed" cellspacing="0">
                <thead>
                    <tr>
                        <th scope="col" id="cb" class="manage-column column-cb check-column"><input type="checkbox" class="headercb" /></th>
                        <?php 
        if (!in_array($filter, array("spam", "trash"))) {
            ?>
                            <th scope="col" id="cb" class="manage-column column-cb check-column" >&nbsp;</th>
                            <?php 
        }
        foreach ($columns as $field_id => $field_info) {
            $dir = $field_id == 0 ? "DESC" : "ASC";
            //default every field so ascending sorting except date_created (id=0)
            if ($field_id == $sort_field) {
                //reverting direction if clicking on the currently sorted field
                $dir = $sort_direction == "ASC" ? "DESC" : "ASC";
            }
            ?>
                            <th scope="col" class="manage-column entry_nowrap" onclick="Search('<?php 
            echo $field_id;
            ?>
', '<?php 
            echo $dir;
            ?>
', <?php 
            echo $form_id;
            ?>
, '<?php 
            echo $search;
            ?>
', '<?php 
            echo $star;
            ?>
', '<?php 
            echo $read;
            ?>
', '<?php 
            echo $filter;
            ?>
');" style="cursor:pointer;"><?php 
            echo esc_html($field_info["label"]);
            ?>
</th>
                            <?php 
        }
        ?>
                        <th scope="col" align="right" width="50">
                            <a title="<?php 
        _e("Select Columns", "gravityforms");
        ?>
" href="<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=select_columns&id=<?php 
        echo $form_id;
        ?>
&TB_iframe=true&height=365&width=600" class="thickbox entries_edit_icon"><?php 
        _e("Edit", "gravityforms");
        ?>
</a>
                        </th>
                    </tr>
                </thead>
                <tfoot>
                    <tr>
                        <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
                        <?php 
        if (!in_array($filter, array("spam", "trash"))) {
            ?>
                            <th scope="col" id="cb" class="manage-column column-cb check-column" >&nbsp;</th>
                        <?php 
        }
        foreach ($columns as $field_id => $field_info) {
            $dir = $field_id == 0 ? "DESC" : "ASC";
            //default every field so ascending sorting except date_created (id=0)
            if ($field_id == $sort_field) {
                //reverting direction if clicking on the currently sorted field
                $dir = $sort_direction == "ASC" ? "DESC" : "ASC";
            }
            ?>
                            <th scope="col" class="manage-column entry_nowrap" onclick="Search('<?php 
            echo $field_id;
            ?>
', '<?php 
            echo $dir;
            ?>
', <?php 
            echo $form_id;
            ?>
, '<?php 
            echo $search;
            ?>
', '<?php 
            echo $star;
            ?>
', '<?php 
            echo $read;
            ?>
', '<?php 
            echo $filter;
            ?>
');" style="cursor:pointer;"><?php 
            echo esc_html($field_info["label"]);
            ?>
</th>
                            <?php 
        }
        ?>
                        <th scope="col" style="width:15px;">
                            <a href="<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=select_columns&id=<?php 
        echo $form_id;
        ?>
&TB_iframe=true&height=365&width=600" class="thickbox entries_edit_icon"><?php 
        _e("Edit", "gravityforms");
        ?>
</a>
                        </th>
                    </tr>
                </tfoot>

                <tbody data-wp-lists="list:gf_entry" class="user-list" id="gf_entry_list">
                    <?php 
        if (sizeof($leads) > 0) {
            $field_ids = array_keys($columns);
            foreach ($leads as $position => $lead) {
                $position = $page_size * $page_index + $position;
                ?>
                            <tr id="lead_row_<?php 
                echo $lead["id"];
                ?>
" class='author-self status-inherit <?php 
                echo $lead["is_read"] ? "" : "lead_unread";
                ?>
 <?php 
                echo $lead["is_starred"] ? "lead_starred" : "";
                ?>
 <?php 
                echo in_array($filter, array("trash", "spam")) ? "lead_spam_trash" : "";
                ?>
'  valign="top">
                                <th scope="row" class="check-column">
                                    <input type="checkbox" name="lead[]" value="<?php 
                echo $lead["id"];
                ?>
" />
                                </th>
                                <?php 
                if (!in_array($filter, array("spam", "trash"))) {
                    ?>
                                    <td >
                                        <img id="star_image_<?php 
                    echo $lead["id"];
                    ?>
" src="<?php 
                    echo GFCommon::get_base_url();
                    ?>
/images/star<?php 
                    echo intval($lead["is_starred"]);
                    ?>
.png" onclick="ToggleStar(this, <?php 
                    echo $lead["id"] . ",'" . $filter . "'";
                    ?>
);" />
                                    </td>
                                <?php 
                }
                $is_first_column = true;
                $nowrap_class = "entry_nowrap";
                foreach ($field_ids as $field_id) {
                    /* maybe move to function */
                    $field = RGFormsModel::get_field($form, $field_id);
                    $value = rgar($lead, $field_id);
                    if ($field['type'] == 'post_category') {
                        $value = GFCommon::prepare_post_category_value($value, $field, 'entry_list');
                    }
                    //filtering lead value
                    $value = apply_filters("gform_get_field_value", $value, $lead, $field);
                    $input_type = !empty($columns[$field_id]["inputType"]) ? $columns[$field_id]["inputType"] : $columns[$field_id]["type"];
                    switch ($input_type) {
                        case "checkbox":
                            $value = "";
                            //if this is the main checkbox field (not an input), display a comma separated list of all inputs
                            if (absint($field_id) == $field_id) {
                                $lead_field_keys = array_keys($lead);
                                $items = array();
                                foreach ($lead_field_keys as $input_id) {
                                    if (is_numeric($input_id) && absint($input_id) == $field_id) {
                                        $items[] = GFCommon::selection_display(rgar($lead, $input_id), null, $lead["currency"], false);
                                    }
                                }
                                $value = GFCommon::implode_non_blank(", ", $items);
                                // special case for post category checkbox fields
                                if ($field['type'] == 'post_category') {
                                    $value = GFCommon::prepare_post_category_value($value, $field, 'entry_list');
                                }
                            } else {
                                $value = "";
                                //looping through lead detail values trying to find an item identical to the column label. Mark with a tick if found.
                                $lead_field_keys = array_keys($lead);
                                foreach ($lead_field_keys as $input_id) {
                                    //mark as a tick if input label (from form meta) is equal to submitted value (from lead)
                                    if (is_numeric($input_id) && absint($input_id) == absint($field_id)) {
                                        if ($lead[$input_id] == $columns[$field_id]["label"]) {
                                            $value = "<img src='" . GFCommon::get_base_url() . "/images/tick.png'/>";
                                        } else {
                                            $field = RGFormsModel::get_field($form, $field_id);
                                            if (rgar($field, "enableChoiceValue") || rgar($field, "enablePrice")) {
                                                foreach ($field["choices"] as $choice) {
                                                    if ($choice["value"] == $lead[$field_id]) {
                                                        $value = "<img src='" . GFCommon::get_base_url() . "/images/tick.png'/>";
                                                        break;
                                                    } else {
                                                        if (rgar($field, "enablePrice")) {
                                                            $ary = explode("|", $lead[$field_id]);
                                                            $val = count($ary) > 0 ? $ary[0] : "";
                                                            $price = count($ary) > 1 ? $ary[1] : "";
                                                            if ($val == $choice["value"]) {
                                                                $value = "<img src='" . GFCommon::get_base_url() . "/images/tick.png'/>";
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                        case "post_image":
                            list($url, $title, $caption, $description) = rgexplode("|:|", $value, 4);
                            if (!empty($url)) {
                                //displaying thumbnail (if file is an image) or an icon based on the extension
                                $thumb = self::get_icon_url($url);
                                $value = "<a href='" . esc_attr($url) . "' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$thumb}'/></a>";
                            }
                            break;
                        case "fileupload":
                            $file_path = $value;
                            if (!empty($file_path)) {
                                //displaying thumbnail (if file is an image) or an icon based on the extension
                                $thumb = self::get_icon_url($file_path);
                                $file_path = esc_attr($file_path);
                                $value = "<a href='{$file_path}' target='_blank' title='" . __("Click to view", "gravityforms") . "'><img src='{$thumb}'/></a>";
                            }
                            break;
                        case "source_url":
                            $value = "<a href='" . esc_attr($lead["source_url"]) . "' target='_blank' alt='" . esc_attr($lead["source_url"]) . "' title='" . esc_attr($lead["source_url"]) . "'>.../" . esc_attr(GFCommon::truncate_url($lead["source_url"])) . "</a>";
                            break;
                        case "textarea":
                        case "post_content":
                        case "post_excerpt":
                            $value = esc_html($value);
                            break;
                        case "date_created":
                        case "payment_date":
                            $value = GFCommon::format_date($value, false);
                            break;
                        case "date":
                            $field = RGFormsModel::get_field($form, $field_id);
                            $value = GFCommon::date_display($value, rgar($field, "dateFormat"));
                            break;
                        case "radio":
                        case "select":
                            $field = RGFormsModel::get_field($form, $field_id);
                            $value = GFCommon::selection_display($value, $field, $lead["currency"]);
                            break;
                        case "number":
                            $field = RGFormsModel::get_field($form, $field_id);
                            $value = GFCommon::format_number($value, rgar($field, "numberFormat"));
                            break;
                        case "total":
                        case "payment_amount":
                            $value = GFCommon::to_money($value, $lead["currency"]);
                            break;
                        case "created_by":
                            if (!empty($value)) {
                                $userdata = get_userdata($value);
                                $value = $userdata->user_login;
                            }
                            break;
                        case "multiselect":
                            // add space after comma-delimited values
                            $value = implode(', ', explode(',', $value));
                            break;
                        default:
                            $value = esc_html($value);
                    }
                    $value = apply_filters("gform_entries_field_value", $value, $form_id, $field_id, $lead);
                    /* ^ maybe move to function */
                    $query_string = "gf_entries&view=entry&id={$form_id}&lid={$lead["id"]}{$search_qs}{$sort_qs}{$dir_qs}{$filter_qs}&paged=" . ($page_index + 1);
                    if ($is_first_column) {
                        ?>
                                        <td class="column-title" >
                                            <a href="admin.php?page=gf_entries&view=entry&id=<?php 
                        echo $form_id;
                        ?>
&lid=<?php 
                        echo $lead["id"] . $search_qs . $sort_qs . $dir_qs . $filter_qs;
                        ?>
&paged=<?php 
                        echo $page_index + 1;
                        ?>
&pos=<?php 
                        echo $position;
                        ?>
"><?php 
                        echo $value;
                        ?>
</a>
                                            <div class="row-actions">
                                                <?php 
                        switch ($filter) {
                            case "trash":
                                ?>
                                                        <span class="edit">
                                                            <a title="<?php 
                                _e("View this entry", "gravityforms");
                                ?>
" href="admin.php?page=gf_entries&view=entry&id=<?php 
                                echo $form_id;
                                ?>
&lid=<?php 
                                echo $lead["id"] . $search_qs . $sort_qs . $dir_qs . $filter_qs;
                                ?>
&paged=<?php 
                                echo $page_index + 1;
                                ?>
&pos=<?php 
                                echo $position;
                                ?>
"><?php 
                                _e("View", "gravityforms");
                                ?>
</a>
                                                            |
                                                        </span>

                                                        <span class="edit">
                                                            <a data-wp-lists='delete:gf_entry_list:lead_row_<?php 
                                echo $lead["id"];
                                ?>
::status=active&entry=<?php 
                                echo $lead["id"];
                                ?>
' title="<?php 
                                echo _e("Restore this entry", "gravityforms");
                                ?>
" href="<?php 
                                echo wp_nonce_url("?page=gf_entries", "gf_delete_entry");
                                ?>
"><?php 
                                _e("Restore", "gravityforms");
                                ?>
</a>
                                                            <?php 
                                echo GFCommon::current_user_can_any("gravityforms_delete_entries") ? "|" : "";
                                ?>
                                                        </span>

                                                        <?php 
                                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                                    ?>
                                                            <span class="delete">
                                                                <?php 
                                    $delete_link = '<a data-wp-lists="delete:gf_entry_list:lead_row_' . $lead["id"] . '::status=delete&entry=' . $lead["id"] . '" title="' . __("Delete this entry permanently", "gravityforms") . '"  href="' . wp_nonce_url("?page=gf_entries", "gf_delete_entry") . '">' . __("Delete Permanently", "gravityforms") . '</a>';
                                    echo apply_filters("gform_delete_entry_link", $delete_link);
                                    ?>
                                                            </span>
                                                            <?php 
                                }
                                break;
                            case "spam":
                                ?>
                                                        <span class="edit">
                                                            <a title="<?php 
                                _e("View this entry", "gravityforms");
                                ?>
" href="admin.php?page=gf_entries&view=entry&id=<?php 
                                echo $form_id;
                                ?>
&lid=<?php 
                                echo $lead["id"] . $search_qs . $sort_qs . $dir_qs . $filter_qs;
                                ?>
&paged=<?php 
                                echo $page_index + 1;
                                ?>
&pos=<?php 
                                echo $position;
                                ?>
"><?php 
                                _e("View", "gravityforms");
                                ?>
</a>
                                                            |
                                                        </span>

                                                        <span class="unspam">
                                                            <a data-wp-lists='delete:gf_entry_list:lead_row_<?php 
                                echo $lead["id"];
                                ?>
::status=unspam&entry=<?php 
                                echo $lead["id"];
                                ?>
' title="<?php 
                                echo _e("Mark this entry as not spam", "gravityforms");
                                ?>
" href="<?php 
                                echo wp_nonce_url("?page=gf_entries", "gf_delete_entry");
                                ?>
"><?php 
                                _e("Not Spam", "gravityforms");
                                ?>
</a>
                                                            <?php 
                                echo GFCommon::current_user_can_any("gravityforms_delete_entries") ? "|" : "";
                                ?>
                                                        </span>

                                                        <?php 
                                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                                    ?>
                                                            <span class="delete">
                                                                <?php 
                                    $delete_link = '<a data-wp-lists="delete:gf_entry_list:lead_row_' . $lead["id"] . '::status=delete&entry=' . $lead["id"] . '" title="' . __("Delete this entry permanently", "gravityforms") . '"  href="' . wp_nonce_url("?page=gf_entries", "gf_delete_entry") . '">' . __("Delete Permanently", "gravityforms") . '</a>';
                                    echo apply_filters("gform_delete_entry_link", $delete_link);
                                    ?>
                                                            </span>
                                                            <?php 
                                }
                                break;
                            default:
                                ?>
                                                        <span class="edit">
                                                            <a title="<?php 
                                _e("View this entry", "gravityforms");
                                ?>
" href="admin.php?page=gf_entries&view=entry&id=<?php 
                                echo $form_id;
                                ?>
&lid=<?php 
                                echo $lead["id"] . $search_qs . $sort_qs . $dir_qs . $filter_qs;
                                ?>
&paged=<?php 
                                echo $page_index + 1;
                                ?>
&pos=<?php 
                                echo $position;
                                ?>
"><?php 
                                _e("View", "gravityforms");
                                ?>
</a>
                                                            |
                                                        </span>
                                                        <span class="edit">
                                                            <a id="mark_read_<?php 
                                echo $lead["id"];
                                ?>
" title="Mark this entry as read" href="javascript:ToggleRead(<?php 
                                echo $lead["id"] . ",'" . $filter . "'";
                                ?>
);" style="display:<?php 
                                echo $lead["is_read"] ? "none" : "inline";
                                ?>
;"><?php 
                                _e("Mark read", "gravityforms");
                                ?>
</a><a id="mark_unread_<?php 
                                echo $lead["id"];
                                ?>
" title="<?php 
                                _e("Mark this entry as unread", "gravityforms");
                                ?>
" href="javascript:ToggleRead(<?php 
                                echo $lead["id"] . ",'" . $filter . "'";
                                ?>
);" style="display:<?php 
                                echo $lead["is_read"] ? "inline" : "none";
                                ?>
;"><?php 
                                _e("Mark unread", "gravityforms");
                                ?>
</a>
                                                            <?php 
                                echo GFCommon::current_user_can_any("gravityforms_delete_entries") || GFCommon::akismet_enabled($form_id) ? "|" : "";
                                ?>
                                                        </span>
                                                        <?php 
                                if (GFCommon::akismet_enabled($form_id)) {
                                    ?>
                                                            <span class="spam">
                                                                <a data-wp-lists='delete:gf_entry_list:lead_row_<?php 
                                    echo $lead["id"];
                                    ?>
::status=spam&entry=<?php 
                                    echo $lead["id"];
                                    ?>
' title="<?php 
                                    _e("Mark this entry as spam", "gravityforms");
                                    ?>
" href="<?php 
                                    echo wp_nonce_url("?page=gf_entries", "gf_delete_entry");
                                    ?>
"><?php 
                                    _e("Spam", "gravityforms");
                                    ?>
</a>
                                                                <?php 
                                    echo GFCommon::current_user_can_any("gravityforms_delete_entries") ? "|" : "";
                                    ?>
                                                            </span>

                                                        <?php 
                                }
                                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                                    ?>
                                                            <span class="trash">
                                                                <a data-wp-lists='delete:gf_entry_list:lead_row_<?php 
                                    echo $lead["id"];
                                    ?>
::status=trash&entry=<?php 
                                    echo $lead["id"];
                                    ?>
' title="<?php 
                                    _e("Move this entry to the trash", "gravityforms");
                                    ?>
" href="<?php 
                                    echo wp_nonce_url("?page=gf_entries", "gf_delete_entry");
                                    ?>
"><?php 
                                    _e("Trash", "gravityforms");
                                    ?>
</a>
                                                            </span>
                                                            <?php 
                                }
                                break;
                        }
                        do_action("gform_entries_first_column_actions", $form_id, $field_id, $value, $lead, $query_string);
                        ?>

                                            </div>
                                            <?php 
                        do_action("gform_entries_first_column", $form_id, $field_id, $value, $lead, $query_string);
                        ?>
                                        </td>
                                        <?php 
                    } else {
                        ?>
                                        <td class="<?php 
                        echo $nowrap_class;
                        ?>
">
                                            <?php 
                        echo apply_filters("gform_entries_column_filter", $value, $form_id, $field_id, $lead, $query_string);
                        ?>
&nbsp;
                                            <?php 
                        do_action("gform_entries_column", $form_id, $field_id, $value, $lead, $query_string);
                        ?>
                                        </td>
                                        <?php 
                    }
                    $is_first_column = false;
                }
                ?>
                                <td>&nbsp;</td>
                            </tr>
                            <?php 
            }
        } else {
            $message = "";
            $column_count = sizeof($columns) + 3;
            switch ($filter) {
                case "unread":
                    $message = __("This form does not have any unread entries.", "gravityforms");
                    break;
                case "star":
                    $message = __("This form does not have any starred entries.", "gravityforms");
                    break;
                case "spam":
                    $message = __("This form does not have any spam.", "gravityforms");
                    $column_count = sizeof($columns) + 2;
                    break;
                case "trash":
                    $message = __("This form does not have any entries in the trash.", "gravityforms");
                    $column_count = sizeof($columns) + 2;
                    break;
                default:
                    $message = __("This form does not have any entries yet.", "gravityforms");
            }
            ?>
                        <tr>
                            <td colspan="<?php 
            echo $column_count;
            ?>
" style="padding:20px;"><?php 
            echo $message;
            ?>
</td>
                        </tr>
                        <?php 
        }
        ?>
                </tbody>
                </table>

                <div class="clear"></div>

                <div class="tablenav">

                    <div class="alignleft actions" style="padding:8px 0 7px 0;">
                        <label class="hidden" for="bulk_action2"> <?php 
        _e("Bulk action", "gravityforms");
        ?>
</label>
                        <select name="bulk_action2" id="bulk_action2">
                            <option value=''><?php 
        _e(" Bulk action ", "gravityforms");
        ?>
</option>
                            <?php 
        switch ($filter) {
            case "trash":
                ?>
                                    <option value='restore'><?php 
                _e("Restore", "gravityforms");
                ?>
</option>
                                    <?php 
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                        <option value='delete'><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</option>
                                        <?php 
                }
                break;
            case "spam":
                ?>
                                    <option value='unspam'><?php 
                _e("Not Spam", "gravityforms");
                ?>
</option>
                                    <?php 
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                        <option value='delete'><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</option>
                                        <?php 
                }
                break;
            default:
                ?>
                                <option value='mark_read'><?php 
                _e("Mark as Read", "gravityforms");
                ?>
</option>
                                <option value='mark_unread'><?php 
                _e("Mark as Unread", "gravityforms");
                ?>
</option>
                                <option value='add_star'><?php 
                _e("Add Star", "gravityforms");
                ?>
</option>
                                <option value='remove_star'><?php 
                _e("Remove Star", "gravityforms");
                ?>
</option>
                                <option value='resend_notifications'><?php 
                _e("Resend Notifications", "gravityforms");
                ?>
</option>
                                <option value='print'><?php 
                _e("Print", "gravityforms");
                ?>
</option>
                                <?php 
                if (GFCommon::akismet_enabled($form_id)) {
                    ?>
                                    <option value='spam'><?php 
                    _e("Spam", "gravityforms");
                    ?>
</option>
                                    <?php 
                }
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                    <option value='trash'><?php 
                    _e("Trash", "gravityforms");
                    ?>
</option>
                                    <?php 
                }
        }
        ?>
                        </select>
                        <?php 
        $apply_button = '<input type="submit" class="button" value="' . __("Apply", "gravityforms") . '" onclick="return handleBulkApply(\'bulk_action2\');" />';
        echo apply_filters("gform_entry_apply_button", $apply_button);
        ?>
                    </div>

                    <?php 
        echo self::display_paging_links("footer", $page_links, $first_item_index, $page_size, $lead_count);
        ?>

                    <div class="clear"></div>
                </div>

            </form>
        </div>
        <?php 
    }
예제 #25
0
 public static function start_export($form)
 {
     $form_id = $form['id'];
     $fields = $_POST['export_field'];
     $start_date = empty($_POST['export_date_start']) ? '' : self::get_gmt_date($_POST['export_date_start'] . ' 00:00:00');
     $end_date = empty($_POST['export_date_end']) ? '' : self::get_gmt_date($_POST['export_date_end'] . ' 23:59:59');
     $search_criteria['status'] = 'active';
     $search_criteria['field_filters'] = GFCommon::get_field_filters_from_post($form);
     if (!empty($start_date)) {
         $search_criteria['start_date'] = $start_date;
     }
     if (!empty($end_date)) {
         $search_criteria['end_date'] = $end_date;
     }
     $sorting = array('key' => 'date_created', 'direction' => 'DESC', 'type' => 'info');
     GFCommon::log_debug("GFExport::start_export(): Start date: {$start_date}");
     GFCommon::log_debug("GFExport::start_export(): End date: {$end_date}");
     $form = self::add_default_export_fields($form);
     $entry_count = GFAPI::count_entries($form_id, $search_criteria);
     $page_size = 100;
     $offset = 0;
     //Adding BOM marker for UTF-8
     $lines = chr(239) . chr(187) . chr(191);
     // set the separater
     $separator = gf_apply_filters('gform_export_separator', $form_id, ',', $form_id);
     $field_rows = self::get_field_row_count($form, $fields, $entry_count);
     //writing header
     $headers = array();
     foreach ($fields as $field_id) {
         $field = RGFormsModel::get_field($form, $field_id);
         $label = gf_apply_filters('gform_entries_field_header_pre_export', array($form_id, $field_id), GFCommon::get_label($field, $field_id), $form, $field);
         $value = str_replace('"', '""', $label);
         GFCommon::log_debug("GFExport::start_export(): Header for field ID {$field_id}: {$value}");
         $headers[$field_id] = $value;
         $subrow_count = isset($field_rows[$field_id]) ? intval($field_rows[$field_id]) : 0;
         if ($subrow_count == 0) {
             $lines .= '"' . $value . '"' . $separator;
         } else {
             for ($i = 1; $i <= $subrow_count; $i++) {
                 $lines .= '"' . $value . ' ' . $i . '"' . $separator;
             }
         }
         GFCommon::log_debug("GFExport::start_export(): Lines: {$lines}");
     }
     $lines = substr($lines, 0, strlen($lines) - 1) . "\n";
     //paging through results for memory issues
     while ($entry_count > 0) {
         $paging = array('offset' => $offset, 'page_size' => $page_size);
         $leads = GFAPI::get_entries($form_id, $search_criteria, $sorting, $paging);
         $leads = gf_apply_filters('gform_leads_before_export', $form_id, $leads, $form, $paging);
         foreach ($leads as $lead) {
             foreach ($fields as $field_id) {
                 switch ($field_id) {
                     case 'date_created':
                         $lead_gmt_time = mysql2date('G', $lead['date_created']);
                         $lead_local_time = GFCommon::get_local_timestamp($lead_gmt_time);
                         $value = date_i18n('Y-m-d H:i:s', $lead_local_time, true);
                         break;
                     default:
                         $field = RGFormsModel::get_field($form, $field_id);
                         $value = is_object($field) ? $field->get_value_export($lead, $field_id, false, true) : rgar($lead, $field_id);
                         $value = apply_filters('gform_export_field_value', $value, $form_id, $field_id, $lead);
                         GFCommon::log_debug("GFExport::start_export(): Value for field ID {$field_id}: {$value}");
                         break;
                 }
                 if (isset($field_rows[$field_id])) {
                     $list = empty($value) ? array() : unserialize($value);
                     foreach ($list as $row) {
                         $row_values = array_values($row);
                         $row_str = implode('|', $row_values);
                         $lines .= '"' . str_replace('"', '""', $row_str) . '"' . $separator;
                     }
                     //filling missing subrow columns (if any)
                     $missing_count = intval($field_rows[$field_id]) - count($list);
                     for ($i = 0; $i < $missing_count; $i++) {
                         $lines .= '""' . $separator;
                     }
                 } else {
                     $value = maybe_unserialize($value);
                     if (is_array($value)) {
                         $value = implode('|', $value);
                     }
                     $lines .= '"' . str_replace('"', '""', $value) . '"' . $separator;
                 }
             }
             $lines = substr($lines, 0, strlen($lines) - 1);
             GFCommon::log_debug("GFExport::start_export(): Lines: {$lines}");
             $lines .= "\n";
         }
         $offset += $page_size;
         $entry_count -= $page_size;
         if (!seems_utf8($lines)) {
             $lines = utf8_encode($lines);
         }
         $lines = apply_filters('gform_export_lines', $lines);
         echo $lines;
         $lines = '';
     }
     /**
      * Fires after exporting all the entries in form
      *
      * @param array $form The Form object to get the entries from
      * @param string $start_date The start date for when the export of entries should take place
      * @param string $end_date The end date for when the export of entries should stop
      * @param array $fields The specified fields where the entries should be exported from
      */
     do_action('gform_post_export_entries', $form, $start_date, $end_date, $fields);
 }
예제 #26
0
 public static function send_admin_notification($form, $lead, $override_options = false)
 {
     $form_id = $form["id"];
     //handling admin notification email
     $subject = GFCommon::replace_variables(rgget("subject", $form["notification"]), $form, $lead, false, false);
     $message_format = apply_filters("gform_notification_format_{$form["id"]}", apply_filters("gform_notification_format", "html", "admin", $form, $lead), "admin", $form, $lead);
     $message = GFCommon::replace_variables(rgget("message", $form["notification"]), $form, $lead, false, false, !rgget("disableAutoformat", $form["notification"]), $message_format);
     $message = do_shortcode($message);
     $version_info = self::get_version_info();
     $is_expired = !rgempty("expiration_time", $version_info) && $version_info["expiration_time"] < time();
     if (!$version_info["is_valid_key"] && $is_expired) {
         $message .= "<br/><br/>Your Gravity Forms License Key has expired. In order to continue receiving support and software updates you must renew your license key. You can do so by following the renewal instructions on the Gravity Forms Settings page in your WordPress Dashboard or by <a href='http://www.gravityhelp.com/renew-license/?key=" . self::get_key() . "'>clicking here</a>.";
     }
     $from = rgempty("fromField", $form["notification"]) ? rgget("from", $form["notification"]) : rgget($form["notification"]["fromField"], $lead);
     if (rgempty("fromNameField", $form["notification"])) {
         $from_name = rgget("fromName", $form["notification"]);
     } else {
         $field = RGFormsModel::get_field($form, rgget("fromNameField", $form["notification"]));
         $value = RGFormsModel::get_lead_field_value($lead, $field);
         $from_name = GFCommon::get_lead_field_display($field, $value);
     }
     $replyTo = rgempty("replyToField", $form["notification"]) ? rgget("replyTo", $form["notification"]) : rgget($form["notification"]["replyToField"], $lead);
     if (rgempty("routing", $form["notification"])) {
         $email_to = rgget("to", $form["notification"]);
     } else {
         $email_to = array();
         foreach ($form["notification"]["routing"] as $routing) {
             $source_field = RGFormsModel::get_field($form, $routing["fieldId"]);
             $field_value = RGFormsModel::get_lead_field_value($lead, $source_field);
             $is_value_match = RGFormsModel::is_value_match($field_value, $routing["value"], $routing["operator"], $source_field) && !RGFormsModel::is_field_hidden($form, $source_field, array(), $lead);
             if ($is_value_match) {
                 $email_to[] = $routing["email"];
             }
         }
         $email_to = join(",", $email_to);
     }
     //Running through variable replacement
     $email_to = GFCommon::replace_variables($email_to, $form, $lead, false, false);
     $from = GFCommon::replace_variables($from, $form, $lead, false, false);
     $bcc = GFCommon::replace_variables(rgget("bcc", $form["notification"]), $form, $lead, false, false);
     $reply_to = GFCommon::replace_variables($replyTo, $form, $lead, false, false);
     $from_name = GFCommon::replace_variables($from_name, $form, $lead, false, false);
     //Filters the admin notification email to address. Allows users to change email address before notification is sent
     $to = apply_filters("gform_notification_email_{$form_id}", apply_filters("gform_notification_email", $email_to, $lead), $lead);
     // override default values if override options provided
     if ($override_options && is_array($override_options)) {
         foreach ($override_options as $override_key => $override_value) {
             ${$override_key} = $override_value;
         }
     }
     $attachments = apply_filters("gform_admin_notification_attachments_{$form_id}", apply_filters("gform_admin_notification_attachments", array(), $lead, $form), $lead, $form);
     self::send_email($from, $to, $bcc, $replyTo, $subject, $message, $from_name, $message_format, $attachments);
     return compact("to", "from", "bcc", "replyTo", "subject", "message", "from_name", "message_format", "attachments");
 }
예제 #27
0
    public static function lead_detail_page()
    {
        global $current_user;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $form = RGFormsModel::get_form_meta(absint($_GET['id']));
        $form_id = absint($form['id']);
        $form = apply_filters('gform_admin_pre_render_' . $form_id, apply_filters('gform_admin_pre_render', $form));
        $lead_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('dir') ? rgget('dir') : 'DESC';
        $sort_field = empty($_GET['sort']) ? 0 : $_GET['sort'];
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta['type'] == 'number';
        $star = $filter == 'star' ? 1 : null;
        $read = $filter == 'unread' ? 0 : null;
        $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');
        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';
                }
            }
        }
        $paging = array('offset' => $position, 'page_size' => 1);
        if (!empty($sort_field)) {
            $sorting = array('key' => $_GET['sort'], 'direction' => $sort_direction, 'is_numeric' => $is_numeric);
        } else {
            $sorting = array();
        }
        $total_count = 0;
        $leads = GFAPI::get_entries($form['id'], $search_criteria, $sorting, $paging, $total_count);
        $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
        $next_pos = !rgblank($position) && $position < $total_count - 1 ? $position + 1 : false;
        // 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;
            }
        }
        if (!$lead_id) {
            $lead = !empty($leads) ? $leads[0] : false;
        } else {
            $lead = GFAPI::get_entry($lead_id);
        }
        if (!$lead) {
            esc_html_e("Oops! We couldn't find your entry. Please try again", 'gravityforms');
            return;
        }
        RGFormsModel::update_lead_property($lead['id'], 'is_read', 1);
        switch (RGForms::post('action')) {
            case 'update':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                //Loading files that have been uploaded to temp folder
                $files = GFCommon::json_decode(stripslashes(RGForms::post('gform_uploaded_files')));
                if (!is_array($files)) {
                    $files = array();
                }
                GFFormsModel::$uploaded_files[$form_id] = $files;
                GFFormsModel::save_lead($form, $lead);
                do_action('gform_after_update_entry', $form, $lead['id']);
                do_action("gform_after_update_entry_{$form['id']}", $form, $lead['id']);
                $lead = RGFormsModel::get_lead($lead['id']);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                break;
            case 'add_note':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::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.');
                    }
                    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);
                RGFormsModel::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')) {
                        die(esc_html__("You don't have adequate permission to delete notes.", 'gravityforms'));
                    }
                    RGFormsModel::delete_notes($_POST['note']);
                }
                break;
            case 'trash':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'trash');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'restore':
            case 'unspam':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'active');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'spam':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'spam');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'delete':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                if (!GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    die(esc_html__("You don't have adequate permission to delete entries.", 'gravityforms'));
                }
                RGFormsModel::delete_lead($lead['id']);
                ?>
				<script type="text/javascript">
					document.location.href = '<?php 
                echo 'admin.php?page=gf_entries&view=entries&id=' . absint($form['id']);
                ?>
';
				</script>
				<?php 
                break;
        }
        $mode = empty($_POST['screen_mode']) ? 'view' : $_POST['screen_mode'];
        $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || isset($_GET['gform_debug']) ? '' : '.min';
        ?>
		<link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin<?php 
        echo $min;
        ?>
.css" />
		<script type="text/javascript">

			jQuery(document).ready(function () {
				toggleNotificationOverride(true);
				jQuery('#gform_update_button').prop('disabled', false);
			});

			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');
				}
			}

			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_container');
					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_container");
						} else {
							displayMessage(<?php 
        echo json_encode(esc_html__('Notifications were resent successfully.', 'gravityforms'));
        ?>
, "updated", "#notifications_container" );

							// 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 ' + 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>

		<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'));
        ?>
" />

		<div class="wrap gf_entry_wrap">
		<h2 class="gf_admin_page_title">
			<span><?php 
        echo esc_html__('Entry #', 'gravityforms') . absint($lead['id']);
        ?>
</span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php 
        echo absint($form['id']);
        ?>
</span><span class='gf_admin_page_formname'><?php 
        esc_html_e('Form Name', 'gravityforms');
        ?>
: <?php 
        echo esc_html($form['title']);
        $gf_entry_locking = new GFEntryLocking();
        $gf_entry_locking->lock_info($lead_id);
        ?>
</span></span></h2>

		<?php 
        if (isset($_GET['pos'])) {
            ?>
			<div class="gf_entry_detail_pagination">
				<ul>
					<li class="gf_entry_count">
						<span>entry <strong><?php 
            echo $position + 1;
            ?>
</strong> of <strong><?php 
            echo $total_count;
            ?>
</strong></span>
					</li>
					<li class="gf_entry_prev gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($prev_pos, 'Previous Entry', 'gf_entry_prev_link', 'fa fa-arrow-circle-o-left');
            ?>
</li>
					<li class="gf_entry_next gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($next_pos, 'Next Entry', 'gf_entry_next_link', 'fa fa-arrow-circle-o-right');
            ?>
</li>
				</ul>
			</div>
		<?php 
        }
        ?>

		<?php 
        RGForms::top_toolbar();
        ?>

		<div id="poststuff" class="metabox-holder has-right-sidebar">
		<div id="side-info-column" class="inner-sidebar">
		<?php 
        do_action('gform_entry_detail_sidebar_before', $form, $lead);
        ?>

		<!-- INFO BOX -->
		<div id="submitdiv" class="stuffbox">
			<h3 class="hndle" style="cursor:default;">
				<span><?php 
        esc_html_e('Entry', 'gravityforms');
        ?>
</span>
			</h3>

			<div class="inside">
				<div id="submitcomment" class="submitbox">
					<div id="minor-publishing" style="padding:10px;">
						<?php 
        esc_html_e('Entry Id', 'gravityforms');
        ?>
: <?php 
        echo absint($lead['id']);
        ?>
<br /><br />
						<?php 
        esc_html_e('Submitted on', 'gravityforms');
        ?>
: <?php 
        echo esc_html(GFCommon::format_date($lead['date_created'], false, 'Y/m/d'));
        ?>
						<br /><br />
						<?php 
        esc_html_e('User IP', 'gravityforms');
        ?>
: <?php 
        echo esc_html($lead['ip']);
        ?>
						<br /><br />
						<?php 
        if (!empty($lead['created_by']) && ($usermeta = get_userdata($lead['created_by']))) {
            ?>
							<?php 
            esc_html_e('User', 'gravityforms');
            ?>
:
							<a href="user-edit.php?user_id=<?php 
            echo absint($lead['created_by']);
            ?>
" alt="<?php 
            esc_attr_e('View user profile', 'gravityforms');
            ?>
" title="<?php 
            esc_attr_e('View user profile', 'gravityforms');
            ?>
"><?php 
            echo esc_html($usermeta->user_login);
            ?>
</a>
							<br /><br />
						<?php 
        }
        ?>

						<?php 
        esc_html_e('Embed Url', 'gravityforms');
        ?>
:
						<a href="<?php 
        echo esc_url($lead['source_url']);
        ?>
" target="_blank" alt="<?php 
        echo esc_attr($lead['source_url']);
        ?>
" title="<?php 
        echo esc_attr($lead['source_url']);
        ?>
">.../<?php 
        echo esc_html(GFCommon::truncate_url($lead['source_url']));
        ?>
</a>
						<br /><br />
						<?php 
        if (!empty($lead['post_id'])) {
            $post = get_post($lead['post_id']);
            ?>
							<?php 
            esc_html_e('Edit Post', 'gravityforms');
            ?>
:
							<a href="post.php?action=edit&post=<?php 
            echo absint($post->ID);
            ?>
" alt="<?php 
            esc_attr_e('Click to edit post', 'gravityforms');
            ?>
" title="<?php 
            esc_attr_e('Click to edit post', 'gravityforms');
            ?>
"><?php 
            echo esc_html($post->post_title);
            ?>
</a>
							<br /><br />
						<?php 
        }
        if (do_action('gform_enable_entry_info_payment_details', true, $lead)) {
            if (!empty($lead['payment_status'])) {
                echo $lead['transaction_type'] != 2 ? esc_html__('Payment Status', 'gravityforms') : esc_html__('Subscription Status', 'gravityforms');
                ?>
:
								<span id="gform_payment_status"><?php 
                echo apply_filters('gform_payment_status', $lead['payment_status'], $form, $lead);
                ?>
</span>
								<br /><br />
								<?php 
                if (!empty($lead['payment_date'])) {
                    echo $lead['transaction_type'] != 2 ? esc_html__('Payment Date', 'gravityforms') : esc_html__('Start Date', 'gravityforms');
                    ?>
: <?php 
                    echo GFCommon::format_date($lead['payment_date'], false, 'Y/m/d', $lead['transaction_type'] != 2);
                    ?>
									<br /><br />
								<?php 
                }
                if (!empty($lead['transaction_id'])) {
                    echo $lead['transaction_type'] != 2 ? esc_html__('Transaction Id', 'gravityforms') : esc_html__('Subscriber Id', 'gravityforms');
                    ?>
: <?php 
                    echo esc_html($lead['transaction_id']);
                    ?>
									<br /><br />
								<?php 
                }
                if (!rgblank($lead['payment_amount'])) {
                    echo $lead['transaction_type'] != 2 ? esc_html__('Payment Amount', 'gravityforms') : esc_html__('Subscription Amount', 'gravityforms');
                    ?>
: <?php 
                    echo GFCommon::to_money($lead['payment_amount'], $lead['currency']);
                    ?>
									<br /><br />
								<?php 
                }
            }
        }
        do_action('gform_entry_info', $form['id'], $lead);
        ?>
					</div>
					<div id="major-publishing-actions">
						<div id="delete-action">
							<?php 
        switch ($lead['status']) {
            case 'spam':
                if (GFCommon::spam_enabled($form['id'])) {
                    ?>
										<a onclick="jQuery('#action').val('unspam'); jQuery('#entry_form').submit()" href="#"><?php 
                    esc_html_e('Not Spam', 'gravityforms');
                    ?>
</a>
										<?php 
                    echo GFCommon::current_user_can_any('gravityforms_delete_entries') ? '|' : '';
                }
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
										<a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    echo esc_js(__("You are about to delete this entry. 'Cancel' to stop, 'OK' to delete.", 'gravityforms'));
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    esc_html_e('Delete Permanently', 'gravityforms');
                    ?>
</a>
									<?php 
                }
                break;
            case 'trash':
                ?>
									<a onclick="jQuery('#action').val('restore'); jQuery('#entry_form').submit()" href="#"><?php 
                esc_html_e('Restore', 'gravityforms');
                ?>
</a>
									<?php 
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
										|
										<a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    echo esc_js(__("You are about to delete this entry. 'Cancel' to stop, 'OK' to delete.", 'gravityforms'));
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    esc_html_e('Delete Permanently', 'gravityforms');
                    ?>
</a>
									<?php 
                }
                break;
            default:
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
										<a class="submitdelete deletion" onclick="jQuery('#action').val('trash'); jQuery('#entry_form').submit()" href="#"><?php 
                    esc_html_e('Move to Trash', 'gravityforms');
                    ?>
</a>
										<?php 
                    echo GFCommon::spam_enabled($form['id']) ? '|' : '';
                }
                if (GFCommon::spam_enabled($form['id'])) {
                    ?>
										<a class="submitdelete deletion" onclick="jQuery('#action').val('spam'); jQuery('#entry_form').submit()" href="#"><?php 
                    esc_html_e('Mark as Spam', 'gravityforms');
                    ?>
</a>
									<?php 
                }
        }
        ?>
						</div>
						<div id="publishing-action">
							<?php 
        if (GFCommon::current_user_can_any('gravityforms_edit_entries') && $lead['status'] != 'trash') {
            $button_text = $mode == 'view' ? __('Edit', 'gravityforms') : __('Update', 'gravityforms');
            $disabled = $mode == 'view' ? '' : ' disabled="disabled" ';
            $update_button_id = $mode == 'view' ? 'gform_edit_button' : 'gform_update_button';
            $button_click = $mode == 'view' ? "jQuery('#screen_mode').val('edit');" : "jQuery('#action').val('update'); jQuery('#screen_mode').val('view');";
            $update_button = '<input id="' . $update_button_id . '" ' . $disabled . ' class="button button-large button-primary" type="submit" tabindex="4" value="' . esc_attr($button_text) . '" name="save" onclick="' . $button_click . '"/>';
            echo apply_filters('gform_entrydetail_update_button', $update_button);
            if ($mode == 'edit') {
                echo '&nbsp;&nbsp;<input class="button button-large" type="submit" tabindex="5" value="' . esc_attr__('Cancel', 'gravityforms') . '" name="cancel" onclick="jQuery(\'#screen_mode\').val(\'view\');"/>';
            }
        }
        ?>
						</div>
						<div class="clear"></div>
					</div>
				</div>
			</div>
		</div>

		<?php 
        if (!empty($lead['payment_status']) && !apply_filters('gform_enable_entry_info_payment_details', true, $lead)) {
            self::payment_details_box($lead, $form);
        }
        ?>

		<?php 
        do_action('gform_entry_detail_sidebar_middle', $form, $lead);
        ?>

		<?php 
        if (GFCommon::current_user_can_any('gravityforms_edit_entry_notes')) {
            ?>
			<!-- start notifications -->
			<div class="postbox" id="notifications_container">
				<h3 class="hndle" style="cursor:default;">
					<span><?php 
            esc_html_e('Notifications', 'gravityforms');
            ?>
</span>
				</h3>

				<div class="inside">
					<div class="message" style="display:none;padding:10px;"></div>
					<div>
						<?php 
            $notifications = GFCommon::get_notifications('resend_notifications', $form);
            if (!is_array($notifications) || count($form['notifications']) <= 0) {
                ?>
							<p class="description"><?php 
                esc_html_e('You cannot resend notifications for this entry because this form does not currently have any notifications configured.', 'gravityforms');
                ?>
</p>

							<a href="<?php 
                echo admin_url("admin.php?page=gf_edit_forms&view=settings&subview=notification&id={$form_id}");
                ?>
" class="button"><?php 
                esc_html_e('Configure Notifications', 'gravityforms');
                ?>
</a>
						<?php 
            } else {
                foreach ($notifications as $notification) {
                    ?>
								<input type="checkbox" class="gform_notifications" value="<?php 
                    echo esc_attr($notification['id']);
                    ?>
" id="notification_<?php 
                    echo esc_attr($notification['id']);
                    ?>
" onclick="toggleNotificationOverride();" />
								<label for="notification_<?php 
                    echo esc_attr($notification['id']);
                    ?>
"><?php 
                    echo esc_html($notification['name']);
                    ?>
</label>
								<br /><br />
							<?php 
                }
                ?>

							<div id="notifications_override_settings" style="display:none;">

								<p class="description" style="padding-top:0; margin-top:0; width:99%;">You may override the default notification settings
									by entering a comma delimited list of emails to which the selected notifications should be sent.</p>
								<label for="notification_override_email"><?php 
                esc_html_e('Send To', 'gravityforms');
                ?>
 <?php 
                gform_tooltip('notification_override_email');
                ?>
</label><br />
								<input type="text" name="notification_override_email" id="notification_override_email" style="width:99%;" />
								<br /><br />

							</div>

							<input type="button" name="notification_resend" value="<?php 
                esc_attr_e('Resend Notifications', 'gravityforms');
                ?>
" class="button" style="" onclick="ResendNotifications();" />
							<span id="please_wait_container" style="display:none; margin-left: 5px;">
								<i class='gficon-gravityforms-spinner-icon gficon-spin'></i> <?php 
                esc_html_e('Resending...', 'gravityforms');
                ?>
                            </span>
						<?php 
            }
            ?>

					</div>
				</div>
			</div>
			<!-- / end notifications -->
		<?php 
        }
        ?>

		<!-- begin print button -->
		<div class="detail-view-print">
			<a href="javascript:;" onclick="var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=print-entry&fid=<?php 
        echo absint($form['id']);
        ?>
&lid=<?php 
        echo absint($lead['id']);
        ?>
' + notes_qs; window.open (url,'printwindow');" class="button"><?php 
        esc_html_e('Print', 'gravityforms');
        ?>
</a>
			<?php 
        if (GFCommon::current_user_can_any('gravityforms_view_entry_notes')) {
            ?>
				<input type="checkbox" name="print_notes" value="print_notes" checked="checked" id="gform_print_notes" />
				<label for="print_notes"><?php 
            esc_html_e('include notes', 'gravityforms');
            ?>
</label>
			<?php 
        }
        ?>
		</div>
		<!-- end print button -->
		<?php 
        do_action('gform_entry_detail_sidebar_after', $form, $lead);
        ?>
		</div>

		<div id="post-body" class="has-sidebar">
			<div id="post-body-content" class="has-sidebar-content">
				<?php 
        do_action('gform_entry_detail_content_before', $form, $lead);
        if ($mode == 'view') {
            self::lead_detail_grid($form, $lead, true);
        } else {
            self::lead_detail_edit($form, $lead);
        }
        do_action('gform_entry_detail', $form, $lead);
        if (GFCommon::current_user_can_any('gravityforms_view_entry_notes')) {
            ?>
					<div class="postbox">
						<h3>
							<label for="name"><?php 
            esc_html_e('Notes', 'gravityforms');
            ?>
</label>
						</h3>

						<form method="post">
							<?php 
            wp_nonce_field('gforms_update_note', 'gforms_update_note');
            ?>
							<div class="inside">
								<?php 
            $notes = RGFormsModel::get_lead_notes($lead['id']);
            //getting email values
            $email_fields = GFCommon::get_email_fields($form);
            $emails = array();
            foreach ($email_fields as $email_field) {
                if (!empty($lead[$email_field->id])) {
                    $emails[] = $lead[$email_field->id];
                }
            }
            //displaying notes grid
            $subject = '';
            self::notes_grid($notes, true, $emails, $subject);
            ?>
							</div>
						</form>
					</div>
				<?php 
        }
        do_action('gform_entry_detail_content_after', $form, $lead);
        ?>
			</div>
		</div>
		</div>
		</div>
		</form>
		<?php 
        if (rgpost('action') == 'update') {
            ?>
			<div class="updated fade" style="padding:6px;">
				<?php 
            esc_html_e('Entry Updated.', 'gravityforms');
            ?>
			</div>
		<?php 
        }
    }
 private static function get_field_values($i, $form, $field_id, $selected_value, $max_field_length = 16)
 {
     if (empty($field_id)) {
         $field_id = self::get_first_routing_field($form);
     }
     if (empty($field_id)) {
         return '';
     }
     $field = RGFormsModel::get_field($form, $field_id);
     $is_any_selected = false;
     $str = '';
     if (!$field) {
         return '';
     }
     if ($field->type == 'post_category' && $field->displayAllCategories == true) {
         $str .= wp_dropdown_categories(array('class' => 'gfield_routing_select gfield_category_dropdown gfield_routing_value_dropdown', 'orderby' => 'name', 'id' => 'routing_value_' . $i, 'selected' => $selected_value, 'hierarchical' => true, 'hide_empty' => 0, 'echo' => false));
     } elseif ($field->choices) {
         $str .= "<select id='routing_value_" . $i . "' class='gfield_routing_select gfield_routing_value_dropdown'>";
         foreach ($field->choices as $choice) {
             $is_selected = $choice['value'] == $selected_value;
             $selected = $is_selected ? "selected='selected'" : '';
             if ($is_selected) {
                 $is_any_selected = true;
             }
             $str .= "<option value='" . esc_attr($choice['value']) . "' " . $selected . '>' . $choice['text'] . '</option>';
         }
         //adding current selected field value to the list
         if (!$is_any_selected && !empty($selected_value)) {
             $str .= "<option value='" . esc_attr($selected_value) . "' selected='selected'>" . $selected_value . '</option>';
         }
         $str .= '</select>';
     } else {
         //create a text field for fields that don't have choices (i.e text, textarea, number, email, etc...)
         $str = "<input type='text' placeholder='" . esc_html__('Enter value', 'gravityforms') . "' class='gfield_routing_select' id='routing_value_" . $i . "' value='" . esc_attr($selected_value) . "' onchange='SetRouting(" . $i . ");' onkeyup='SetRouting(" . $i . ");'>";
     }
     return $str;
 }
예제 #29
0
 public static function ajax_get_more_results()
 {
     $form_id = rgpost('form_id');
     $field_id = rgpost('field_id');
     $offset = rgpost('offset');
     $search_criteria = rgpost('search_criteria');
     if (empty($search_criteria)) {
         $search_criteria = array();
     }
     $page_size = 10;
     $form = RGFormsModel::get_form_meta($form_id);
     $form_id = $form['id'];
     $field = RGFormsModel::get_field($form, $field_id);
     $more_remaining = false;
     $html = self::get_default_field_results($form_id, $field, $search_criteria, $offset, $page_size, $more_remaining);
     $response = array();
     $response['more_remaining'] = $more_remaining;
     $response['html'] = $html;
     $response['offset'] = $offset;
     echo json_encode($response);
     die;
 }
예제 #30
0
 public static function build_lead_array($results, $use_long_values = false)
 {
     $leads = array();
     $lead = array();
     $form_id = 0;
     if (is_array($results) && sizeof($results) > 0) {
         $form_id = $results[0]->form_id;
         $lead = array("id" => $results[0]->id, "form_id" => $results[0]->form_id, "date_created" => $results[0]->date_created, "is_starred" => intval($results[0]->is_starred), "is_read" => intval($results[0]->is_read), "ip" => $results[0]->ip, "source_url" => $results[0]->source_url, "post_id" => $results[0]->post_id, "currency" => $results[0]->currency, "payment_status" => $results[0]->payment_status, "payment_date" => $results[0]->payment_date, "transaction_id" => $results[0]->transaction_id, "payment_amount" => $results[0]->payment_amount, "is_fulfilled" => $results[0]->is_fulfilled, "created_by" => $results[0]->created_by, "transaction_type" => $results[0]->transaction_type, "user_agent" => $results[0]->user_agent, "status" => $results[0]->status);
         $form = RGFormsModel::get_form_meta($form_id);
         $prev_lead_id = 0;
         foreach ($results as $result) {
             if ($prev_lead_id != $result->id && $prev_lead_id > 0) {
                 array_push($leads, $lead);
                 $lead = array("id" => $result->id, "form_id" => $result->form_id, "date_created" => $result->date_created, "is_starred" => intval($result->is_starred), "is_read" => intval($result->is_read), "ip" => $result->ip, "source_url" => $result->source_url, "post_id" => $result->post_id, "currency" => $result->currency, "payment_status" => $result->payment_status, "payment_date" => $result->payment_date, "transaction_id" => $result->transaction_id, "payment_amount" => $result->payment_amount, "is_fulfilled" => $result->is_fulfilled, "created_by" => $result->created_by, "transaction_type" => $result->transaction_type, "user_agent" => $result->user_agent, "status" => $result->status);
             }
             $field_value = $result->value;
             //using long values if specified
             if ($use_long_values && strlen($field_value) >= GFORMS_MAX_FIELD_LENGTH - 10) {
                 $field = RGFormsModel::get_field($form, $result->field_number);
                 $long_text = RGFormsModel::get_field_value_long($lead, $result->field_number, $form, false);
                 $field_value = !empty($long_text) ? $long_text : $field_value;
             }
             $lead[$result->field_number] = $field_value;
             $prev_lead_id = $result->id;
         }
     }
     //adding last lead.
     if (sizeof($lead) > 0) {
         array_push($leads, $lead);
     }
     //running entry through gform_get_field_value filter
     foreach ($leads as &$lead) {
         foreach ($form["fields"] as $field) {
             if (isset($field["inputs"]) && is_array($field["inputs"])) {
                 foreach ($field["inputs"] as $input) {
                     $lead[(string) $input["id"]] = apply_filters("gform_get_input_value", rgar($lead, (string) $input["id"]), $lead, $field, $input["id"]);
                 }
             } else {
                 $lead[$field["id"]] = apply_filters("gform_get_input_value", rgar($lead, (string) $field["id"]), $lead, $field, "");
             }
         }
     }
     //adding custom entry properties
     $entry_ids = array();
     foreach ($leads as $l) {
         $entry_ids[] = $l["id"];
     }
     $entry_meta = GFFormsModel::get_entry_meta($form_id);
     $meta_keys = array_keys($entry_meta);
     $entry_meta_data_rows = gform_get_meta_values_for_entries($entry_ids, $meta_keys);
     foreach ($leads as &$lead) {
         foreach ($entry_meta_data_rows as $entry_meta_data_row) {
             if ($entry_meta_data_row->lead_id == $lead["id"]) {
                 foreach ($meta_keys as $meta_key) {
                     $lead[$meta_key] = $entry_meta_data_row->{$meta_key};
                 }
             }
         }
     }
     return $leads;
 }