Esempio n. 1
0
 /**
  *
  * Checks if a certain entry is valid according to the View search filters (specially the Adv Filters)
  *
  * @see GFFormsModel::is_value_match()
  *
  * @since 1.7.4
  *
  * @param array $entry Gravity Forms Entry object
  * @return bool|array Returns 'false' if entry is not valid according to the view search filters (Adv Filter)
  */
 public static function check_entry_display($entry)
 {
     if (!$entry || is_wp_error($entry)) {
         do_action('gravityview_log_debug', __METHOD__ . ' Entry was not found.', $entry);
         return false;
     }
     if (empty($entry['form_id'])) {
         do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry);
         return false;
     }
     $criteria = self::calculate_get_entries_criteria();
     if (empty($criteria['search_criteria']) || !is_array($criteria['search_criteria'])) {
         do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria);
         return $entry;
     }
     $search_criteria = $criteria['search_criteria'];
     unset($criteria);
     // check entry status
     if (array_key_exists('status', $search_criteria) && $search_criteria['status'] != $entry['status']) {
         do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status']), $search_criteria);
         return false;
     }
     // check entry date
     // @todo: Does it make sense to apply the Date create filters to the single entry?
     // field_filters
     if (empty($search_criteria['field_filters']) || !is_array($search_criteria['field_filters'])) {
         do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria);
         return $entry;
     }
     $filters = $search_criteria['field_filters'];
     unset($search_criteria);
     $mode = array_key_exists('mode', $filters) ? strtolower($filters['mode']) : 'all';
     unset($filters['mode']);
     $form = self::get_form($entry['form_id']);
     foreach ($filters as $filter) {
         if (!isset($filter['key'])) {
             continue;
         }
         $k = $filter['key'];
         if ('created_by' === $k) {
             $field_value = $entry['created_by'];
             $field = null;
         } else {
             $field = self::get_field($form, $k);
             $field_value = GFFormsModel::get_lead_field_value($entry, $field);
         }
         $operator = isset($filter['operator']) ? strtolower($filter['operator']) : 'is';
         $is_value_match = GFFormsModel::is_value_match($field_value, $filter['value'], $operator, $field);
         // verify if we are already free to go!
         if (!$is_value_match && 'all' === $mode) {
             do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter);
             return false;
         } elseif ($is_value_match && 'any' === $mode) {
             return $entry;
         }
     }
     // at this point, if in ALL mode, then entry is approved - all conditions were met.
     // Or, for ANY mode, means none of the conditions were satisfied, so entry is not approved
     if ('all' === $mode) {
         return $entry;
     } else {
         do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters);
         return false;
     }
 }
 public static function evaluate_conditional_logic($logic, $form, $lead)
 {
     if (!$logic || !is_array(rgar($logic, 'rules'))) {
         return true;
     }
     $entry_meta_keys = array_keys(GFFormsModel::get_entry_meta($form['id']));
     $match_count = 0;
     if (is_array($logic['rules'])) {
         foreach ($logic['rules'] as $rule) {
             if (in_array($rule['fieldId'], $entry_meta_keys)) {
                 $is_value_match = GFFormsModel::is_value_match(rgar($lead, $rule['fieldId']), $rule['value'], $rule['operator'], $rule, $form);
             } else {
                 $source_field = GFFormsModel::get_field($form, $rule['fieldId']);
                 $field_value = empty($lead) ? GFFormsModel::get_field_value($source_field, array()) : GFFormsModel::get_lead_field_value($lead, $source_field);
                 $is_value_match = GFFormsModel::is_value_match($field_value, $rule['value'], $rule['operator'], $source_field, $rule, $form);
             }
             if ($is_value_match) {
                 $match_count++;
             }
         }
     }
     $do_action = $logic['logicType'] == 'all' && $match_count == sizeof($logic['rules']) || $logic['logicType'] == 'any' && $match_count > 0;
     return $do_action;
 }
