コード例 #1
0
<?php

// Get Time from Timesheets
// Return more than 30 entries (the default)
$the_form = 4;
$all_entries = RGFormsModel::get_leads($the_form, 0, 'ASC', '', 0, 999, NULL, NULL, FALSE, NULL, NULL, 'active', FALSE);
?>


<div class="medium caps">
	<a href="<?php 
echo get_bloginfo('wpurl') . '/?gf_pdf=1&fid=' . $_GET['fid'] . '&lid=' . $_GET['lid'] . '&template=sg360.php';
?>
" target="_blank">
		<span class="purple"><?php 
echo $lead[27];
?>
: <?php 
echo $lead[37];
?>
</span>
	</a>
</div>

<div class="left half">
<span class="medium">Task:
<span class="red"> 
<?php 
$f_id = 1;
// Form ID
$f_ld = $_GET['task'];
コード例 #2
0
        public function rtlib_importer()
        {
            $flag = true;
            if ('csv' == $_REQUEST['type']) {
                if (isset($_FILES['map_upload']) && 0 == $_FILES['map_upload']['error']) {
                    if ('text/csv' != $_FILES['map_upload']['type']) {
                        echo "<div class='error'>" . esc_html(__('Please upload a CSV file only!')) . '</div>';
                        return;
                    }
                    //Upload the file to 'Uploads' folder
                    $file = $_FILES['map_upload'];
                    $upload = wp_handle_upload($file, array('test_form' => false));
                    if (isset($upload['error'])) {
                        ?>
						<div id="map_message" class="error"><p><?php 
                        echo esc_html($upload['error']);
                        ?>
  </p>
						</div> <?php 
                        return false;
                    }
                    if (!$flag) {
                        return;
                    }
                    $csv = new parseCSV();
                    $csv->auto($upload['file']);
                    $data = $csv->data[rand(1, count($csv->data) - 1)];
                    ?>
					<div id="map_message" class="updated map_message"><p>
							<?php 
                    _e('File uploaded:');
                    ?>
							<strong><?php 
                    echo esc_html($_FILES['map_upload']['name']);
                    ?>
</strong>
							<?php 
                    _e('Total Rows:');
                    ?>
							<strong><?php 
                    echo esc_html(count($csv->data));
                    ?>
</strong></p>
					</div>

					<form method="post" action="" id="rtlibMappingForm" name="rtlibMappingForm">
					<input type="hidden" name="mapSource" id="mapSource"
					       value="<?php 
                    echo esc_attr($upload['file']);
                    ?>
"/>
					<input type="hidden" name="mapSourceType" id="mapSourceType"
					       value="<?php 
                    echo esc_attr($_REQUEST['type']);
                    ?>
"/>
					<input type="hidden" name="mapEntryCount" id="mapEntryCount"
					       value="<?php 
                    echo esc_attr(count($csv->data));
                    ?>
"/>
					<table class="wp-list-table widefat fixed" id="map_mapping_table">
					<thead>
					<tr>
						<th scope="row"><?php 
                    _e('Column Name');
                    ?>
</th>
						<th scope="row"><?php 
                    _e('Field Name');
                    ?>
</th>
						<th scope="row"><?php 
                    _e('Default Value');
                    ?>
</th>
						<th scope="row"><a href="#dummyDataPrev"> << </a><?php 
                    _e('Sample');
                    ?>
 <a
								href="#dummyDataNext"> >> </a></th>
					</tr>
					</thead>
					<tbody style="background: white;">
					<?php 
                    foreach ($csv->titles as $value) {
                        ?>
						<tr>
							<td><?php 
                        echo esc_html(ucfirst($value));
                        ?>
</td>
							<td>
								<?php 
                        $fieldname = str_replace(' ', '-s-', $value);
                        $form_fields = '<select data-og="' . $fieldname . '" name="field-' . $fieldname . '"  id="field-' . $fieldname . '" class="map_form_fields map_form_fixed_fields">';
                        $form_fields .= '<option value="">Choose a field or Skip it</option>';
                        foreach ($this->field_array as $key => $lfield) {
                            /*if ($lfield["type"] == 'defined')
                            		continue;*/
                            $form_fields .= '<option value="' . $lfield['slug'] . '">' . ucfirst($lfield['display_name']) . '</option>';
                        }
                        //$form_fields .= '<option value="ticketmeta">Other Field</option>';
                        $form_fields .= '</select>';
                        echo balanceTags($form_fields);
                        ?>
							</td>
							<td></td>
							<td class='rtlib-importer-dummy-data'
							    data-field-name="<?php 
                        echo esc_attr($value);
                        ?>
"><?php 
                        echo esc_html($data[$value]);
                        ?>
</td>
						</tr>
					<?php 
                    }
                    ?>
					</tbody>

					<?php 
                } else {
                    echo "<div class='error'><p>" . esc_html(__('Please Select File')) . '</p></div>';
                    return false;
                }
            } else {
                $form_id = intval($_REQUEST['mapSource']);
                $post_type = $_REQUEST['mapPostType'];
                $form_data = RGFormsModel::get_form_meta($form_id);
                $form_count = RGFormsModel::get_form_counts($form_id);
                if (!$form_data) {
                    ?>
					<div id="map_message" class="error">Invalid Form</div>
					<?php 
                    return false;
                }
                if (!$flag) {
                    return;
                }
                $style = '';
                if (empty($form_count['total'])) {
                    $style = 'style="display:none;"';
                }
                ?>

				<div id="map_message" class="updated map_message">
					<div>Form Selected : <strong><?php 
                echo esc_html($form_data['title']);
                ?>
</strong></div>
					<div>Total Entries:
						<strong><?php 
                echo esc_html($form_count['total']);
                ?>
</strong></div>
				</div>
				<?php 
                if (empty($form_data['fields'])) {
                    echo 'Form doesn\'t seem to have any fields!';
                    die;
                }
                ?>

				<form method="post" action="" id="rtlibMappingForm" name="rtlibMappingForm">
				<input type="hidden" name="mapSource" id="mapSource" value="<?php 
                echo esc_attr($form_id);
                ?>
"/>
				<input type="hidden" name="mapPostType" id="mapPostType" value="<?php 
                echo esc_attr($post_type);
                ?>
"/>
				<input type="hidden" name="mapSourceType" id="mapSourceType"
				       value="<?php 
                echo esc_attr($_REQUEST['type']);
                ?>
"/>
				<input type="hidden" name="mapEntryCount" id="mapEntryCount"
				       value="<?php 
                echo esc_attr($form_count['total']);
                ?>
"/>
				<table class="wp-list-table widefat fixed posts rt-importer" >
				<thead>
				<tr>
					<th scope="row"><?php 
                _e('Form field name');
                ?>
</th>
					<th scope="row"><?php 
                _e('Mapped with entity');
                ?>
</th>
					<th scope="row"><?php 
                _e('Default value (optional)');
                ?>
</th>
					<th scope="row"><a href="#dummyDataPrev"> << </a><?php 
                _e('Sample');
                ?>
<a
							href="#dummyDataNext"> >> </a></th>
				</tr>
				</thead>
				<tbody style="  ">
				<?php 
                $formdummydata = RGFormsModel::get_leads($form_id, 0, 'ASC', '', 0, 1);
                foreach ($form_data['fields'] as &$field) {
                    ?>
				<tr data-field-name="<?php 
                    echo esc_attr($field['label']);
                    ?>
">
					<td><?php 
                    echo esc_html(ucfirst($field['label']));
                    ?>
						<input type="hidden" value="<?php 
                    echo esc_attr(ucfirst($field['type']));
                    ?>
"/>
					</td>
					<td>
						<?php 
                    $form_fields = '<select name="field-' . $field['id'] . '"  id="field-' . $field['id'] . '" class="map_form_fields map_form_fixed_fields">';
                    $form_fields .= '<option value="">Choose a field or Skip it</option>';
                    foreach ($this->field_array[$post_type] as $key => $lfield) {
                        /*if (isset($lfield["type"]) &&  $lfield["type"]== 'defined')
                        		continue;*/
                        $form_fields .= '<option value="' . esc_attr($lfield['slug']) . '">' . esc_html(ucfirst($lfield['display_name'])) . '</option>';
                    }
                    //                                                /$form_fields .= '<option value="ticketmeta">Other Field</option>';
                    $form_fields .= '</select>';
                    echo balanceTags($form_fields);
                    ?>
					</td>
					<td></td>
					<td class='rtlib-importer-dummy-data'
					    data-field-name="<?php 
                    echo esc_attr($field['id']);
                    ?>
"><?php 
                    echo esc_html(isset($formdummydata[0][$field['id']]) ? $formdummydata[0][$field['id']] : '');
                    ?>
</td>
					</tr><?php 
                }
                ?>
				</tbody><?php 
            }
            ?>
			<tfoot>

			<tr>
				<td colspan="4">
					<hr>
					<strong>Other Settings</strong>
					<hr>
				</td>
			</tr>
			<?php 
            echo apply_filters('rtlib_add_mapping_field_ui', $post_type);
            /*
            * 	<!--<tr>
            							<td>
            								Date Format
            							</td>
            							<td>
            								<input type="text" value="" name="dateformat"/> <a
            									href='http://www.php.net/manual/en/datetime.createfromformat.php' target='_blank'>Reference</a>
            							</td>
            							<td><p class="description"> for example enter: l M d, Y H:i e : Friday Feb 13, 2015 10:01 UTC</p></td>
            							<td></td>
            						</tr>-->
            *
            *
            */
            ?>

			<tr>
				<td>
					Title Prefix
				</td>
				<td>
					<input type="text" value="" name="titleprefix"/>
				</td>
				<td></td>
				<td></td>
			</tr>
			<tr>
				<td colspan="4">
					<hr>
					<strong>Additional fields to map</strong>
					<hr>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
            $form_fields = '<select name="otherfield0" class="other-field">';
            $form_fields .= '<option value="">Select</option>';
            foreach ($this->field_array[$post_type] as $lfield) {
                if (isset($lfield['type']) && 'defined' == $lfield['type']) {
                    continue;
                }
                $form_fields .= '<option data-type="' . esc_attr($lfield['type']) . '" value="' . esc_attr($lfield['slug']) . '">' . esc_html(ucfirst($lfield['display_name'])) . '</option>';
            }
            $form_fields .= '</select>';
            echo balanceTags($form_fields);
            ?>
				</td>
				<td>
					<input type="text" value="" id="otherfield0"/>
				</td>
				<td></td>
			</tr>
			<!--	<tr>
					<td>

					</td>
					<td>
						<label><input type="checkbox" value="" id="forceimport"/>Also Import previously Imported
							Entry(Duplicate)</label>
					</td>
					<td>

					</td>
					<td></td>
				</tr>-->
			</tfoot>
			</table>
			<script>
				var transaction_id =<?php 
            echo esc_attr(time());
            ?>
;
				var arr_map_fields =<?php 
            echo json_encode($this->field_array[$post_type]);
            ?>
;
				<?php 
            if ('gravity' == $_REQUEST['type']) {
                ?>
				var arr_lead_id = <?php 
                $this->get_all_gravity_lead($form_id);
                ?>
;
				<?php 
            } else {
                $jsonArray = array();
                $rCount = 0;
                foreach ($csv->data as $cdata) {
                    $jsonArray[] = array('id' => $rCount++);
                }
                ?>
				var arr_lead_id = <?php 
                echo json_encode($jsonArray);
                ?>
;
				<?php 
            }
            ?>
			</script>
			<input type="button" name="map_mapping_import" id="map_mapping_import" value="Import"
			       class="button button-primary"/>
			</form>
			<div id='startImporting'>
			<h2 <?php 
            echo $style;
            ?>
> <?php 
            _e(esc_attr(sprintf('Importing %s ...', isset($formname) ? $formname : '')));
            ?>
</h2>

			<div id="progressbar" <?php 
            echo $style;
            ?>
 ></div>
			<div class="myupdate" <?php 
            echo $style;
            ?>
 >
				<p> <?php 
            _e('Successfully imported :');
            ?>
 <span
						id='sucessfullyImported'>0</span></p>
			</div>
			<div class="myerror" <?php 
            echo $style;
            ?>
>
				<p> <?php 
            _e('Failed to import :');
            ?>
 <span id='failImported'>0</span></p>
			</div>
			<div class="importloading"></div>
			<div class="sucessmessage">
				<?php 
            if ('gravity' == $_REQUEST['type']) {
                _e('Would you like to import future entries automatically?');
                ?>
 &nbsp;
					<input type='button' id='futureYes' value='Yes' class="button button-primary"/>&nbsp;
					<input type='button' id='futureNo' value='No' class="button "/>
				<?php 
            } else {
                ?>
					<h4 class="rt-import-success-message"><?php 
                _e('Success !');
                ?>
</h4>
					<span id="extra-data-importer"></span>
				<?php 
            }
            ?>
			</div>

			</div><?php 
            die;
        }
