function output_data($pdf, $lead = array(), $form = array(), $fieldData = array()) { $pdf->AddPage(); $dataArray = array(array('Project ID #', 3), array('Project Name', 28), array('Name of person responsible for fire safety at your exhibit', 5), array('Their Email', 15), array('Their phone', 16), array('Description', 19), array('Describe your safety concerns', 12), array('Describe how you plan to keep your exhibit safe', 20), array('Who will be assisting at your exhibit to keep it safe', 11), array('Placement Requirements', 7), array('Do you have Insurance', 9), array('Additional Comments', 13), array('Are you 18 years or older?', 23), array('Signed', 25), array('I am the Parent and/or Legal Guardian of', 26), array('Date', 27)); $pdf->SetFillColor(190, 210, 247); $lineheight = 6; foreach ($dataArray as $data) { $fieldID = $data[1]; if (isset($fieldData[$fieldID])) { $field = $fieldData[$fieldID]; $value = RGFormsModel::get_lead_field_value($lead, $field); if (RGFormsModel::get_input_type($field) != 'email') { $display_value = GFCommon::get_lead_field_display($field, $value); $display_value = apply_filters('gform_entry_field_value', $display_value, $field, $lead, $form); } else { $display_value = $value; } } else { $display_value = ''; } $pdf->MultiCell(0, $lineheight, $data[0] . ': '); $pdf->MultiCell(0, $lineheight, $display_value, 0, 'L', true); $pdf->Ln(); } }
function output_data($pdf, $lead = array(), $form = array(), $fieldData = array()) { $pdf->AddPage(); $dataArray = array(array('Project ID #', 3, 'text'), array('Project Name', 38, 'text'), array('Name of person responsible for fire safety at your exhibit', 21, 'text'), array('Their Email', 23, 'text'), array('Their Phone', 24, 'text'), array('Description', 37, 'textarea'), array('Describe your fire safety concerns', 19, 'textarea'), array('Describe how you plan to keep your exhibit safe', 27, 'textarea'), array('Who will be assisting at your exhibit to keep it safe', 20, 'text'), array('Placement Requirements', 7, 'textarea'), array('What is burning', 10, 'text'), array('What is the fuel source', 11, 'text'), array('how much is fuel is burning and in what time period', 12, 'textarea'), array('how much fuel will you have at the event, including tank sizes', 13, 'textarea'), array('where and how is the fuel stored', 14, 'text'), array('Does the valve have an electronic propane sniffer', 15, 'text'), array('Other suppression devices', 16, 'textarea'), array('Do you have insurance?', 18, 'text'), array('Additional comments', 28, 'textarea'), array('Are you 18 years or older?', 30, 'text'), array('Signed', 32, 'text'), array('I am the Parent and/or Legal Guardian of', 33, 'text'), array('Date', 34, 'text')); $pdf->SetFillColor(190, 210, 247); $lineheight = 6; foreach ($dataArray as $data) { $fieldID = $data[1]; if (isset($fieldData[$fieldID])) { $field = $fieldData[$fieldID]; $value = RGFormsModel::get_lead_field_value($lead, $field); if (RGFormsModel::get_input_type($field) != 'email') { $display_value = GFCommon::get_lead_field_display($field, $value); $display_value = apply_filters('gform_entry_field_value', $display_value, $field, $lead, $form); } else { $display_value = $value; } } else { $display_value = ''; } $pdf->MultiCell(0, $lineheight, $data[0] . ': '); $pdf->MultiCell(0, $lineheight, $display_value, 0, 'L', true); $pdf->Ln(); } }
/** * Adds special support for file upload, post image and multi input merge tags. */ public static function preview_special_merge_tags($value, $input_id, $merge_tag, $field) { // added to prevent overriding :noadmin filter (and other filters that remove fields) if (!$value) { return $value; } $input_type = RGFormsModel::get_input_type($field); $is_upload_field = in_array($input_type, array('post_image', 'fileupload')); $is_multi_input = is_array(rgar($field, 'inputs')); $is_input = intval($input_id) != $input_id; if (!$is_upload_field && !$is_multi_input) { return $value; } // if is individual input of multi-input field, return just that input value if ($is_input) { return $value; } $form = RGFormsModel::get_form_meta($field['formId']); $lead = self::create_lead($form); $currency = GFCommon::get_currency(); if (is_array(rgar($field, 'inputs'))) { $value = RGFormsModel::get_lead_field_value($lead, $field); return GFCommon::get_lead_field_display($field, $value, $currency); } switch ($input_type) { case 'fileupload': $value = self::preview_image_value("input_{$field['id']}", $field, $form, $lead); $value = self::preview_image_display($field, $form, $value); break; default: $value = self::preview_image_value("input_{$field['id']}", $field, $form, $lead); $value = GFCommon::get_lead_field_display($field, $value, $currency); break; } return $value; }
/** * Given an entry and a form field id, calculate the entry value for that field. * * @access public * @param array $entry * @param array $field * @return null|string */ public static function field_value($entry, $field_settings, $format = 'html') { if (empty($entry['form_id']) || empty($field_settings['id'])) { return NULL; } $gravityview_view = GravityView_View::getInstance(); $field_id = $field_settings['id']; $form = $gravityview_view->getForm(); $field = gravityview_get_field($form, $field_id); if ($field && is_numeric($field_id)) { // Used as file name of field template in GV. // Don't use RGFormsModel::get_input_type( $field ); we don't care if it's a radio input; we want to know it's a 'quiz' field $field_type = $field->type; $value = RGFormsModel::get_lead_field_value($entry, $field); } else { $field = GravityView_Fields::get_associated_field($field_id); $field_type = $field_id; // Used as file name of field template in GV } // If a Gravity Forms Field is found, get the field display if ($field) { // Prevent any PHP warnings that may be generated ob_start(); $display_value = GFCommon::get_lead_field_display($field, $value, $entry["currency"], false, $format); if ($errors = ob_get_clean()) { do_action('gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors); } $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $entry, $form); // prevent the use of merge_tags for non-admin fields if (!empty($field->adminOnly)) { $display_value = self::replace_variables($display_value, $form, $entry); } } else { $value = $display_value = rgar($entry, $field_id); $display_value = $value; } // Check whether the field exists in /includes/fields/{$field_type}.php // This can be overridden by user template files. $field_path = $gravityview_view->locate_template("fields/{$field_type}.php"); // Set the field data to be available in the templates $gravityview_view->setCurrentField(array('form' => $form, 'field_id' => $field_id, 'field' => $field, 'field_settings' => $field_settings, 'value' => $value, 'display_value' => $display_value, 'format' => $format, 'entry' => $entry, 'field_type' => $field_type, 'field_path' => $field_path)); if (!empty($field_path)) { do_action('gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path)); ob_start(); load_template($field_path, false); $output = ob_get_clean(); } else { // Backup; the field template doesn't exist. $output = $display_value; } // Get the field settings again so that the field template can override the settings $field_settings = $gravityview_view->getCurrentField('field_settings'); /** * @filter `gravityview_field_entry_value_{$field_type}_pre_link` Modify the field value output for a field type before Show As Link setting is applied. Example: `gravityview_field_entry_value_number_pre_link` * @since 1.16 * @param string $output HTML value output * @param array $entry The GF entry array * @param array $field_settings Settings for the particular GV field * @param array $field Field array, as fetched from GravityView_View::getCurrentField() */ $output = apply_filters('gravityview_field_entry_value_' . $field_type . '_pre_link', $output, $entry, $field_settings, $gravityview_view->getCurrentField()); /** * Link to the single entry by wrapping the output in an anchor tag * * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example. * */ if (!empty($field_settings['show_as_link']) && !gv_empty($output, false, false)) { $link_atts = empty($field_settings['new_window']) ? array() : array('target' => '_blank'); $output = self::entry_link_html($entry, $output, $link_atts, $field_settings); } /** * @filter `gravityview_field_entry_value_{$field_type}` Modify the field value output for a field type. Example: `gravityview_field_entry_value_number` * @since 1.6 * @param string $output HTML value output * @param array $entry The GF entry array * @param array $field_settings Settings for the particular GV field * @param array $field Current field being displayed */ $output = apply_filters('gravityview_field_entry_value_' . $field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField()); /** * @filter `gravityview_field_entry_value` Modify the field value output for all field types * @param string $output HTML value output * @param array $entry The GF entry array * @param array $field_settings Settings for the particular GV field * @param array $field_data {@since 1.6} */ $output = apply_filters('gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField()); return $output; }
function make_directory($atts) { global $wpdb, $wp_rewrite, $post, $wpdb, $directory_shown, $kws_gf_scripts, $kws_gf_styles; if (!class_exists('GFEntryDetail')) { @(require_once GFCommon::get_base_path() . "/entry_detail.php"); } if (!class_exists('GFCommon')) { @(require_once WP_PLUGIN_DIR . "/gravityforms/common.php"); } if (!class_exists('RGFormsModel')) { @(require_once WP_PLUGIN_DIR . "/gravityforms/forms_model.php"); } //quit if version of wp is not supported if (!class_exists('GFCommon') || !GFCommon::ensure_wp_version()) { return; } ob_start(); // Using ob_start() allows us to use echo instead of $output .= foreach ($atts as $key => $att) { if (strtolower($att) == 'false') { $atts[$key] = false; } if (strtolower($att) == 'true') { $atts[$key] = true; } } $atts['approved'] = isset($atts['approved']) ? $atts['approved'] : -1; if (!empty($atts['lightboxsettings']) && is_string($atts['lightboxsettings'])) { $atts['lightboxsettings'] = explode(',', $atts['lightboxsettings']); } $options = self::directory_defaults($atts); // Make sure everything is on the same page. if (is_array($options['lightboxsettings'])) { foreach ($options['lightboxsettings'] as $key => $value) { if (is_numeric($key)) { $options['lightboxsettings']["{$value}"] = $value; unset($options['lightboxsettings']["{$key}"]); } } } extract($options); $form_id = $form; $form = RGFormsModel::get_form_meta($form_id); if (empty($form)) { return; } $sort_field = empty($_GET["sort"]) ? $sort : $_GET["sort"]; $sort_direction = empty($_GET["dir"]) ? $dir : $_GET["dir"]; $search_query = !empty($_GET["gf_search"]) ? $_GET["gf_search"] : null; $start_date = !empty($_GET["start_date"]) ? $_GET["start_date"] : $start_date; $end_date = !empty($_GET["end_date"]) ? $_GET["end_date"] : $end_date; $page_index = empty($_GET["page"]) ? $startpage - 1 : intval($_GET["page"]) - 1; $star = isset($_GET["star"]) && is_numeric($_GET["star"]) ? intval($_GET["star"]) : null; $read = isset($_GET["read"]) && is_numeric($_GET["read"]) ? intval($_GET["read"]) : null; $first_item_index = $page_index * $page_size; $link_params = array(); if (!empty($page_index)) { $link_params['page'] = $page_index; } $formaction = remove_query_arg(array('gf_search', 'sort', 'dir', 'page', 'edit'), add_query_arg($link_params)); $tableclass .= !empty($jstable) ? ' tablesorter' : ''; $title = $form["title"]; $sort_field_meta = RGFormsModel::get_field($form, $sort_field); $is_numeric = $sort_field_meta["type"] == "number"; $columns = RGFormsModel::get_grid_columns($form_id, true); $approvedcolumn = false; if ($approved || !empty($smartapproval) && $approved === -1) { $approvedcolumn = self::get_approved_column($form); } if (!empty($smartapproval) && $approved === -1 && !empty($approvedcolumn)) { $approved = true; // If there is an approved column, turn on approval } else { $approved = false; // Otherwise, show entries as normal. } $entrylinkcolumns = self::get_entrylink_column($form, $entry); $adminonlycolumns = self::get_admin_only($form); // // Show only a single entry // if (!empty($entry) && ($detail = self::process_lead_detail(true, $entryback, $showadminonly, $adminonlycolumns, $approvedcolumn, $options, $entryonly))) { echo $detail; if (!empty($entryonly)) { do_action('kws_gf_after_directory', do_action('kws_gf_after_directory_form_' . $form_id, $form, compact($approved, $sort_field, $sort_direction, $search_query, $first_item_index, $page_size, $star, $read, $is_numeric, $start_date, $end_date))); $content = ob_get_contents(); // Get the output ob_end_clean(); // Clear the cache // If the form is form #2, two filters are applied: `kws_gf_directory_output_2` and `kws_gf_directory_output` $content = apply_filters('kws_gf_directory_output', apply_filters('kws_gf_directory_output_' . $form_id, self::pseudo_filter($content, $directoryview))); return $content; } } // // Or start to generate the directory // $leads = GFDirectory::get_leads($form_id, $sort_field, $sort_direction, $search_query, $first_item_index, $page_size, $star, $read, $is_numeric, $start_date, $end_date, 'active', $approvedcolumn, $limituser); # if(!$showadminonly) { $columns = self::remove_admin_only($columns, $adminonlycolumns, $approvedcolumn, false, false, $form); $leads = self::remove_admin_only($leads, $adminonlycolumns, $approvedcolumn, true, false, $form); # } // Allow lightbox to determine whether showadminonly is valid without passing a query string in URL if ($entry === true && !empty($lightboxsettings['entry'])) { if (get_transient('gf_form_' . $form_id . '_post_' . $post->ID . '_showadminonly') != $showadminonly) { set_transient('gf_form_' . $form_id . '_post_' . $post->ID . '_showadminonly', $showadminonly, 60 * 60); } } else { delete_transient('gf_form_' . $form_id . '_post_' . $post->ID . '_showadminonly'); } // Get a list of query args for the pagination links if (!empty($search_query)) { $args["gf_search"] = urlencode($search_query); } if (!empty($sort_field)) { $args["sort"] = $sort_field; } if (!empty($sort_direction)) { $args["dir"] = $sort_direction; } if (!empty($star)) { $args["star"] = $star; } if ($page_size > 0) { $lead_count = self::get_lead_count($form_id, $search_query, $star, $read, $approvedcolumn, $approved, $leads, $start_date, $end_date, $limituser); $page_links = array('base' => @add_query_arg('page', '%#%'), 'format' => '&page=%#%', 'add_args' => $args, 'prev_text' => $prev_text, 'next_text' => $next_text, 'total' => ceil($lead_count / $page_size), 'current' => $page_index + 1, 'show_all' => $pagelinksshowall); $page_links = apply_filters('kws_gf_results_pagination', $page_links); $page_links = paginate_links($page_links); } else { // Showing all results $page_links = false; $lead_count = sizeof($leads); } if (!isset($directory_shown)) { $directory_shown = true; if (!empty($lightboxsettings['images']) || !empty($lightboxsettings['entry'])) { if (!is_array($kws_gf_scripts) || !in_array('colorbox', $kws_gf_scripts)) { wp_print_scripts(array("colorbox")); } if (!is_array($kws_gf_styles) || !in_array('colorbox', $kws_gf_styles)) { wp_print_styles(array("colorbox")); } } if (!empty($jstable)) { ?> <?php if (!in_array('tablesorter-blue', $kws_gf_styles)) { ?> <link href="<?php echo WP_PLUGIN_URL . "/" . basename(dirname(__FILE__)); ?> /tablesorter/themes/blue/style.css" rel="stylesheet" /> <?php } if (!in_array('tablesorter-min', $kws_gf_scripts)) { ?> <script type="text/javascript" src="<?php echo WP_PLUGIN_URL . "/" . basename(dirname(__FILE__)); ?> /tablesorter/jquery.tablesorter.min.js"></script> <?php } } ?> <script type="text/javascript"> <?php if (!empty($lightboxsettings['images']) || !empty($lightboxsettings['entry'])) { ?> var tb_pathToImage = "<?php echo site_url('/wp-includes/js/thickbox/loadingAnimation.gif'); ?> "; var tb_closeImage = "<?php echo site_url('/wp-includes/js/thickbox/tb-close.png'); ?> "; var tb_height = 600; <?php } ?> function not_empty(variable) { if(variable == '' || variable == null || variable == 'undefined' || typeof(variable) == 'undefined') { return false; } else { return true; } } <?php if (!empty($jstable)) { ?> jQuery(document).ready(function($) { jQuery('.tablesorter').each(function() { $(this).tablesorter(<?php echo apply_filters('kws_gf_directory_tablesorter_options', ''); ?> ); }); }); <?php } else { if (isset($jssearch) && $jssearch) { ?> function Search(search, sort_field_id, sort_direction){ if(not_empty(search)) { var search = "&gf_search=" + encodeURIComponent(search); } else { var search = ''; } if(not_empty(sort_field_id)) { var sort = "&sort=" + sort_field_id; } else { var sort = ''; } if(not_empty(sort_direction)) { var dir = "&dir=" + sort_direction; } else { var dir = ''; } var page = '<?php if ($wp_rewrite->using_permalinks()) { echo '?'; } else { echo '&'; } ?> page='+<?php echo isset($_GET['page']) ? intval($_GET['page']) : '"1"'; ?> ; var location = "<?php echo get_permalink($post->ID); ?> "+page+search+sort+dir; document.location = location; } <?php } } ?> </script> <link rel="stylesheet" href="<?php echo GFCommon::get_base_url(); ?> /css/admin.css" type="text/css" /> <?php } ?> <div class="wrap"> <?php if ($icon) { ?> <img alt="<?php _e("Gravity Forms", "gravity-forms-addons"); ?> " src="<?php echo GFCommon::get_base_url(); ?> /images/gravity-title-icon-32.png" style="float:left; margin:15px 7px 0 0;"/><?php } ?> <?php if ($titleshow) { ?> <h2><?php echo $titleprefix . $title; ?> </h2><?php } ?> <?php if ($search && ($lead_count > 0 || !empty($_GET['gf_search']))) { ?> <form id="lead_form" method="get" action="<?php echo $formaction; ?> "> <p class="search-box"> <label class="hidden" for="lead_search"><?php _e("Search Entries:", "gravity-forms-addons"); ?> </label> <input type="text" name="gf_search" id="lead_search" value="<?php echo $search_query; ?> "<?php if ($searchtabindex) { echo ' tabindex="' . intval($searchtabindex) . '"'; } ?> /> <?php if (!empty($_GET['p'])) { ?> <input name="p" type="hidden" value="<?php echo esc_html($_GET['p']); ?> " /> <?php } ?> <input type="submit" class="button" id="lead_search_button" value="<?php _e("Search", "gravity-forms-addons"); ?> "<?php if ($searchtabindex) { echo ' tabindex="' . intval($searchtabindex++) . '"'; } ?> /> </p> </form> <?php } //Displaying paging links if appropriate if ($lead_count > 0 && $showcount || $page_links) { if ($lead_count == 0) { $first_item_index--; } ?> <div class="tablenav"> <div class="tablenav-pages"> <?php if ($showcount) { if ($first_item_index + $page_size > $lead_count || $page_size <= 0) { $second_part = $lead_count; } else { $second_part = $first_item_index + $page_size; } ?> <span class="displaying-num"><?php printf(__("Displaying %d - %d of %d", "gravity-forms-addons"), $first_item_index + 1, $second_part, $lead_count); ?> </span> <?php } if ($page_links) { echo $page_links; } ?> </div> <div class="clear"></div> </div> <?php } do_action('kws_gf_before_directory_after_nav', do_action('kws_gf_before_directory_after_nav_form_' . $form_id, $form, $leads, compact($approved, $sort_field, $sort_direction, $search_query, $first_item_index, $page_size, $star, $read, $is_numeric, $start_date, $end_date))); ?> <table class="<?php echo $tableclass; ?> " cellspacing="0"<?php if (!empty($tablewidth)) { echo ' width="' . $tablewidth . '"'; } echo $tablestyle ? ' style="' . $tablestyle . '"' : ''; ?> > <?php if ($thead) { ?> <thead> <tr> <?php $addressesExist = false; 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"; } if (is_array($adminonlycolumns) && !in_array($field_id, $adminonlycolumns) || is_array($adminonlycolumns) && in_array($field_id, $adminonlycolumns) && $showadminonly || !$showadminonly) { if ($field_info['type'] == 'address' && $appendaddress && $hideaddresspieces) { $addressesExist = true; continue; } ?> <?php if (isset($jssearch) && $jssearch && !isset($jstable)) { ?> <th scope="col" class="manage-column" onclick="Search('<?php echo $search_query; ?> ', '<?php echo $field_id; ?> ', '<?php echo $dir; ?> ');" style="cursor:pointer;"><?php } elseif (isset($jstable) && $jstable) { ?> <th scope="col" class="manage-column"> <?php } else { ?> <th scope="col" class="manage-column"> <a href="<?php $searchpage = isset($_GET['page']) ? intval($_GET['page']) : 1; echo add_query_arg(array('gf_search' => $search_query, 'sort' => $field_id, 'dir' => $dir, 'page' => $searchpage), get_permalink($post->ID)); ?> "><?php } if ($field_info['type'] == 'id' && $entry) { $label = $entryth; } else { $label = $field_info["label"]; } $label = apply_filters('kws_gf_directory_th', apply_filters('kws_gf_directory_th_' . $field_id, apply_filters('kws_gf_directory_th_' . sanitize_title($label), $label))); echo esc_html($label); if (!isset($jssearch) || !$jssearch && empty($jstable)) { ?> </a> <?php } ?> </th> <?php } } if ($appendaddress && $addressesExist) { ?> <th scope="col" class="manage-column" onclick="Search('<?php echo $search_query; ?> ', '<?php echo $field_id; ?> ', '<?php echo $dir; ?> ');" style="cursor:pointer;"><?php $label = apply_filters('kws_gf_directory_th', apply_filters('kws_gf_directory_th_address', 'Address')); echo esc_html($label); ?> </th> <?php } ?> </tr> </thead> <?php } ?> <tbody class="list:user user-list"> <?php if (sizeof($leads) > 0 && $lead_count > 0) { $field_ids = array_keys($columns); $evenodd = ''; foreach ($leads as $lead) { flush(); echo "\n\t\t\t\t\t\t"; $address = array(); $celltitle = ''; if ($approved) { $leadapproved = self::check_approval($lead, $approvedcolumn); } if (isset($leadapproved) && $leadapproved && $approved || !$approved) { $target = ''; if ($linknewwindow && empty($lightboxsettings['images'])) { $target = ' target="_blank"'; } $valignattr = ''; if ($valign && $directoryview == 'table') { $valignattr = ' valign="' . $valign . '"'; } $nofollow = ''; if ($nofollowlinks) { $nofollow = ' rel="nofollow"'; } $evenodd = $evenodd == ' odd' ? ' even' : ' odd'; $evenodd = apply_filters('kws_gf_directory_evenodd', $evenodd); ?> <tr<?php if ($showrowids) { ?> id="lead_row_<?php echo $lead["id"]; ?> " <?php } ?> class='<?php echo trim($rowclass . $evenodd); echo $lead["is_starred"] ? " featured" : ""; ?> '<?php echo $rowstyle ? ' style="' . $rowstyle . '"' : ''; echo $valignattr; ?> ><?php $class = ""; $is_first_column = true; $full_address = ''; foreach ($field_ids as $field_id) { $lightboxclass = ''; if (!empty($lightboxsettings['images'])) { $lightboxclass = ' class="thickbox colorbox lightbox"'; } $value = isset($lead[$field_id]) ? $lead[$field_id] : ''; $input_type = !empty($columns[$field_id]["inputType"]) ? $columns[$field_id]["inputType"] : $columns[$field_id]["type"]; switch ($input_type) { case "address": $address['id'] = floor((int) $field_id); $address[$field_id] = $value; if ($hideaddresspieces) { $value = NULL; break; } break; 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) && $lead[$input_id] == $columns[$field_id]["label"]) { $value = "<img src='" . GFCommon::get_base_url() . "/images/tick.png'/>"; } } break; case "fileupload": case "post_image": $valueArray = explode("|:|", $value); @(list($url, $title, $caption, $description) = $valueArray); $size = ''; if (!empty($url)) { //displaying thumbnail (if file is an image) or an icon based on the extension $icon = self::get_icon_url($url); if (!preg_match('/icon\\_image\\.gif/ism', $icon)) { $src = $icon; if (!empty($getimagesize)) { $size = @getimagesize($src); $img = "<img src='{$src}' {$size[3]}/>"; } else { $size = false; $img = "<img src='{$src}' />"; } } else { // No thickbox for non-images please switch (strtolower(trim($postimage))) { case 'image': $src = $url; break; case 'icon': default: $src = $icon; break; } if (!empty($getimagesize)) { $size = @getimagesize($src); } else { $size = false; } } $img = array('src' => $src, 'size' => $size, 'title' => $title, 'caption' => $caption, 'description' => $description, 'url' => esc_attr($url), 'code' => isset($size[3]) ? "<img src='{$src}' {$size[3]} />" : "<img src='{$src}' />"); $img = apply_filters('kws_gf_directory_lead_image', apply_filters('kws_gf_directory_lead_image_' . $postimage, apply_filters('kws_gf_directory_lead_image_' . $lead['id'], $img))); if (in_array('images', $lightboxsettings) || !empty($lightboxsettings['images'])) { $lightboxclass .= ' rel="directory_all directory_images"'; } $value = "<a href='{$url}'{$target}{$lightboxclass}>{$img['code']}</a>"; } break; case "source_url": if (in_array('urls', $lightboxsettings) || !empty($lightboxsettings['urls'])) { $lightboxclass .= ' rel="directory_all directory_urls"'; } if ($linkwebsite) { $value = "<a href='" . esc_attr($lead["source_url"]) . "'{$target}{$lightboxclass} title='" . esc_attr($lead["source_url"]) . "'{$nofollow}>.../" . esc_attr(GFCommon::truncate_url($lead["source_url"])) . "</a>"; } else { $value = esc_attr(GFCommon::truncate_url($lead["source_url"])); } break; case "textarea": case "post_content": case "post_excerpt": if ($fulltext) { $long_text = $value = ""; if (isset($lead[$field_id]) && strlen($lead[$field_id]) >= GFORMS_MAX_FIELD_LENGTH) { $long_text = get_gf_field_value_long($lead["id"], $field_id); } if (isset($lead[$field_id])) { $value = !empty($long_text) ? $long_text : $lead[$field_id]; } if ($wpautop) { $value = wpautop($value); } } else { $value = esc_html($value); } break; case "date_created": $value = GFCommon::format_date($value, false, $datecreatedformat); break; case "date": $field = RGFormsModel::get_field($form, $field_id); if ($dateformat) { $value = GFCommon::date_display($value, $dateformat); } else { $value = GFCommon::date_display($value, $field["dateFormat"]); } break; case "id": $linkClass = ''; break; case "list": $field = RGFormsModel::get_field($form, $field_id); $value = GFCommon::get_lead_field_display($field, $value); break; default: $input_type = 'text'; if (is_email($value) && $linkemail) { $value = "<a href='mailto:{$value}'{$nofollow}>{$value}</a>"; } elseif (preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $value) && $linkwebsite) { $href = $value; if (!empty($lightboxsettings['images'])) { if (in_array('urls', $lightboxsettings) || !empty($lightboxsettings['urls'])) { $lightboxclass .= ' rel="directory_all directory_urls"'; } $linkClass = $lightboxclass; } else { $linkClass = isset($linkClass) ? $linkClass : ''; } if ($truncatelink) { $value = apply_filters('kws_gf_directory_anchor_text', $value); } $value = "<a href='{$href}'{$nofollow}{$target}{$linkClass}>{$value}</a>"; } else { $value = esc_html($value); } } if ($is_first_column) { echo "\n"; } if ($value !== NULL) { if (isset($columns["{$field_id}"]['label']) && $hovertitle || $directoryview !== 'table') { $celltitle = ' title="' . esc_html(apply_filters('kws_gf_directory_th', apply_filters('kws_gf_directory_th_' . $field_id, apply_filters('kws_gf_directory_th_' . sanitize_title($columns["{$field_id}"]['label']), $columns["{$field_id}"]['label'])))) . '"'; } else { $celltitle = ''; } echo "\t\t\t\t\t\t\t"; ?> <td<?php echo empty($class) ? ' class="' . $input_type . '"' : ' class="' . $input_type . ' ' . $class . '"'; echo $valignattr; echo $celltitle; ?> ><?php $value = empty($value) ? ' ' : $value; if (isset($entrylinkcolumns[floor($field_id)])) { $type = $entrylinkcolumns[floor($field_id)]; if ($input_type == 'id' && $entry) { $linkvalue = $entrylink; } elseif ($type === 'label') { $linkvalue = $columns["{$field_id}"]['label']; } elseif (!empty($type) && $type !== 'on') { $linkvalue = str_replace('%value%', $value, $type); } else { $linkvalue = $value; } $value = self::make_entry_link($options, $linkvalue, $lead['id'], $form_id, $field_id); } $value = apply_filters('kws_gf_directory_value', apply_filters('kws_gf_directory_value_' . $input_type, apply_filters('kws_gf_directory_value_' . $field_id, $value))); echo $value; ?> </td><?php echo "\n"; $is_first_column = false; } } if (is_array($address) && !empty($address) && $appendaddress) { $address = apply_filters('kws_gf_directory_td_address', $address, $linknewwindow); if (!is_array($address)) { echo "\t\t\t\t\t\t\t" . '<td class="address" title="' . esc_html(apply_filters('kws_gf_directory_th', apply_filters('kws_gf_directory_th_address', 'Address'))) . '">' . $address . '</td>'; } } ?> </tr> <?php } } } else { ?> <tr> <td colspan="<?php echo sizeof($columns); ?> " style="padding:20px;"><?php if ($search_query) { _e("This search returned no results.", "gravity-forms-addons"); } elseif ($limituser) { _e("This form does not have any visible entries.", "gravity-forms-addons"); } else { _e("This form does not have any entries yet.", "gravity-forms-addons"); } ?> </td> </tr> <?php } ?> </tbody> <?php if ($tfoot) { if (isset($jssearch) && $jssearch && !isset($jstable)) { $th = '<th scope="col" class="manage-column" onclick="Search(\'' . $search_query . '\', \'' . $field_id . '\', \'' . $dir . '\');" style="cursor:pointer;">'; } else { $th = '<th scope="col" class="manage-column">'; } ?> <tfoot> <tr> <?php $addressesExist = false; 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"; } if (is_array($adminonlycolumns) && !in_array($field_id, $adminonlycolumns) || is_array($adminonlycolumns) && in_array($field_id, $adminonlycolumns) && $showadminonly || !$showadminonly) { if ($field_info['type'] == 'address' && $appendaddress && $hideaddresspieces) { $addressesExist = true; continue; } echo $th; if ($field_info['type'] == 'id' && $entry) { $label = $entryth; } else { $label = $field_info["label"]; } $label = apply_filters('kws_gf_directory_th', apply_filters('kws_gf_directory_th_' . $field_id, apply_filters('kws_gf_directory_th_' . sanitize_title($label), $label))); echo esc_html($label); ?> </th> <?php } } if ($appendaddress && $addressesExist) { ?> <th scope="col" class="manage-column" onclick="Search('<?php echo $search_query; ?> ', '<?php echo $field_id; ?> ', '<?php echo $dir; ?> ');" style="cursor:pointer;"><?php $label = apply_filters('kws_gf_directory_th', apply_filters('kws_gf_directory_th_address', 'Address')); echo esc_html($label); ?> </th> <?php } ?> </tr> <?php if (!empty($credit)) { self::get_credit_link(sizeof($columns)); } ?> </tfoot> <?php } ?> </table> <?php do_action('kws_gf_after_directory_before_nav', do_action('kws_gf_after_directory_before_nav_form_' . $form_id, $form, $leads, compact($approved, $sort_field, $sort_direction, $search_query, $first_item_index, $page_size, $star, $read, $is_numeric, $start_date, $end_date))); //Displaying paging links if appropriate if ($lead_count > 0 && $showcount || $page_links) { if ($lead_count == 0) { $first_item_index--; } ?> <div class="tablenav"> <div class="tablenav-pages"> <?php if ($showcount) { if ($first_item_index + $page_size > $lead_count || $page_size <= 0) { $second_part = $lead_count; } else { $second_part = $first_item_index + $page_size; } ?> <span class="displaying-num"><?php printf(__("Displaying %d - %d of %d", "gravity-forms-addons"), $first_item_index + 1, $second_part, $lead_count); ?> </span> <?php } if ($page_links) { echo $page_links; } ?> </div> <div class="clear"></div> </div> <?php } ?> </div> <?php if (empty($credit)) { echo "\n" . '<!-- Directory generated by Gravity Forms Directory & Addons : http://wordpress.org/extend/plugins/gravity-forms-addons/ -->' . "\n"; } do_action('kws_gf_after_directory', do_action('kws_gf_after_directory_form_' . $form_id, $form, $leads, compact($approved, $sort_field, $sort_direction, $search_query, $first_item_index, $page_size, $star, $read, $is_numeric, $start_date, $end_date))); $content = ob_get_contents(); // Get the output ob_end_clean(); // Clear the cache // If the form is form #2, two filters are applied: `kws_gf_directory_output_2` and `kws_gf_directory_output` $content = apply_filters('kws_gf_directory_output', apply_filters('kws_gf_directory_output_' . $form_id, self::pseudo_filter($content, $directoryview))); return $content; // Return it! }
public static function lead_detail_grid($form, $lead, $allow_display_empty_fields = false) { $form_id = $form["id"]; $display_empty_fields = false; if ($allow_display_empty_fields) { $display_empty_fields = rgget("gf_display_empty_fields", $_COOKIE); } ?> <table cellspacing="0" class="widefat fixed entry-detail-view"> <thead> <tr> <th id="details"> <?php echo $form["title"]; ?> : <?php _e("Entry # ", "gravityforms"); ?> <?php echo $lead["id"]; ?> </th> <th style="width:140px; font-size:10px; text-align: right;"> <?php if ($allow_display_empty_fields) { ?> <input type="checkbox" id="gentry_display_empty_fields" <?php echo $display_empty_fields ? "checked='checked'" : ""; ?> onclick="ToggleShowEmptyFields();"/> <label for="gentry_display_empty_fields"><?php _e("show empty fields", "gravityforms"); ?> </label> <?php } ?> </th> </tr> </thead> <tbody> <?php $count = 0; $field_count = sizeof($form["fields"]); $has_product_fields = false; foreach ($form["fields"] as $field) { switch (RGFormsModel::get_input_type($field)) { case "section": if (!GFCommon::is_section_empty($field, $form, $lead) || $display_empty_fields) { $count++; $is_last = $count >= $field_count ? true : false; ?> <tr> <td colspan="2" class="entry-view-section-break<?php echo $is_last ? " lastrow" : ""; ?> "><?php echo esc_html(GFCommon::get_label($field)); ?> </td> </tr> <?php } break; case "captcha": case "html": case "password": case "page": //ignore captcha, html, password, page field break; default: //ignore product fields as they will be grouped together at the end of the grid if (GFCommon::is_product_field($field["type"])) { $has_product_fields = true; continue; } $value = RGFormsModel::get_lead_field_value($lead, $field); $display_value = GFCommon::get_lead_field_display($field, $value, $lead["currency"]); $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $lead, $form); if ($display_empty_fields || !empty($display_value) || $display_value === "0") { $count++; $is_last = $count >= $field_count && !$has_product_fields ? true : false; $last_row = $is_last ? " lastrow" : ""; $display_value = empty($display_value) && $display_value !== "0" ? " " : $display_value; $content = ' <tr> <td colspan="2" class="entry-view-field-name">' . esc_html(GFCommon::get_label($field)) . '</td> </tr> <tr> <td colspan="2" class="entry-view-field-value' . $last_row . '">' . $display_value . '</td> </tr>'; $content = apply_filters("gform_field_content", $content, $field, $value, $lead["id"], $form["id"]); echo $content; } break; } } $products = array(); if ($has_product_fields) { $products = GFCommon::get_product_fields($form, $lead); if (!empty($products["products"])) { ?> <tr> <td colspan="2" class="entry-view-field-name"><?php echo apply_filters("gform_order_label_{$form["id"]}", apply_filters("gform_order_label", __("Order", "gravityforms"), $form["id"]), $form["id"]); ?> </td> </tr> <tr> <td colspan="2" class="entry-view-field-value lastrow"> <table class="entry-products" cellspacing="0" width="97%"> <colgroup> <col class="entry-products-col1"> <col class="entry-products-col2"> <col class="entry-products-col3"> <col class="entry-products-col4"> </colgroup> <thead> <th scope="col"><?php echo apply_filters("gform_product_{$form_id}", apply_filters("gform_product", __("Product", "gravityforms"), $form_id), $form_id); ?> </th> <th scope="col" class="textcenter"><?php echo apply_filters("gform_product_qty_{$form_id}", apply_filters("gform_product_qty", __("Qty", "gravityforms"), $form_id), $form_id); ?> </th> <th scope="col"><?php echo apply_filters("gform_product_unitprice_{$form_id}", apply_filters("gform_product_unitprice", __("Unit Price", "gravityforms"), $form_id), $form_id); ?> </th> <th scope="col"><?php echo apply_filters("gform_product_price_{$form_id}", apply_filters("gform_product_price", __("Price", "gravityforms"), $form_id), $form_id); ?> </th> </thead> <tbody> <?php $total = 0; foreach ($products["products"] as $product) { ?> <tr> <td> <div class="product_name"><?php echo $product["name"]; ?> </div> <ul class="product_options"> <?php $price = GFCommon::to_number($product["price"]); if (is_array(rgar($product, "options"))) { $count = sizeof($product["options"]); $index = 1; foreach ($product["options"] as $option) { $price += GFCommon::to_number($option["price"]); $class = $index == $count ? " class='lastitem'" : ""; $index++; ?> <li<?php echo $class; ?> ><?php echo $option["option_label"]; ?> </li> <?php } } $subtotal = floatval($product["quantity"]) * $price; $total += $subtotal; ?> </ul> </td> <td class="textcenter"><?php echo $product["quantity"]; ?> </td> <td><?php echo GFCommon::to_money($price, $lead["currency"]); ?> </td> <td><?php echo GFCommon::to_money($subtotal, $lead["currency"]); ?> </td> </tr> <?php } $total += floatval($products["shipping"]["price"]); ?> </tbody> <tfoot> <?php if (!empty($products["shipping"]["name"])) { ?> <tr> <td colspan="2" rowspan="2" class="emptycell"> </td> <td class="textright shipping"><?php echo $products["shipping"]["name"]; ?> </td> <td class="shipping_amount"><?php echo GFCommon::to_money($products["shipping"]["price"], $lead["currency"]); ?> </td> </tr> <?php } ?> <tr> <?php if (empty($products["shipping"]["name"])) { ?> <td colspan="2" class="emptycell"> </td> <?php } ?> <td class="textright grandtotal"><?php _e("Total", "gravityforms"); ?> </td> <td class="grandtotal_amount"><?php echo GFCommon::to_money($total, $lead["currency"]); ?> </td> </tr> </tfoot> </table> </td> </tr> <?php } } ?> </tbody> </table> <?php }
private static function get_entry_value($field_id, $entry, $name_fields) { foreach ($name_fields as $name_field) { if ($field_id == $name_field["id"]) { $value = RGFormsModel::get_lead_field_value($entry, $name_field); return GFCommon::get_lead_field_display($name_field, $value); } } return $entry[$field_id]; }
/** * Given an entry and a form field id, calculate the entry value for that field. * * @access public * @param array $entry * @param integer $field * @return null|string */ public static function field_value($entry, $field_settings, $format = 'html') { if (empty($entry['form_id']) || empty($field_settings['id'])) { return NULL; } $gravityview_view = GravityView_View::getInstance(); if (class_exists('GFCache')) { /** * Gravity Forms' GFCache function was thrashing the database, causing double the amount of time for the field_value() method to run. * * The reason is that the cache was checking against a field value stored in a transient every time `GFFormsModel::get_lead_field_value()` is called. * * What we're doing here is telling the GFCache that it's already checked the transient and the value is false, forcing it to just use the non-cached data, which is actually faster. * * @hack * @since 1.3 * @param string $cache_key Field Value transient key used by Gravity Forms * @param mixed false Setting the value of the cache to false so that it's not used by Gravity Forms' GFFormsModel::get_lead_field_value() method * @param boolean false Tell Gravity Forms not to store this as a transient * @param int 0 Time to store the value. 0 is maximum amount of time possible. */ GFCache::set("GFFormsModel::get_lead_field_value_" . $entry["id"] . "_" . $field_settings["id"], false, false, 0); } $field_id = $field_settings['id']; $form = $gravityview_view->getForm(); $field = gravityview_get_field($form, $field_id); $field_type = RGFormsModel::get_input_type($field); if ($field_type) { $field_type = $field['type']; $value = RGFormsModel::get_lead_field_value($entry, $field); } else { // For non-integer field types (`id`, `date_created`, etc.) $field_type = $field_id; $field['type'] = $field_id; $value = isset($entry[$field_type]) ? $entry[$field_type] : NULL; } // Prevent any PHP warnings that may be generated ob_start(); $display_value = GFCommon::get_lead_field_display($field, $value, $entry["currency"], false, $format); if ($errors = ob_get_clean()) { do_action('gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors); } $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $entry, $form); // prevent the use of merge_tags for non-admin fields if (!empty($field['adminOnly'])) { $display_value = self::replace_variables($display_value, $form, $entry); } // Check whether the field exists in /includes/fields/{$field_type}.php // This can be overridden by user template files. $field_exists = $gravityview_view->locate_template("fields/{$field_type}.php"); // Set the field data to be available in the templates $gravityview_view->setCurrentField(array('form' => $form, 'field_id' => $field_id, 'field' => $field, 'field_settings' => $field_settings, 'value' => $value, 'display_value' => $display_value, 'format' => $format, 'entry' => $entry, 'field_type' => $field_type)); if ($field_exists) { do_action('gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_exists)); ob_start(); load_template($field_exists, false); $output = ob_get_clean(); } else { // Backup; the field template doesn't exist. $output = $display_value; } $field_settings = $gravityview_view->getCurrentField('field_settings'); /** * Link to the single entry by wrapping the output in an anchor tag * * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example. * */ if (!empty($field_settings['show_as_link'])) { $output = self::entry_link_html($entry, $output, array(), $field_settings); } /** * @filter `gravityview_field_entry_value_{$field_type}` Modify the field value output for a field type. Example: `gravityview_field_entry_value_number` * @since 1.6 * @param string $output HTML value output * @param array $entry The GF entry array * @param array $field_settings Settings for the particular GV field */ $output = apply_filters('gravityview_field_entry_value_' . $field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField()); /** * @filter `gravityview_field_entry_value` Modify the field value output for all field types * @param string $output HTML value output * @param array $entry The GF entry array * @param array $field_settings Settings for the particular GV field * @param array $field_data {@since 1.6} */ $output = apply_filters('gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField()); return $output; }
public static function send_admin_notification($form, $lead) { $form_id = $form["id"]; //handling admin notification email $subject = GFCommon::replace_variables($form["notification"]["subject"], $form, $lead, false, false); $message = GFCommon::replace_variables($form["notification"]["message"], $form, $lead, false, false, !$form["notification"]["disableAutoformat"]); $message = do_shortcode($message); $from = empty($form["notification"]["fromField"]) ? $form["notification"]["from"] : $lead[$form["notification"]["fromField"]]; if (empty($form["notification"]["fromNameField"])) { $from_name = $form["notification"]["fromName"]; } else { $field = RGFormsModel::get_field($form, $form["notification"]["fromNameField"]); $value = RGFormsModel::get_lead_field_value($lead, $field); $from_name = GFCommon::get_lead_field_display($field, $value); } $replyTo = empty($form["notification"]["replyToField"]) ? $form["notification"]["replyTo"] : $lead[$form["notification"]["replyToField"]]; if (empty($form["notification"]["routing"])) { $email_to = $form["notification"]["to"]; } else { $email_to = array(); foreach ($form["notification"]["routing"] as $routing) { $source_field = RGFormsModel::get_field($form, $routing["fieldId"]); $field_value = RGFormsModel::get_field_value($source_field, array()); $is_value_match = is_array($field_value) ? in_array($routing["value"], $field_value) : $field_value == $routing["value"]; if ($routing["operator"] == "is" && $is_value_match || $routing["operator"] == "isnot" && !$is_value_match) { $email_to[] = $routing["email"]; } } $email_to = join(",", $email_to); } //Running through variable replacement $email_to = GFCommon::replace_variables($email_to, $form, $lead, false, false); $from = GFCommon::replace_variables($from, $form, $lead, false, false); $bcc = GFCommon::replace_variables($form["notification"]["bcc"], $form, $lead, false, false); $reply_to = GFCommon::replace_variables($replyTo, $form, $lead, false, false); $from_name = GFCommon::replace_variables($from_name, $form, $lead, false, false); //Filters the admin notification email to address. Allows users to change email address before notification is sent $to = apply_filters("gform_notification_email_{$form_id}", apply_filters("gform_notification_email", $email_to, $lead), $lead); self::send_email($from, $to, $bcc, $replyTo, $subject, $message, $from_name); }
/** * Shortcode to display the list of completed entries */ function shortcode_gravitylistcompleted($atts) { global $wpdb; $id = $atts['id']; /** * Only do something if we have a form-id */ if ($id) { /** * Get the form data */ $form = $this->gravitylist_form[$id]; /** * Get the Attributes with the defaults from the form-settings * * id : id of the form * rows : number of rows to display * title : display the form title * debug : display field-id and field-type * tquery : enabled tQuery support * gfediturl : destination-url to edit this record * showtoall : show the records to all users or only to form-admin and the record-creator * description : display the form description * displaylead : display lead-id as first column * requirelogin: the user must be logged-in to see the entry-list * */ extract(shortcode_atts(array('id' => $id, 'rows' => $form['spgfle_rows'], 'debug' => 'false', 'title' => 'true', 'tquery' => $form['spgfle_tquery'], 'showtoall' => $form['spgfle_showtoall'], 'description' => 'true', 'displaylead' => $form['spgfle_displaylead'], 'requirelogin' => $form['spgfle_requirelogin']), $atts)); $rows = intval($rows); $debug = strtolower($debug) == "true" ? true : false; $title = strtolower($title) == "true" ? true : false; $tquery = strtolower($tquery) == "true" ? true : false; $showtoall = strtolower($showtoall) == "true" ? true : false; $displaylead = strtolower($displaylead) == "true" ? true : false; $description = strtolower($description) == "true" ? true : false; $requirelogin = strtolower($requirelogin) == "true" ? true : false; /** * Check if it's possible to edit * and build the gfediturl */ $gfediturl = $form['spgfle_gfediturl']; if (!$form['spgfle_enableedit']) { unset($gfediturl); } if (!is_user_logged_in()) { unset($gfediturl); } if ($gfediturl) { $gfediturl = get_permalink($gfediturl); } /** * if requirelogin is set, check if an user is logged in */ if (!$requirelogin || $requirelogin && is_user_logged_in()) { $cssclass = $form['spgfle_cssclass']; $classes = GFCommon::get_browser_class(); $html .= "\t<div class=\"{$classes} gform_wrapper {$cssclass}\" id=\"gform_wrapper_{$id}\" >\n"; /** * Display title and description if needed */ $html .= "\t<div class=\"gform_body {$cssclass}\">\n"; $html .= "\t<br />\n"; /** * Add tQuery support if needed */ if ($tquery) { $tableid = " id=\"gravitylist{$id}\""; if ($form['spgfle_tquerysearch']) { $html .= "<div class=\"gform_tquery_search\">\n"; $html .= "\t" . __("Search", 'spgfle') . ": <input id=\"searchinput{$id}\" type=\"text\" class=\"filter\" />\n"; $html .= "</div>\n"; $html .= "<br />"; } } $html .= "\t<form name=\"gravitylist\" action=\"{$gfediturl}\" method=\"post\">\n"; $html .= "\t\t<input type=\"hidden\" id=\"gform_edit_id\" name=\"gform_edit_id\" value=\"\" />\n"; $html .= "\t\t<input type=\"hidden\" id=\"gform_edit_mode\" name=\"gform_edit_mode\" value=\"\" />\n"; $html .= "\t\t<table class=\"table table-striped table-bordered table-advance table-hover\" {$tableid} cellspacing=\"0\" itemscope=\"itemscope\" itemtype=\"http://schema.org/Table\">\n"; $html .= "\t\t\t<thead>\n"; $html .= "\t\t\t\t<tr>\n"; /** * Add a column to display the lead-id */ if ($displaylead) { $html .= "\t\t\t\t\t<th scope=\"col\">" . esc_html('Order ID') . "</th>\n"; } /** * Loop through the Fields */ foreach ((array) $form['fields'] as $field) { /** * Display 'adminOnly' fields only to form admins */ if (!$field['adminOnly'] || GFCommon::current_user_can_any('gravityforms_edit_entries')) { /** * Only display fields that are checked at the field-settings */ if ($field['spgfle_showinlist']) { $html .= "\t\t\t\t\t<th scope=\"col\">" . esc_html($field['label']); if ($debug == true) { $html .= "\t\t\t\t\t<br />{$field['id']}<br />{$field['type']}"; } $html .= "\t\t\t\t\t</th>\n"; } } } /** * Add a blank column if we need to link to an edit, view or delete url */ if ($gfediturl) { $html .= "\t\t\t\t\t<th scope=\"col\"> </th>\n"; } $html .= "\t\t\t\t</tr>\n"; $html .= "\t\t\t</thead>\n"; $html .= "\t\t\t<tbody>\n"; /** * Create the LIMIT statement */ if (!empty($rows)) { $sqlLimit = "LIMIT {$rows}"; } /** * Support for SpGfMySQL-Connect * If we connected the record to a mysql-table and set 'delete lead' to true * we have to retrieve the values from the mysql-table */ if ($form['spgfmc_tablename'] && $form['spgfmc_deletelead']) { $leads = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$form['spgfmc_tablename']} ORDER BY lead_id DESC {$sqlLimit}"), ARRAY_A); } else { $lead_table_name = RGFormsModel::get_lead_table_name(); if (GFCommon::current_user_can_any('gravityforms_edit_entries') || $showtoall) { $leads = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$lead_table_name} WHERE form_id = {$id} AND status = 'active' AND orderStatus = 'complete' ORDER BY id DESC {$sqlLimit}"), ARRAY_A); } else { $leads = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$lead_table_name} WHERE form_id = {$id} AND created_by = %d AND created_by <> 0 AND status = 'active' AND orderStatus = 'complete' ORDER BY id DESC {$sqlLimit}", wp_get_current_user()->ID), ARRAY_A); } } //echo print_r($leads, true); /** * Loop through the Leads */ foreach ($leads as $lead) { if (is_null($lead['id'])) { $lead['id'] = $lead['lead_id']; } if (is_null($lead['lead_id'])) { $lead['lead_id'] = $lead['id']; } //echo print_r($lead, true); /** * Support for Sp-Gf-MySQL-Connect * If we connected the record to a mysql-table and deleted the data * we have to retrieve the values from the mysql-table */ if ($form['spgfmc_tablename'] && $form['spgfmc_deletefield']) { if (!$form['spgfmc_spgfmc_deletelead']) { /** * If the lead was not deleted we use the 'lead_id' to * connect the MySQL record with the GF lead */ $data = $wpdb->get_row("SELECT * FROM {$form['spgfmc_tablename']} WHERE {$form['spgfmc_field_leadid']} = {$lead['lead_id']}", ARRAY_A); $lead['gform_edit_id'] = $lead['lead_id']; } elseif ($form['spgfmc_spgfmc_deletelead']) { /** * If the lead was deleted we use the already loaded data * But we have to setup some lead values */ $data = $lead; $lead['created_by'] = 0; $lead['gform_edit_id'] = $data[$form['spgfmc_primarykey']]; } else { /** * We can't load any data */ unset($data); } if ($data) { foreach ((array) $form['fields'] as $field) { switch ($field['type']) { case 'address': if ($field['spgfmc_fieldname_address1']) { $lead[$field['id'] . '.1'] = $data[$field['spgfmc_fieldname_address1']]; } if ($field['spgfmc_fieldname_address1']) { $lead[$field['id'] . '.2'] = $data[$field['spgfmc_fieldname_address2']]; } if ($field['spgfmc_fieldname_city']) { $lead[$field['id'] . '.3'] = $data[$field['spgfmc_fieldname_city']]; } if ($field['spgfmc_fieldname_state']) { $lead[$field['id'] . '.4'] = $data[$field['spgfmc_fieldname_state']]; } if ($field['spgfmc_fieldname_zip']) { $lead[$field['id'] . '.5'] = $data[$field['spgfmc_fieldname_zip']]; } if ($field['spgfmc_fieldname_country']) { $lead[$field['id'] . '.6'] = $data[$field['spgfmc_fieldname_country']]; } break; case 'name': if ($field['spgfmc_fieldname_firstname']) { $lead[$field['id'] . '.3'] = $data[$field['spgfmc_fieldname_firstname']]; } if ($field['spgfmc_fieldname_lastname']) { $lead[$field['id'] . '.6'] = $data[$field['spgfmc_fieldname_lastname']]; } default: if ($field['spgfmc_fieldname']) { $lead[$field['id']] = $data[$field['spgfmc_fieldname']]; } break; } } } } else { /** * Retrieve the lead */ $lead = RGFormsModel::get_lead($lead['id']); $lead['gform_edit_id'] = $lead['id']; if (is_null($lead['lead_id'])) { $lead['lead_id'] = $lead['id']; } } $i = 0; $html .= "\t\t\t\t<tr>\n"; //echo print_r($lead, true); /** * Add a column to display the lead-id */ if ($displaylead) { $html .= "\t\t\t\t\t<td scope=\"col\" class=\"col{$i}\" width=\"10%\">{$lead['lead_id']}</td>\n"; } /** * Loop through the Fields */ foreach ($form['fields'] as $field) { /** * Display 'adminOnly' fields only to form admins */ if (!$field['adminOnly'] || GFCommon::current_user_can_any('gravityforms_edit_entries')) { /** * Only display fields that are checked at the field-settings */ if ($field['spgfle_showinlist']) { $i++; unset($value, $display_value); $value = RGFormsModel::get_lead_field_value($lead, $field); /** * Only the value is stored, but we need to display * the display-data for this value */ if ($field['enableChoiceValue'] == '1') { if (!empty($value)) { unset($item, $items, $itemcount); foreach ((array) $value as $single_value) { if (!empty($single_value)) { foreach ($field['choices'] as $choices) { if ($choices['value'] == $single_value) { $items .= '<li>' . $choices['text'] . '</li>'; $item = $choices['text']; $itemcount++; break; } } } } if ($itemcount == 1) { $display_value = $item; } elseif ($itemcount > 0) { $display_value = "<ul class='bulleted'>{$items}</ul>"; } else { $display_value = ""; } } } else { $display_value = GFCommon::get_lead_field_display($field, $value, $lead["currency"]); } $html .= "\t\t\t\t\t<td scope=\"col\" class=\"col{$i}\">{$display_value}</td>\n"; } } } /** * Display Button to the gfEdit Destination */ if ($gfediturl || $gfdeleteurl) { $i++; $html .= "\t\t\t\t\t<td scope=\"col\" class=\"col{$i}\" width=\"25%\">\n"; /** * Display the view button */ if ($form['spgfle_enableview']) { $html .= "\t\t\t\t\t\t<button class=\"btn default btn-xs blue\" onClick=\"SetHiddenFormSettings({$lead['gform_edit_id']}, 'view')\"><i class=\"fa fa-share\"></i>" . __("PDF", 'spgfle') . "</button>\n"; } $html .= "\t\t\t\t\t</td>\n"; } $html .= "\t\t\t\t</tr>\n"; } $html .= "\t\t\t</tbody>\n"; $html .= "\t\t</table>\n"; if (empty($leads)) { $html .= "<p>No Completed Orders Found</p>\n"; } $html .= "\t</form>\n"; $html .= "\t</div>\n"; } else { $html = '<p>' . __("You must be logged in.", 'spgfle') . '</p>'; } } return $html; }
public static function send_admin_notification($form, $lead) { $form_id = $form["id"]; //handling admin notification email $subject = GFCommon::replace_variables(rgget("subject", $form["notification"]), $form, $lead, false, false); $message = GFCommon::replace_variables(rgget("message", $form["notification"]), $form, $lead, false, false, !rgget("disableAutoformat", $form["notification"])); $message = do_shortcode($message); $version_info = self::get_version_info(); $is_expired = !rgempty("expiration_time", $version_info) && $version_info["expiration_time"] < time(); if (!$version_info["is_valid_key"] && $is_expired) { $message .= "<br/><br/>Your Gravity Forms License Key has expired. In order to continue receiving support and software updates you must renew your license key. You can do so by following the renewal instructions on the Gravity Forms Settings page in your WordPress Dashboard or by <a href='http://www.gravityhelp.com/renew-license/?key=" . self::get_key() . "'>clicking here</a>."; } $from = rgempty("fromField", $form["notification"]) ? rgget("from", $form["notification"]) : rgget($form["notification"]["fromField"], $lead); if (rgempty("fromNameField", $form["notification"])) { $from_name = rgget("fromName", $form["notification"]); } else { $field = RGFormsModel::get_field($form, rgget("fromNameField", $form["notification"])); $value = RGFormsModel::get_lead_field_value($lead, $field); $from_name = GFCommon::get_lead_field_display($field, $value); } $replyTo = rgempty("replyToField", $form["notification"]) ? rgget("replyTo", $form["notification"]) : rgget($form["notification"]["replyToField"], $lead); if (rgempty("routing", $form["notification"])) { $email_to = rgget("to", $form["notification"]); } else { $email_to = array(); foreach ($form["notification"]["routing"] as $routing) { $source_field = RGFormsModel::get_field($form, $routing["fieldId"]); $field_value = RGFormsModel::get_field_value($source_field, array()); $is_value_match = is_array($field_value) ? in_array($routing["value"], $field_value) : $field_value == $routing["value"]; if ($routing["operator"] == "is" && $is_value_match || $routing["operator"] == "isnot" && !$is_value_match) { $email_to[] = $routing["email"]; } } $email_to = join(",", $email_to); } //Running through variable replacement $email_to = GFCommon::replace_variables($email_to, $form, $lead, false, false); $from = GFCommon::replace_variables($from, $form, $lead, false, false); $bcc = GFCommon::replace_variables(rgget("bcc", $form["notification"]), $form, $lead, false, false); $reply_to = GFCommon::replace_variables($replyTo, $form, $lead, false, false); $from_name = GFCommon::replace_variables($from_name, $form, $lead, false, false); //Filters the admin notification email to address. Allows users to change email address before notification is sent $to = apply_filters("gform_notification_email_{$form_id}", apply_filters("gform_notification_email", $email_to, $lead), $lead); self::send_email($from, $to, $bcc, $replyTo, $subject, $message, $from_name); }
function set_export_values($value, $form_id, $field_id, $lead) { if ($field_id == 320) { $form = GFAPI::get_form($form_id); foreach ($form['fields'] as $field) { if ($field->id == $field_id) { if (in_array($field->type, array('checkbox', 'select', 'radio'))) { $value = RGFormsModel::get_lead_field_value($lead, $field); return GFCommon::get_lead_field_display($field, $value, $lead["currency"], true); } else { return $value; } } } } return $value; }
/** * Adds special support for file upload, post image and multi input merge tags. */ public static function preview_special_merge_tags($value, $input_id, $options, $field) { $input_type = GFFormsModel::get_input_type($field); $is_upload_field = in_array($input_type, array('post_image', 'fileupload')); $is_multi_upload_field = $is_upload_field && rgar($field, 'multipleFiles'); // added to prevent overriding :noadmin filter (and other filters that remove fields) // added exception for multi upload file fields which have an empty $value at this stage if (!$value && !$is_multi_upload_field) { return $value; } $is_multi_input = is_array(rgar($field, 'inputs')); $is_input = intval($input_id) != $input_id; if (!$is_upload_field && !$is_multi_input) { return $value; } // if is individual input of multi-input field, return just that input value if ($is_input) { return $value; } $form = GFFormsModel::get_form_meta($field['formId']); $entry = self::create_lead($form); $currency = GFCommon::get_currency(); if (is_array(rgar($field, 'inputs'))) { $value = GFFormsModel::get_lead_field_value($entry, $field); return GFCommon::get_lead_field_display($field, $value, $currency, true); } switch ($input_type) { case 'fileupload': $value = self::preview_image_value("input_{$field['id']}", $field, $form, $entry); if ($is_multi_upload_field) { if (is_a($field, 'GF_Field')) { $value = $field->get_value_entry_detail(json_encode(array_filter((array) $value))); } else { $value = GFCommon::get_lead_field_display($field, json_encode($value)); } $input_name = "input_" . str_replace('.', '_', $field['id']); $file_info = self::get_uploaded_file_info($form['id'], $input_name, $field); if ($file_info) { foreach ($file_info as $file) { $value = str_replace('>' . $file['temp_filename'], '>' . $file['uploaded_filename'], $value); } } } else { $value = $input_id == 'all_fields' || $options == 'link' ? self::preview_image_display($field, $form, $value) : $value; } break; default: $value = self::preview_image_value("input_{$field['id']}", $field, $form, $entry); $value = GFCommon::get_lead_field_display($field, $value, $currency); break; } $value = apply_filters('gpps_special_merge_tags_value', $value, $field, $input_id, $options, $form, $entry); $value = apply_filters(sprintf('gpps_special_merge_tags_value_%s', $form['id']), $value, $field, $input_id, $options, $form, $entry); $value = apply_filters(sprintf('gpps_special_merge_tags_value_%s_%s', $form['id'], $field['id']), $value, $field, $input_id, $options, $form, $entry); $value = apply_filters(sprintf('gpps_special_merge_tags_value_%s', $input_type), $value, $field, $input_id, $options, $form, $entry); $value = apply_filters(sprintf('gpps_special_merge_tags_value_%s_%s', $form['id'], $input_type), $value, $field, $input_id, $options, $form, $entry); return $value; }
private function get_entry_value($field_id, $entry, $name_fields) { foreach ($name_fields as $name_field) { if ($field_id == $name_field['id']) { $value = RGFormsModel::get_lead_field_value($entry, $name_field); return GFCommon::get_lead_field_display($name_field, $value); } } return rgar($entry, $field_id); }
function createCSVfile() { //create CSV for individual entries come as a GET request, the mass entry list is a POST request $form_id = isset($_POST['exportForm']) && $_POST['exportForm'] != '' ? $_POST['exportForm'] : ''; //if the form_id is not set in the post fields, let check the get fields if ($form_id == '') { $form_id = isset($_GET['exForm']) && $_GET['exForm'] != '' ? $_GET['exForm'] : ''; } if ($form_id == '') { die('please select a form'); } $entry_id = isset($_GET['exEntry']) && $_GET['exEntry'] != '' ? $_GET['exEntry'] : ''; //create CSV file $form = GFAPI::get_form($form_id); $fieldData = array(); //put fieldData in a usable array foreach ($form['fields'] as $field) { if ($field->type != 'section' && $field->type != 'html' && $field->type != 'page') { $fieldData[$field['id']] = $field; } } $search_criteria['status'] = 'active'; $entries = array(); if ($entry_id == '') { $entries = GFAPI::get_entries($form_id, $search_criteria, null, array('offset' => 0, 'page_size' => 9999)); } else { //use the submitted entry $entries[] = GFAPI::get_entry($entry_id); } $output = array('Entry ID', 'FormID'); $list = array(); foreach ($fieldData as $field) { $output[] = $field['label']; } $list[] = $output; foreach ($entries as $entry) { $fieldArray = array($entry['id'], $form_id); foreach ($fieldData as $field) { if ($field->id == 320 || $field->id == 321) { if (in_array($field->type, array('checkbox', 'select', 'radio'))) { $currency = GFCommon::get_currency(); $value = RGFormsModel::get_lead_field_value($entry, $field); array_push($fieldArray, GFCommon::get_lead_field_display($field, $value, $currency, true)); } } else { array_push($fieldArray, isset($entry[$field->id]) ? $entry[$field->id] : ""); } } $list[] = $fieldArray; } //write CSV file // output headers so that the file is downloaded rather than displayed header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=form-' . $form_id . ($entry_id != '' ? '-' . $entry_id : '') . '.csv'); $file = fopen('php://output', 'w'); foreach ($list as $line) { fputcsv($file, $line); } fclose($file); //wp_redirect( admin_url( 'admin.php?page=mf_export')); die; exit; }
/** * @param $form * @param $entry * @param bool|false $allow_display_empty_fields * @param array $editable_fields * @param Gravity_Flow_Step|null $current_step */ public static function entry_detail_grid($form, $entry, $allow_display_empty_fields = false, $editable_fields = array(), $current_step = null) { $form_id = absint($form['id']); $display_empty_fields = false; if ($allow_display_empty_fields) { $display_empty_fields = rgget('gf_display_empty_fields', $_COOKIE); } $display_empty_fields = (bool) apply_filters('gravityflow_entry_detail_grid_display_empty_fields', $display_empty_fields, $form, $entry); $condtional_logic_enabled = $current_step && $current_step->conditional_logic_editable_fields_enabled; self::register_form_init_scripts($form, array(), $condtional_logic_enabled); if (apply_filters('gform_init_scripts_footer', false)) { add_action('wp_footer', create_function('', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');'), 20); add_action('gform_preview_footer', create_function('', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');')); } else { echo GFFormDisplay::get_form_init_scripts($form); $current_page = 1; $scripts = "<script type='text/javascript'>" . apply_filters('gform_cdata_open', '') . " jQuery(document).ready(function(){jQuery(document).trigger('gform_post_render', [{$form_id}, {$current_page}]) } ); " . apply_filters('gform_cdata_close', '') . '</script>'; echo $scripts; } ?> <input type="hidden" name="action" id="action" value="" /> <input type="hidden" name="save" id="action" value="Update" /> <input type="hidden" name="screen_mode" id="screen_mode" value="<?php echo esc_attr(rgpost('screen_mode')); ?> " /> <table cellspacing="0" class="widefat fixed entry-detail-view"> <thead> <tr> <th id="details"> <?php $title = sprintf('%s : %s %s', esc_html($form['title']), __('Entry # ', 'gravityflow'), absint($entry['id'])); echo apply_filters('gravityflow_title_entry_detail', $title, $form, $entry); ?> </th> <th style="width:140px; font-size:10px; text-align: right;"> <?php if ($allow_display_empty_fields) { ?> <input type="checkbox" id="gentry_display_empty_fields" <?php echo $display_empty_fields ? "checked='checked'" : ''; ?> onclick="ToggleShowEmptyFields();" /> <label for="gentry_display_empty_fields"><?php _e('show empty fields', 'gravityflow'); ?> </label> <?php } ?> </th> </tr> </thead> <tbody class="<?php echo GFCommon::get_ul_classes($form); ?> "> <?php $count = 0; $field_count = sizeof($form['fields']); $has_product_fields = false; $display_fields_mode = $current_step ? $current_step->display_fields_mode : 'all_fields'; $display_fields_selected = $current_step && is_array($current_step->display_fields_selected) ? $current_step->display_fields_selected : array(); foreach ($form['fields'] as &$field) { /* @var GF_Field $field */ $display_field = true; if ($display_fields_mode == 'selected_fields') { if (!in_array($field->id, $display_fields_selected)) { $display_field = false; } } else { if (GFFormsModel::is_field_hidden($form, $field, array(), $entry)) { $display_field = false; } } $display_field = (bool) apply_filters('gravityflow_workflow_detail_display_field', $display_field, $field, $form, $entry, $current_step); switch (RGFormsModel::get_input_type($field)) { case 'section': if (!GFCommon::is_section_empty($field, $form, $entry) || $display_empty_fields) { $count++; $is_last = $count >= $field_count ? true : false; ?> <tr> <td colspan="2" class="entry-view-section-break<?php echo $is_last ? ' lastrow' : ''; ?> "><?php echo esc_html(rgar($field, 'label')); ?> </td> </tr> <?php } break; case 'captcha': case 'password': case 'page': //ignore captcha, password, page field break; case 'html': if ($display_field) { ?> <tr> <td colspan="2" class="entry-view-field-value"><?php echo $field->content; ?> </td> </tr> <?php } break; default: $field_id = $field->id; if (in_array($field_id, $editable_fields)) { if ($current_step->conditional_logic_editable_fields_enabled) { $field->conditionalLogicFields = GFFormDisplay::get_conditional_logic_fields($form, $field->id); } if (GFCommon::is_product_field($field->type)) { $has_product_fields = true; } $posted_step_id = rgpost('step_id'); if ($posted_step_id == $current_step->get_id()) { $value = GFFormsModel::get_field_value($field); } else { $value = GFFormsModel::get_lead_field_value($entry, $field); if ($field->get_input_type() == 'email' && $field->emailConfirmEnabled) { $_POST['input_' . $field->id . '_2'] = $value; } } if ($field->get_input_type() == 'fileupload') { $field->_is_entry_detail = true; } $content = self::get_field_content($field, $value, $form, $entry); $content = apply_filters('gform_field_content', $content, $field, $value, $entry['id'], $form['id']); $content = apply_filters('gravityflow_field_content', $content, $field, $value, $entry['id'], $form['id']); echo $content; } else { //$field->conditionalLogic = null; if (!$display_field) { continue; } if (GFCommon::is_product_field($field->type)) { $has_product_fields = true; } $value = RGFormsModel::get_lead_field_value($entry, $field); $conditional_logic_fields = GFFormDisplay::get_conditional_logic_fields($form, $field->id); if (!empty($conditional_logic_fields)) { $field->conditionalLogicFields = $conditional_logic_fields; $field_input = self::get_field_input($field, $value, $entry['id'], $form_id, $form); echo '<div style="display:none;"">' . $field_input . '</div>'; } if ($field->type == 'product') { if ($field->has_calculation()) { $product_name = trim($value[$field->id . '.1']); $price = trim($value[$field->id . '.2']); $quantity = trim($value[$field->id . '.3']); if (empty($product_name)) { $value[$field->id . '.1'] = $field->get_field_label(false, $value); } if (empty($price)) { $value[$field->id . '.2'] = '0'; } if (empty($quantity)) { $value[$field->id . '.3'] = '0'; } } } $input_type = $field->get_input_type(); if ($input_type == 'hiddenproduct') { $display_value = $value[$field->id . '.2']; } else { $display_value = GFCommon::get_lead_field_display($field, $value, $entry['currency']); } $display_value = apply_filters('gform_entry_field_value', $display_value, $field, $entry, $form); if ($display_empty_fields || !empty($display_value) || $display_value === '0') { $count++; $is_last = $count >= $field_count && !$has_product_fields ? true : false; $last_row = $is_last ? ' lastrow' : ''; $display_value = empty($display_value) && $display_value !== '0' ? ' ' : $display_value; $content = ' <tr> <td colspan="2" class="entry-view-field-name">' . esc_html(rgar($field, 'label')) . '</td> </tr> <tr> <td colspan="2" class="entry-view-field-value' . $last_row . '">' . $display_value . '</td> </tr>'; $content = apply_filters('gform_field_content', $content, $field, $value, $entry['id'], $form['id']); $content = apply_filters('gravityflow_field_content', $content, $field, $value, $entry['id'], $form['id']); echo $content; } } break; } } $products = array(); if ($has_product_fields) { $products = GFCommon::get_product_fields($form, $entry); if (!empty($products['products'])) { ?> <tr> <td colspan="2" class="entry-view-field-name"><?php echo apply_filters("gform_order_label_{$form_id}", apply_filters('gform_order_label', __('Order', 'gravityflow'), $form_id), $form_id); ?> </td> </tr> <tr> <td colspan="2" class="entry-view-field-value lastrow"> <table class="entry-products" cellspacing="0" width="97%"> <colgroup> <col class="entry-products-col1" /> <col class="entry-products-col2" /> <col class="entry-products-col3" /> <col class="entry-products-col4" /> </colgroup> <thead> <th scope="col"><?php echo apply_filters("gform_product_{$form_id}", apply_filters('gform_product', __('Product', 'gravityflow'), $form_id), $form_id); ?> </th> <th scope="col" class="textcenter"><?php echo esc_html(apply_filters("gform_product_qty_{$form_id}", apply_filters('gform_product_qty', __('Qty', 'gravityflow'), $form_id), $form_id)); ?> </th> <th scope="col"><?php echo esc_html(apply_filters("gform_product_unitprice_{$form_id}", apply_filters('gform_product_unitprice', __('Unit Price', 'gravityflow'), $form_id), $form_id)); ?> </th> <th scope="col"><?php echo esc_html(apply_filters("gform_product_price_{$form_id}", apply_filters('gform_product_price', __('Price', 'gravityflow'), $form_id), $form_id)); ?> </th> </thead> <tbody> <?php $total = 0; foreach ($products['products'] as $product) { ?> <tr> <td> <div class="product_name"><?php echo esc_html($product['name']); ?> </div> <ul class="product_options"> <?php $price = GFCommon::to_number($product['price']); if (is_array(rgar($product, 'options'))) { $count = sizeof($product['options']); $index = 1; foreach ($product['options'] as $option) { $price += GFCommon::to_number($option['price']); $class = $index == $count ? " class='lastitem'" : ''; $index++; ?> <li<?php echo $class; ?> ><?php echo $option['option_label']; ?> </li> <?php } } $subtotal = floatval($product['quantity']) * $price; $total += $subtotal; ?> </ul> </td> <td class="textcenter"><?php echo esc_html($product['quantity']); ?> </td> <td><?php echo GFCommon::to_money($price, $entry['currency']); ?> </td> <td><?php echo GFCommon::to_money($subtotal, $entry['currency']); ?> </td> </tr> <?php } $total += floatval($products['shipping']['price']); ?> </tbody> <tfoot> <?php if (!empty($products['shipping']['name'])) { ?> <tr> <td colspan="2" rowspan="2" class="emptycell"> </td> <td class="textright shipping"><?php echo esc_html($products['shipping']['name']); ?> </td> <td class="shipping_amount"><?php echo GFCommon::to_money($products['shipping']['price'], $entry['currency']); ?> </td> </tr> <?php } ?> <tr> <?php if (empty($products['shipping']['name'])) { ?> <td colspan="2" class="emptycell"> </td> <?php } ?> <td class="textright grandtotal"><?php _e('Total', 'gravityflow'); ?> </td> <td class="grandtotal_amount"><?php echo GFCommon::to_money($total, $entry['currency']); ?> </td> </tr> </tfoot> </table> </td> </tr> <?php } } ?> </tbody> </table> <div class="gform_footer"> <input type="hidden" name="gform_unique_id" value="" /> <input type="hidden" name="is_submit_<?php echo $form_id; ?> " value="1" /> <input type="hidden" name="step_id" value="<?php echo $current_step ? $current_step->get_id() : ''; ?> " /> <?php if (GFCommon::has_multifile_fileupload_field($form) || !empty(GFFormsModel::$uploaded_files[$form_id])) { $files = !empty(GFFormsModel::$uploaded_files[$form_id]) ? GFCommon::json_encode(GFFormsModel::$uploaded_files[$form_id]) : ''; $files_input = "<input type='hidden' name='gform_uploaded_files' id='gform_uploaded_files_{$form_id}' value='" . str_replace("'", ''', $files) . "' />"; echo $files_input; } //GFFormDisplay::print_form_scripts( $form, false ); ?> </div> <?php }
public function order_item_meta_2($item_id, $cart_item) { if (function_exists('woocommerce_add_order_item_meta')) { if (isset($cart_item['_gravity_form_lead']) && isset($cart_item['_gravity_form_data'])) { woocommerce_add_order_item_meta($item_id, '_gravity_forms_history', array('_gravity_form_lead' => $cart_item['_gravity_form_lead'], '_gravity_form_data' => $cart_item['_gravity_form_data'])); //Gravity forms generates errors and warnings. To prevent these from conflicting with other things, we are going to disable warnings and errors. $err_level = error_reporting(); error_reporting(0); $gravity_form_data = $cart_item['_gravity_form_data']; $form_meta = RGFormsModel::get_form_meta($gravity_form_data['id']); if (!empty($form_meta)) { $lead = $cart_item['_gravity_form_lead']; $lead['id'] = uniqid() . time() . rand(); $products = $this->get_product_fields($form_meta, $lead); $valid_products = array(); foreach ($products['products'] as $id => $product) { if (!isset($product['quantity'])) { } elseif ($product['quantity']) { $valid_products[] = $id; } } foreach ($form_meta['fields'] as $field) { if (isset($field['inputType']) && $field['inputType'] == 'hiddenproduct' || isset($field['displayOnly']) && $field['displayOnly']) { continue; } if ($field['type'] == 'product') { if (!in_array($field['id'], $valid_products)) { continue; } } $value = RGFormsModel::get_lead_field_value($lead, $field); $arr_var = is_array($value) ? implode('', $value) : '-'; if (!empty($value) && !empty($arr_var)) { try { if ($field['type'] == 'fileupload' && isset($lead[$field['id']])) { $display_value = $lead[$field['id']]; } else { $display_value = GFCommon::get_lead_field_display($field, $value, isset($lead["currency"]) ? $lead["currency"] : false, apply_filters('woocommerce_gforms_use_label_as_value', true, $value, $field, $lead, $form_meta)); $price_adjustement = false; $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $lead, $form_meta); } $display_title = GFCommon::get_label($field); $display_title = apply_filters("woocommerce_gforms_order_meta_title", $display_title, $field, $lead, $form_meta, $item_id, $cart_item); $display_value = apply_filters("woocommerce_gforms_order_meta_value", $display_value, $field, $lead, $form_meta, $item_id, $cart_item); if (apply_filters('woocommerce_gforms_strip_meta_html', true, $display_value, $field, $lead, $form_meta, $item_id, $cart_item)) { if (strstr($display_value, '<li>')) { $display_value = str_replace('<li>', '', $display_value); $display_value = explode('</li>', $display_value); $display_value = trim(strip_tags(implode(', ', $display_value))); $display_value = trim($display_value, ','); } $display_value = strip_tags(wp_kses($display_value, '')); } $display_text = GFCommon::get_lead_field_display($field, $value, isset($lead["currency"]) ? $lead["currency"] : false, false); $display_value = apply_filters("woocommerce_gforms_field_display_text", $display_value, $display_text, $field, $lead, $form_meta); $hidden = $field['type'] == 'hidden'; $prefix = $hidden ? '_' : ''; woocommerce_add_order_item_meta($item_id, $prefix . $display_title, $display_value); } catch (Exception $e) { } } } } error_reporting($err_level); } } }
break; case "date_created": $value = GFCommon::format_date($lead['date_created'], true, apply_filters('kws_gf_date_format', '')); break; case "date": if ($dateformat) { $value = GFCommon::date_display($value, $dateformat); } else { $value = GFCommon::date_display($value, $field["dateFormat"]); } break; case "id": $linkClass = ''; break; case "list": $value = GFCommon::get_lead_field_display($field, $value); break; default: $input_type = 'text'; if (is_email($value) && $linkemail) { $value = "<a href='mailto:{$value}'{$nofollow}>{$value}</a>"; } elseif (preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $value) && $linkwebsite) { $href = $value; if (!empty($lightboxsettings['images'])) { if (in_array('urls', $lightboxsettings) || !empty($lightboxsettings['urls'])) { $lightboxclass .= ' rel="directory_all directory_urls"'; } $linkClass = $lightboxclass; } else { $linkClass = isset($linkClass) ? $linkClass : ''; }
private static function get_akismet_field($field_type, $form, $lead) { $fields = GFCommon::get_fields_by_type($form, array($field_type)); if (empty($fields)) { return ""; } $value = RGFormsModel::get_lead_field_value($lead, $fields[0]); switch ($field_type) { case "name": $value = GFCommon::get_lead_field_display($fields[0], $value); break; } return $value; }
public static function get_submitted_fields($form, $lead, $display_empty = false) { $field_data = '<table width="99%" border="0" cellpadding="1" cellpsacing="0" bgcolor="#EAEAEA"><tr><td><table width="100%" border="0" cellpadding="5" cellpsacing="0" bgcolor="#FFFFFF">'; foreach ($form["fields"] as $field) { $field_label = esc_html(GFCommon::get_label($field)); switch ($field["type"]) { case "captcha": break; case "section": $field_data .= sprintf('<tr><td colspan="2" style="font-size:14px; font-weight:bold; background-color:#EEE; border-bottom:1px solid #DFDFDF; padding:7px 7px">%s</td></tr>', $field_label); break; default: $value = RGFormsModel::get_lead_field_value($lead, $field); $field_value = GFCommon::get_lead_field_display($field, $value); if (!empty($field_value) || $display_empty) { $field_data .= sprintf('<tr bgcolor="#EAF2FA"><td colspan="2"><font style="font-family:verdana; font-size:12px;"><strong>%s</strong></font></td></tr><tr bgcolor="#FFFFFF"><td width="20"> </td><td><font style="font-family:verdana; font-size:12px;">%s</font></td></tr>', $field_label, empty($field_value) ? " " : $field_value); } } } $field_data .= "</table></td></tr></table>"; return $field_data; }
public function get_value_merge_tag($value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br) { $output_format = in_array($modifier, array('text', 'html', 'url')) ? $modifier : $format; return GFCommon::get_lead_field_display($this, $raw_value, $entry['currency'], true, $output_format); }
function getmetaData($entry_id) { $return = ''; $metaData = mf_get_form_meta('entry_id', $entry_id); foreach ($metaData as $data) { $entry = GFAPI::get_entry($data->lead_id); //check if entry-id is valid if (is_array($entry)) { //display entry data $formPull = GFAPI::get_form($data->form_id); $return .= '<h2>' . $formPull['title'] . '</h2>'; $return .= '<table>'; foreach ($formPull['fields'] as $formFields) { $gwreadonly_enable = isset($formFields['gwreadonly_enable']) ? $formFields['gwreadonly_enable'] : 0; //exclude page breaks and the entry fields used to verify the entry // and the display only fields from the additional forms if ($formFields['type'] != 'page' && $formFields['inputName'] != 'entry-id' && $formFields['inputName'] != 'contact-email' && $gwreadonly_enable != 1) { $display_empty_fields = false; switch (RGFormsModel::get_input_type($formFields)) { case 'section': if (!GFCommon::is_section_empty($formFields, $formPull, $entry) || $display_empty_fields) { $count++; $is_last = $count >= $field_count ? true : false; ?> <tr> <td colspan="2" class="entry-view-section-break<?php echo $is_last ? ' lastrow' : ''; ?> "><?php echo esc_html(GFCommon::get_label($formFields)); ?> </td> </tr> <?php } break; case 'captcha': case 'html': case 'password': case 'page': //ignore captcha, html, password, page field break; default: //ignore product fields as they will be grouped together at the end of the grid if (GFCommon::is_product_field($formFields->type)) { $has_product_fields = true; continue; } $value = RGFormsModel::get_lead_field_value($entry, $formFields); $display_value = GFCommon::get_lead_field_display($formFields, $value, $entry['currency']); $display_value = apply_filters('gform_entry_field_value', $display_value, $formFields, $entry, $formPull); if ($display_empty_fields || !empty($display_value) || $display_value === '0') { $display_value = empty($display_value) && $display_value !== '0' ? ' ' : $display_value; $content = ' <tr> <td colspan="2" class="entry-view-field-name">' . esc_html(GFCommon::get_label($formFields)) . '</td> </tr> <tr> <td colspan="2" class="entry-view-field-value">' . $display_value . '</td> </tr>'; $content = apply_filters('gform_field_content', $content, $formFields, $value, $entry['id'], $formPull['id']); $return .= $content; } break; } } } $return .= '</table>'; } } return $return; }
*/ $gravityview_view = GravityView_View::getInstance(); extract($gravityview_view->getCurrentField()); // If it's the full address if (floor($field_id) === floatval($field_id)) { /** * Make sure we're only showing enabled inputs. * @since 1.16.2 */ foreach ($field->inputs as $input) { if (!empty($input['isHidden'])) { unset($value["{$input['id']}"]); } } // @todo Implement the `gform_disable_address_map_link` filter (boolean) added in GF 1.9 to enable/disable map link // Use Gravity Forms' method to get the full address. // Pass the `text` parameter so the map link isn't added like when passing `html` $value_with_newline = GFCommon::get_lead_field_display($field, $value, "", false, 'text'); if (empty($value_with_newline)) { return; } // Add map link if it's not set (default, back compat) or if it's set to yes if (!isset($field_settings['show_map_link']) || !empty($field_settings['show_map_link'])) { // Add the map link as another line $value_with_newline .= "\n" . gravityview_get_map_link($value_with_newline); } // Full address without the "Map It" link echo str_replace("\n", '<br />', $value_with_newline); } else { echo gravityview_get_field_value($entry, $field_id, $display_value); }
public static function lead_detail($Form, $lead, $allow_display_empty_fields = false, $inline = true, $options = array()) { if (!class_exists('GFEntryList')) { require_once GFCommon::get_base_path() . "/entry_list.php"; } global $current_user, $_gform_directory_approvedcolumn; get_currentuserinfo(); $display_empty_fields = ''; $allow_display_empty_fields = true; if ($allow_display_empty_fields) { $display_empty_fields = @rgget("gf_display_empty_fields", $_COOKIE); } if (empty($options)) { $options = self::directory_defaults(); } // There is no edit link if (isset($_GET['edit']) || RGForms::post("action") === "update") { // Process editing leads $lead = self::edit_lead_detail($Form, $lead, $options); if (RGForms::post("action") !== "update") { return; } } extract($options); ?> <table cellspacing="0" class="widefat fixed entry-detail-view"> <?php $title = str_replace('%%formtitle%%', $Form["title"], str_replace('%%leadid%%', $lead['id'], $entrydetailtitle)); if (!empty($title) && $inline) { ?> <thead> <tr> <th id="details" colspan="2" scope="col"> <?php $title = apply_filters('kws_gf_directory_detail_title', apply_filters('kws_gf_directory_detail_title_' . (int) $lead['id'], array($title, $lead), true), true); if (is_array($title)) { echo $title[0]; } else { echo $title; } ?> </th> </tr> </thead> <?php } ?> <tbody> <?php $count = 0; $has_product_fields = false; $field_count = sizeof($Form["fields"]); $display_value = ''; foreach ($Form["fields"] as $field) { // Don't show fields defined as hide in single. if (!empty($field['hideInSingle'])) { if (self::has_access("gravityforms_directory")) { echo "\n\t\t\t\t\t\t\t\t\t" . '<!-- ' . sprintf(esc_html__('(Admin-only notice) Field #%d not shown: "Hide This Field in Single Entry View" was selected.', 'gravity-forms-addons'), $field['id']) . ' -->' . "\n\n"; } continue; } $count++; $is_last = $count >= $field_count ? true : false; switch (RGFormsModel::get_input_type($field)) { case "section": if (!GFCommon::is_section_empty($field, $Form, $lead) || $display_empty_fields) { $count++; $is_last = $count >= $field_count ? true : false; ?> <tr> <td colspan="2" class="entry-view-section-break<?php echo $is_last ? " lastrow" : ""; ?> "><?php echo esc_html(GFCommon::get_label($field)); ?> </td> </tr> <?php } break; case "captcha": case "html": case "password": case "page": //ignore captcha, html, password, page field break; case "post_image": $value = RGFormsModel::get_lead_field_value($lead, $field); $valueArray = explode("|:|", $value); @(list($url, $title, $caption, $description) = $valueArray); if (!empty($url)) { $value = $display_value = self::render_image_link($url, $lead, $options, $title, $caption, $description); } break; default: //ignore product fields as they will be grouped together at the end of the grid if (GFCommon::is_product_field($field["type"])) { $has_product_fields = true; continue; } $value = RGFormsModel::get_lead_field_value($lead, $field); $display_value = GFCommon::get_lead_field_display($field, $value, $lead["currency"]); break; } // end switch $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $lead, $Form); if ($display_empty_fields || !empty($display_value) || $display_value === "0") { $count++; $is_last = $count >= $field_count && !$has_product_fields ? true : false; $last_row = $is_last ? " lastrow" : ""; $display_value = empty($display_value) && $display_value !== "0" ? " " : $display_value; $content = ' <tr> <th colspan="2" class="entry-view-field-name">' . esc_html(GFCommon::get_label($field)) . '</th> </tr> <tr> <td colspan="2" class="entry-view-field-value' . $last_row . '">' . $display_value . '</td> </tr>'; $content = apply_filters("gform_field_content", $content, $field, $value, $lead["id"], $Form["id"]); echo $content; } } // End foreach $products = array(); if ($has_product_fields) { $products = GFCommon::get_product_fields($Form, $lead); if (!empty($products["products"])) { ?> <tr> <td colspan="2" class="entry-view-field-name"><?php echo apply_filters("gform_order_label_{$Form["id"]}", apply_filters("gform_order_label", __("Order", "gravityforms"), $Form["id"]), $Form["id"]); ?> </td> </tr> <tr> <td colspan="2" class="entry-view-field-value lastrow"> <table class="entry-products" cellspacing="0" width="97%"> <colgroup> <col class="entry-products-col1"> <col class="entry-products-col2"> <col class="entry-products-col3"> <col class="entry-products-col4"> </colgroup> <thead> <th scope="col"><?php echo apply_filters("gform_product_{$Form['id']}", apply_filters("gform_product", __("Product", "gravityforms"), $Form['id']), $Form['id']); ?> </th> <th scope="col" class="textcenter"><?php echo apply_filters("gform_product_qty_{$Form['id']}", apply_filters("gform_product_qty", __("Qty", "gravityforms"), $Form['id']), $Form['id']); ?> </th> <th scope="col"><?php echo apply_filters("gform_product_unitprice_{$Form['id']}", apply_filters("gform_product_unitprice", __("Unit Price", "gravityforms"), $Form['id']), $Form['id']); ?> </th> <th scope="col"><?php echo apply_filters("gform_product_price_{$Form['id']}", apply_filters("gform_product_price", __("Price", "gravityforms"), $Form['id']), $Form['id']); ?> </th> </thead> <tbody> <?php $total = 0; foreach ($products["products"] as $product) { ?> <tr> <td> <div class="product_name"><?php echo esc_html($product["name"]); ?> </div> <ul class="product_options"> <?php $price = GFCommon::to_number($product["price"]); if (is_array(rgar($product, "options"))) { $count = sizeof($product["options"]); $index = 1; foreach ($product["options"] as $option) { $price += GFCommon::to_number($option["price"]); $class = $index == $count ? " class='lastitem'" : ""; $index++; ?> <li<?php echo $class; ?> ><?php echo $option["option_label"]; ?> </li> <?php } } $subtotal = floatval($product["quantity"]) * $price; $total += $subtotal; ?> </ul> </td> <td class="textcenter"><?php echo $product["quantity"]; ?> </td> <td><?php echo GFCommon::to_money($price, $lead["currency"]); ?> </td> <td><?php echo GFCommon::to_money($subtotal, $lead["currency"]); ?> </td> </tr> <?php } $total += floatval($products["shipping"]["price"]); ?> </tbody> <tfoot> <?php if (!empty($products["shipping"]["name"])) { ?> <tr> <td colspan="2" rowspan="2" class="emptycell"> </td> <td class="textright shipping"><?php echo $products["shipping"]["name"]; ?> </td> <td class="shipping_amount"><?php echo GFCommon::to_money($products["shipping"]["price"], $lead["currency"]); ?> </td> </tr> <?php } ?> <tr> <?php if (empty($products["shipping"]["name"])) { ?> <td colspan="2" class="emptycell"> </td> <?php } ?> <td class="textright grandtotal"><?php esc_html_e("Total", "gravityforms"); ?> </td> <td class="grandtotal_amount"><?php echo GFCommon::to_money($total, $lead["currency"]); ?> </td> </tr> </tfoot> </table> </td> </tr> <?php } } // Edit link if (!empty($options['useredit']) && is_user_logged_in() && intval($current_user->ID) === intval($lead['created_by']) || !empty($options['adminedit']) && self::has_access("gravityforms_directory")) { if (!empty($options['adminedit']) && self::has_access("gravityforms_directory")) { $editbuttontext = apply_filters('kws_gf_directory_edit_entry_text_admin', __("Edit Entry", 'gravity-forms-addons')); } else { $editbuttontext = apply_filters('kws_gf_directory_edit_entry_text_user', __("Edit Your Entry", 'gravity-forms-addons')); } ?> <tr> <th scope="row" class="entry-view-field-name"><?php echo esc_html(apply_filters('kws_gf_directory_edit_entry_th', __("Edit", "gravity-forms-addons"))); ?> </th> <td class="entry-view-field-value useredit"><a href="<?php echo add_query_arg(array('edit' => wp_create_nonce('edit' . $lead['id'] . $Form["id"]))); ?> "><?php echo $editbuttontext; ?> </a></td> </tr> <?php } ?> </tbody> </table> <?php }
public static function lead_detail_grid($form, $lead, $allow_display_empty_fields = false) { $form_id = absint($form['id']); $display_empty_fields = false; if ($allow_display_empty_fields) { $display_empty_fields = rgget('gf_display_empty_fields', $_COOKIE); } $display_empty_fields = apply_filters('gform_entry_detail_grid_display_empty_fields', $display_empty_fields, $form, $lead); ?> <table cellspacing="0" class="widefat fixed entry-detail-view"> <thead> <tr> <th id="details"> <?php $title = sprintf('%s : %s %s', esc_html($form['title']), esc_html__('Entry # ', 'gravityforms'), absint($lead['id'])); echo apply_filters('gravityflow_title_entry_detail', $title, $form, $lead); ?> </th> <th style="width:140px; font-size:10px; text-align: right;"> <?php if ($allow_display_empty_fields) { ?> <input type="checkbox" id="gentry_display_empty_fields" <?php echo $display_empty_fields ? "checked='checked'" : ''; ?> onclick="ToggleShowEmptyFields();" /> <label for="gentry_display_empty_fields"><?php esc_html_e('show empty fields', 'gravityforms'); ?> </label> <?php } ?> </th> </tr> </thead> <tbody> <?php $count = 0; $field_count = sizeof($form['fields']); $has_product_fields = false; foreach ($form['fields'] as $field) { switch (RGFormsModel::get_input_type($field)) { case 'section': if (!GFCommon::is_section_empty($field, $form, $lead) || $display_empty_fields) { $count++; $is_last = $count >= $field_count ? true : false; ?> <tr> <td colspan="2" class="entry-view-section-break<?php echo $is_last ? ' lastrow' : ''; ?> "><?php echo esc_html(GFCommon::get_label($field)); ?> </td> </tr> <?php } break; case 'captcha': case 'html': case 'password': case 'page': //ignore captcha, html, password, page field break; default: //ignore product fields as they will be grouped together at the end of the grid if (GFCommon::is_product_field($field->type)) { $has_product_fields = true; continue; } $value = RGFormsModel::get_lead_field_value($lead, $field); $display_value = GFCommon::get_lead_field_display($field, $value, $lead['currency']); $display_value = apply_filters('gform_entry_field_value', $display_value, $field, $lead, $form); if ($display_empty_fields || !empty($display_value) || $display_value === '0') { $count++; $is_last = $count >= $field_count && !$has_product_fields ? true : false; $last_row = $is_last ? ' lastrow' : ''; $display_value = empty($display_value) && $display_value !== '0' ? ' ' : $display_value; $content = ' <tr> <td colspan="2" class="entry-view-field-name">' . esc_html(GFCommon::get_label($field)) . '</td> </tr> <tr> <td colspan="2" class="entry-view-field-value' . $last_row . '">' . $display_value . '</td> </tr>'; $content = apply_filters('gform_field_content', $content, $field, $value, $lead['id'], $form['id']); echo $content; } break; } } $products = array(); if ($has_product_fields) { $products = GFCommon::get_product_fields($form, $lead); if (!empty($products['products'])) { ?> <tr> <td colspan="2" class="entry-view-field-name"><?php echo esc_html(apply_filters("gform_order_label_{$form_id}", apply_filters('gform_order_label', __('Order', 'gravityforms'), $form_id), $form_id)); ?> </td> </tr> <tr> <td colspan="2" class="entry-view-field-value lastrow"> <table class="entry-products" cellspacing="0" width="97%"> <colgroup> <col class="entry-products-col1" /> <col class="entry-products-col2" /> <col class="entry-products-col3" /> <col class="entry-products-col4" /> </colgroup> <thead> <th scope="col"><?php echo apply_filters("gform_product_{$form_id}", apply_filters('gform_product', __('Product', 'gravityforms'), $form_id), $form_id); ?> </th> <th scope="col" class="textcenter"><?php echo esc_html(apply_filters("gform_product_qty_{$form_id}", apply_filters('gform_product_qty', __('Qty', 'gravityforms'), $form_id), $form_id)); ?> </th> <th scope="col"><?php echo esc_html(apply_filters("gform_product_unitprice_{$form_id}", apply_filters('gform_product_unitprice', __('Unit Price', 'gravityforms'), $form_id), $form_id)); ?> </th> <th scope="col"><?php echo esc_html(apply_filters("gform_product_price_{$form_id}", apply_filters('gform_product_price', __('Price', 'gravityforms'), $form_id), $form_id)); ?> </th> </thead> <tbody> <?php $total = 0; foreach ($products['products'] as $product) { ?> <tr> <td> <div class="product_name"><?php echo esc_html($product['name']); ?> </div> <ul class="product_options"> <?php $price = GFCommon::to_number($product['price']); if (is_array(rgar($product, 'options'))) { $count = sizeof($product['options']); $index = 1; foreach ($product['options'] as $option) { $price += GFCommon::to_number($option['price']); $class = $index == $count ? " class='lastitem'" : ''; $index++; ?> <li<?php echo $class; ?> ><?php echo $option['option_label']; ?> </li> <?php } } $subtotal = floatval($product['quantity']) * $price; $total += $subtotal; ?> </ul> </td> <td class="textcenter"><?php echo esc_html($product['quantity']); ?> </td> <td><?php echo GFCommon::to_money($price, $lead['currency']); ?> </td> <td><?php echo GFCommon::to_money($subtotal, $lead['currency']); ?> </td> </tr> <?php } $total += floatval($products['shipping']['price']); ?> </tbody> <tfoot> <?php if (!empty($products['shipping']['name'])) { ?> <tr> <td colspan="2" rowspan="2" class="emptycell"> </td> <td class="textright shipping"><?php echo esc_html($products['shipping']['name']); ?> </td> <td class="shipping_amount"><?php echo GFCommon::to_money($products['shipping']['price'], $lead['currency']); ?> </td> </tr> <?php } ?> <tr> <?php if (empty($products['shipping']['name'])) { ?> <td colspan="2" class="emptycell"> </td> <?php } ?> <td class="textright grandtotal"><?php esc_html_e('Total', 'gravityforms'); ?> </td> <td class="grandtotal_amount"><?php echo GFCommon::to_money($total, $lead['currency']); ?> </td> </tr> </tfoot> </table> </td> </tr> <?php } } ?> </tbody> </table> <?php }
public static function displayGravityForm($entryId, $textMode = false, $email = false) { $out = ''; $formId = self::getGravityFormIdForEntry($entryId); require_once GFCommon::get_base_path() . "/entry_detail.php"; $form = RGFormsModel::get_form_meta($formId); $lead = RGFormsModel::get_lead($entryId); if (!$textMode) { ob_start(); echo '<table class="form-table entry-details"><tbody>'; $count = 0; $field_count = sizeof($form["fields"]); foreach ($form["fields"] as $field) { $count++; $is_last = $count >= $field_count ? true : false; switch (RGFormsModel::get_input_type($field)) { case "section": ?> <tr> <td colspan="2" class="entry-view-section-break<?php echo $is_last ? " lastrow" : ""; ?> "><?php echo esc_html(GFCommon::get_label($field)); ?> </td> </tr> <?php break; case "captcha": case "html": //ignore captcha field break; default: if (GFCommon::is_product_field($field["type"])) { $has_product_fields = true; } $value = RGFormsModel::get_lead_field_value($lead, $field); $display_value = GFCommon::get_lead_field_display($field, $value, $lead["currency"], Cart66Setting::getValue('gravity_display_option_labels')); $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $lead, $form); if (isset($display_empty_fields) && $display_empty_fields || !empty($display_value) || $display_value === "0") { $count++; if (!isset($has_product_fields)) { $has_product_fields = false; } $is_last = $count >= $field_count && !$has_product_fields ? true : false; $last_row = $is_last ? " lastrow" : ""; $display_value = empty($display_value) && $display_value !== "0" ? " " : $display_value; if ($email) { $content = ' <tr> <td style="color:#555;font-size:12px;padding:4px 7px;vertical-align:top;text-align:right" class="entry-view-field-name">' . esc_html(GFCommon::get_label($field)) . ': </td> <td style="color:#555;font-size:12px;padding:4px 7px;vertical-align:top" class="entry-view-field-value' . $last_row . '">' . $display_value . '</td> </tr>'; } else { $content = ' <tr> <td colspan="2" class="entry-view-field-name">' . esc_html(GFCommon::get_label($field)) . '</td> </tr> <tr> <td colspan="2" class="entry-view-field-value' . $last_row . '">' . $display_value . '</td> </tr>'; } $content = apply_filters("gform_field_content", $content, $field, $value, $lead["id"], $form["id"]); echo $content; } break; } } echo '</tbody></table>'; $out = ob_get_contents(); ob_end_clean(); } else { $count = 0; $field_count = sizeof($form["fields"]); if (is_array($form["fields"])) { foreach ($form["fields"] as $field) { $count++; $is_last = $count >= $field_count ? true : false; switch (RGFormsModel::get_input_type($field)) { case "section": $out .= "\t" . GFCommon::get_label($field) . "\n"; break; case "captcha": case "html": //ignore captcha field break; default: $value = RGFormsModel::get_lead_field_value($lead, $field); $display_value = strip_tags(str_replace('</li>', "\t\t", GFCommon::get_lead_field_display($field, $value))); if (!empty($display_value) || $display_value === "0") { $out .= "\t" . GFCommon::get_label($field) . ': '; $out .= empty($display_value) && $display_value !== "0" ? " " : $display_value; $out .= "\n"; } break; } } } $out .= "\n"; } return $out; }