Esempio n. 3
0
 public static function evaluate_conditional_logic($logic, $form, $lead)
 {
     if (!$logic || !is_array($logic["rules"])) {
         return true;
     }
     $match_count = 0;
     if (is_array($logic["rules"])) {
         foreach ($logic["rules"] as $rule) {
             $source_field = GFFormsModel::get_field($form, $rule["fieldId"]);
             $field_value = empty($lead) ? GFFormsModel::get_field_value($source_field, array()) : GFFormsModel::get_lead_field_value($lead, $source_field);
             $is_value_match = GFFormsModel::is_value_match($field_value, $rule["value"], $rule["operator"], $source_field);
             if ($is_value_match) {
                 $match_count++;
             }
         }
     }
     $do_action = $logic["logicType"] == "all" && $match_count == sizeof($logic["rules"]) || $logic["logicType"] == "any" && $match_count > 0;
     return $do_action;
 }
 public function validate_status_update($new_status, $form)
 {
     $note = rgpost('gravityflow_note');
     $valid = true;
     switch ($this->note_mode) {
         case 'required':
             $valid = !empty($note);
             break;
         case 'required_if_in_progress':
             if ($new_status == 'in_progress' && empty($note)) {
                 $valid = false;
             }
             break;
         case 'required_if_complete':
             if ($new_status == 'complete' && empty($note)) {
                 $valid = false;
             }
     }
     if (!$valid) {
         $form['workflow_note'] = array('failed_validation' => true, 'validation_message' => esc_html__('A note is required'));
     }
     $editable_fields = $this->get_editable_fields();
     foreach ($form['fields'] as $field) {
         /* @var GF_Field $field */
         if (in_array($field->id, $editable_fields)) {
             $value = GFFormsModel::get_field_value($field);
             if ($field->get_input_type() == 'fileupload') {
                 $entry = $this->get_entry();
                 $input_name = 'input_' . $field->id;
                 $form_id = $form['id'];
                 $value = null;
                 if (isset($entry[$field->id])) {
                     $value = $entry[$field->id];
                 }
                 if (!empty($_FILES[$input_name]) && !empty($_FILES[$input_name]['name'])) {
                     $file_path = GFFormsModel::get_file_upload_path($form['id'], $_FILES[$input_name]['name']);
                     $value = $file_path['url'];
                 } else {
                     $_FILES[$input_name] = array('name' => '', 'size' => '');
                 }
                 if ($field->multipleFiles) {
                     if (isset(GFFormsModel::$uploaded_files[$form_id][$input_name])) {
                         $value = empty($value) ? '[]' : $value;
                         $value = stripslashes_deep($value);
                         $value = GFFormsModel::prepare_value($form, $field, $value, $input_name, $entry['id'], array());
                     }
                 } else {
                     GFFormsModel::$uploaded_files[$form_id][$input_name] = $value;
                 }
                 $original_value = GFFormsModel::get_lead_field_value($entry, $field);
                 if (empty($value) && !empty($original_value)) {
                     continue;
                 }
                 $_POST[$input_name] = $value;
                 if ($field->isRequired && empty($value)) {
                     $field->failed_validation = true;
                     $field->validation_message = empty($field->errorMessage) ? __('This field is required.', 'gravityforms') : $field->errorMessage;
                     $valid = false;
                 }
                 $field->validate($value, $form);
                 if ($field->failed_validation) {
                     $valid = false;
                 }
                 continue;
             }
             if ($field->isRequired && $field->is_value_submission_empty($form['id'])) {
                 $field->failed_validation = true;
                 $field->validation_message = empty($field->errorMessage) ? __('This field is required.', 'gravityforms') : $field->errorMessage;
                 $valid = false;
             } else {
                 $field->validate($value, $form);
                 if ($field->failed_validation) {
                     $valid = false;
                 }
             }
         }
     }
     $validation_result = array('is_valid' => $valid, 'form' => $form);
     $validation_result = apply_filters('gravityflow_validation_user_input', $validation_result, $this);
     if (!is_wp_error($validation_result)) {
         if (!$validation_result['is_valid']) {
             $valid = new WP_Error('validation_result', esc_html__('There was a problem while updating your form.', 'gravityflow'), $validation_result);
         }
     }
     return $valid;
 }
 public static function get_body($entry, $form)
 {
     $current_body = self::$_current_body;
     if (is_array($current_body)) {
         return $current_body;
     }
     $body = array();
     foreach ($form['fields'] as $field) {
         $input_type = GFFormsModel::get_input_type($field);
         if ($input_type == 'honeypot') {
             //skip the honeypot field
             continue;
         }
         $field_value = GFFormsModel::get_lead_field_value($entry, $field);
         if (!empty($entry)) {
             $field_value = apply_filters('gform_zapier_field_value', $field_value, $form['id'], $field->id, $entry);
         }
         $field_label = GFFormsModel::get_label($field);
         $inputs = $field instanceof GF_Field ? $field->get_entry_inputs() : rgar($field, 'inputs');
         if (is_array($inputs) && (is_array($field_value) || empty($entry))) {
             //handling multi-input fields
             $non_blank_items = array();
             //field has inputs, complex field like name, address and checkboxes. Get individual inputs
             foreach ($inputs as $input) {
                 $input_label = GFFormsModel::get_label($field, $input['id']);
                 $field_id = (string) $input['id'];
                 $input_value = rgar($field_value, $field_id);
                 $body[$input_label] = $input_value;
                 if (!rgblank($input_value)) {
                     $non_blank_items[] = $input_value;
                 }
             }
             //Also adding an item for the "whole" field, which will be a concatenation of the individual inputs
             switch ($input_type) {
                 case 'checkbox':
                     //checkboxes will create a comma separated list of values
                     $body[$field_label] = implode(', ', $non_blank_items);
                     break;
                 case 'name':
                 case 'address':
                     //name and address will separate inputs by a single blank space
                     $body[$field_label] = implode(' ', $non_blank_items);
                     break;
             }
         } else {
             $body[$field_label] = rgblank($field_value) ? '' : $field_value;
         }
     }
     $entry_meta = GFFormsModel::get_entry_meta($form['id']);
     foreach ($entry_meta as $meta_key => $meta_config) {
         $body[$meta_config['label']] = empty($entry) ? null : rgar($entry, $meta_key);
     }
     self::$_current_body = $body;
     return $body;
 }