コード例 #3
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" => "created_by", "label" => __("Created By (User Id)", "gravityforms")));
     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" => "source_url", "label" => __("Source Url", "gravityforms")));
     array_push($form["fields"], array("id" => "transaction_id", "label" => __("Transaction Id", "gravityforms")));
     array_push($form["fields"], array("id" => "payment_amount", "label" => __("Payment Amount", "gravityforms")));
     array_push($form["fields"], array("id" => "payment_date", "label" => __("Payment Date", "gravityforms")));
     array_push($form["fields"], array("id" => "payment_status", "label" => __("Payment Status", "gravityforms")));
     array_push($form["fields"], array("id" => "post_id", "label" => __("Post Id", "gravityforms")));
     array_push($form["fields"], array("id" => "user_agent", "label" => __("User Agent", "gravityforms")));
     array_push($form["fields"], array("id" => "ip", "label" => __("User IP", "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);
     // 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
     foreach ($fields as $field_id) {
         $field = RGFormsModel::get_field($form, $field_id);
         $value = str_replace('"', '""', GFCommon::get_label($field, $field_id));
         $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;
             }
         }
     }
     $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) {
                 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);
                         break;
                     default:
                         $long_text = "";
                         if (strlen($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 : $lead[$field_id];
                         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);
             $lines .= "\n";
         }
         $offset += $page_size;
         $entry_count -= $page_size;
         if (!seems_utf8($lines)) {
             $lines = utf8_encode($lines);
         }
         echo $lines;
         $lines = "";
     }
 }
