Пример #1
0
 private static function add_user_meta($user_id, $config, $form, $entry, $name_fields)
 {
     self::log_debug('adding user meta');
     $standard_meta = array('firstname' => 'first_name', 'lastname' => 'last_name');
     foreach ($standard_meta as $meta_key => $wp_meta_key) {
         if (self::is_meta_key_mapped($meta_key, $config)) {
             update_user_meta($user_id, $wp_meta_key, self::get_meta_value($meta_key, $config, $form, $entry));
         }
     }
     // to track which entry the user was registered from
     update_user_meta($user_id, 'entry_id', $entry['id']);
     // add custom user meta
     $custom_meta = rgars($config, 'meta/user_meta');
     if (is_array($custom_meta) && !empty($custom_meta)) {
         $value = '';
         foreach ($custom_meta as $custom_meta_item) {
             self::log_debug("adding meta item: {$custom_meta_item['meta_name']}");
             // skip empty meta items
             if (!$custom_meta_item['meta_name'] || !$custom_meta_item['meta_value']) {
                 self::log_debug("Meta item is empty. Skipping it");
                 continue;
             }
             $field = RGFormsModel::get_field($form, $custom_meta_item['meta_value']);
             self::log_debug("Meta item mapped to field #{$field['id']}.");
             if (GFFormsModel::is_field_hidden($form, $field, array(), $entry)) {
                 self::log_debug('Field is hidden. Skipping it.');
                 continue;
             }
             $value = self::get_prepared_value($field, $custom_meta_item['meta_value'], $entry);
             self::log_debug("Field value: {$value}");
             if ($custom_meta_item['meta_name'] == 'user_url' && $value) {
                 self::update_user_property($user_id, 'user_url', $value);
             } else {
                 if (rgblank($value)) {
                     self::log_debug("Deleting meta item since it has a blank value.");
                     delete_user_meta($user_id, $custom_meta_item['meta_name']);
                 } else {
                     self::log_debug("Updating/Adding meta item.");
                     update_user_meta($user_id, $custom_meta_item['meta_name'], $value);
                 }
             }
         }
     }
 }
 public static function save_lead($form, &$lead)
 {
     global $wpdb;
     GFCommon::log_debug(__METHOD__ . '(): Saving entry.');
     $is_form_editor = GFCommon::is_form_editor();
     $is_entry_detail = GFCommon::is_entry_detail();
     $is_admin = $is_form_editor || $is_entry_detail;
     if ($is_admin && !GFCommon::current_user_can_any('gravityforms_edit_entries')) {
         die(esc_html__("You don't have adequate permission to edit entries.", 'gravityforms'));
     }
     $lead_detail_table = self::get_lead_details_table_name();
     $is_new_lead = $lead == null;
     //Inserting lead if null
     if ($is_new_lead) {
         global $current_user;
         $user_id = $current_user && $current_user->ID ? $current_user->ID : 'NULL';
         $lead_table = RGFormsModel::get_lead_table_name();
         $user_agent = self::truncate($_SERVER['HTTP_USER_AGENT'], 250);
         $currency = GFCommon::get_currency();
         $source_url = self::truncate(self::get_current_page_url(), 200);
         $wpdb->query($wpdb->prepare("INSERT INTO {$lead_table}(form_id, ip, source_url, date_created, user_agent, currency, created_by) VALUES(%d, %s, %s, utc_timestamp(), %s, %s, {$user_id})", $form['id'], self::get_ip(), $source_url, $user_agent, $currency));
         //reading newly created lead id
         $lead_id = $wpdb->insert_id;
         $lead = array('id' => $lead_id);
         GFCommon::log_debug(__METHOD__ . "(): Entry record created in the database. ID: {$lead_id}.");
     }
     $current_fields = $wpdb->get_results($wpdb->prepare("SELECT id, field_number FROM {$lead_detail_table} WHERE lead_id=%d", $lead['id']));
     $total_fields = array();
     /* @var $calculation_fields GF_Field[] */
     $calculation_fields = array();
     $recalculate_total = false;
     GFCommon::log_debug(__METHOD__ . '(): Saving entry fields.');
     foreach ($form['fields'] as $field) {
         /* @var $field GF_Field */
         // ignore the honeypot field
         if ($field->type == 'honeypot') {
             continue;
         }
         //Ignore fields that are marked as display only
         if ($field->displayOnly && $field->type != 'password') {
             continue;
         }
         //ignore pricing fields in the entry detail
         if (RG_CURRENT_VIEW == 'entry' && GFCommon::is_pricing_field($field->type)) {
             continue;
         }
         //process total field after all fields have been saved
         if ($field->type == 'total') {
             $total_fields[] = $field;
             continue;
         }
         $is_entry_update = RG_CURRENT_VIEW == 'entry' || !$is_new_lead;
         $read_value_from_post = $is_new_lead || !isset($lead['date_created']);
         //only save fields that are not hidden (except when updating an entry)
         if ($is_entry_update || !GFFormsModel::is_field_hidden($form, $field, array(), $read_value_from_post ? null : $lead)) {
             // process calculation fields after all fields have been saved (moved after the is hidden check)
             if ($field->has_calculation()) {
                 $calculation_fields[] = $field;
                 continue;
             }
             if ($field->type == 'post_category') {
                 $field = GFCommon::add_categories_as_choices($field, '');
             }
             $inputs = $field->get_entry_inputs();
             if (is_array($inputs)) {
                 foreach ($inputs as $input) {
                     self::save_input($form, $field, $lead, $current_fields, $input['id']);
                 }
             } else {
                 self::save_input($form, $field, $lead, $current_fields, $field->id);
             }
         }
     }
     if (!empty($calculation_fields)) {
         foreach ($calculation_fields as $calculation_field) {
             $inputs = $calculation_field->get_entry_inputs();
             if (is_array($inputs)) {
                 foreach ($inputs as $input) {
                     self::save_input($form, $calculation_field, $lead, $current_fields, $input['id']);
                     self::refresh_lead_field_value($lead['id'], $input['id']);
                 }
             } else {
                 self::save_input($form, $calculation_field, $lead, $current_fields, $calculation_field->id);
                 self::refresh_lead_field_value($lead['id'], $calculation_field->id);
             }
         }
         self::refresh_product_cache($form, $lead = RGFormsModel::get_lead($lead['id']));
     }
     //saving total field as the last field of the form.
     if (!empty($total_fields)) {
         foreach ($total_fields as $total_field) {
             self::save_input($form, $total_field, $lead, $current_fields, $total_field->id);
             self::refresh_lead_field_value($lead['id'], $total_field['id']);
         }
     }
     GFCommon::log_debug(__METHOD__ . '(): Finished saving entry fields.');
 }
 /**
  * extract the shipping amount from a shipping field
  * @return float
  */
 private static function getShipping($form, $field)
 {
     $shipping = 0;
     $id = $field['id'];
     if (!GFFormsModel::is_field_hidden($form, $field, array())) {
         $value = rgpost("input_{$id}");
         if (!empty($value) && $field["inputType"] != 'singleshipping') {
             // drop-down list / radio buttons
             list($name, $value) = rgexplode('|', $value, 2);
         }
         $shipping = GFCommon::to_number($value);
     }
     return $shipping;
 }