Esempio n. 6
0
 /**
  * Evaluates a routing rule.
  *
  * @param $routing_rule
  *
  * @return bool Is the routing rule a match?
  */
 public function evaluate_routing_rule($routing_rule)
 {
     gravity_flow()->log_debug(__METHOD__ . '(): rule:' . print_r($routing_rule, true));
     $entry = $this->get_entry();
     $form_id = $this->get_form_id();
     $entry_meta_keys = array_keys(GFFormsModel::get_entry_meta($form_id));
     $form = GFAPI::get_form($form_id);
     if (in_array($routing_rule['fieldId'], $entry_meta_keys)) {
         $is_value_match = GFFormsModel::is_value_match(rgar($entry, $routing_rule['fieldId']), $routing_rule['value'], $routing_rule['operator'], null, $routing_rule, $form);
     } else {
         $source_field = GFFormsModel::get_field($form, $routing_rule['fieldId']);
         $field_value = empty($entry) ? GFFormsModel::get_field_value($source_field, array()) : GFFormsModel::get_lead_field_value($entry, $source_field);
         $is_value_match = GFFormsModel::is_value_match($field_value, $routing_rule['value'], $routing_rule['operator'], $source_field, $routing_rule, $form);
     }
     gravity_flow()->log_debug(__METHOD__ . '(): is_match:' . print_r($is_value_match, true));
     return $is_value_match;
 }
 /**
  * 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;
 }
Esempio n. 8
0
    public static function evaluate_conditional_logic($logic, $form, $lead) {

        if(!$logic || !is_array(rgar($logic,"rules")))
            return true;

        $entry_meta_keys = array_keys(GFFormsModel::get_entry_meta($form["id"]));
        $match_count = 0;
        if(is_array($logic["rules"])){
            foreach($logic["rules"] as $rule) {

                if (in_array($rule["fieldId"], $entry_meta_keys)){
                        $is_value_match = GFFormsModel::is_value_match(rgar($lead,$rule["fieldId"]), $rule["value"], $rule["operator"]);;
                } else {
                    $source_field = GFFormsModel::get_field($form, $rule["fieldId"]);
                    $field_value = empty($lead) ? GFFormsModel::get_field_value($source_field, array()) : GFFormsModel::get_lead_field_value($lead, $source_field);
                    $is_value_match = GFFormsModel::is_value_match($field_value, $rule["value"], $rule["operator"], $source_field);
                }

                if($is_value_match)
                    $match_count++;

            }
        }

        $do_action = ($logic["logicType"] == "all" && $match_count == sizeof($logic["rules"]) ) || ($logic["logicType"] == "any"  && $match_count > 0);
        return $do_action;
    }
Esempio n. 9
0
 public static function get_body($entry, $form)
 {
     $body = array();
     foreach ($form["fields"] as $field) {
         if ($field["type"] == "honeypot") {
             //skip the honeypot field
             continue;
         }
         $field_value = GFFormsModel::get_lead_field_value($entry, $field);
         if (!empty($entry)) {
             $field_value = apply_filters("gform_zapier_field_value", $field_value, $form["id"], $field["id"], $entry);
         }
         $field_label = GFFormsModel::get_label($field);
         if (is_array($field["inputs"])) {
             //handling multi-input fields
             $non_blank_items = array();
             //field has inputs, complex field like name, address and checkboxes. Get individual inputs
             foreach ($field["inputs"] as $input) {
                 $input_label = GFFormsModel::get_label($field, $input["id"]);
                 $field_id = (string) $input["id"];
                 $input_value = $field_value == null ? "" : $field_value[$field_id];
                 $body[$input_label] = $input_value;
                 if (!rgblank($input_value)) {
                     $non_blank_items[] = $input_value;
                 }
             }
             //Also adding an item for the "whole" field, which will be a concatenation of the individual inputs
             switch (GFFormsModel::get_input_type($field)) {
                 case "checkbox":
                     //checkboxes will create a comma separated list of values
                     $body[$field_label] = implode(", ", $non_blank_items);
                     break;
                 case "name":
                 case "address":
                     //name and address will separate inputs by a single blank space
                     $body[$field_label] = implode(" ", $non_blank_items);
                     break;
             }
         } else {
             $body[$field_label] = rgblank($field_value) ? "" : $field_value;
         }
     }
     $entry_meta = GFFormsModel::get_entry_meta($form["id"]);
     foreach ($entry_meta as $meta_key => $meta_config) {
         $body[$meta_config["label"]] = empty($entry) ? null : rgar($entry, $meta_key);
     }
     return $body;
 }
    /**
     * @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 
    }