コード例 #4
0
 // i need to do some counting here, or rather at the end;
 // if the number of steps = 0, output a message
 // and unhide the section and increment use_this_section_id
 $number_of_steps_selected = 0;
 // build the div with the goal title
 $goal_text_div = '<div class="report-top">';
 $goal_text_div .= '<h4 class="plan-goal-top">Goal ' . ($goal_index + 1) . ': ' . $my_selected_goal_names[$goal_index] . '</h4>';
 $goal_text_div .= '</div>';
 // echo out the javascript needed to fill the 'section' div, and show the page
 echo '<script>fillDiv(' . $use_this_section_id . ',\'' . $goal_text_div . '\');</script>';
 // define steps arrays
 $policy_step_names = array();
 $practice_step_names = array();
 $communication_step_names = array();
 // find BUILDER leads for current user
 $builder_leads = RGFormsModel::get_leads($selected_ap_builder_form_id);
 // get the form meta for the GOALS AND PLANNING form from ID
 $builder_form_meta = RGFormsModel::get_form_meta($selected_ap_builder_form_id);
 // loop BUILDER results and return the 1st lead that matches on user-login
 $my_builder_lead = null;
 $user_field_id = get_field_id_by_label('user-login', $builder_form_meta);
 foreach ($builder_leads as $builder_lead) {
     if ($builder_lead[$user_field_id] == $user_login) {
         $my_builder_lead = $builder_lead;
         break;
     }
 }
 // loop all fields
 $am_i_first = true;
 $last_step_in_goal = '';
 if (is_array($builder_form_meta["fields"])) {
コード例 #5
0
ファイル: entry_list.php プロジェクト: hypenotic/slowfood
    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");
        switch ($action) {
            case "delete":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $lead_id = $_POST["action_argument"];
                RGFormsModel::delete_lead($lead_id);
                break;
            case "bulk":
                check_admin_referer('gforms_entry_list', 'gforms_entry_list');
                $bulk_action = !empty($_POST["bulk_action"]) ? $_POST["bulk_action"] : $_POST["bulk_action2"];
                $leads = $_POST["lead"];
                switch ($bulk_action) {
                    case "delete":
                        RGFormsModel::delete_leads($leads);
                        break;
                    case "mark_read":
                        RGFormsModel::update_leads_property($leads, "is_read", 1);
                        break;
                    case "mark_unread":
                        RGFormsModel::update_leads_property($leads, "is_read", 0);
                        break;
                    case "add_star":
                        RGFormsModel::update_leads_property($leads, "is_starred", 1);
                        break;
                    case "remove_star":
                        RGFormsModel::update_leads_property($leads, "is_starred", 0);
                        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;
        }
        $sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"];
        $sort_direction = empty($_GET["dir"]) ? "DESC" : $_GET["dir"];
        $search = RGForms::get("s");
        $page_index = empty($_GET["paged"]) ? 0 : intval($_GET["paged"]) - 1;
        $star = is_numeric(RGForms::get("star")) ? intval(RGForms::get("star")) : null;
        $read = is_numeric(RGForms::get("read")) ? intval(RGForms::get("read")) : null;
        $page_size = 20;
        $first_item_index = $page_index * $page_size;
        $form = RGFormsModel::get_form_meta($form_id);
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta["type"] == "number";
        $leads = RGFormsModel::get_leads($form_id, $sort_field, $sort_direction, $search, $first_item_index, $page_size, $star, $read, $is_numeric);
        $lead_count = RGFormsModel::get_lead_count($form_id, $search, $star, $read);
        $summary = RGFormsModel::get_form_counts($form_id);
        $total_lead_count = $summary["total"];
        $unread_count = $summary["unread"];
        $starred_count = $summary["starred"];
        $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}" : "";
        $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, 'format' => 'paged=%#%', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($lead_count / $page_size), 'current' => $page_index + 1, 'show_all' => false));
        wp_print_scripts(array("thickbox"));
        wp_print_styles(array("thickbox"));
        ?>

        <script src="<?php 
        echo GFCommon::get_base_url();
        ?>
/js/jquery.json-1.3.js?ver=<?php 
        echo GFCommon::$version;
        ?>
"></script>

        <script>
            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){
                var search_qs = search == "" ? "" : "&s=" + search;
                var star_qs = star == "" ? "" : "&star=" + star;
                var read_qs = read == "" ? "" : "&read=" + read;

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

            function ToggleStar(img, lead_id){
                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");

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

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

            function ToggleRead(lead_id){
                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");
                title.toggleClass("lead_unread");

                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.encVar( "cookie", document.cookie, false );
                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 DeleteLead(lead_id){
                jQuery("#action").val("delete");
                jQuery("#action_argument").val(lead_id);
                jQuery("#lead_form")[0].submit();
                return true;
            }



            jQuery(document).ready(function(){
                jQuery("#lead_search").keyup(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;
        ?>
');
                });

            });

        </script>
        <link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin.css" type="text/css" />
        <style>
            .lead_unread a, .lead_unread td{font-weight: bold;}
            .row-actions a{ font-weight:normal;}
            .entry_nowrap{
                overflow:hidden; white-space:nowrap;
            }
        </style>


        <div class="wrap">
            <img alt="<?php 
        _e("Gravity Forms", "gravityforms");
        ?>
" src="<?php 
        echo GFCommon::get_base_url();
        ?>
/images/gravity-entry-icon-32.png" style="float:left; margin:15px 7px 0 0;"/>
            <h2><?php 
        _e("Entries", "gravityforms");
        ?>
 : <?php 
        echo $form["title"];
        ?>
 </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" />

                <ul class="subsubsub">
                    <li><a class="<?php 
        echo $star === null && $read === null ? "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 $total_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;
        ?>
&read=0"><?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;
        ?>
&star=1"><?php 
        _e("Starred", "gravityforms");
        ?>
 <span class="count">(<span id="star_count"><?php 
        echo $starred_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 
        _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 
        if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
            ?>
                            <option value='delete'><?php 
            _e("Delete", "gravityforms");
            ?>
</option>
                            <?php 
        }
        ?>

                            <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>
                        </select>
                        <?php 
        $apply_button = '<input type="submit" class="button" value="' . __("Apply", "gravityforms") . '" onclick="jQuery(\'#action\').val(\'bulk\');" />';
        echo apply_filters("gform_entry_apply_button", $apply_button);
        ?>

                    </div>

                    <?php 
        //Displaying paging links if appropriate
        if ($page_links) {
            ?>
                        <div class="tablenav-pages">
                            <span class="displaying-num"><?php 
            printf(__("Displaying %d - %d of %d", "gravityforms"), $first_item_index + 1, $first_item_index + $page_size > $lead_count ? $lead_count : $first_item_index + $page_size, $lead_count);
            ?>
</span>
                            <?php 
            echo $page_links;
            ?>
                        </div>
                        <?php 
        }
        ?>
                    <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" style="vertical-align:middle;"><input type="checkbox" class="headercb" /></th>
                        <th scope="col" 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;
            ?>
');" 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 GFCommon::get_base_url();
        ?>
/select_columns.php?id=<?php 
        echo $form_id;
        ?>
&TB_iframe=true&height=365&width=600" class="thickbox entries_edit_icon">Edit</a>
                        </th>
                    </tr>
                </thead>
                <tfoot>
                    <tr>
                        <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
                        <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;
            ?>
');" style="cursor:pointer;"><?php 
            echo esc_html($field_info["label"]);
            ?>
</th>
                            <?php 
        }
        ?>
                        <th scope="col" style="width:15px;">
                            <a href="<?php 
        echo GFCommon::get_base_url();
        ?>
/select_columns.php?id=<?php 
        echo $form_id;
        ?>
&TB_iframe=true&height=350&width=500" class="thickbox entries_edit_icon">Edit</a>
                        </th>
                    </tr>
                </tfoot>

                <tbody class="list:user user-list">
                    <?php 
        if (sizeof($leads) > 0) {
            $field_ids = array_keys($columns);
            foreach ($leads as $lead) {
                ?>
                            <tr id="lead_row_<?php 
                echo $lead["id"];
                ?>
" class='author-self status-inherit <?php 
                echo $lead["is_read"] ? "" : "lead_unread";
                ?>
' valign="top">
                                <th scope="row" class="check-column">
                                    <input type="checkbox" name="lead[]" value="<?php 
                echo $lead["id"];
                ?>
" />
                                </th>
                                <td >
                                    <img src="<?php 
                echo GFCommon::get_base_url();
                ?>
/images/star<?php 
                echo intval($lead["is_starred"]);
                ?>
.png" onclick="ToggleStar(this, <?php 
                echo $lead["id"];
                ?>
);" />
                                </td>
                                <?php 
                $is_first_column = true;
                $nowrap_class = "entry_nowrap";
                foreach ($field_ids as $field_id) {
                    $value = RGForms::get($field_id, $lead);
                    //filtering lead value
                    $value = apply_filters("gform_get_field_value", $value, $lead, RGFormsModel::get_field($form, $field_id));
                    $input_type = !empty($columns[$field_id]["inputType"]) ? $columns[$field_id]["inputType"] : $columns[$field_id]["type"];
                    switch ($input_type) {
                        case "checkbox":
                            $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 ($field["enableChoiceValue"] || $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 ($field["enablePrice"]) {
                                                        list($val, $price) = explode("|", $lead[$field_id]);
                                                        if ($val == $choice["value"]) {
                                                            $value = "<img src='" . GFCommon::get_base_url() . "/images/tick.png'/>";
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                        case "post_image":
                            list($url, $title, $caption, $description) = explode("|:|", $value);
                            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 "post_category":
                            $ary = explode(":", $value);
                            $cat_name = count($ary) > 0 ? $ary[0] : "";
                            $value = $cat_name;
                            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, $field["dateFormat"]);
                            break;
                        case "radio":
                        case "select":
                            $field = RGFormsModel::get_field($form, $field_id);
                            $value = GFCommon::selection_display($value, $field, $lead["currency"]);
                            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;
                        default:
                            $value = esc_html($value);
                    }
                    $value = apply_filters("gform_entries_field_value", $value, $form_id, $field_id, $lead);
                    $query_string = "gf_entries&view=entry&id={$form_id}&lid={$lead["id"]}{$search_qs}{$sort_qs}{$dir_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;
                        ?>
&paged=<?php 
                        echo $page_index + 1;
                        ?>
"><?php 
                        echo $value;
                        ?>
</a>
                                            <div class="row-actions">
                                                <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;
                        ?>
&paged=<?php 
                        echo $page_index + 1;
                        ?>
"><?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"];
                        ?>
);" 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"];
                        ?>
);" 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") ? "|" : "";
                        ?>
                                                </span>

                                                <?php 
                        if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                            ?>
                                                    <span class="edit">
                                                        <?php 
                            $delete_link = '<a title="' . __("Delete this entry", "gravityforms") . '"  href="javascript:if ( confirm(' . __("'You are about to delete this entry. \\'Cancel\\' to stop, \\'OK\\' to delete.'", "gravityforms") . ') ) { DeleteLead(' . $lead["id"] . ')};">' . __("Delete", "gravityforms") . '</a>';
                            echo apply_filters("gform_delete_entry_link", $delete_link);
                            ?>
                                                    </span>
                                                    <?php 
                        }
                        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 $value;
                        ?>
