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 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); $has_product_fields = false; foreach ($form["fields"] as $field) { $field_value = ""; $field_label = $use_admin_label && !rgempty("adminLabel", $field) ? rgar($field, "adminLabel") : esc_html(GFCommon::get_label($field)); switch ($field["type"]) { case "captcha": break; case "section": if (!GFCommon::is_section_empty($field, $form, $lead) || $display_empty) { 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: //ignore product fields as they will be grouped together at the end of the grid if (self::is_product_field($field["type"])) { $has_product_fields = true; continue; } else { if (RGFormsModel::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 && rgar($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="#EAF2FA"> <td colspan="2"> <font style="font-family: sans-serif; font-size:12px;"><strong>%s</strong></font> </td> </tr> <tr bgcolor="#FFFFFF"> <td width="20"> </td> <td> <font style="font-family: sans-serif; font-size:12px;">%s</font> </td> </tr>', $field_label, empty($field_value) && strlen($field_value) == 0 ? " " : $field_value); break; } } } } if ($has_product_fields) { $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; }
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 }
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"> </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 ? ' ' : $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; }
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"> </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"> </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' ? ' ' : $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 }
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 }
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; }
/** * @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 }