Пример #4
0
    public static function get_submitted_fields($form, $lead, $display_empty = false, $use_text = false, $format = 'html', $use_admin_label = false, $merge_tag = '', $options = '')
    {
        $field_data = '';
        if ($format == 'html') {
            $field_data = '<table width="99%" border="0" cellpadding="1" cellspacing="0" bgcolor="#EAEAEA"><tr><td>
                            <table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">
                            ';
        }
        $options_array = explode(',', $options);
        $no_admin = in_array('noadmin', $options_array);
        $no_hidden = in_array('nohidden', $options_array);
        $display_product_summary = false;
        foreach ($form['fields'] as $field) {
            $field_value = '';
            $field_label = $use_admin_label && !empty($field->adminLabel) ? $field->adminLabel : esc_html(GFCommon::get_label($field, 0, false, $use_admin_label));
            switch ($field->type) {
                case 'captcha':
                    break;
                case 'section':
                    if (GFFormsModel::is_field_hidden($form, $field, array(), $lead)) {
                        continue;
                    }
                    if ((!GFCommon::is_section_empty($field, $form, $lead) || $display_empty) && !$field->adminOnly) {
                        switch ($format) {
                            case 'text':
                                $field_value = "--------------------------------\n{$field_label}\n\n";
                                break;
                            default:
                                $field_value = 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;
                        }
                    }
                    $field_value = apply_filters('gform_merge_tag_filter', $field_value, $merge_tag, $options, $field, $field_label);
                    $field_data .= $field_value;
                    break;
                case 'password':
                    //ignore password fields
                    break;
                default:
                    if (self::is_product_field($field->type)) {
                        // ignore product fields as they will be grouped together at the end of the grid
                        $display_product_summary = apply_filters('gform_display_product_summary', true, $field, $form, $lead);
                        if ($display_product_summary) {
                            continue;
                        }
                    } else {
                        if (GFFormsModel::is_field_hidden($form, $field, array(), $lead)) {
                            // ignore fields hidden by conditional logic
                            continue;
                        }
                    }
                    $raw_field_value = RGFormsModel::get_lead_field_value($lead, $field);
                    $field_value = GFCommon::get_lead_field_display($field, $raw_field_value, rgar($lead, 'currency'), $use_text, $format, 'email');
                    $display_field = true;
                    //depending on parameters, don't display adminOnly or hidden fields
                    if ($no_admin && $field->adminOnly) {
                        $display_field = false;
                    } else {
                        if ($no_hidden && RGFormsModel::get_input_type($field) == 'hidden') {
                            $display_field = false;
                        }
                    }
                    //if field is not supposed to be displayed, pass false to filter. otherwise, pass field's value
                    if (!$display_field) {
                        $field_value = false;
                    }
                    $field_value = apply_filters('gform_merge_tag_filter', $field_value, $merge_tag, $options, $field, $raw_field_value);
                    if ($field_value === false) {
                        continue;
                    }
                    if (!empty($field_value) || strlen($field_value) > 0 || $display_empty) {
                        switch ($format) {
                            case 'text':
                                $field_data .= "{$field_label}: {$field_value}\n\n";
                                break;
                            default:
                                $field_data .= sprintf('<tr bgcolor="%3$s">
		                                    <td colspan="2">
		                                        <font style="font-family: sans-serif; font-size:12px;"><strong>%1$s</strong></font>
		                                    </td>
		                               </tr>
		                               <tr bgcolor="%4$s">
		                                    <td width="20">&nbsp;</td>
		                                    <td>
		                                        <font style="font-family: sans-serif; font-size:12px;">%2$s</font>
		                                    </td>
		                               </tr>
		                               ', $field_label, empty($field_value) && strlen($field_value) == 0 ? '&nbsp;' : $field_value, esc_attr(apply_filters('gform_email_background_color_label', '#EAF2FA', $field, $lead)), esc_attr(apply_filters('gform_email_background_color_data', '#FFFFFF', $field, $lead)));
                                break;
                        }
                    }
            }
        }
        if ($display_product_summary) {
            $field_data .= self::get_submitted_pricing_fields($form, $lead, $format, $use_text, $use_admin_label);
        }
        if ($format == 'html') {
            $field_data .= '</table>
                        </td>
                   </tr>
               </table>';
        }
        return $field_data;
    }
Пример #5
0
 public static function save_lead($form, &$lead)
 {
     global $wpdb;
     GFCommon::log_debug("Saving entry.");
     if (IS_ADMIN && !GFCommon::current_user_can_any("gravityforms_edit_entries")) {
         die(__("You don't have adequate permission to edit entries.", "gravityforms"));
     }
     $lead_detail_table = self::get_lead_details_table_name();
     $is_new_lead = $lead == null;
     //Inserting lead if null
     if ($is_new_lead) {
         global $current_user;
         $user_id = $current_user && $current_user->ID ? $current_user->ID : 'NULL';
         $lead_table = RGFormsModel::get_lead_table_name();
         $user_agent = self::truncate($_SERVER["HTTP_USER_AGENT"], 250);
         $currency = GFCommon::get_currency();
         $source_url = self::truncate(self::get_current_page_url(), 200);
         $wpdb->query($wpdb->prepare("INSERT INTO {$lead_table}(form_id, ip, source_url, date_created, user_agent, currency, created_by) VALUES(%d, %s, %s, utc_timestamp(), %s, %s, {$user_id})", $form["id"], self::get_ip(), $source_url, $user_agent, $currency));
         //reading newly created lead id
         $lead_id = $wpdb->insert_id;
         $lead = array('id' => $lead_id);
         GFCommon::log_debug("Entry record created in the database. ID: {$lead_id}");
     }
     $current_fields = $wpdb->get_results($wpdb->prepare("SELECT id, field_number FROM {$lead_detail_table} WHERE lead_id=%d", $lead["id"]));
     $original_post_id = rgget("post_id", $lead);
     $total_fields = array();
     $calculation_fields = array();
     $recalculate_total = false;
     GFCommon::log_debug("Saving entry fields.");
     foreach ($form["fields"] as $field) {
         //Ignore fields that are marked as display only
         if (rgget("displayOnly", $field) && $field["type"] != "password") {
             continue;
         }
         //ignore pricing fields in the entry detail
         if (RG_CURRENT_VIEW == "entry" && GFCommon::is_pricing_field($field["type"])) {
             continue;
         }
         //process total field after all fields have been saved
         if ($field["type"] == "total") {
             $total_fields[] = $field;
             continue;
         }
         //only save fields that are not hidden (except on entry screen)
         if (RG_CURRENT_VIEW == 'entry' || !GFFormsModel::is_field_hidden($form, $field, array(), $is_new_lead ? null : $lead)) {
             // process calculation fields after all fields have been saved (moved after the is hidden check)
             if (GFCommon::has_field_calculation($field)) {
                 $calculation_fields[] = $field;
                 continue;
             }
             GFCommon::log_debug("Saving field {$field["label"]}");
             if ($field['type'] == 'post_category') {
                 $field = GFCommon::add_categories_as_choices($field, '');
             }
             if (isset($field["inputs"]) && is_array($field["inputs"])) {
                 foreach ($field["inputs"] as $input) {
                     self::save_input($form, $field, $lead, $current_fields, $input["id"]);
                 }
             } else {
                 self::save_input($form, $field, $lead, $current_fields, $field["id"]);
             }
         }
     }
     if (!empty($calculation_fields)) {
         foreach ($calculation_fields as $calculation_field) {
             GFCommon::log_debug("Saving calculated field {$calculation_field["label"]}");
             if (isset($calculation_field["inputs"]) && is_array($calculation_field["inputs"])) {
                 foreach ($calculation_field["inputs"] as $input) {
                     self::save_input($form, $calculation_field, $lead, $current_fields, $input["id"]);
                     self::refresh_lead_field_value($lead["id"], $input["id"]);
                 }
             } else {
                 self::save_input($form, $calculation_field, $lead, $current_fields, $calculation_field["id"]);
                 self::refresh_lead_field_value($lead["id"], $calculation_field["id"]);
             }
         }
         self::refresh_product_cache($form, $lead = RGFormsModel::get_lead($lead['id']));
     }
     //saving total field as the last field of the form.
     if (!empty($total_fields)) {
         foreach ($total_fields as $total_field) {
             GFCommon::log_debug("Saving total field.");
             self::save_input($form, $total_field, $lead, $current_fields, $total_field["id"]);
         }
     }
 }
Пример #6
0
        public static function do_lead_detail_grid($form, $lead, $config)
        {
            $form_id = $form['id'];
            $results = array();
            /*
             * Set up our defaults and merge down the user config
             */
            $defaults = array('empty_field' => false, 'html_field' => false, 'page_names' => false, 'return' => false, 'section_content' => false);
            $config = array_merge($defaults, $config);
            if ($config['return'] === true) {
                $results['title'] = '<h2 id="details" class="default">' . $form['title'] . '</h2>';
            } else {
                ?>
			<div id='container'>
				<h2 id='details' class='default'><?php 
                echo $form['title'];
                ?>
</h2>
                <?php 
            }
            $count = 0;
            $field_count = sizeof($form['fields']);
            $has_product_fields = false;
            $page_number = 0;
            foreach ($form['fields'] as $field) {
                /*
                 * Check if this field has been excluded from the list
                 */
                if (isset($field['cssClass']) && strpos($field['cssClass'], 'exclude') !== false) {
                    /* skip this field */
                    continue;
                }
                /*
                 * Skip over hidden fields 
                 */
                if (GFFormsModel::is_field_hidden($form, $field, array(), $lead)) {
                    continue;
                }
                /*
                 * Check if we are to show the page names
                 */
                if ($config['page_names'] === true) {
                    if ((int) $field['pageNumber'] !== $page_number && isset($form['pagination']['pages'][$page_number])) {
                        /*
                         * Display the page number
                         */
                        if ($config['return'] === true) {
                            $results['field'][] = '<h2 id="field-' . $field['id'] . '" class="default entry-view-page-break">' . $form['pagination']['pages'][$page_number] . '</h2>';
                        } else {
                            ?>
                                	<h2 id='field-<?php 
                            echo $field['id'];
                            ?>
' class='default entry-view-page-break'><?php 
                            echo $form['pagination']['pages'][$page_number];
                            ?>
</h2>
                                <?php 
                        }
                        /*
                         * Increment the page number
                         */
                        $page_number++;
                    }
                }
                $even = $odd = '';
                switch (RGFormsModel::get_input_type($field)) {
                    case 'section':
                        if (!GFCommon::is_section_empty($field, $form, $lead) || $config['empty_field'] || $config['section_content']) {
                            $count++;
                            if ($config['return'] === true) {
                                $results['field'][] = '<h2 id="field-' . $field['id'] . '" class="default entry-view-section-break">' . esc_html(GFCommon::get_label($field)) . '</h2>';
                                if ($config['section_content']) {
                                    $results['field'][] = '<div class="default entry-view-section-break entry-view-section-break-content">' . $field['description'] . '</div>';
                                }
                            } else {
                                ?>
										<h2 id="field-<?php 
                                echo $field['id'];
                                ?>
" class="default entry-view-section-break"><?php 
                                echo esc_html(GFCommon::get_label($field));
                                ?>
</h2>

										<?php 
                                if ($config['section_content']) {
                                    ?>
											<div class="default entry-view-section-break entry-view-section-break-content"><?php 
                                    echo $field['description'];
                                    ?>
</div>
										<?php 
                                }
                                ?>
									<?php 
                            }
                        }
                        break;
                    case 'captcha':
                    case 'password':
                    case 'page':
                        //ignore captcha, html, password, page field
                        break;
                    case 'html':
                        if ($config['html_field'] == true) {
                            $count++;
                            $is_last = $count >= $field_count && !$has_product_fields ? true : false;
                            $last_row = $is_last ? ' lastrow' : '';
                            $even = $count % 2 ? ' odd' : ' even';
                            $display_value = $field['content'];
                            $value = '';
                            $content = '<div id="field-' . $field['id'] . '" class="entry-view-html-value' . $last_row . $even . '"><div class="value">' . $display_value . '</div></div>';
                            $content = apply_filters('gfpdf_field_content', $content, $field, $value, $lead['id'], $form['id']);
                            if ($config['return'] === true) {
                                $results['field'][] = $content;
                            } else {
                                echo $content;
                            }
                        }
                        break;
                    case 'signature':
                        $value = RGFormsModel::get_lead_field_value($lead, $field);
                        $public_folder = RGFormsModel::get_upload_url_root() . 'signatures/';
                        $server_folder = RGFormsModel::get_upload_root() . 'signatures/';
                        $file = $server_folder . $value;
                        $display_value = false;
                        $is_last = $count >= $field_count ? true : false;
                        $last_row = $is_last ? ' lastrow' : '';
                        if (file_exists($file) && !is_dir($file)) {
                            $image_size = getimagesize($file);
                            $width = apply_filters('gfpdfe_signature_width', $image_size[0] / 4, $image_size[0]);
                            $display_value = '<img src="' . $file . '" alt="Signature" width=" ' . $width . '" />';
                        }
                        if ($display_value) {
                            $content = '<div id="field-' . $field['id'] . '" class="entry-view-field-value' . $last_row . $even . '"><div class="strong">' . esc_html(GFCommon::get_label($field)) . '</div> <div class="value">' . $display_value . '</div></div>	';
                            if ($config['return'] === true) {
                                $results['field'][] = $content;
                            } else {
                                echo $content;
                            }
                        } elseif ($config['empty_field']) {
                            if ($config['return'] === true) {
                                $results['field'][] = '<div id="field-' . $field['id'] . '" class="entry-view-field-value' . $last_row . $even . '"><div class="strong">' . esc_html(GFCommon::get_label($field)) . '</div> <div class="value">&nbsp;</div></div>';
                            } else {
                                print '<div id="field-' . $field['id'] . '" class="entry-view-field-value' . $last_row . $even . '"><div class="strong">' . esc_html(GFCommon::get_label($field)) . '</div><div class="value">&nbsp;</div></div>';
                            }
                        }
                        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 = self::pdf_get_lead_field_display($field, $value, $lead['currency']);
                        $display_value = apply_filters('gform_entry_field_value', $display_value, $field, $lead, $form);
                        if (!empty($display_value) || $display_value === '0' || $config['empty_field']) {
                            $count++;
                            $is_last = $count >= $field_count && !$has_product_fields ? true : false;
                            $last_row = $is_last ? ' lastrow' : '';
                            $even = $count % 2 ? ' odd' : ' even';
                            $display_value = empty($display_value) && $display_value !== '0' ? '&nbsp;' : $display_value;
                            $content = '<div id="field-' . $field['id'] . '" class="entry-view-field-value' . $last_row . $even . '"><div class="strong">' . esc_html(GFCommon::get_label($field)) . '</div> <div class="value">' . $display_value . '</div></div>';
                            $content = apply_filters('gfpdf_field_content', $content, $field, $value, $lead['id'], $form['id']);
                            if ($config['return'] === true) {
                                $results['field'][] = $content;
                            } else {
                                echo $content;
                            }
                        }
                        break;
                }
            }
            $products = array();
            if ($has_product_fields) {
                if ($config['return'] === true) {
                    ob_start();
                    self::product_table($form, $lead);
                    $results['field'][] = ob_get_contents();
                    ob_end_clean();
                } else {
                    self::product_table($form, $lead);
                }
            }
            if ($config['return'] === true) {
                return $results;
            }
            ?>
				</div>
			<?php 
        }
    /**
     * @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();" />&nbsp;&nbsp;
						<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' ? '&nbsp;' : $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">&nbsp;</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']);
                    ?>
&nbsp;</td>
									</tr>
								<?php 
                }
                ?>
								<tr>
									<?php 
                if (empty($products['shipping']['name'])) {
                    ?>
										<td colspan="2" class="emptycell">&nbsp;</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("'", '&#039;', $files) . "' />";
            echo $files_input;
        }
        //GFFormDisplay::print_form_scripts( $form, false );
        ?>
		</div>

	<?php 
    }