&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 {
            ?>
                        <tr>
                            <td colspan="<?php 
            echo sizeof($columns) + 3;
            ?>
" style="padding:20px;"><?php 
            _e("This form does not have any entries yet.", "gravityforms");
            ?>
</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>
                            <option value='delete'><?php 
        _e("Delete", "gravityforms");
        ?>
</option>
                            <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>
                        </select>
                        <?php 
        $apply_button = '<input type="submit" class="button" value="' . __("Apply", "gravityforms") . '" onclick="jQuery(\'#action\').val(\'bulk\');" />';
        echo apply_filters("gform_entry_apply_button", $apply_button);
        ?>
                    </div>

                    <?php 
        //Displaying paging links if appropriate
        if ($page_links) {
            ?>
                        <div class="tablenav-pages">
                            <span class="displaying-num"><?php 
            printf(__("Displaying %d - %d of %d", "gravityforms"), $first_item_index + 1, $first_item_index + $page_size > $lead_count ? $lead_count : $first_item_index + $page_size, $lead_count);
            ?>
</span>
                            <?php 
            echo $page_links;
            ?>
                        </div>
                        <?php 
        }
        ?>
                    <div class="clear"></div>
                </div>

            </form>
        </div>
        <?php 
    }
コード例 #6
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 = 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";
        $search = rgget("s");
        $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;
        // added status as an optional parameter to get_lead_count because the counts are inaccurate without using the status
        $lead_count = RGFormsModel::get_lead_count($form['id'], $search, $star, $read, null, null, $status);
        $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
        $next_pos = !rgblank($position) && $position < $lead_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 == $lead_count) {
                $next_pos = false;
            }
        }
        // get the lead
        $leads = RGFormsModel::get_leads($form['id'], $sort_field, $sort_direction, $search, $position, 1, $star, $read, $is_numeric, null, null, $status);
        if (!$lead_id) {
            $lead = !empty($leads) ? $leads[0] : false;
        } else {
            $lead = RGFormsModel::get_lead($lead_id);
        }
        if (!$lead) {
            _e("Oops! We couldn't find your lead. 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');
                RGFormsModel::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');
                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){
                if(confirm(<?php 
        _e("'Would you like to delete this file? \\'Cancel\\' to stop. \\'OK\\' to delete'", "gravityforms");
        ?>
)){

                    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.onError = function() { alert('<?php 
        echo esc_js(__("Ajax error while deleting field.", "gravityforms"));
        ?>
' )};
                    mysack.runAJAX();

                    return true;
                }
            }

            function EndDeleteFile(fieldId){
                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">
            <div class="icon32" id="gravity-title-icon"><br></div>
            <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'];
        ?>
</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 $lead_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');
            ?>
</li>
                    <li class="gf_entry_next gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($next_pos, 'Next Entry', 'gf_entry_next_link');
            ?>
</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);
        ?>

                    <div id="submitdiv" class="stuffbox">
                        <h3>
                            <span class="hndle"><?php 
        _e("Info", "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 (!empty($lead["payment_status"])) {
            echo $lead["transaction_type"] != 2 ? __("Payment Status", "gravityforms") : __("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"] == 1 ? __("Payment Date", "gravityforms") : __("Start Date", "gravityforms");
                ?>
: <?php 
                echo GFCommon::format_date($lead["payment_date"], false, "Y/m/d", $lead["transaction_type"] == 1);
                ?>
                                            <br/><br/>
                                            <?php 
            }
            if (!empty($lead["transaction_id"])) {
                echo $lead["transaction_type"] == 1 ? __("Transaction Id", "gravityforms") : __("Subscriber Id", "gravityforms");
                ?>
: <?php 
                echo $lead["transaction_id"];
                ?>
                                            <br/><br/>
                                            <?php 
            }
            if (!rgblank($lead["payment_amount"])) {
                echo $lead["transaction_type"] == 1 ? __("Payment Amount", "gravityforms") : __("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>
                                        <?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 
                }
        }
        /*if(GFCommon::current_user_can_any("gravityforms_delete_entries")){
              $delete_link = '<a class="submitdelete deletion" onclick="if ( confirm(\''. __("You are about to delete this entry. \'Cancel\' to stop, \'OK\' to delete.", "gravityforms") .'\') ) { jQuery(\'#action\').val(\'delete\'); jQuery(\'#entry_form\')[0].submit();} return false;" href="#">' . __("Delete", "gravityforms") . '</a>';
              echo apply_filters("gform_entrydetail_delete_link", $delete_link);
          }*/
        ?>
                                    </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>
                            </div>
                        </div>
                    </div>
                    <?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 id="namediv" class="stuffbox">
                                <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 
        }
    }
コード例 #7
0
    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 
    }
コード例 #8
0
// wordpress urls
$template_url = get_bloginfo('template_url');
$site_url = get_site_url();
// user info
$user_login = $current_user->user_login;
// find prev/next page in menu
$pagelist = get_pages('sort_column=menu_order&sort_order=asc');
$pages = array();
foreach ($pagelist as $page) {
    $pages[] += $page->ID;
}
$current = array_search(get_the_ID(), $pages);
$prevID = $pages[$current - 1];
$nextID = $pages[$current + 1];
// find all PRACTICE leads
$practice_leads = RGFormsModel::get_leads(4);
// practice form_id=4
// gather the first 5 (or fewer) leads for this user
$my_practice_leads = array();
$has_practice_lead = false;
$total_practice_leads = 0;
$i = 0;
foreach ($practice_leads as $practice_lead) {
    if ($practice_lead['29'] == $user_login) {
        array_push($my_practice_leads, $practice_lead);
        $has_practice_lead = true;
        $total_practice_leads++;
        if (++$i == 4) {
            break;
        }
    }
コード例 #9
0
ファイル: functions.php プロジェクト: healthcommcore/osnap
function deleteAllMyEntries()
{
    // get current user info
    global $current_user;
    get_currentuserinfo();
    $user_id = $current_user->ID;
    // initialize
    $result = "";
    $my_lead_ids = array();
    $successes = 0;
    $failures = 0;
    $failure_msg = "";
    // find entries for this user in all forms that we want to wipe out
    $form_ids = array(1, 4, 7, 8, 10, 16, 18, 19, 20, 21, 22, 49);
    foreach ($form_ids as $form_id) {
        // reset running count of number of entries found
        $number_of_entries_f[$form_id] = 0;
        // get all leads for that form id
        $leads = RGFormsModel::get_leads($form_id);
        // get form meta and then user-login field id for each form
        $form_meta = RGFormsModel::get_form_meta($form_id);
        $form_title = $form_meta["title"];
        // get leads that match on user-login
        foreach ($leads as $lead) {
            if ($lead['created_by'] == $user_id) {
                array_push($my_lead_ids, $lead['id']);
                $number_of_entries_f[$form_id]++;
            }
        }
        $result .= $form_title . ": " . $number_of_entries_f[$form_id] . "<br/>";
    }
    // delete the entries
    foreach ($my_lead_ids as $lead_id) {
        $del_result = GFAPI::delete_entry($lead_id);
        //echo "dr: ".$del_result;
        if ($del_result == true) {
            $successes++;
        } else {
            $failures++;
            $failure_msg .= "<br>" . $del_result;
        }
    }
    $final_result = "<br><br><b>Reset of all forms is complete.</b><br/><br/>Details - Attempted to delete the following number of entries:<br/>" . $result;
    $final_result .= "<br/>Successes: " . $successes . "<br/>Failures: " . $failures . "<br>" . $failure_msg;
    return $final_result;
}
コード例 #10
0
 public function gpoll_get_data($form_id, $gpoll_data = array())
 {
     $time_start = microtime(true);
     $max_execution_time = 20;
     //seconds
     $form_meta = RGFormsModel::get_form_meta($form_id);
     $form_meta = apply_filters("gform_polls_form_pre_results_{$form_id}", apply_filters("gform_polls_form_pre_results", $form_meta));
     $totals = RGFormsModel::get_form_counts($form_id);
     $total = $totals["total"];
     $sort_field_number = 0;
     $sort_direction = 'DESC';
     $search = '';
     $offset = 0;
     $page_size = 200;
     $star = null;
     $read = null;
     $is_numeric_sort = false;
     $start_date = null;
     $end_date = null;
     $status = 'active';
     $field_counter = 0;
     if (empty($gpoll_data)) {
         //first build list of fields to count and later count the entries
         //it's split up this way to avoid a timeout on large resultsets
         foreach ($form_meta["fields"] as $field) {
             $fieldid = $field["id"];
             if ($field["type"] !== "poll") {
                 continue;
             }
             $gpoll_field_data = array("field_label" => $field["label"], "field_id" => $fieldid, "type" => $field["type"], "inputType" => $field["inputType"]);
             $gpoll_data["fields"][$field_counter] = $gpoll_field_data;
             $gpoll_input_data = array();
             //for checkboxes
             if ($field["inputType"] == "checkbox") {
                 $input_counter = 0;
                 foreach ($field["inputs"] as $input) {
                     $inputid = str_replace(".", "_", $input["id"]);
                     $gpoll_input_data = array("input_id" => "#choice_{$inputid}", "label" => $input["label"]);
                     $gpoll_data["fields"][$field_counter]["inputs"][$input_counter] = $gpoll_input_data;
                     $input_counter += 1;
                 }
             } else {
                 //for radio & dropdowns
                 $choice_counter = 0;
                 if (isset($field["enableOtherChoice"]) && $field["enableOtherChoice"] === true) {
                     $choice_index = count($field["choices"]);
                     $field["choices"][$choice_index]["text"] = __("Other", "gravityformspolls");
                 }
                 foreach ($field["choices"] as $choice) {
                     $gpoll_input_data = array("input_id" => "#choice_{$fieldid}_{$choice_counter}", "label" => $choice["text"]);
                     $gpoll_data["fields"][$field_counter]["inputs"][$choice_counter] = $gpoll_input_data;
                     $choice_counter += 1;
                 }
             }
             $field_counter += 1;
             $i = $offset;
         }
     } else {
         $i = $gpoll_data["offset"];
         unset($gpoll_data["offset"]);
     }
     $precision = apply_filters("gform_polls_percentage_precision", 0, $form_id);
     //get leads in groups of $page_size to avoid timeouts
     while ($i <= $total) {
         $field_counter = 0;
         $get_leads_time_start = microtime(true);
         $entries = RGFormsModel::get_leads($form_id, $sort_field_number, $sort_direction, $search, $i, $page_size, null, null, false, null, null);
         $get_leads_time_end = microtime(true);
         $get_leads_time = $get_leads_time_end - $get_leads_time_start;
         //loop through each field currently on the form and count the entries for each choice
         foreach ($form_meta["fields"] as $field) {
             $fieldid = $field["id"];
             if ($field["type"] !== "poll") {
                 continue;
             }
             if (isset($gpoll_data["fields"][$field_counter]["total_entries"])) {
                 $field_total_entries = $gpoll_data["fields"][$field_counter]["total_entries"];
             } else {
                 $field_total_entries = 0;
             }
             foreach ($entries as $entry) {
                 $entry_value = RGFormsModel::get_lead_field_value($entry, $field);
                 if (false === empty($entry_value)) {
                     $field_total_entries++;
                 }
             }
             $gpoll_data["fields"][$field_counter]["total_entries"] = $field_total_entries;
             $gpoll_input_data = array();
             // checkboxes store entries differently to radio & dropdowns
             if ($field["inputType"] == "checkbox") {
                 //for checkboxes
                 // loop through all the choices and count the entries for each choice
                 $input_counter = 0;
                 foreach ($field["inputs"] as $input) {
                     // running total of entries for each set of entries
                     if (isset($gpoll_data["fields"][$field_counter]["inputs"][$input_counter]["total_entries"])) {
                         $total_entries = $gpoll_data["fields"][$field_counter]["inputs"][$input_counter]["total_entries"];
                     } else {
                         $total_entries = 0;
                     }
                     $entry_index = 1;
                     // loop through all the entries and count the entries for the choice
                     foreach ($entries as $entry) {
                         // loop through each item in the lead object and pick out the entries for this field id
                         foreach ($entry as $key => $entry_value) {
                             // checkboxes store the key as [field number].[input index] (e.g. 2.1 or 2.2)
                             // so convert to integer to identify all the responses inside the lead object for this field id
                             if (intval($key) == $field["id"]) {
                                 //compare the user's response with the current choice
                                 if ($entry_value == $field["choices"][$input_counter]["value"]) {
                                     // found a response for this choice so continue to the next lead
                                     $total_entries++;
                                     break;
                                 }
                             }
                         }
                         $entry_index += 1;
                     }
                     //calculate the ratio of total number of responses counted to the total number of entries for this form
                     $ratio = 0;
                     if ($field_total_entries != 0) {
                         $ratio = round($total_entries / $field_total_entries * 100, $precision);
                     }
                     //store the data
                     $gpoll_data["fields"][$field_counter]["inputs"][$input_counter]["value"] = $field["choices"][$input_counter]["value"];
                     $gpoll_data["fields"][$field_counter]["inputs"][$input_counter]["total_entries"] = $total_entries;
                     $gpoll_data["fields"][$field_counter]["inputs"][$input_counter]["ratio"] = $ratio;
                     $input_counter += 1;
                 }
             } else {
                 // for radio & dropdowns
                 $choice_counter = 0;
                 // if the Enable "other" choice option is selected for this field then add it as a pseudo-value
                 if (isset($field["enableOtherChoice"]) && $field["enableOtherChoice"] === true) {
                     $choice_index = count($field["choices"]);
                     $field["choices"][$choice_index]["value"] = "gpoll_other";
                 }
                 // loop through each choice and count the responses
                 foreach ($field["choices"] as $choice) {
                     // running total of entries for each set of entries
                     if (isset($gpoll_data["fields"][$field_counter]["inputs"][$choice_counter]["total_entries"])) {
                         $total_entries = $gpoll_data["fields"][$field_counter]["inputs"][$choice_counter]["total_entries"];
                     } else {
                         $total_entries = 0;
                     }
                     // count responses for "Other"
                     if ($choice["value"] == "gpoll_other") {
                         $possible_choices = array();
                         foreach ($field["choices"] as $possible_choice) {
                             array_push($possible_choices, $possible_choice["value"]);
                         }
                         foreach ($entries as $entry) {
                             $entry_value = RGFormsModel::get_lead_field_value($entry, $field);
                             if (!empty($entry_value) && !in_array($entry_value, $possible_choices)) {
                                 $total_entries++;
                             }
                         }
                     } else {
                         // count entries
                         foreach ($entries as $entry) {
                             $entry_value = RGFormsModel::get_lead_field_value($entry, $field);
                             if ($entry_value === $choice["value"]) {
                                 $total_entries++;
                             }
                         }
                     }
                     // calculate the ratio of total number of responses counted to the total number of entries for this form
                     $ratio = 0;
                     if ($field_total_entries != 0) {
                         $ratio = round($total_entries / $field_total_entries * 100, $precision);
                     }
                     //store the data
                     $gpoll_data["fields"][$field_counter]["inputs"][$choice_counter]["value"] = $choice["value"];
                     $gpoll_data["fields"][$field_counter]["inputs"][$choice_counter]["total_entries"] = $total_entries;
                     $gpoll_data["fields"][$field_counter]["inputs"][$choice_counter]["ratio"] = $ratio;
                     $choice_counter += 1;
                 }
             }
             $field_counter += 1;
         }
         $i += $page_size;
         $time_end = microtime(true);
         $execution_time = $time_end - $time_start;
         $gpoll_data["execution_time"] = $execution_time;
         $gpoll_data["incomplete"] = false;
         if ($execution_time + $get_leads_time > $max_execution_time) {
             $gpoll_data["incomplete"] = true;
             $gpoll_data["offset"] = $i;
             break;
         }
     }
     //end while
     return $gpoll_data;
 }
コード例 #11
0
ファイル: page-tool.php プロジェクト: healthcommcore/osnap
/*
Template Name: Tool Page
*/
?>

<?php 
// get the wp header
get_header();
// get all of the Advanced Custom Fields for this page
$fields = get_fields();
// get current user
$user_login = $current_user->user_login;
// find BACKGROUND info for current user
$my_background_lead = null;
$background_leads = RGFormsModel::get_leads(6);
// form_id=6
// loop results and return the first ONE for this user
foreach ($background_leads as $background_lead) {
    if ($background_lead['9'] == $user_login) {
        $my_background_lead = $background_lead;
        break;
    }
}
// find prev/next page in menu
$pagelist = get_pages('sort_column=menu_order&sort_order=asc');
$pages = array();
foreach ($pagelist as $page) {
    $pages[] += $page->ID;
}
$current = array_search(get_the_ID(), $pages);
コード例 #12
0
    echo "<h4>" . $fields['subtitle'] . "</h4>";
}
?>
	
	
		<?php 
// image tags
$template_url = get_bloginfo('template_url');
$greencheck_url = $template_url . "/images/icon-green-check.png";
$orangemark_url = $template_url . "/images/icon-orange-ex-point.png";
$redex_url = $template_url . "/images/icon-red-ex.png";
//user info
$user_login = $current_user->user_login;
// find leads for current user
//function get_leads($form_id, $sort_field_number=0, $sort_direction='DESC', $search='', $offset=0, $page_size=30, $star=null, $read=null, $is_numeric_sort = false, $start_date=null, $end_date=null, $status='active')
$leads = RGFormsModel::get_leads(1, 0, 'DESC', $user_login);
//<?php if ($entry_count > 0) { code hidden here... };
?>

		
		<div class="results-table">
		
		<!-- only write out the results table if results were found -->
		<?php 
if ($results_found == 'false') {
    echo "<div class='no-results'><p><b>No results were found for your IP</b> (" . $ip . ")</p>";
    echo "<p>&nbsp;</p>";
    echo "<p>You must first complete the interview questions. </p>";
    echo "<p>Use the link to the left to start the interview, and make sure to click submit when you are done.</p></div>";
} else {
    ?>
コード例 #13
0
ファイル: page-goals.php プロジェクト: healthcommcore/osnap
// get the form meta for the GOALS AND PLANNING form
$form = RGFormsModel::get_form_meta(7);
// get the field with the checkboxed goals
$field = RGFormsModel::get_field($form, 2);
// get the labels for each option in that field
$label_s1 = $field["choices"][0]["text"];
$label_s2 = $field["choices"][1]["text"];
$label_s3 = $field["choices"][2]["text"];
$label_s4 = $field["choices"][3]["text"];
$label_s5 = $field["choices"][4]["text"];
$label_s6 = $field["choices"][5]["text"];
$label_s7 = $field["choices"][6]["text"];
$label_s8 = $field["choices"][7]["text"];
$label_s9 = $field["choices"][8]["text"];
// find GOALS leads for current user
$goal_leads = RGFormsModel::get_leads(7);
// form_id=7
// loop GOALS results and return the 1st lead that matches on user-login
$my_goal_lead = null;
$has_goal_lead = false;
foreach ($goal_leads as $goal_lead) {
    if ($goal_lead['4'] == $user_login) {
        $my_goal_lead = $goal_lead;
        $has_goal_lead = true;
        break;
    }
}
// find which goals were checked/selected in this lead
$buttons_div = "<div class='goal-buttons-div'>";
if ($my_goal_lead['2.1']) {
    $buttons_div = $buttons_div . "<p><a href='" . $site_url . "/tools/action-plan-builder/mod-pa/' class='btn btn-block'>" . $label_s1 . "</a></p>";
コード例 #14
0
function get_btc_participants($form_id, $event_id)
{
    // cache participants per form
    $cacher = new Cacher();
    $registrants = $cacher->get_cache('gravity_forms_' . $form_id);
    if ($registrants == false) {
        $registrants = RGFormsModel::get_leads($form_id, '2', 'ASC', '', 0, 500000);
        $cacher->set_cache($registrants, 'gravity_forms_' . $form_id);
    }
    $racers = array();
    foreach ($registrants as $racer) {
        if ($racer[EVENT_FIELD_ID] == $event_id) {
            $racers[$racer["id"]] = $racer['92'];
        }
    }
    return $racers;
}
コード例 #15
0
// find GOAL leads for current user
$my_goal_lead = null;
$goal_leads = RGFormsModel::get_leads(7);
// loop GOALS results and return the 1st lead that matches on user-login
foreach ($goal_leads as $goal_lead) {
    if ($goal_lead['4'] == $user_login) {
        $my_goal_lead = $goal_lead;
        break;
    }
}
// find only if current user has any BUILDER leads
$has_builder_lead = false;
$builder_form_ids = array(8, 10, 16, 17, 18, 19, 20, 21, 22);
foreach ($builder_form_ids as $form_id) {
    // get all leads for that form id
    $builder_leads = RGFormsModel::get_leads($form_id);
    // get form meta for that form id, to use for matching on user-login
    $builder_form_meta = RGFormsModel::get_form_meta($form_id);
    // get leads that match on user-login
    $user_field_id = get_field_id_by_label('user-login', $builder_form_meta);
    foreach ($builder_leads as $builder_lead) {
        if ($builder_lead[$user_field_id] == $user_login) {
            $has_builder_lead = true;
            break;
        }
    }
}
// if user has builder leads, then they will have an ACTION PLAN
$has_action_plan = $has_builder_lead;
// ROWS //////////////////////////////////////////////////////
// BACKGROUND row
コード例 #16
0
 /**
  * Cycles through all entries, counts responses and returns an associative array with the data for each field.
  * It's then optionally cached later according to the user settings.
  *
  * @param int $form_id The form ID.
  * @param array $gpoll_data The poll results data.
  *
  * @return array
  */
 public function gpoll_get_data($form_id, $gpoll_data = array())
 {
     $time_start = microtime(true);
     $max_execution_time = 20;
     //seconds
     $totals = RGFormsModel::get_form_counts($form_id);
     $total = $totals['total'];
     $form_meta = RGFormsModel::get_form_meta($form_id);
     $form_meta = apply_filters("gform_polls_form_pre_results_{$form_id}", apply_filters('gform_polls_form_pre_results', $form_meta));
     $poll_fields = array();
     foreach ($form_meta['fields'] as $field) {
         if ($field->type !== 'poll') {
             continue;
         }
         $poll_fields[] = clone $field;
     }
     $sort_field_number = 0;
     $sort_direction = 'DESC';
     $search = '';
     $offset = 0;
     $page_size = 200;
     $star = null;
     $read = null;
     $is_numeric_sort = false;
     $start_date = null;
     $end_date = null;
     $status = 'active';
     $field_counter = 0;
     if (empty($gpoll_data)) {
         //first build list of fields to count and later count the entries
         //it's split up this way to avoid a timeout on large resultsets
         foreach ($poll_fields as $poll_field) {
             $fieldid = $poll_field->id;
             $gpoll_field_data = array('field_label' => $poll_field->label, 'field_id' => $fieldid, 'type' => $poll_field->type, 'inputType' => $poll_field->inputType);
             $gpoll_data['fields'][$field_counter] = $gpoll_field_data;
             $gpoll_input_data = array();
             //for checkboxes
             if ($poll_field->inputType == 'checkbox') {
                 $input_counter = 0;
                 foreach ($poll_field->inputs as $input) {
                     $inputid = str_replace('.', '_', $input['id']);
                     $gpoll_input_data = array('input_id' => "#choice_{$inputid}", 'label' => $input['label']);
                     $gpoll_data['fields'][$field_counter]['inputs'][$input_counter] = $gpoll_input_data;
                     $input_counter += 1;
                 }
             } else {
                 //for radio & dropdowns
                 $choice_counter = 0;
                 if ($poll_field->enableOtherChoice) {
                     $choice_index = count($poll_field->choices);
                     $choices = $poll_field->choices;
                     $choices[$choice_index]['text'] = esc_html__('Other', 'gravityformspolls');
                     $choices[$choice_index]['value'] = 'gpoll_other';
                     $poll_field->choices = $choices;
                 }
                 foreach ($poll_field->choices as $choice) {
                     $gpoll_input_data = array('input_id' => "#choice_{$fieldid}_{$choice_counter}", 'label' => $choice['text']);
                     $gpoll_data['fields'][$field_counter]['inputs'][$choice_counter] = $gpoll_input_data;
                     $choice_counter += 1;
                 }
             }
             $field_counter += 1;
             $i = $offset;
         }
     } else {
         $i = $gpoll_data['offset'];
         unset($gpoll_data['offset']);
     }
     $precision = apply_filters('gform_polls_percentage_precision', 0, $form_id);
     //get leads in groups of $page_size to avoid timeouts
     while ($i <= $total) {
         $field_counter = 0;
         $get_leads_time_start = microtime(true);
         $entries = RGFormsModel::get_leads($form_id, $sort_field_number, $sort_direction, $search, $i, $page_size, null, null, false, null, null);
         $get_leads_time_end = microtime(true);
         $get_leads_time = $get_leads_time_end - $get_leads_time_start;
         //loop through each field currently on the form and count the entries for each choice
         foreach ($poll_fields as $poll_field) {
             if (isset($gpoll_data['fields'][$field_counter]['total_entries'])) {
                 $field_total_entries = $gpoll_data['fields'][$field_counter]['total_entries'];
             } else {
                 $field_total_entries = 0;
             }
             foreach ($entries as $entry) {
                 $entry_value = RGFormsModel::get_lead_field_value($entry, $poll_field);
                 if (false === empty($entry_value)) {
                     $field_total_entries++;
                 }
             }
             $gpoll_data['fields'][$field_counter]['total_entries'] = $field_total_entries;
             $gpoll_input_data = array();
             // checkboxes store entries differently to radio & dropdowns
             if ($poll_field->inputType == 'checkbox') {
                 //for checkboxes
                 // loop through all the choices and count the entries for each choice
                 $input_counter = 0;
                 foreach ($poll_field->inputs as $input) {
                     // running total of entries for each set of entries
                     if (isset($gpoll_data['fields'][$field_counter]['inputs'][$input_counter]['total_entries'])) {
                         $total_entries = $gpoll_data['fields'][$field_counter]['inputs'][$input_counter]['total_entries'];
                     } else {
                         $total_entries = 0;
                     }
                     $entry_index = 1;
                     // loop through all the entries and count the entries for the choice
                     foreach ($entries as $entry) {
                         // loop through each item in the lead object and pick out the entries for this field id
                         foreach ($entry as $key => $entry_value) {
                             // checkboxes store the key as [field number].[input index] (e.g. 2.1 or 2.2)
                             // so convert to integer to identify all the responses inside the lead object for this field id
                             if (intval($key) == $poll_field->id) {
                                 //compare the user's response with the current choice
                                 if ($entry_value == $poll_field->choices[$input_counter]['value']) {
                                     // found a response for this choice so continue to the next lead
                                     $total_entries++;
                                     break;
                                 }
                             }
                         }
                         $entry_index += 1;
                     }
                     //calculate the ratio of total number of responses counted to the total number of entries for this form
                     $ratio = 0;
                     if ($field_total_entries != 0) {
                         $ratio = round($total_entries / $field_total_entries * 100, $precision);
                     }
                     //store the data
                     $gpoll_data['fields'][$field_counter]['inputs'][$input_counter]['value'] = $poll_field->choices[$input_counter]['value'];
                     $gpoll_data['fields'][$field_counter]['inputs'][$input_counter]['total_entries'] = $total_entries;
                     $gpoll_data['fields'][$field_counter]['inputs'][$input_counter]['ratio'] = $ratio;
                     $input_counter += 1;
                 }
             } else {
                 // for radio & dropdowns
                 $choice_counter = 0;
                 // loop through each choice and count the responses
                 foreach ($poll_field->choices as $choice) {
                     // running total of entries for each set of entries
                     if (isset($gpoll_data['fields'][$field_counter]['inputs'][$choice_counter]['total_entries'])) {
                         $total_entries = $gpoll_data['fields'][$field_counter]['inputs'][$choice_counter]['total_entries'];
                     } else {
                         $total_entries = 0;
                     }
                     // count responses for 'Other'
                     if (rgar($choice, 'value') == 'gpoll_other') {
                         $possible_choices = array();
                         foreach ($poll_field->choices as $possible_choice) {
                             array_push($possible_choices, rgar($possible_choice, 'value'));
                         }
                         foreach ($entries as $entry) {
                             $entry_value = RGFormsModel::get_lead_field_value($entry, $poll_field);
                             if (!empty($entry_value) && !in_array($entry_value, $possible_choices)) {
                                 $total_entries++;
                             }
                         }
                     } else {
                         // count entries
                         foreach ($entries as $entry) {
                             $entry_value = RGFormsModel::get_lead_field_value($entry, $poll_field);
                             if ($entry_value === rgar($choice, 'value')) {
                                 $total_entries++;
                             }
                         }
                     }
                     // calculate the ratio of total number of responses counted to the total number of entries for this form
                     $ratio = 0;
                     if ($field_total_entries != 0) {
                         $ratio = round($total_entries / $field_total_entries * 100, $precision);
                     }
                     //store the data
                     $gpoll_data['fields'][$field_counter]['inputs'][$choice_counter]['value'] = rgar($choice, 'value');
                     $gpoll_data['fields'][$field_counter]['inputs'][$choice_counter]['total_entries'] = $total_entries;
                     $gpoll_data['fields'][$field_counter]['inputs'][$choice_counter]['ratio'] = $ratio;
                     $choice_counter += 1;
                 }
             }
             $field_counter += 1;
         }
         $i += $page_size;
         $time_end = microtime(true);
         $execution_time = $time_end - $time_start;
         $gpoll_data['execution_time'] = isset($gpoll_data['execution_time']) ? $gpoll_data['execution_time'] + $execution_time : $execution_time;
         $gpoll_data['incomplete'] = false;
         if ($execution_time + $get_leads_time > $max_execution_time) {
             $gpoll_data['incomplete'] = true;
             $gpoll_data['offset'] = $i;
             break;
         }
     }
     //end while
     return $gpoll_data;
 }
コード例 #17
0
 public function cleanup_saved_entries($form_id, $max = 100)
 {
     /* Removes all entries/leads that are not tied to a user */
     $leads = RGFormsModel::get_leads($form_id, 0, 'DESC', '', 0, $max, null, null, false, null, null, 'pending');
     RGFormsModel::delete_leads($leads);
     foreach ($this->get_users($form_id, false) as $user) {
         if ($user->pending_entry) {
             delete_user_meta($user->ID, 'has_pending_form_' . $form_id);
         }
     }
 }
コード例 #18
0
     }
     if ($g7_met == 'no') {
         $dates_g7_not_met .= "<li>" . $for_date . "</li>";
         $total_g7_not_met++;
     }
     if ($g8_met == 'no') {
         $dates_g8_not_met .= "<li>" . $for_date . "</li>";
         $total_g8_not_met++;
     }
     if ($g9_met == 'no') {
         $dates_g9_not_met .= "<li>" . $for_date . "</li>";
         $total_g9_not_met++;
     }
 }
 // find POLICY leads for current user
 $policy_leads = RGFormsModel::get_leads(1);
 // form_id=1
 // loop POLICY results and return the 1st one that matches on user-login
 $my_policy_lead = null;
 $has_policy_lead = false;
 foreach ($policy_leads as $policy_lead) {
     if ($policy_lead['174'] == $user_login) {
         $my_policy_lead = $policy_lead;
         $has_policy_lead = true;
         break;
     }
 }
 if ($has_practice_lead) {
     $date_created = $my_policy_lead['date_created'];
     $days_per_week = $my_policy_lead['1'];
     $c_username = $my_policy_lead['174'];
コード例 #19
0
 private function maybe_save_signature()
 {
     //see if this is an entry and it needs to be updated. abort if not
     if (!(RG_CURRENT_VIEW == 'entry' && rgpost('save') == 'Update')) {
         return;
     }
     $lead_id = rgget('lid');
     $form = RGFormsModel::get_form_meta(rgget('id'));
     if (empty($lead_id)) {
         //lid is not always in the querystring when paging through entries, use same logic from entry detail page
         $filter = rgget('filter');
         $status = in_array($filter, array('trash', 'spam')) ? $filter : 'active';
         $search = rgget('s');
         $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;
         $leads = RGFormsModel::get_leads(rgget('id'), $sort_field, $sort_direction, $search, $position, 1, $star, $read, $is_numeric, null, null, $status);
         if (!$lead_id) {
             $lead = !empty($leads) ? $leads[0] : false;
         } else {
             $lead = RGFormsModel::get_lead($lead_id);
         }
         if (!$lead) {
             _e("Oops! We couldn't find your lead. Please try again", 'gravityforms');
             return;
         }
         $lead_id = $lead['id'];
     }
     //get lead and form
     $lead = RGFormsModel::get_lead($lead_id);
     //loop through form fields, get the field name of the signature field
     foreach ($form['fields'] as $field) {
         if (RGFormsModel::get_input_type($field) == 'signature') {
             //get field name so the value can be pulled from the post data
             $input_name = 'input_' . str_replace('.', '_', $field['id']);
             //when adding a new signature the data field will be populated
             if (!rgempty("{$input_name}_data")) {
                 //new image added, save
                 $filename = $this->save_signature($input_name . '_data');
             } else {
                 //existing image edited
                 $filename = rgpost($input_name . '_signature_filename');
             }
             $_POST["input_{$field['id']}"] = $filename;
         }
     }
 }
コード例 #20
0
ファイル: export.php プロジェクト: rainrose/WoodsDev
 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");
     $end_date = empty($_POST["export_date_end"]) ? "" : self::get_gmt_date($_POST["export_date_end"] . " 23:59:59");
     GFCommon::log_debug("start date: {$start_date}");
     GFCommon::log_debug("end date: {$end_date}");
     $form = self::add_default_export_fields($form);
     $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);
     // 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
     foreach ($fields as $field_id) {
         $field = RGFormsModel::get_field($form, $field_id);
         $value = str_replace('"', '""', GFCommon::get_label($field, $field_id));
         $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;
             }
         }
     }
     $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) {
                 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($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 : $lead[$field_id];
                         $value = apply_filters("gform_export_field_value", $value, $form_id, $field_id, $lead);
                         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);
             $lines .= "\n";
         }
         $offset += $page_size;
         $entry_count -= $page_size;
         if (!seems_utf8($lines)) {
             $lines = utf8_encode($lines);
         }
         echo $lines;
         $lines = "";
     }
 }
コード例 #21
0
ファイル: export.php プロジェクト: hypenotic/slowfood
 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 = "";
     }
 }
コード例 #22
0
 public static function dailyGravityFormsOrphanedEntryRemoval()
 {
     if (class_exists('RGFormsModel') && !Cart66Setting::getValue('keep_orphaned_gravity_entries')) {
         $forms = RGFormsModel::get_forms();
         $delete_leads = array();
         foreach ($forms as $form) {
             $leads = RGFormsModel::get_leads($form->id, 0, 'DESC', '', 0, 30, null, null, false, null, null, $status = 'unpaid');
             foreach ($leads as $lead) {
                 if (strtotime($lead['date_created']) < strtotime('24 hours ago', Cart66Common::localTs())) {
                     $delete_leads[] = $lead['id'];
                 }
             }
         }
         RGFormsModel::delete_leads($delete_leads);
     }
 }