Beispiel #1
0
function lpop_gform_get_entry($attrs)
{
    /* Parse the id */
    $entry = RGFormsModel::get_lead(1);
    $form = GFFormsModel::get_form_meta($entry['form_id']);
    LPOP_Logger::logit("Loading Mini Audits: Form =  " . $form['title'] . ", Entry = " . $entry['id']);
    LPOP_Mini_Audits::process_mini_audit_entry($entry);
    LPOP_Logger::flush();
}
 public function get_value_save_entry($value, $form, $input_name, $lead_id, $lead)
 {
     // ignore submitted value and recalculate price in backend
     list($prefix, $field_id, $input_id) = rgexplode('_', $input_name, 3);
     if ($input_id == 2) {
         require_once GFCommon::get_base_path() . '/currency.php';
         $currency = new RGCurrency(GFCommon::get_currency());
         $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
         $value = $currency->to_money(GFCommon::calculate($this, $form, $lead));
     }
     return $value;
 }
 /**
  * Maybed redirect to Gravity Forms entry
  */
 public static function maybe_redirect_to_entry()
 {
     if (filter_has_var(INPUT_GET, 'pronamic_gf_lid')) {
         $lead_id = filter_input(INPUT_GET, 'pronamic_gf_lid', FILTER_SANITIZE_STRING);
         $lead = RGFormsModel::get_lead($lead_id);
         if (!empty($lead)) {
             $url = add_query_arg(array('page' => 'gf_entries', 'view' => 'entry', 'id' => $lead['form_id'], 'lid' => $lead_id), admin_url('admin.php'));
             wp_redirect($url);
             exit;
         }
     }
 }
Beispiel #4
0
 /**
  * Save the order and return the order id
  *
  * If the order is new, then save all the order items and manage the inventory.
  * If the order already exists, only the order data is updated. The order items and inventory
  * remain unchanged.
  *
  * @return int The order id (primary key form database)
  */
 public function save()
 {
     // If the order is already in the database, only save the order data, not the ordered items or anything else
     if ($this->id > 0) {
         //prevent null values from being inserted
         foreach ($this->_data as $key => $value) {
             $this->_data[$key] = is_null($value) ? '' : $value;
         }
         $this->_db->update($this->_tableName, $this->_data, array('id' => $this->id));
     } else {
         // This is a new order so save the order items and deduct from inventory if necessary
         $this->_orderInfo['ouid'] = md5($this->_orderInfo['trans_id'] . $this->_orderInfo['bill_address']);
         //prevent null values from being inserted
         foreach ($this->_orderInfo as $key => $value) {
             $this->_orderInfo[$key] = is_null($value) ? '' : $value;
         }
         $this->_db->insert($this->_tableName, $this->_orderInfo);
         $this->id = $this->_db->insert_id;
         if ($this->id == 0 || empty($this->id)) {
             throw new Cart66Exception('The order was not saved.');
             return false;
         }
         $key = $this->_orderInfo['trans_id'] . '-' . $this->id . '-';
         foreach ($this->_items as $item) {
             // Deduct from inventory
             Cart66Product::decrementInventory($item->getProductId(), $item->getOptionInfo(), $item->getQuantity());
             $data = array('order_id' => $this->id, 'product_id' => $item->getProductId(), 'product_price' => $item->getProductPrice(), 'item_number' => $item->getItemNumber(), 'description' => $item->getFullDisplayName(), 'quantity' => $item->getQuantity(), 'duid' => md5($key . $item->getProductId()));
             $formEntryIds = '';
             $fIds = $item->getFormEntryIds();
             if (is_array($fIds) && count($fIds)) {
                 foreach ($fIds as $entryId) {
                     if (class_exists('RGFormsModel')) {
                         if ($lead = RGFormsModel::get_lead($entryId)) {
                             $lead['status'] = 'active';
                             RGFormsModel::update_lead($lead);
                         }
                     }
                 }
                 $formEntryIds = implode(',', $fIds);
             }
             $data['form_entry_ids'] = $formEntryIds;
             if ($item->getCustomFieldInfo()) {
                 $data['description'] .= "\n" . $item->getCustomFieldDesc() . ":\n" . $item->getCustomFieldInfo();
             }
             $orderItems = Cart66Common::getTableName('order_items');
             $this->_db->insert($orderItems, $data);
             $orderItemId = $this->_db->insert_id;
             Cart66Common::log("Saved order item ({$orderItemId}): " . $data['description'] . "\nSQL: " . $this->_db->last_query);
         }
     }
     return $this->id;
 }
Beispiel #5
0
 public static function process_ipn($wp)
 {
     //Ignore requests that are not IPN
     if (RGForms::get("page") != "gf_paypal_ipn") {
         return;
     }
     if (!isset(self::$log)) {
         self::$log = self::create_logger();
     }
     self::$log->LogDebug("IPN request received. Starting to process...");
     self::$log->LogDebug(print_r($_POST, true));
     //Send request to paypal and verify it has not been spoofed
     if (!self::verify_paypal_ipn()) {
         self::$log->LogError("IPN request could not be verified by PayPal. Aborting.");
         return;
     }
     self::$log->LogDebug("IPN message successfully verified by PayPal");
     //Valid IPN requests must have a custom field
     $custom = RGForms::post("custom");
     if (empty($custom)) {
         self::$log->LogError("IPN request does not have a custom field, so it was not created by Gravity Forms. Aborting.");
         return;
     }
     //Getting entry associated with this IPN message (entry id is sent in the "custom" field)
     list($entry_id, $hash) = explode("|", $custom);
     $hash_matches = wp_hash($entry_id) == $hash;
     //Validates that Entry Id wasn't tampered with
     if (!RGForms::post("test_ipn") && !$hash_matches) {
         self::$log->LogError("Entry Id verification failed. Hash does not match. Custom field: {$custom}. Aborting.");
         return;
     }
     self::$log->LogDebug("IPN message has a valid custom field: {$custom}");
     //$entry_id = RGForms::post("custom");
     $entry = RGFormsModel::get_lead($entry_id);
     //Ignore orphan IPN messages (ones without an entry)
     if (!$entry) {
         self::$log->LogError("Entry could not be found. Entry ID: {$entry_id}. Aborting.");
         return;
     }
     self::$log->LogDebug("Entry has been found." . print_r($entry, true));
     $config = self::get_config($entry["form_id"]);
     //Ignore IPN messages from forms that are no longer configured with the PayPal add-on
     if (!$config) {
         self::$log->LogError("Form no longer is configured with PayPal Addon. Form ID: {$entry["form_id"]}. Aborting.");
         return;
     }
     self::$log->LogDebug("Form {$entry["form_id"]} is properly configured.");
     //Only process test messages coming fron SandBox and only process production messages coming from production PayPal
     if ($config["meta"]["mode"] == "test" && !RGForms::post("test_ipn") || $config["meta"]["mode"] == "production" && RGForms::post("test_ipn")) {
         self::$log->LogError("Invalid test/production mode. IPN message mode (test/production) does not match mode configured in the PayPal feed. Configured Mode: {$config["meta"]["mode"]}. IPN test mode: " . RGForms::post("test_ipn"));
         return;
     }
     //Check business email to make sure it matches
     if (strtolower(trim($_POST["business"])) != strtolower(trim($config["meta"]["email"]))) {
         self::$log->LogError("PayPal email does not match. Configured email:" . strtolower(trim($config["meta"]["email"])) . " - Email from IPN message: " . strtolower(trim($_POST["business"])));
         return;
     }
     //Pre IPN processing filter. Allows users to cancel IPN processing
     $cancel = apply_filters("gform_paypal_pre_ipn", false, $_POST, $entry, $config);
     if (!$cancel) {
         self::$log->LogDebug("Setting payment status...");
         self::set_payment_status($config, $entry, RGForms::post("payment_status"), RGForms::post("txn_type"), RGForms::post("txn_id"), RGForms::post("parent_txn_id"), RGForms::post("subscr_id"), RGForms::post("mc_gross"), RGForms::post("pending_reason"), RGForms::post("reason_code"));
     } else {
         self::$log->LogDebug("IPN processing cancelled by the gform_paypal_pre_ipn filter. Aborting.");
     }
     self::$log->LogDebug("Before gform_paypal_post_ipn.");
     //Post IPN processing action
     do_action("gform_paypal_post_ipn", $_POST, $entry, $config, $cancel);
     self::$log->LogDebug("IPN processing complete.");
 }
 public static function resend_notifications()
 {
     check_admin_referer('gf_resend_notifications', 'gf_resend_notifications');
     $leads = rgpost('leadIds');
     // may be a single ID or an array of IDs
     $leads = !is_array($leads) ? array($leads) : $leads;
     $form = RGFormsModel::get_form_meta(rgpost('formId'));
     if (empty($leads) || empty($form)) {
         _e("There was an error while resending the notifications.", "gravityforms");
         die;
     }
     $send_admin = rgpost('sendAdmin');
     $send_user = rgpost('sendUser');
     $override_options = array();
     $validation_errors = array();
     if (rgpost('sendTo')) {
         if (rgpost('sendTo') && GFCommon::is_invalid_or_empty_email(rgpost('sendTo'))) {
             $validation_errors[] = __("The <strong>Send To</strong> email address provided is not valid.", "gravityforms");
         }
         if (!empty($validation_errors)) {
             echo count($validation_errors) > 1 ? '<ul><li>' . implode('</li><li>', $validation_errors) . '</li></ul>' : $validation_errors[0];
             die;
         }
         $override_options['to'] = rgpost('sendTo');
         $override_options['bcc'] = '';
         // overwrite bcc settings
     }
     foreach ($leads as $lead_id) {
         $lead = RGFormsModel::get_lead($lead_id);
         if ($send_admin) {
             GFCommon::send_admin_notification($form, $lead, $override_options);
         }
         if ($send_user) {
             GFCommon::send_user_notification($form, $lead, $override_options);
         }
     }
     die;
 }
 public function get_value_save_entry($value, $form, $input_name, $lead_id, $lead)
 {
     $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
     $value = GFCommon::get_order_total($form, $lead);
     return $value;
 }
			text-align: ;  page-break-after:avoid; }
		h6 {	font-weight: bold; font-size: 9.5pt; color: #333333; 
			font-family: DejaVuSansCondensed; margin-top: 6pt; margin-bottom: ; 
			text-align: ;  page-break-after:avoid; }




</style>
    <title>Gravity Forms PDF Extended</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
	<body>
        <?php 
foreach ($lead_ids as $lead_id) {
    $lead = RGFormsModel::get_lead($lead_id);
    do_action("gform_print_entry_header", $form, $lead);
    $form_data = GFPDFEntryDetail::lead_detail_grid_array($form, $lead);
    /*
     * Add &data=1 when viewing the PDF via the admin area to view the $form_data array
     */
    PDF_Common::view_data($form_data);
    /* get all the form values */
    /*$date_created		= $form_data['date_created'];
    
    			$first_name 		= $form_data['1.Name']['first'];
    			$last_name 			= $form_data['1.Name']['last'];*/
    //echo print_r($form_data['field'], true);
    $fundName = $form_data['field']['Fund Name'];
    $trusteeType = $form_data['field']['Trustee Type'];
    $attendedBy = "";
 public static function handle_submission($form, &$lead, $ajax = false)
 {
     //creating entry in DB
     RGFormsModel::save_lead($form, $lead);
     //reading entry that was just saved
     $lead = RGFormsModel::get_lead($lead["id"]);
     $lead = GFFormsModel::set_entry_meta($lead, $form);
     do_action('gform_entry_created', $lead, $form);
     //if Akismet plugin is installed, run lead through Akismet and mark it as Spam when appropriate
     $is_spam = false;
     if (GFCommon::akismet_enabled($form['id']) && GFCommon::is_akismet_spam($form, $lead)) {
         $is_spam = true;
     }
     if (!$is_spam) {
         GFCommon::create_post($form, $lead);
         //send auto-responder and notification emails
         self::send_emails($form, $lead);
     } else {
         //marking entry as spam
         RGFormsModel::update_lead_property($lead["id"], "status", "spam", false, true);
         $lead["status"] = "spam";
     }
     //display confirmation message or redirect to confirmation page
     return self::handle_confirmation($form, $lead, $ajax);
 }
Beispiel #10
0
 public function update_entry_status($lead_id)
 {
     $lead = RGFormsModel::get_lead($lead_id);
     $form_id = $lead["form_id"];
     $form = GFFormsModel::get_form_meta($form_id);
     $this->maybe_update_results_cache_meta($form);
 }
Beispiel #11
0
    public static function lead_detail_page()
    {
        global $wpdb;
        global $current_user;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $form = RGFormsModel::get_form_meta($_GET["id"]);
        $form_id = $form["id"];
        $form = apply_filters("gform_admin_pre_render_" . $form["id"], apply_filters("gform_admin_pre_render", $form));
        $lead_id = rgget('lid');
        $filter = rgget("filter");
        $status = in_array($filter, array("trash", "spam")) ? $filter : "active";
        $position = rgget('pos') ? rgget('pos') : 0;
        $sort_direction = rgget('dir') ? rgget('dir') : 'DESC';
        $sort_field = empty($_GET["sort"]) ? 0 : $_GET["sort"];
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta["type"] == "number";
        $star = $filter == "star" ? 1 : null;
        $read = $filter == "unread" ? 0 : null;
        $search_criteria["status"] = $status;
        if ($star) {
            $search_criteria["field_filters"][] = array("key" => "is_starred", "value" => (bool) $star);
        }
        if (!is_null($read)) {
            $search_criteria["field_filters"][] = array("key" => "is_read", "value" => (bool) $read);
        }
        $search_field_id = rgget("field_id");
        if (isset($_GET["field_id"]) && $_GET["field_id"] !== '') {
            $key = $search_field_id;
            $val = rgget("s");
            $strpos_row_key = strpos($search_field_id, "|");
            if ($strpos_row_key !== false) {
                //multi-row likert
                $key_array = explode("|", $search_field_id);
                $key = $key_array[0];
                $val = $key_array[1] . ":" . $val;
            }
            $type = rgget("type");
            if (empty($type)) {
                $type = rgget("field_id") == "0" ? "global" : "field";
            }
            $search_criteria["field_filters"][] = array("key" => $key, "type" => $type, "operator" => rgempty("operator", $_GET) ? "is" : rgget("operator"), "value" => $val);
        }
        $paging = array('offset' => $position, 'page_size' => 1);
        if (!empty($sort_field)) {
            $sorting = array('key' => $_GET["sort"], 'direction' => $sort_direction, 'is_numeric' => $is_numeric);
        } else {
            $sorting = array();
        }
        $total_count = 0;
        $leads = GFAPI::get_entries($form['id'], $search_criteria, $sorting, $paging, $total_count);
        $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
        $next_pos = !rgblank($position) && $position < $total_count - 1 ? $position + 1 : false;
        // unread filter requires special handling for pagination since entries are filter out of the query as they are read
        if ($filter == 'unread') {
            $next_pos = $position;
            if ($next_pos + 1 == $total_count) {
                $next_pos = false;
            }
        }
        if (!$lead_id) {
            $lead = !empty($leads) ? $leads[0] : false;
        } else {
            $lead = GFAPI::get_entry($lead_id);
        }
        if (!$lead) {
            _e("Oops! We couldn't find your entry. Please try again", "gravityforms");
            return;
        }
        RGFormsModel::update_lead_property($lead["id"], "is_read", 1);
        switch (RGForms::post("action")) {
            case "update":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                //Loading files that have been uploaded to temp folder
                $files = GFCommon::json_decode(stripslashes(RGForms::post("gform_uploaded_files")));
                if (!is_array($files)) {
                    $files = array();
                }
                GFFormsModel::$uploaded_files[$form_id] = $files;
                GFFormsModel::save_lead($form, $lead);
                do_action("gform_after_update_entry", $form, $lead["id"]);
                do_action("gform_after_update_entry_{$form["id"]}", $form, $lead["id"]);
                $lead = RGFormsModel::get_lead($lead["id"]);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                break;
            case "add_note":
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead["id"], $current_user->ID, $user_data->display_name, stripslashes($_POST["new_note"]));
                //emailing notes if configured
                if (rgpost("gentry_email_notes_to")) {
                    $email_to = $_POST["gentry_email_notes_to"];
                    $email_from = $current_user->user_email;
                    $email_subject = stripslashes($_POST["gentry_email_subject"]);
                    $headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
                    $result = wp_mail($email_to, $email_subject, stripslashes($_POST["new_note"]), $headers);
                }
                break;
            case "add_quick_note":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead["id"], $current_user->ID, $user_data->display_name, stripslashes($_POST["quick_note"]));
                break;
            case "bulk":
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                if ($_POST["bulk_action"] == "delete") {
                    RGFormsModel::delete_notes($_POST["note"]);
                }
                break;
            case "trash":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "trash");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "restore":
            case "unspam":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "active");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "spam":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead["id"], "status", "spam");
                $lead = RGFormsModel::get_lead($lead["id"]);
                break;
            case "delete":
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                if (!GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    die(__("You don't have adequate permissions to delete entries.", "gravityforms"));
                }
                RGFormsModel::delete_lead($lead["id"]);
                ?>
                <script type="text/javascript">
                    document.location.href='<?php 
                echo "admin.php?page=gf_entries&view=entries&id=" . absint($form["id"]);
                ?>
';
                </script>
                <?php 
                break;
        }
        $mode = empty($_POST["screen_mode"]) ? "view" : $_POST["screen_mode"];
        ?>
        <link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin.css" />
         <script type="text/javascript">

            jQuery(document).ready(function(){
                toggleNotificationOverride(true);
            });

            function DeleteFile(leadId, fieldId, deleteButton){
                if(confirm(<?php 
        _e("'Would you like to delete this file? \\'Cancel\\' to stop. \\'OK\\' to delete'", "gravityforms");
        ?>
)){
                    var fileIndex = jQuery(deleteButton).parent().index();
                    var mysack = new sack("<?php 
        echo admin_url("admin-ajax.php");
        ?>
");
                    mysack.execute = 1;
                    mysack.method = 'POST';
                    mysack.setVar( "action", "rg_delete_file" );
                    mysack.setVar( "rg_delete_file", "<?php 
        echo wp_create_nonce("rg_delete_file");
        ?>
" );
                    mysack.setVar( "lead_id", leadId );
                    mysack.setVar( "field_id", fieldId );
                    mysack.setVar( "file_index", fileIndex );
                    mysack.onError = function() { alert('<?php 
        echo esc_js(__("Ajax error while deleting field.", "gravityforms"));
        ?>
' )};
                    mysack.runAJAX();

                    return true;
                }
            }

            function EndDeleteFile(fieldId, fileIndex){
                var previewFileSelector = "#preview_existing_files_" + fieldId + " .ginput_preview";
                var $previewFiles = jQuery(previewFileSelector);
                var rr = $previewFiles.eq(fileIndex);
                $previewFiles.eq(fileIndex).remove();
                var $visiblePreviewFields = jQuery(previewFileSelector);
                if($visiblePreviewFields.length == 0){
                    jQuery('#preview_' + fieldId).hide();
                    jQuery('#upload_' + fieldId).show('slow');
                }
            }

            function ToggleShowEmptyFields(){
                if(jQuery("#gentry_display_empty_fields").is(":checked")){
                    createCookie("gf_display_empty_fields", true, 10000);
                    document.location = document.location.href;
                }
                else{
                    eraseCookie("gf_display_empty_fields");
                    document.location = document.location.href;
                }
            }

            function createCookie(name,value,days) {
                if (days) {
                    var date = new Date();
                    date.setTime(date.getTime()+(days*24*60*60*1000));
                    var expires = "; expires="+date.toGMTString();
                }
                else var expires = "";
                document.cookie = name+"="+value+expires+"; path=/";
            }

            function eraseCookie(name) {
                createCookie(name,"",-1);
            }

            function ResendNotifications() {

                var selectedNotifications = new Array();
                jQuery(".gform_notifications:checked").each(function(){
                    selectedNotifications.push(jQuery(this).val());
                });

                var sendTo = jQuery('#notification_override_email').val();

                if(selectedNotifications.length <=0) {
                    displayMessage("<?php 
        _e("You must select at least one type of notification to resend.", "gravityforms");
        ?>
", "error", "#notifications_container");
                    return;
                }

                jQuery('#please_wait_container').fadeIn();

                jQuery.post(ajaxurl, {
                        action : "gf_resend_notifications",
                        gf_resend_notifications : '<?php 
        echo wp_create_nonce('gf_resend_notifications');
        ?>
',
                        notifications: jQuery.toJSON(selectedNotifications),
                        sendTo : sendTo,
                        leadIds : '<?php 
        echo $lead['id'];
        ?>
',
                        formId : '<?php 
        echo $form['id'];
        ?>
'
                    },
                    function(response) {
                        if(response) {
                            displayMessage(response, "error", "#notifications_container");
                        } else {
                            displayMessage("<?php 
        _e("Notifications were resent successfully.", "gravityforms");
        ?>
", "updated", "#notifications_container");

                            // reset UI
                            jQuery(".gform_notifications").attr('checked', false);
                            jQuery('#notification_override_email').val('');
                        }

                        jQuery('#please_wait_container').hide();
                        setTimeout(function(){jQuery('#notifications_container').find('.message').slideUp();}, 5000);
                    }
                );

            }

            function displayMessage(message, messageClass, container){

                jQuery(container).find('.message').hide().html(message).attr('class', 'message ' + messageClass).slideDown();

            }

            function toggleNotificationOverride(isInit) {

                if(isInit)
                    jQuery('#notification_override_email').val('');

                if(jQuery(".gform_notifications:checked").length > 0 ) {
                    jQuery('#notifications_override_settings').slideDown();
                }
                else {
                    jQuery('#notifications_override_settings').slideUp(function(){
                        jQuery('#notification_override_email').val('');
                    });
                }
            }

        </script>

        <form method="post" id="entry_form" enctype='multipart/form-data'>
            <?php 
        wp_nonce_field('gforms_save_entry', 'gforms_save_entry');
        ?>
            <input type="hidden" name="action" id="action" value=""/>
            <input type="hidden" name="screen_mode" id="screen_mode" value="<?php 
        echo esc_attr(rgpost("screen_mode"));
        ?>
" />

            <div class="wrap gf_entry_wrap">
            <h2 class="gf_admin_page_title"><span><?php 
        echo __("Entry #", "gravityforms") . absint($lead["id"]);
        ?>
</span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php 
        echo $form['id'];
        ?>
</span><?php 
        echo $form['title'];
        $gf_entry_locking = new GFEntryLocking();
        $gf_entry_locking->lock_info($lead_id);
        ?>
</span></h2>

            <?php 
        if (isset($_GET["pos"])) {
            ?>
            <div class="gf_entry_detail_pagination">
                <ul>
                    <li class="gf_entry_count"><span>entry <strong><?php 
            echo $position + 1;
            ?>
</strong> of <strong><?php 
            echo $total_count;
            ?>
</strong></span></li>
                    <li class="gf_entry_prev gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($prev_pos, 'Previous Entry', 'gf_entry_prev_link', "fa fa-arrow-circle-o-left");
            ?>
</li>
                    <li class="gf_entry_next gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($next_pos, 'Next Entry', 'gf_entry_next_link', "fa fa-arrow-circle-o-right");
            ?>
</li>
                </ul>
            </div>
            <?php 
        }
        ?>

            <?php 
        RGForms::top_toolbar();
        ?>

            <div id="poststuff" class="metabox-holder has-right-sidebar">
                <div id="side-info-column" class="inner-sidebar">
                	<?php 
        do_action("gform_entry_detail_sidebar_before", $form, $lead);
        ?>

                    <!-- INFO BOX -->
                    <div id="submitdiv" class="stuffbox">
                        <h3>
                            <span class="hndle"><?php 
        _e("Entry", "gravityforms");
        ?>
</span>
                        </h3>
                        <div class="inside">
                            <div id="submitcomment" class="submitbox">
                                <div id="minor-publishing" style="padding:10px;">
                                    <br/>
                                    <?php 
        _e("Entry Id", "gravityforms");
        ?>
: <?php 
        echo absint($lead["id"]);
        ?>
<br/><br/>
                                    <?php 
        _e("Submitted on", "gravityforms");
        ?>
: <?php 
        echo esc_html(GFCommon::format_date($lead["date_created"], false, "Y/m/d"));
        ?>
                                    <br/><br/>
                                    <?php 
        _e("User IP", "gravityforms");
        ?>
: <?php 
        echo $lead["ip"];
        ?>
                                    <br/><br/>
                                    <?php 
        if (!empty($lead["created_by"]) && ($usermeta = get_userdata($lead["created_by"]))) {
            ?>
                                        <?php 
            _e("User", "gravityforms");
            ?>
: <a href="user-edit.php?user_id=<?php 
            echo absint($lead["created_by"]);
            ?>
" alt="<?php 
            _e("View user profile", "gravityforms");
            ?>
" title="<?php 
            _e("View user profile", "gravityforms");
            ?>
"><?php 
            echo esc_html($usermeta->user_login);
            ?>
</a>
                                        <br/><br/>
                                        <?php 
        }
        ?>

                                    <?php 
        _e("Embed Url", "gravityforms");
        ?>
: <a href="<?php 
        echo esc_url($lead["source_url"]);
        ?>
" target="_blank" alt="<?php 
        echo esc_url($lead["source_url"]);
        ?>
" title="<?php 
        echo esc_url($lead["source_url"]);
        ?>
">.../<?php 
        echo esc_html(GFCommon::truncate_url($lead["source_url"]));
        ?>
</a>
                                    <br/><br/>
                                    <?php 
        if (!empty($lead["post_id"])) {
            $post = get_post($lead["post_id"]);
            ?>
                                        <?php 
            _e("Edit Post", "gravityforms");
            ?>
: <a href="post.php?action=edit&post=<?php 
            echo absint($post->ID);
            ?>
" alt="<?php 
            _e("Click to edit post", "gravityforms");
            ?>
" title="<?php 
            _e("Click to edit post", "gravityforms");
            ?>
"><?php 
            echo esc_html($post->post_title);
            ?>
</a>
                                        <br/><br/>
                                        <?php 
        }
        if (apply_filters("gform_enable_entry_info_payment_details", true, $lead)) {
            if (!empty($lead["payment_status"])) {
                echo $lead["transaction_type"] == 2 ? __("Subscription Status", "gravityforms") : __("Payment Status", "gravityforms");
                ?>
: <span id="gform_payment_status"><?php 
                echo apply_filters("gform_payment_status", $lead["payment_status"], $form, $lead);
                ?>
</span>
                                            <br/><br/>
                                            <?php 
                if (!empty($lead["payment_date"])) {
                    echo $lead["transaction_type"] == 2 ? __("Start Date", "gravityforms") : __("Payment Date", "gravityforms");
                    ?>
: <?php 
                    echo GFCommon::format_date($lead["payment_date"], false, "Y/m/d", $lead["transaction_type"] != 2);
                    ?>
                                                <br/><br/>
                                                <?php 
                }
                if (!empty($lead["transaction_id"])) {
                    echo $lead["transaction_type"] == 2 ? __("Subscriber Id", "gravityforms") : __("Transaction Id", "gravityforms");
                    ?>
: <?php 
                    echo $lead["transaction_id"];
                    ?>
                                                <br/><br/>
                                                <?php 
                }
                if (!rgblank($lead["payment_amount"])) {
                    echo $lead["transaction_type"] == 2 ? __("Subscription Amount", "gravityforms") : __("Payment Amount", "gravityforms");
                    ?>
: <?php 
                    echo GFCommon::to_money($lead["payment_amount"], $lead["currency"]);
                    ?>
                                                <br/><br/>
                                                <?php 
                }
            }
        }
        do_action("gform_entry_info", $form["id"], $lead);
        ?>
                                </div>
                                <div id="major-publishing-actions">
                                    <div id="delete-action">
                                        <?php 
        switch ($lead["status"]) {
            case "spam":
                if (GFCommon::akismet_enabled($form['id'])) {
                    ?>
                                                    <a onclick="jQuery('#action').val('unspam'); jQuery('#entry_form').submit()" href="#"><?php 
                    _e("Not Spam", "gravityforms");
                    ?>
</a>
                                                    <?php 
                    echo GFCommon::current_user_can_any("gravityforms_delete_entries") ? "|" : "";
                }
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                                    <a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    _e("You are about to delete this entry. \\'Cancel\\' to stop, \\'OK\\' to delete.", "gravityforms");
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</a>
                                                    <?php 
                }
                break;
            case "trash":
                ?>
                                                <a onclick="jQuery('#action').val('restore'); jQuery('#entry_form').submit()" href="#"><?php 
                _e("Restore", "gravityforms");
                ?>
</a>
                                                <?php 
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                                    |
                                                    <a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    _e("You are about to delete this entry. \\'Cancel\\' to stop, \\'OK\\' to delete.", "gravityforms");
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    _e("Delete Permanently", "gravityforms");
                    ?>
</a>
                                                    <?php 
                }
                break;
            default:
                if (GFCommon::current_user_can_any("gravityforms_delete_entries")) {
                    ?>
                                                    <a class="submitdelete deletion" onclick="jQuery('#action').val('trash'); jQuery('#entry_form').submit()" href="#"><?php 
                    _e("Move to Trash", "gravityforms");
                    ?>
</a>
                                                    <?php 
                    echo GFCommon::akismet_enabled($form['id']) ? "|" : "";
                }
                if (GFCommon::akismet_enabled($form['id'])) {
                    ?>
                                                    <a class="submitdelete deletion" onclick="jQuery('#action').val('spam'); jQuery('#entry_form').submit()" href="#"><?php 
                    _e("Mark as Spam", "gravityforms");
                    ?>
</a>
                                                <?php 
                }
        }
        ?>
                                    </div>
                                    <div id="publishing-action">
                                        <?php 
        if (GFCommon::current_user_can_any("gravityforms_edit_entries") && $lead["status"] != "trash") {
            $button_text = $mode == "view" ? __("Edit", "gravityforms") : __("Update", "gravityforms");
            $button_click = $mode == "view" ? "jQuery('#screen_mode').val('edit');" : "jQuery('#action').val('update'); jQuery('#screen_mode').val('view');";
            $update_button = '<input class="button button-large button-primary" type="submit" tabindex="4" value="' . $button_text . '" name="save" onclick="' . $button_click . '"/>';
            echo apply_filters("gform_entrydetail_update_button", $update_button);
            if ($mode == "edit") {
                echo '&nbsp;&nbsp;<input class="button button-large" type="submit" tabindex="5" value="' . __("Cancel", "gravityforms") . '" name="cancel" onclick="jQuery(\'#screen_mode\').val(\'view\');"/>';
            }
        }
        ?>
                                    </div>
                                    <div class="clear"></div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <?php 
        if (!empty($lead["payment_status"]) && !apply_filters("gform_enable_entry_info_payment_details", true, $lead)) {
            self::payment_details_box($lead, $form);
        }
        ?>

                    <?php 
        do_action("gform_entry_detail_sidebar_middle", $form, $lead);
        ?>

                    <?php 
        if (GFCommon::current_user_can_any("gravityforms_edit_entry_notes")) {
            ?>
                        <!-- start notifications -->
                        <div class="postbox" id="notifications_container">
                            <h3 style="cursor:default;"><span><?php 
            _e("Notifications", "gravityforms");
            ?>
</span></h3>
                            <div class="inside">
                                <div class="message" style="display:none; padding:10px; margin:10px 0px;"></div>
                                <div>
                                    <?php 
            if (!is_array($form["notifications"]) || count($form["notifications"]) <= 0) {
                ?>
                                        <p class="description"><?php 
                _e("You cannot resend notifications for this entry because this form does not currently have any notifications configured.", "gravityforms");
                ?>
</p>

                                        <a href="<?php 
                echo admin_url("admin.php?page=gf_edit_forms&view=settings&subview=notification&id={$form["id"]}");
                ?>
" class="button"><?php 
                _e("Configure Notifications", "gravityforms");
                ?>
</a>
                                    <?php 
            } else {
                foreach ($form["notifications"] as $notification) {
                    ?>
                                            <input type="checkbox" class="gform_notifications" value="<?php 
                    echo $notification["id"];
                    ?>
" id="notification_<?php 
                    echo $notification["id"];
                    ?>
" onclick="toggleNotificationOverride();" />
                                            <label for="notification_<?php 
                    echo $notification["id"];
                    ?>
"><?php 
                    echo $notification["name"];
                    ?>
</label> <br /><br />
                                        <?php 
                }
                ?>

                                        <div id="notifications_override_settings" style="display:none;">

                                            <p class="description" style="padding-top:0; margin-top:0; width:99%;">You may override the default notification settings
                                                by entering a comma delimited list of emails to which the selected notifications should be sent.</p>
                                            <label for="notification_override_email"><?php 
                _e("Send To", "gravityforms");
                ?>
 <?php 
                gform_tooltip("notification_override_email");
                ?>
</label><br />
                                            <input type="text" name="notification_override_email" id="notification_override_email" style="width:99%;" />
                                            <br /><br />

                                        </div>

                                        <input type="button" name="notification_resend" value="<?php 
                _e("Resend Notifications", "gravityforms");
                ?>
" class="button" style="" onclick="ResendNotifications();"/>
                                        <span id="please_wait_container" style="display:none; margin-left: 5px;">
                                            <img src="<?php 
                echo GFCommon::get_base_url();
                ?>
/images/loading.gif"> <?php 
                _e("Resending...", "gravityforms");
                ?>
                                        </span>
                                    <?php 
            }
            ?>

                                </div>
                            </div>
                        </div>
                       <!-- / end notifications -->
                   <?php 
        }
        ?>

                   <!-- begin print button -->
                   <div class="detail-view-print">
                       <a href="javascript:;" onclick="var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=print-entry&fid=<?php 
        echo $form['id'];
        ?>
&lid=<?php 
        echo $lead['id'];
        ?>
' + notes_qs; window.open (url,'printwindow');" class="button"><?php 
        _e("Print", "gravityforms");
        ?>
</a>
                       <?php 
        if (GFCommon::current_user_can_any("gravityforms_view_entry_notes")) {
            ?>
                           <input type="checkbox" name="print_notes" value="print_notes" checked="checked" id="gform_print_notes"/>
                           <label for="print_notes"><?php 
            _e("include notes", "gravityforms");
            ?>
</label>
                       <?php 
        }
        ?>
                   </div>
                   <!-- end print button -->
				   <?php 
        do_action("gform_entry_detail_sidebar_after", $form, $lead);
        ?>
                </div>

                <div id="post-body" class="has-sidebar">
                    <div id="post-body-content" class="has-sidebar-content">
                        <?php 
        do_action("gform_entry_detail_content_before", $form, $lead);
        if ($mode == "view") {
            self::lead_detail_grid($form, $lead, true);
        } else {
            self::lead_detail_edit($form, $lead);
        }
        do_action("gform_entry_detail", $form, $lead);
        if (GFCommon::current_user_can_any("gravityforms_view_entry_notes")) {
            ?>
                            <div class="postbox">
                                <h3>
                                    <label for="name"><?php 
            _e("Notes", "gravityforms");
            ?>
</label>
                                </h3>

                                <form method="post">
                                    <?php 
            wp_nonce_field('gforms_update_note', 'gforms_update_note');
            ?>
                                    <div class="inside">
                                        <?php 
            $notes = RGFormsModel::get_lead_notes($lead["id"]);
            //getting email values
            $email_fields = GFCommon::get_email_fields($form);
            $emails = array();
            foreach ($email_fields as $email_field) {
                if (!empty($lead[$email_field["id"]])) {
                    $emails[] = $lead[$email_field["id"]];
                }
            }
            //displaying notes grid
            $subject = !empty($form["autoResponder"]["subject"]) ? "RE: " . GFCommon::replace_variables($form["autoResponder"]["subject"], $form, $lead) : "";
            self::notes_grid($notes, true, $emails, $subject);
            ?>
                                    </div>
                                </form>
                            </div>
                        <?php 
        }
        do_action("gform_entry_detail_content_after", $form, $lead);
        ?>
                    </div>
                </div>
            </div>
        </div>
        </form>
        <?php 
        if (rgpost("action") == "update") {
            ?>
            <div class="updated fade" style="padding:6px;">
                <?php 
            _e("Entry Updated.", "gravityforms");
            ?>
            </div>
            <?php 
        }
    }
 /**
  * Perform actions normally performed after updating a lead
  *
  * @since 1.8
  *
  * @see GFEntryDetail::lead_detail_page()
  *
  * @return void
  */
 function after_update()
 {
     do_action('gform_after_update_entry', $this->form, $this->entry['id']);
     do_action("gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id']);
     // Re-define the entry now that we've updated it.
     $entry = RGFormsModel::get_lead($this->entry['id']);
     $entry = GFFormsModel::set_entry_meta($entry, $this->form);
     // We need to clear the cache because Gravity Forms caches the field values, which
     // we have just updated.
     foreach ($this->form['fields'] as $key => $field) {
         GFFormsModel::refresh_lead_field_value($entry['id'], $field->id);
     }
     $this->entry = $entry;
 }
 public function try_restore_saved_state($form)
 {
     if (!isset($form['enableFormState']) || !$form['enableFormState']) {
         return $form;
     }
     /**
      * We are currently unable to restore values of a saved form
      * when a different form on the page is being navigated, saved or
      * submitted. See issue #27.
      */
     if (isset($_POST['gform_submit']) && $_POST['gform_submit'] != $form['id']) {
         return $form;
     }
     $user = wp_get_current_user();
     $lead_id = get_user_meta($user->ID, 'has_pending_form_' . $form['id'], true);
     if (!$lead_id) {
         return $form;
     }
     $lead = RGFormsModel::get_lead($lead_id);
     /* populate the available values */
     foreach ($form['fields'] as $form_part) {
         if ($form_part['inputs'] === null || $form_part['inputs'] === '') {
             /* single-part */
             $input_id = $form_part['id'];
             if (!isset($lead[strval($input_id)])) {
                 continue;
             }
             $input_name = 'input_' . str_replace('.', '_', strval($input_id));
             // only add value from saved lead if new value is not entered
             if (isset($_POST[$input_name]) && !empty($_POST[$input_name])) {
                 continue;
             }
             $_POST[$input_name] = $this->maybe_transform_data($lead[strval($input_id)], $lead, $form_part, $form);
         } else {
             foreach ($form_part['inputs'] as $input) {
                 /* multi-part */
                 if (!isset($lead[strval($input['id'])])) {
                     continue;
                 }
                 $input_name = 'input_' . str_replace('.', '_', strval($input['id']));
                 // only add value from saved lead if new value is not entered
                 if (isset($_POST[$input_name]) && !empty($_POST[$input_name])) {
                     continue;
                 }
                 $_POST[$input_name] = $this->maybe_transform_data($lead[strval($input['id'])], $lead, $form_part, $form);
             }
         }
     }
     $_POST['is_submit_' . $form['id']] = '1';
     /* force the form to be poisoned */
     return $form;
 }
Beispiel #14
0
 public static function get_field_input($field, $value = "", $lead_id = 0, $form_id = 0)
 {
     $id = $field["id"];
     $field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}";
     $form_id = IS_ADMIN && empty($form_id) ? $_GET["id"] : $form_id;
     $size = $field["size"];
     $disabled_text = IS_ADMIN && RG_CURRENT_VIEW != "entry" ? "disabled='disabled'" : "";
     $class_suffix = RG_CURRENT_VIEW == "entry" ? "_admin" : "";
     $class = $size . $class_suffix;
     $currency = "";
     if (RG_CURRENT_VIEW == "entry") {
         $lead = RGFormsModel::get_lead($lead_id);
         $post_id = $lead["post_id"];
         $post_link = "";
         if (is_numeric($post_id) && self::is_post_field($field)) {
             $post_link = "You can <a href='post.php?action=edit&post={$post_id}'>edit this post</a> from the post page.";
         }
         $currency = $lead["currency"];
     }
     $field_input = apply_filters("gform_field_input", "", $field, $value, $lead_id, $form_id);
     if ($field_input) {
         return $field_input;
     }
     //product fields are not editable
     if (RG_CURRENT_VIEW == "entry" && self::is_product_field($field["type"])) {
         return "<div class='ginput_container'>" . _e("Product fields are not editable", "gravityforms") . "</div>";
     } else {
         if (RG_CURRENT_VIEW == "entry" && $field["type"] == "donation") {
             return "<div class='ginput_container'>" . _e("Donations are not editable", "gravityforms") . "</div>";
         }
     }
     $max_length = "";
     $html5_attributes = "";
     switch (RGFormsModel::get_input_type($field)) {
         case "total":
             if (RG_CURRENT_VIEW == "entry") {
                 return "<div class='ginput_container'><input type='text' name='input_{$id}' value='{$value}' /></div>";
             } else {
                 return "<div class='ginput_container'><span class='ginput_total ginput_total_{$form_id}'>" . self::to_money("0") . "</span><input type='hidden' name='input_{$id}' id='{$field_id}' class='gform_hidden'/></div>";
             }
             break;
         case "singleproduct":
             $product_name = !is_array($value) || empty($value[$field["id"] . ".1"]) ? esc_attr($field["label"]) : esc_attr($value[$field["id"] . ".1"]);
             $price = !is_array($value) || empty($value[$field["id"] . ".2"]) ? $field["basePrice"] : esc_attr($value[$field["id"] . ".2"]);
             $quantity = is_array($value) ? esc_attr($value[$field["id"] . ".3"]) : "";
             if (empty($price)) {
                 $price = 0;
             }
             $form = RGFormsModel::get_form_meta($form_id);
             $has_quantity = sizeof(GFCommon::get_product_fields_by_type($form, array("quantity"), $field["id"])) > 0;
             if ($has_quantity) {
                 $field["disableQuantity"] = true;
             }
             $quantity_field = "";
             if (IS_ADMIN) {
                 $style = $field["disableQuantity"] ? "style='display:none;'" : "";
                 $quantity_field = " <span class='ginput_quantity_label' {$style}>" . __("Quantity:", "gravityformspaypal") . "</span> <input type='text' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' />";
             } else {
                 if (!$field["disableQuantity"]) {
                     $tabindex = self::get_tabindex();
                     $quantity_field .= " <span class='ginput_quantity_label'>" . __("Quantity:", "gravityformspaypal") . "</span> <input type='text' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' {$tabindex}/>";
                 } else {
                     if (!is_numeric($quantity)) {
                         $quantity = 1;
                     }
                     if (!$has_quantity) {
                         $quantity_field .= "<input type='hidden' name='input_{$id}.3' value='{$quantity}' class='ginput_quantity_{$form_id}_{$field["id"]} gform_hidden' />";
                     }
                 }
             }
             return "<div class='ginput_container'><input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' /><span class='ginput_product_price_label'>" . __("Price:", "gravityformspaypal") . "</span> <span class='ginput_product_price' id='{$field_id}'>" . GFCommon::to_money($price, $currency) . "</span><input type='hidden' name='input_{$id}.2' id='ginput_base_price_{$form_id}_{$field["id"]}' class='gform_hidden' value='{$price}'/>{$quantity_field}</div>";
             break;
         case "singleshipping":
             $price = !empty($value) ? $value : $field["basePrice"];
             if (empty($price)) {
                 $price = 0;
             }
             return "<div class='ginput_container'><input type='hidden' name='input_{$id}' value='{$price}' class='gform_hidden'/><span class='ginput_shipping_price' id='{$field_id}'>" . GFCommon::to_money($price, $currency) . "</span></div>";
             break;
         case "website":
             $is_html5 = RGFormsModel::is_html5_enabled();
             $value = empty($value) && !$is_html5 ? "http://" : $value;
             $html_input_type = $is_html5 ? "url" : "text";
             $html5_attributes = $is_html5 ? "placeholder='http://'" : "";
         case "text":
             if (empty($html_input_type)) {
                 $html_input_type = "text";
             }
             if ($field["enablePasswordInput"] && RG_CURRENT_VIEW != "entry") {
                 $html_input_type = "password";
             }
             if (is_numeric($field["maxLength"])) {
                 $max_length = "maxlength='{$field["maxLength"]}'";
             }
             if (!empty($post_link)) {
                 return $post_link;
             }
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='%s' value='%s' class='%s' {$max_length} {$tabindex} {$html5_attributes} %s/></div>", $id, $field_id, $html_input_type, esc_attr($value), esc_attr($class), $disabled_text);
             break;
         case "email":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $html_input_type = RGFormsModel::is_html5_enabled() ? "email" : "text";
             if (IS_ADMIN && RG_CURRENT_VIEW != "entry") {
                 $single_style = $field["emailConfirmEnabled"] ? "style='display:none;'" : "";
                 $confirm_style = $field["emailConfirmEnabled"] ? "" : "style='display:none;'";
                 return "<div class='ginput_container ginput_single_email' {$single_style}><input name='input_{$id}' type='{$html_input_type}' class='" . esc_attr($class) . "' disabled='disabled' /></div><div class='ginput_complex ginput_container ginput_confirm_email' {$confirm_style} id='{$field_id}_container'><span id='{$field_id}_1_container' class='ginput_left'><input type='text' name='input_{$id}' id='{$field_id}' disabled='disabled' /><label for='{$field_id}'>" . apply_filters("gform_email_{$form_id}", apply_filters("gform_email", __("Enter Email", "gravityforms"), $form_id), $form_id) . "</label></span><span id='{$field_id}_2_container' class='ginput_right'><input type='text' name='input_{$id}_2' id='{$field_id}_2' disabled='disabled' /><label for='{$field_id}_2'>" . apply_filters("gform_email_confirm_{$form_id}", apply_filters("gform_email_confirm", __("Confirm Email", "gravityforms"), $form_id), $form_id) . "</label></span></div>";
             } else {
                 if ($field["emailConfirmEnabled"] && RG_CURRENT_VIEW != "entry") {
                     $first_tabindex = self::get_tabindex();
                     $last_tabindex = self::get_tabindex();
                     return "<div class='ginput_complex ginput_container' id='{$field_id}_container'><span id='{$field_id}_1_container' class='ginput_left'><input type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='" . esc_attr($value) . "' {$first_tabindex} {$disabled_text}/><label for='{$field_id}'>" . apply_filters("gform_email_{$form_id}", apply_filters("gform_email", __("Enter Email", "gravityforms"), $form_id), $form_id) . "</label></span><span id='{$field_id}_2_container' class='ginput_right'><input type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='{$_POST["input_" . $id . "_2"]}' {$last_tabindex} {$disabled_text}/><label for='{$field_id}_2'>" . apply_filters("gform_email_confirm_{$form_id}", apply_filters("gform_email_confirm", __("Confirm Email", "gravityforms"), $form_id), $form_id) . "</label></span></div>";
                 } else {
                     $tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='%s' value='%s' class='%s' {$max_length} {$tabindex} {$html5_attributes} %s/></div>", $id, $field_id, $html_input_type, esc_attr($value), esc_attr($class), $disabled_text);
                 }
             }
             break;
         case "honeypot":
             return "<div class='ginput_container'><input name='input_{$id}' id='{$field_id}' type='text' value=''/></div>";
             break;
         case "hidden":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $field_type = IS_ADMIN ? "text" : "hidden";
             $class_attribute = IS_ADMIN ? "" : "class='gform_hidden'";
             return sprintf("<input name='input_%d' id='%s' type='{$field_type}' {$class_attribute} value='%s' %s/>", $id, $field_id, esc_attr($value), $disabled_text);
             break;
         case "html":
             $content = IS_ADMIN ? "<img class='gfield_html_block' src='" . self::get_base_url() . "/images/gf_html_admin_placeholder.jpg' alt='HTML Block'/>" : $field["content"];
             return do_shortcode($content);
             break;
         case "adminonly_hidden":
             if (!is_array($field["inputs"])) {
                 return sprintf("<input name='input_%d' id='%s' class='gform_hidden' type='hidden' value='%s'/>", $id, $field_id, esc_attr($value));
             }
             $fields = "";
             foreach ($field["inputs"] as $input) {
                 $fields .= sprintf("<input name='input_%s' class='gform_hidden' type='hidden' value='%s'/>", $input["id"], esc_attr($value[$input["id"]]));
             }
             return $fields;
             break;
         case "number":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $instruction = "";
             if (!IS_ADMIN) {
                 $min = $field["rangeMin"];
                 $max = $field["rangeMax"];
                 $validation_class = $field["failed_validation"] ? "validation_message" : "";
                 $message = self::get_range_message($field);
                 if (!$field["failed_validation"] && !empty($message) && empty($field["errorMessage"])) {
                     $instruction = "<div class='instruction {$validation_class}'>" . $message . "</div>";
                 }
             }
             $html_input_type = RGFormsModel::is_html5_enabled() ? "number" : "text";
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='{$html_input_type}' value='%s' class='%s' {$tabindex} %s/>%s</div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text, $instruction);
         case "donation":
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s' {$tabindex} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "price":
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s ginput_amount' {$tabindex} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "phone":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $instruction = $field["phoneFormat"] == "standard" ? __("Phone format:", "gravityforms") . " (###)###-####" : "";
             $instruction_div = $field["failed_validation"] ? "<div class='instruction validation_message'>{$instruction}</div>" : "";
             $html_input_type = RGFormsModel::is_html5_enabled() ? "tel" : "text";
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='{$html_input_type}' value='%s' class='%s' {$tabindex} %s/>{$instruction_div}</div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "textarea":
             if (!IS_ADMIN && !empty($field["maxLength"]) && is_numeric($field["maxLength"])) {
                 $max_chars = self::get_counter_script($form_id, $field_id, $field["maxLength"]);
             }
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><textarea name='input_%d' id='%s' class='textarea %s' {$tabindex} %s rows='10' cols='50'>%s</textarea></div>{$max_chars}", $id, $field_id, esc_attr($class), $disabled_text, esc_html($value));
         case "post_title":
         case "post_tags":
         case "post_custom_field":
             $tabindex = self::get_tabindex();
             return !empty($post_link) ? $post_link : sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s' {$tabindex} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
             break;
         case "post_content":
         case "post_excerpt":
             if (!IS_ADMIN && !empty($field["maxLength"]) && is_numeric($field["maxLength"])) {
                 $max_chars = self::get_counter_script($form_id, $field_id, $field["maxLength"]);
             }
             $tabindex = self::get_tabindex();
             return !empty($post_link) ? $post_link : sprintf("<div class='ginput_container'><textarea name='input_%d' id='%s' class='textarea %s' {$tabindex} %s rows='10' cols='50'>%s</textarea></div>{$max_chars}", $id, $field_id, esc_attr($class), $disabled_text, esc_html($value));
             break;
         case "post_category":
             if (!empty($post_link)) {
                 return $post_link;
             }
             if ($field["displayAllCategories"] && !IS_ADMIN) {
                 $default_category = $field["categoryInitialItemEnabled"] ? "-1" : get_option('default_category');
                 $selected = empty($value) ? $default_category : $value;
                 $args = array('echo' => 0, 'selected' => $selected, "class" => esc_attr($class) . " gfield_select", 'hide_empty' => 0, 'name' => "input_{$id}", 'orderby' => 'name', 'hierarchical' => true);
                 if (self::$tab_index > 0) {
                     $args["tab_index"] = self::$tab_index++;
                 }
                 if ($field["categoryInitialItemEnabled"]) {
                     $args["show_option_none"] = empty($field["categoryInitialItem"]) ? " " : $field["categoryInitialItem"];
                 }
                 return "<div class='ginput_container'>" . wp_dropdown_categories($args) . "</div>";
             } else {
                 $tabindex = self::get_tabindex();
                 $choices = self::get_select_choices($field, $value);
                 //Adding first option
                 if ($field["categoryInitialItemEnabled"]) {
                     $selected = empty($value) ? "selected='selected'" : "";
                     $choices = "<option value='-1' {$selected}>{$field["categoryInitialItem"]}</option>" . $choices;
                 }
                 return sprintf("<div class='ginput_container'><select name='input_%d' id='%s' class='%s gfield_select' {$tabindex} %s>%s</select></div>", $id, $field_id, esc_attr($class), $disabled_text, $choices);
             }
             break;
         case "post_image":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $title = esc_attr($value[$field["id"] . ".1"]);
             $caption = esc_attr($value[$field["id"] . ".4"]);
             $description = esc_attr($value[$field["id"] . ".7"]);
             //hidding meta fields for admin
             $hidden_style = "style='display:none;'";
             $title_style = !$field["displayTitle"] && IS_ADMIN ? $hidden_style : "";
             $caption_style = !$field["displayCaption"] && IS_ADMIN ? $hidden_style : "";
             $description_style = !$field["displayDescription"] && IS_ADMIN ? $hidden_style : "";
             $file_label_style = IS_ADMIN && !($field["displayTitle"] || $field["displayCaption"] || $field["displayDescription"]) ? $hidden_style : "";
             $hidden_class = "";
             $file_info = RGFormsModel::get_temp_filename($form_id, "input_{$id}");
             if ($file_info) {
                 $hidden_class = " gform_hidden";
                 $file_label_style = $hidden_style;
                 $preview = "<span class='ginput_preview'><strong>{$file_info["uploaded_filename"]}</strong> | <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$id});'>" . __("delete", "gravityforms") . "</a></span>";
             }
             //in admin, render all meta fields to allow for immediate feedback, but hide the ones not selected
             $file_label = IS_ADMIN || $field["displayTitle"] || $field["displayCaption"] || $field["displayDescription"] ? "<label for='{$field_id}' class='ginput_post_image_file' {$file_label_style}>" . apply_filters("gform_postimage_file_{$form_id}", apply_filters("gform_postimage_file", __("File", "gravityforms"), $form_id), $form_id) . "</label>" : "";
             $tabindex = self::get_tabindex();
             $upload = sprintf("<span class='ginput_full{$class_suffix}'>{$preview}<input name='input_%d' id='%s' type='file' value='%s' class='%s' {$tabindex} %s/>{$file_label}</span>", $id, $field_id, esc_attr($value), esc_attr($class . $hidden_class), $disabled_text);
             $tabindex = self::get_tabindex();
             $title_field = $field["displayTitle"] || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_title' {$title_style}><input type='text' name='input_%d.1' id='%s.1' value='%s' {$tabindex} %s/><label for='%s.1'>" . apply_filters("gform_postimage_title_{$form_id}", apply_filters("gform_postimage_title", __("Title", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $title, $disabled_text, $field_id) : "";
             $tabindex = self::get_tabindex();
             $caption_field = $field["displayCaption"] || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_caption' {$caption_style}><input type='text' name='input_%d.4' id='%s.4' value='%s' {$tabindex} %s/><label for='%s.4'>" . apply_filters("gform_postimage_caption_{$form_id}", apply_filters("gform_postimage_caption", __("Caption", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $caption, $disabled_text, $field_id) : "";
             $tabindex = self::get_tabindex();
             $description_field = $field["displayDescription"] || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_description' {$description_style}><input type='text' name='input_%d.7' id='%s.7' value='%s' {$tabindex} %s/><label for='%s.7'>" . apply_filters("gform_postimage_description_{$form_id}", apply_filters("gform_postimage_description", __("Description", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $description, $disabled_text, $field_id) : "";
             return "<div class='ginput_complex{$class_suffix} ginput_container'>" . $upload . $title_field . $caption_field . $description_field . "</div>";
             break;
         case "select":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $logic_event = empty($field["conditionalLogicFields"]) || IS_ADMIN ? "" : "onchange='gf_apply_rules(" . $field["formId"] . "," . GFCommon::json_encode($field["conditionalLogicFields"]) . ");'";
             $css_class = trim(esc_attr($class) . " gfield_select");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><select name='input_%d' id='%s' {$logic_event} class='%s' {$tabindex} %s>%s</select></div>", $id, $field_id, $css_class, $disabled_text, self::get_select_choices($field, $value));
         case "checkbox":
             return sprintf("<div class='ginput_container'><ul class='gfield_checkbox' id='%s'>%s</ul></div>", $field_id, self::get_checkbox_choices($field, $value, $disabled_text));
         case "radio":
             if (!empty($post_link)) {
                 return $post_link;
             }
             return sprintf("<div class='ginput_container'><ul class='gfield_radio' id='%s'>%s</ul></div>", $field_id, self::get_radio_choices($field, $value, $disabled_text));
         case "password":
             $first_tabindex = self::get_tabindex();
             $last_tabindex = self::get_tabindex();
             $strength_style = !$field["passwordStrengthEnabled"] ? "style='display:none;'" : "";
             $strength = $field["passwordStrengthEnabled"] || IS_ADMIN ? "<div id='{$field_id}_strength_indicator' class='gfield_password_strength' {$strength_style}>" . __("Strength indicator", "gravityforms") . "</div><input type='hidden' class='gform_hidden' id='{$field_id}_strength' name='input_{$id}_strength' />" : "";
             $action = "gformShowPasswordStrength(\"{$field_id}\");";
             $onchange = $field["passwordStrengthEnabled"] ? "onchange='{$action}'" : "";
             $onkeyup = $field["passwordStrengthEnabled"] ? "onkeyup='{$action}'" : "";
             $script = $field["passwordStrengthEnabled"] && !IS_ADMIN ? "<script type=\"text/javascript\">if(window[\"gformShowPasswordStrength\"]) jQuery(document).ready(function(){{$action}});</script>" : "";
             $pass = RGForms::post("input_" . $id . "_2");
             return sprintf("<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}_container'><span id='" . $field_id . "_1_container' class='ginput_left'><input type='password' name='input_%d' id='%s' {$onkeyup} {$onchange} value='%s' {$first_tabindex} %s/><label for='%s'>" . apply_filters("gform_password_{$form_id}", apply_filters("gform_password", __("Enter Password", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_2_container' class='ginput_right'><input type='password' name='input_%d_2' id='%s_2' {$onkeyup} {$onchange} value='%s' {$last_tabindex} %s/><label for='%s_2'>" . apply_filters("gform_password_confirm_{$form_id}", apply_filters("gform_password_confirm", __("Confirm Password", "gravityforms"), $form_id), $form_id) . "</label></span>{$script}</div>{$strength}", $id, $field_id, $value, $disabled_text, $field_id, $id, $field_id, $pass, $disabled_text, $field_id);
         case "name":
             $prefix = "";
             $first = "";
             $last = "";
             $suffix = "";
             if (is_array($value)) {
                 $prefix = esc_attr(RGForms::get($field["id"] . ".2", $value));
                 $first = esc_attr(RGForms::get($field["id"] . ".3", $value));
                 $last = esc_attr(RGForms::get($field["id"] . ".6", $value));
                 $suffix = esc_attr(RGForms::get($field["id"] . ".8", $value));
             }
             switch ($field["nameFormat"]) {
                 case "extended":
                     $prefix_tabindex = self::get_tabindex();
                     $first_tabindex = self::get_tabindex();
                     $last_tabindex = self::get_tabindex();
                     $suffix_tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'><span id='" . $field_id . "_2_container' class='name_prefix'><input type='text' name='input_%d.2' id='%s.2' value='%s' {$prefix_tabindex} %s/><label for='%s.2'>" . apply_filters("gform_name_prefix_{$form_id}", apply_filters("gform_name_prefix", __("Prefix", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_3_container' class='name_first'><input type='text' name='input_%d.3' id='%s.3' value='%s' {$first_tabindex} %s/><label for='%s.3'>" . apply_filters("gform_name_first_{$form_id}", apply_filters("gform_name_first", __("First", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_6_container' class='name_last'><input type='text' name='input_%d.6' id='%s.6' value='%s' {$last_tabindex} %s/><label for='%s.6'>" . apply_filters("gform_name_last_{$form_id}", apply_filters("gform_name_last", __("Last", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_8_container' class='name_suffix'><input type='text' name='input_%d.8' id='%s.8' value='%s' {$suffix_tabindex} %s/><label for='%s.8'>" . apply_filters("gform_name_suffix_{$form_id}", apply_filters("gform_name_suffix", __("Suffix", "gravityforms"), $form_id), $form_id) . "</label></span></div>", $id, $field_id, $prefix, $disabled_text, $field_id, $id, $field_id, $first, $disabled_text, $field_id, $id, $field_id, $last, $disabled_text, $field_id, $id, $field_id, $suffix, $disabled_text, $field_id);
                 case "simple":
                     $tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s' {$tabindex} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
                 default:
                     $first_tabindex = self::get_tabindex();
                     $last_tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'><span id='" . $field_id . "_3_container' class='ginput_left'><input type='text' name='input_%d.3' id='%s.3' value='%s' {$first_tabindex} %s/><label for='%s.3'>" . apply_filters("gform_name_first_{$form_id}", apply_filters("gform_name_first", __("First", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_6_container' class='ginput_right'><input type='text' name='input_%d.6' id='%s.6' value='%s' {$last_tabindex} %s/><label for='%s.6'>" . apply_filters("gform_name_last_{$form_id}", apply_filters("gform_name_last", __("Last", "gravityforms"), $form_id), $form_id) . "</label></span></div>", $id, $field_id, $first, $disabled_text, $field_id, $id, $field_id, $last, $disabled_text, $field_id);
             }
         case "address":
             $street_value = "";
             $street2_value = "";
             $city_value = "";
             $state_value = "";
             $zip_value = "";
             $country_value = "";
             if (is_array($value)) {
                 $street_value = esc_attr($value[$field["id"] . ".1"]);
                 $street2_value = esc_attr($value[$field["id"] . ".2"]);
                 $city_value = esc_attr($value[$field["id"] . ".3"]);
                 $state_value = esc_attr($value[$field["id"] . ".4"]);
                 $zip_value = esc_attr($value[$field["id"] . ".5"]);
                 $country_value = esc_attr($value[$field["id"] . ".6"]);
             }
             $address_types = self::get_address_types($form_id);
             $addr_type = empty($field["addressType"]) ? "international" : $field["addressType"];
             $address_type = $address_types[$addr_type];
             $state_label = empty($address_type["state_label"]) ? __("State", "gravityforms") : $address_type["state_label"];
             $zip_label = empty($address_type["zip_label"]) ? __("Zip Code", "gravityforms") : $address_type["zip_label"];
             $hide_country = !empty($address_type["country"]) || $field["hideCountry"];
             if (empty($country_value)) {
                 $country_value = $field["defaultCountry"];
             }
             if (empty($state_value)) {
                 $state_value = $field["defaultState"];
             }
             $country_list = self::get_country_dropdown($country_value);
             //address field
             $tabindex = self::get_tabindex();
             $street_address = sprintf("<span class='ginput_full{$class_suffix}' id='" . $field_id . "_1_container'><input type='text' name='input_%d.1' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1' id='" . $field_id . "_1_label'>" . apply_filters("gform_address_street_{$form_id}", apply_filters("gform_address_street", __("Street Address", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $street_value, $disabled_text, $field_id);
             //address line 2 field
             $style = IS_ADMIN && $field["hideAddress2"] ? "style='display:none;'" : "";
             if (IS_ADMIN || !$field["hideAddress2"]) {
                 $tabindex = self::get_tabindex();
                 $street_address2 = sprintf("<span class='ginput_full{$class_suffix}' id='" . $field_id . "_2_container' {$style}><input type='text' name='input_%d.2' id='%s_2' value='%s' {$tabindex} %s/><label for='%s_2' id='" . $field_id . "_2_label'>" . apply_filters("gform_address_street2_{$form_id}", apply_filters("gform_address_street2", __("Address Line 2", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $street2_value, $disabled_text, $field_id);
             }
             //city field
             $tabindex = self::get_tabindex();
             $city = sprintf("<span class='ginput_left{$class_suffix}' id='" . $field_id . "_3_container'><input type='text' name='input_%d.3' id='%s_3' value='%s' {$tabindex} %s/><label for='%s_3' id='{$field_id}.3_label'>" . apply_filters("gform_address_city_{$form_id}", apply_filters("gform_address_city", __("City", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $city_value, $disabled_text, $field_id);
             //state field
             $style = IS_ADMIN && $field["hideState"] ? "style='display:none;'" : "";
             if (IS_ADMIN || !$field["hideState"]) {
                 $state_field = self::get_state_field($field, $id, $field_id, $state_value, $disabled_text, $form_id);
                 $state = sprintf("<span class='ginput_right{$class_suffix}' id='" . $field_id . "_4_container' {$style}>{$state_field}<label for='%s.4' id='" . $field_id . "_4_label'>" . apply_filters("gform_address_state_{$form_id}", apply_filters("gform_address_state", $state_label, $form_id), $form_id) . "</label></span>", $field_id);
             } else {
                 $state = sprintf("<input type='hidden' class='gform_hidden' name='input_%d.4' id='%s_4' value='%s'/>", $id, $field_id, $state_value);
             }
             //zip field
             $tabindex = self::get_tabindex();
             $zip = sprintf("<span class='ginput_left{$class_suffix}' id='" . $field_id . "_5_container'><input type='text' name='input_%d.5' id='%s_5' value='%s' {$tabindex} %s/><label for='%s_5' id='" . $field_id . "_5_label'>" . apply_filters("gform_address_zip_{$form_id}", apply_filters("gform_address_zip", $zip_label, $form_id), $form_id) . "</label></span>", $id, $field_id, $zip_value, $disabled_text, $field_id);
             if (IS_ADMIN || !$hide_country) {
                 $style = $hide_country ? "style='display:none;'" : "";
                 $tabindex = self::get_tabindex();
                 $country = sprintf("<span class='ginput_right{$class_suffix}' id='" . $field_id . "_6_container' {$style}><select name='input_%d.6' id='%s_6' {$tabindex} %s>%s</select><label for='%s_6' id='" . $field_id . "_6_label'>" . apply_filters("gform_address_country_{$form_id}", apply_filters("gform_address_country", __("Country", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $disabled_text, $country_list, $field_id);
             } else {
                 $country = sprintf("<input type='hidden' class='gform_hidden' name='input_%d.6' id='%s_6' value='%s'/>", $id, $field_id, $country_value);
             }
             return "<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'>" . $street_address . $street_address2 . $city . $state . $zip . $country . "</div>";
         case "date":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $format = empty($field["dateFormat"]) ? "mdy" : esc_attr($field["dateFormat"]);
             if (IS_ADMIN && RG_CURRENT_VIEW != "entry") {
                 $datepicker_display = $field["dateType"] == "datefield" ? "none" : "inline";
                 $dropdown_display = $field["dateType"] == "datefield" ? "inline" : "none";
                 $icon_display = $field["calendarIconType"] == "calendar" ? "inline" : "none";
                 $month_field = "<div class='gfield_date_month ginput_date' id='gfield_input_date_month' style='display:{$dropdown_display}'><input name='ginput_month' type='text' disabled='disabled'/><label>" . __("MM", "gravityforms") . "</label></div>";
                 $day_field = "<div class='gfield_date_day ginput_date' id='gfield_input_date_day' style='display:{$dropdown_display}'><input name='ginput_day' type='text' disabled='disabled'/><label>" . __("DD", "gravityforms") . "</label></div>";
                 $year_field = "<div class='gfield_date_year ginput_date' id='gfield_input_date_year' style='display:{$dropdown_display}'><input type='text' name='ginput_year' disabled='disabled'/><label>" . __("YYYY", "gravityforms") . "</label></div>";
                 $field_string = "<div class='ginput_container' id='gfield_input_datepicker' style='display:{$datepicker_display}'><input name='ginput_datepicker' type='text' /><img src='" . GFCommon::get_base_url() . "/images/calendar.png' id='gfield_input_datepicker_icon' style='display:{$icon_display}'/></div>";
                 $field_string .= $field["dateFormat"] == "dmy" ? $day_field . $month_field . $year_field : $month_field . $day_field . $year_field;
                 return $field_string;
             } else {
                 $date_info = GFCommon::parse_date($value, $format);
                 if ($field["dateType"] == "datefield") {
                     if ($format == "mdy") {
                         $tabindex = self::get_tabindex();
                         $field_str = sprintf("<div class='clear-multi'><div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.1' value='%s' {$tabindex} %s/><label for='%s.1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["month"], $disabled_text, $field_id);
                         $tabindex = self::get_tabindex();
                         $field_str .= sprintf("<div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.2' value='%s' {$tabindex} %s/><label for='%s.2'>" . __("DD", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["day"], $disabled_text, $field_id);
                     } else {
                         $tabindex = self::get_tabindex();
                         $field_str = sprintf("<div class='clear-multi'><div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.2' value='%s' {$tabindex} %s/><label for='%s.2'>" . __("DD", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["day"], $disabled_text, $field_id);
                         $tabindex = self::get_tabindex();
                         $field_str .= sprintf("<div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.1' value='%s' {$tabindex} %s/><label for='%s.1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, $date_info["month"], $disabled_text, $field_id);
                     }
                     $tabindex = self::get_tabindex();
                     $field_str .= sprintf("<div class='gfield_date_year ginput_container' id='%s'><input type='text' maxlength='4' name='input_%d[]' id='%s.3' value='%s' {$tabindex} %s/><label for='%s.3'>" . __("YYYY", "gravityforms") . "</label></div></div>", $field_id, $id, $field_id, $date_info["year"], $disabled_text, $field_id);
                     return $field_str;
                 } else {
                     $value = GFCommon::date_display($value, $format);
                     $icon_class = $field["calendarIconType"] == "none" ? "datepicker_no_icon" : "datepicker_with_icon";
                     $icon_url = empty($field["calendarIconUrl"]) ? GFCommon::get_base_url() . "/images/calendar.png" : $field["calendarIconUrl"];
                     $tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='datepicker %s %s %s' {$tabindex} %s/> </div><input type='hidden' id='gforms_calendar_icon_{$field_id}' class='gform_hidden' value='{$icon_url}'/>", $id, $field_id, esc_attr($value), esc_attr($class), $format, $icon_class, $disabled_text);
                 }
             }
         case "time":
             if (!empty($post_link)) {
                 return $post_link;
             }
             if (!is_array($value) && !empty($value)) {
                 preg_match('/^(\\d*):(\\d*) (.*)$/', $value, $matches);
                 $hour = esc_attr($matches[1]);
                 $minute = esc_attr($matches[2]);
                 $am_selected = $matches[3] == "am" ? "selected='selected'" : "";
                 $pm_selected = $matches[3] == "pm" ? "selected='selected'" : "";
             } else {
                 $hour = esc_attr($value[0]);
                 $minute = esc_attr($value[1]);
                 $am_selected = $value[2] == "am" ? "selected='selected'" : "";
                 $pm_selected = $value[2] == "pm" ? "selected='selected'" : "";
             }
             $hour_tabindex = self::get_tabindex();
             $minute_tabindex = self::get_tabindex();
             $ampm_tabindex = self::get_tabindex();
             return sprintf("<div class='clear-multi'><div class='gfield_time_hour ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s.1' value='%s' {$hour_tabindex} %s/> : <label for='%s.1'>" . __("HH", "gravityforms") . "</label></div><div class='gfield_time_minute ginput_container'><input type='text' maxlength='2' name='input_%d[]' id='%s.2' value='%s' {$minute_tabindex} %s/><label for='%s.2'>" . __("MM", "gravityforms") . "</label></div><div class='gfield_time_ampm ginput_container'><select name='input_%d[]' id='%s.3' {$ampm_tabindex} %s><option value='am' %s>" . __("AM", "gravityforms") . "</option><option value='pm' %s>" . __("PM", "gravityforms") . "</option></select></div></div>", $field_id, $id, $field_id, $hour, $disabled_text, $field_id, $id, $field_id, $minute, $disabled_text, $field_id, $id, $field_id, $disabled_text, $am_selected, $pm_selected);
         case "fileupload":
             $tabindex = self::get_tabindex();
             $upload = sprintf("<input name='input_%d' id='%s' type='file' value='%s' size='20' class='%s' {$tabindex} %s/>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
             if (IS_ADMIN && !empty($value)) {
                 $value = esc_attr($value);
                 $preview = sprintf("<div id='preview_%d'><a href='%s' target='_blank' alt='%s' title='%s'>%s</a><a href='%s' target='_blank' alt='" . __("Download file", "gravityforms") . "' title='" . __("Download file", "gravityforms") . "'><img src='%s' style='margin-left:10px;'/></a><a href='javascript:void(0);' alt='" . __("Delete file", "gravityforms") . "' title='" . __("Delete file", "gravityforms") . "' onclick='DeleteFile(%d,%d);' ><img src='%s' style='margin-left:10px;'/></a></div>", $id, $value, $value, $value, GFCommon::truncate_url($value), $value, GFCommon::get_base_url() . "/images/download.png", $lead_id, $id, GFCommon::get_base_url() . "/images/delete.png");
                 return $preview . "<div id='upload_{$id}' style='display:none;'>{$upload}</div>";
             } else {
                 $file_info = RGFormsModel::get_temp_filename($form_id, "input_{$id}");
                 if ($file_info && !$field["failed_validation"]) {
                     $preview = "<span class='ginput_preview'><strong>{$file_info["uploaded_filename"]}</strong> | <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$id});'>" . __("delete", "gravityforms") . "</a></span>";
                     return "<div class='ginput_container'>" . str_replace(" class='", " class='gform_hidden ", $upload) . " {$preview}</div>";
                 } else {
                     return "<div class='ginput_container'>{$upload}</div>";
                 }
             }
         case "captcha":
             switch ($field["captchaType"]) {
                 case "simple_captcha":
                     $size = empty($field["simpleCaptchaSize"]) ? "medium" : $field["simpleCaptchaSize"];
                     $captcha = self::get_captcha($field);
                     $tagindex = self::get_tabindex();
                     $dimensions = IS_ADMIN ? "" : "width='{$captcha["width"]}' height='{$captcha["height"]}'";
                     return "<div class='gfield_captcha_container'><img class='gfield_captcha' src='{$captcha["url"]}' alt='' {$dimensions} /><div class='gfield_captcha_input_container simple_captcha_{$size}'><input type='text' name='input_{$id}' id='input_{$field_id}' /><input type='hidden' name='input_captcha_prefix_{$id}' value='{$captcha["prefix"]}' /></div></div>";
                     break;
                 case "math":
                     $size = empty($field["simpleCaptchaSize"]) ? "medium" : $field["simpleCaptchaSize"];
                     $captcha_1 = self::get_math_captcha($field, 1);
                     $captcha_2 = self::get_math_captcha($field, 2);
                     $captcha_3 = self::get_math_captcha($field, 3);
                     $tagindex = self::get_tabindex();
                     $dimensions = IS_ADMIN ? "" : "width='{$captcha_1["width"]}' height='{$captcha_1["height"]}'";
                     return "<div class='gfield_captcha_container'><img class='gfield_captcha' src='{$captcha_1["url"]}' alt='' {$dimensions} /><img class='gfield_captcha' src='{$captcha_2["url"]}' alt='' {$dimensions} /><img class='gfield_captcha' src='{$captcha_3["url"]}' alt='' {$dimensions} /><div class='gfield_captcha_input_container math_{$size}'><input type='text' name='input_{$id}' id='input_{$field_id}' /><input type='hidden' name='input_captcha_prefix_{$id}' value='{$captcha_1["prefix"]},{$captcha_2["prefix"]},{$captcha_3["prefix"]}' /></div></div>";
                     break;
                 default:
                     if (!function_exists("recaptcha_get_html")) {
                         require_once GFCommon::get_base_path() . '/recaptchalib.php';
                     }
                     $theme = empty($field["captchaTheme"]) ? "red" : esc_attr($field["captchaTheme"]);
                     $publickey = get_option("rg_gforms_captcha_public_key");
                     $privatekey = get_option("rg_gforms_captcha_private_key");
                     if (IS_ADMIN) {
                         if (empty($publickey) || empty($privatekey)) {
                             return "<div class='captcha_message'>" . __("To use the reCaptcha field you must first do the following:", "gravityforms") . "</div><div class='captcha_message'>1 - <a href='https://admin.recaptcha.net/recaptcha/createsite/?app=php' target='_blank'>" . __(sprintf("Sign up%s for a free reCAPTCHA account", "</a>"), "gravityforms") . "</div><div class='captcha_message'>2 - " . __(sprintf("Enter your reCAPTCHA keys in the %ssettings page%s", "<a href='?page=gf_settings'>", "</a>"), "gravityforms") . "</div>";
                         } else {
                             return "<div class='ginput_container'><img class='gfield_captcha' src='" . GFCommon::get_base_url() . "/images/captcha_{$theme}.jpg' alt='reCAPTCHA' title='reCAPTCHA'/></div>";
                         }
                     } else {
                         $language = empty($field["captchaLanguage"]) ? "en" : esc_attr($field["captchaLanguage"]);
                         $options = "<script type='text/javascript'>var RecaptchaOptions = {theme : '{$theme}', lang : '{$language}'}; if(parseInt('" . self::$tab_index . "') > 0) {RecaptchaOptions.tabindex = " . self::$tab_index++ . ";}</script>";
                         $is_ssl = !empty($_SERVER['HTTPS']);
                         return $options . "<div class='ginput_container' id='{$field_id}'>" . recaptcha_get_html($publickey, null, $is_ssl) . "</div>";
                     }
             }
             break;
     }
 }
 public function get_value_save_entry($value, $form, $input_name, $lead_id, $lead)
 {
     $value = GFCommon::maybe_add_leading_zero($value);
     $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
     $value = $this->has_calculation() ? GFCommon::round_number(GFCommon::calculate($this, $form, $lead), $this->calculationRounding) : $this->clean_number($value);
     //return the value as a string when it is zero and a calc so that the "==" comparison done when checking if the field has changed isn't treated as false
     if ($this->has_calculation() && $value == 0) {
         $value = '0';
     }
     return $value;
 }
 /**
  * @param GF_Field $field
  * @param string   $value
  * @param int      $lead_id
  * @param int      $form_id
  * @param null     $form
  *
  * @return mixed|string|void
  */
 public static function get_field_input($field, $value = '', $lead_id = 0, $form_id = 0, $form = null)
 {
     if (!$field instanceof GF_Field) {
         $field = GF_Fields::create($field);
     }
     $is_form_editor = GFCommon::is_form_editor();
     $is_entry_detail = GFCommon::is_entry_detail();
     $is_admin = $is_form_editor || $is_entry_detail;
     $id = intval($field->id);
     $field_id = $is_admin || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
     $form_id = $is_admin && empty($form_id) ? rgget('id') : $form_id;
     if (RG_CURRENT_VIEW == 'entry') {
         $lead = RGFormsModel::get_lead($lead_id);
         $post_id = $lead['post_id'];
         $post_link = '';
         if (is_numeric($post_id) && self::is_post_field($field)) {
             $post_link = "<div>You can <a href='post.php?action=edit&post={$post_id}'>edit this post</a> from the post page.</div>";
         }
     }
     $field_input = apply_filters('gform_field_input', '', $field, $value, $lead_id, $form_id);
     if ($field_input) {
         return $field_input;
     }
     //product fields are not editable
     if (RG_CURRENT_VIEW == 'entry' && self::is_product_field($field->type)) {
         return "<div class='ginput_container'>" . esc_html__('Product fields are not editable', 'gravityforms') . '</div>';
     } else {
         if (RG_CURRENT_VIEW == 'entry' && $field->type == 'donation') {
             return "<div class='ginput_container'>" . esc_html__('Donations are not editable', 'gravityforms') . '</div>';
         }
     }
     // add categories as choices for Post Category field
     if ($field->type == 'post_category') {
         $field = self::add_categories_as_choices($field, $value);
     }
     $type = RGFormsModel::get_input_type($field);
     switch ($type) {
         case 'honeypot':
             $autocomplete = RGFormsModel::is_html5_enabled() ? "autocomplete='off'" : '';
             return "<div class='ginput_container'><input name='input_{$id}' id='{$field_id}' type='text' value='' {$autocomplete}/></div>";
             break;
         case 'adminonly_hidden':
             if (!is_array($field->inputs)) {
                 if (is_array($value)) {
                     $value = json_encode($value);
                 }
                 return sprintf("<input name='input_%d' id='%s' class='gform_hidden' type='hidden' value='%s'/>", $id, esc_attr($field_id), esc_attr($value));
             }
             $fields = '';
             foreach ($field->inputs as $input) {
                 $fields .= sprintf("<input name='input_%s' class='gform_hidden' type='hidden' value='%s'/>", $input['id'], esc_attr(rgar($value, strval($input['id']))));
             }
             return $fields;
             break;
         default:
             if (!empty($post_link)) {
                 return $post_link;
             }
             if (!isset($lead)) {
                 $lead = null;
             }
             return $field->get_field_input($form, $value, $lead);
             break;
     }
 }
</td>
        <td><?php 
            echo Cart66Common::currency($item->product_price);
            ?>
</td>
        <td><?php 
            echo Cart66Common::currency($item->product_price * $item->quantity);
            ?>
</td>
      </tr>
      <?php 
            if (!empty($item->form_entry_ids)) {
                $entries = explode(',', $item->form_entry_ids);
                foreach ($entries as $entryId) {
                    if (class_exists('RGFormsModel')) {
                        if (RGFormsModel::get_lead($entryId)) {
                            echo "<tr><td colspan='4'><div class='Cart66GravityFormDisplay'>" . Cart66GravityReader::displayGravityForm($entryId) . "</div></td></tr>";
                        }
                    } else {
                        echo "<tr><td colspan='5' style='color: #955;'>" . __('This order requires Gravity Forms in order to view all of the order information', 'cart66') . "</td></tr>";
                    }
                }
            }
            ?>
      <?php 
            if (Cart66Setting::getValue('enable_google_analytics') == 1 && $order->viewed == 0) {
                ?>
        <script type="text/javascript">
          /* <![CDATA[ */
          _gaq.push(['_addItem',
            '<?php 
 /**
  * Prepare the value before saving it to the lead.
  *
  * @param mixed $form
  * @param mixed $field
  * @param mixed $value
  * @param mixed $input_name
  * @param mixed $lead_id the current lead ID, used for fields that are processed after other fields have been saved (ie Total, Calculations)
  * @param mixed $lead passed by the RGFormsModel::create_lead() method, lead ID is not available for leads created by this function
  */
 public static function prepare_value($form, $field, $value, $input_name, $lead_id, $lead = array())
 {
     $form_id = $form["id"];
     $input_type = self::get_input_type($field);
     switch ($input_type) {
         case "total":
             $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
             $value = GFCommon::get_order_total($form, $lead);
             break;
         case "calculation":
             // ignore submitted value and recalculate price in backend
             list(, , $input_id) = rgexplode("_", $input_name, 3);
             if ($input_id == 2) {
                 require_once GFCommon::get_base_path() . '/currency.php';
                 $currency = new RGCurrency(GFCommon::get_currency());
                 $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
                 $value = $currency->to_money(GFCommon::calculate($field, $form, $lead));
             }
             break;
         case "phone":
             if ($field["phoneFormat"] == "standard" && preg_match('/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/', $value, $matches)) {
                 $value = sprintf("(%s)%s-%s", $matches[1], $matches[2], $matches[3]);
             }
             break;
         case "time":
             if (!is_array($value) && !empty($value)) {
                 preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches);
                 $value = array();
                 $value[0] = $matches[1];
                 $value[1] = $matches[2];
                 $value[2] = rgar($matches, 3);
             }
             $hour = empty($value[0]) ? "0" : strip_tags($value[0]);
             $minute = empty($value[1]) ? "0" : strip_tags($value[1]);
             $ampm = strip_tags(rgar($value, 2));
             if (!empty($ampm)) {
                 $ampm = " {$ampm}";
             }
             if (!(empty($hour) && empty($minute))) {
                 $value = sprintf("%02d:%02d%s", $hour, $minute, $ampm);
             } else {
                 $value = "";
             }
             break;
         case "date":
             $value = self::prepare_date($field["dateFormat"], $value);
             break;
         case "post_image":
             $url = self::get_fileupload_value($form_id, $input_name);
             $image_title = isset($_POST["{$input_name}_1"]) ? strip_tags($_POST["{$input_name}_1"]) : "";
             $image_caption = isset($_POST["{$input_name}_4"]) ? strip_tags($_POST["{$input_name}_4"]) : "";
             $image_description = isset($_POST["{$input_name}_7"]) ? strip_tags($_POST["{$input_name}_7"]) : "";
             $value = !empty($url) ? $url . "|:|" . $image_title . "|:|" . $image_caption . "|:|" . $image_description : "";
             break;
         case "fileupload":
             $value = self::get_fileupload_value($form_id, $input_name);
             break;
         case "number":
             $lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
             $value = GFCommon::has_field_calculation($field) ? GFCommon::round_number(GFCommon::calculate($field, $form, $lead), rgar($field, "calculationRounding")) : GFCommon::clean_number($value, rgar($field, "numberFormat"));
             //return the value as a string when it is zero and a calc so that the "==" comparison done when checking if the field has changed isn't treated as false
             if (GFCommon::has_field_calculation($field) && $value == 0) {
                 $value = "0";
             }
             break;
         case "website":
             if ($value == "http://") {
                 $value = "";
             }
             break;
         case "list":
             if (GFCommon::is_empty_array($value)) {
                 $value = "";
             } else {
                 $value = self::create_list_array($field, $value);
                 $value = serialize($value);
             }
             break;
         case "radio":
             if (rgar($field, 'enableOtherChoice') && $value == 'gf_other_choice') {
                 $value = rgpost("input_{$field['id']}_other");
             }
             break;
         case "multiselect":
             $value = empty($value) ? "" : implode(",", $value);
             break;
         case "creditcard":
             //saving last 4 digits of credit card
             list($input_token, $field_id_token, $input_id) = rgexplode("_", $input_name, 3);
             if ($input_id == "1") {
                 $value = str_replace(" ", "", $value);
                 $card_number_length = strlen($value);
                 $value = substr($value, -4, 4);
                 $value = str_pad($value, $card_number_length, "X", STR_PAD_LEFT);
             } else {
                 if ($input_id == "4") {
                     $card_number = rgpost("input_{$field_id_token}_1");
                     $card_type = GFCommon::get_card_type($card_number);
                     $value = $card_type ? $card_type["name"] : "";
                 } else {
                     $value = "";
                 }
             }
             break;
         default:
             //allow HTML for certain field types
             $allow_html = in_array($field["type"], array("post_custom_field", "post_title", "post_content", "post_excerpt", "post_tags")) || in_array($input_type, array("checkbox", "radio")) ? true : false;
             $allowable_tags = apply_filters("gform_allowable_tags_{$form_id}", apply_filters("gform_allowable_tags", $allow_html, $field, $form_id), $field, $form_id);
             if ($allowable_tags !== true) {
                 $value = strip_tags($value, $allowable_tags);
             }
             break;
     }
     // special format for Post Category fields
     if ($field['type'] == 'post_category') {
         $full_values = array();
         if (!is_array($value)) {
             $value = explode(',', $value);
         }
         foreach ($value as $cat_id) {
             $cat = get_term($cat_id, 'category');
             $full_values[] = !is_wp_error($cat) && is_object($cat) ? $cat->name . ":" . $cat_id : "";
         }
         $value = implode(',', $full_values);
     }
     //do not save price fields with blank price
     if (rgar($field, "enablePrice")) {
         $ary = explode("|", $value);
         $label = count($ary) > 0 ? $ary[0] : "";
         $price = count($ary) > 1 ? $ary[1] : "";
         $is_empty = strlen(trim($price)) <= 0;
         if ($is_empty) {
             $value = "";
         }
     }
     return $value;
 }
Beispiel #19
0
 public static function gf_process_user($lead_id, $status, $prev_status)
 {
     // check if user has already been created for this lead
     if (self::get_user_id_by_meta('entry_id', $lead_id) || !($prev_status == 'spam' && $status == 'active')) {
         return;
     }
     $entry = RGFormsModel::get_lead($lead_id);
     $form = RGFormsModel::get_form_meta($entry['form_id']);
     self::log_debug("in gf_process_user - calling gf_create_user");
     self::gf_create_user($entry, $form);
 }
 /**
  * Perform actions normally performed after updating a lead
  *
  * @since 1.8
  *
  * @see GFEntryDetail::lead_detail_page()
  *
  * @return void
  */
 function after_update()
 {
     //custom MF code
     /* update has occurred, reset the validation form as this has admin only fields set to false */
     unset($this->form_after_validation);
     do_action('gform_after_update_entry', $this->form, $this->entry['id']);
     do_action("gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id']);
     // Re-define the entry now that we've updated it.
     $entry = RGFormsModel::get_lead($this->entry['id']);
     $entry = GFFormsModel::set_entry_meta($entry, $this->form);
     // We need to clear the cache because Gravity Forms caches the field values, which
     // we have just updated.
     foreach ($this->form['fields'] as $key => $field) {
         GFFormsModel::refresh_lead_field_value($entry['id'], $field->id);
     }
     $this->entry = $entry;
 }
Beispiel #21
0
 public static function admin_update_payment($form, $lead_id)
 {
     check_admin_referer('gforms_save_entry', 'gforms_save_entry');
     //update payment information in admin, need to use this function so the lead data is updated before displayed in the sidebar info section
     //check meta to see if this entry is paypal
     $payment_gateway = gform_get_meta($lead_id, "payment_gateway");
     $form_action = strtolower(rgpost("save"));
     if ($payment_gateway != "paypal" || $form_action != "update") {
         return;
     }
     //get lead
     $lead = RGFormsModel::get_lead($lead_id);
     //get payment fields to update
     $payment_status = rgpost("payment_status");
     //when updating, payment status may not be editable, if no value in post, set to lead payment status
     if (empty($payment_status)) {
         $payment_status = $lead["payment_status"];
     }
     $payment_amount = rgpost("payment_amount");
     $payment_transaction = rgpost("paypal_transaction_id");
     $payment_date = rgpost("payment_date");
     if (empty($payment_date)) {
         $payment_date = gmdate("y-m-d H:i:s");
     } else {
         //format date entered by user
         $payment_date = date("Y-m-d H:i:s", strtotime($payment_date));
     }
     global $current_user;
     $user_id = 0;
     $user_name = "System";
     if ($current_user && ($user_data = get_userdata($current_user->ID))) {
         $user_id = $current_user->ID;
         $user_name = $user_data->display_name;
     }
     $lead["payment_status"] = $payment_status;
     $lead["payment_amount"] = $payment_amount;
     $lead["payment_date"] = $payment_date;
     $lead["transaction_id"] = $payment_transaction;
     // if payment status does not equal approved or the lead has already been fulfilled, do not continue with fulfillment
     if ($payment_status == 'Approved' && !$lead["is_fulfilled"]) {
         //call fulfill order, mark lead as fulfilled
         self::fulfill_order($lead, $payment_transaction, $payment_amount);
         $lead["is_fulfilled"] = true;
     }
     //update lead, add a note
     RGFormsModel::update_lead($lead);
     RGFormsModel::add_note($lead["id"], $user_id, $user_name, sprintf(__("Payment information was manually updated. Status: %s. Amount: %s. Transaction Id: %s. Date: %s", "gravityforms"), $lead["payment_status"], GFCommon::to_money($lead["payment_amount"], $lead["currency"]), $payment_transaction, $lead["payment_date"]));
 }
Beispiel #22
0
 public static function resend_notifications()
 {
     check_admin_referer('gf_resend_notifications', 'gf_resend_notifications');
     $form_id = rgpost('formId');
     $leads = rgpost('leadIds');
     // may be a single ID or an array of IDs
     if (0 == $leads) {
         // get all the lead ids for the current filter / search
         $filter = rgpost("filter");
         $search = rgpost("search");
         $star = $filter == "star" ? 1 : null;
         $read = $filter == "unread" ? 0 : null;
         $status = in_array($filter, array("trash", "spam")) ? $filter : "active";
         $search_criteria["status"] = $status;
         if ($star) {
             $search_criteria["field_filters"][] = array("key" => "is_starred", "value" => (bool) $star);
         }
         if (!is_null($read)) {
             $search_criteria["field_filters"][] = array("key" => "is_read", "value" => (bool) $read);
         }
         $search_field_id = rgpost("fieldId");
         if (isset($_POST["fieldId"]) && $_POST["fieldId"] !== '') {
             $key = $search_field_id;
             $val = $search;
             $strpos_row_key = strpos($search_field_id, "|");
             if ($strpos_row_key !== false) {
                 //multi-row
                 $key_array = explode("|", $search_field_id);
                 $key = $key_array[0];
                 $val = $key_array[1] . ":" . $val;
             }
             $search_criteria["field_filters"][] = array("key" => $key, "operator" => rgempty("operator", $_POST) ? "is" : rgpost("operator"), "value" => $val);
         }
         $leads = GFFormsModel::search_lead_ids($form_id, $search_criteria);
     } else {
         $leads = !is_array($leads) ? array($leads) : $leads;
     }
     $form = apply_filters("gform_before_resend_notifications_{$form_id}", apply_filters('gform_before_resend_notifications', RGFormsModel::get_form_meta($form_id), $leads), $leads);
     if (empty($leads) || empty($form)) {
         _e("There was an error while resending the notifications.", "gravityforms");
         die;
     }
     $notifications = json_decode(rgpost('notifications'));
     if (!is_array($notifications)) {
         die(__("No notifications have been selected. Please select a notification to be sent.", "gravityforms"));
     }
     if (rgpost('sendTo') && GFCommon::is_invalid_or_empty_email(rgpost('sendTo'))) {
         die(__("The <strong>Send To</strong> email address provided is not valid.", "gravityforms"));
     }
     foreach ($leads as $lead_id) {
         $lead = RGFormsModel::get_lead($lead_id);
         foreach ($notifications as $notification_id) {
             $notification = $form["notifications"][$notification_id];
             if (!$notification) {
                 continue;
             }
             //overriding To email if one was specified
             if (rgpost('sendTo')) {
                 $notification["to"] = rgpost('sendTo');
                 $notification["toType"] = "email";
             }
             GFCommon::send_notification($notification, $form, $lead);
         }
     }
     die;
 }
Beispiel #23
0
 public static function handle_submission($form, &$lead, $ajax = false)
 {
     $lead_id = gf_apply_filters(array('gform_entry_id_pre_save_lead', $form['id']), null, $form);
     if (!empty($lead_id)) {
         if (empty($lead)) {
             $lead = array();
         }
         $lead['id'] = $lead_id;
     }
     //creating entry in DB
     RGFormsModel::save_lead($form, $lead);
     //reading entry that was just saved
     $lead = RGFormsModel::get_lead($lead['id']);
     $lead = GFFormsModel::set_entry_meta($lead, $form);
     //if Akismet plugin is installed, run lead through Akismet and mark it as Spam when appropriate
     $is_spam = GFCommon::akismet_enabled($form['id']) && GFCommon::is_akismet_spam($form, $lead);
     /**
      * A filter to set if an entry is spam
      *
      * @param int $form['id'] The Form ID to filter through (take directly from the form object)
      * @param bool $is_spam True or false to filter if the entry is spam
      * @param array $form The Form object to filer through
      * @param array $lead The Lead object to filter through
      */
     $is_spam = gf_apply_filters(array('gform_entry_is_spam', $form['id']), $is_spam, $form, $lead);
     if (GFCommon::spam_enabled($form['id'])) {
         GFCommon::log_debug('GFFormDisplay::handle_submission(): Akismet integration enabled OR gform_entry_is_spam hook in use.');
         $log_is_spam = $is_spam ? 'Yes' : 'No';
         GFCommon::log_debug("GFFormDisplay::handle_submission(): Is entry considered spam? {$log_is_spam}.");
     }
     if ($is_spam) {
         //marking entry as spam
         RGFormsModel::update_lead_property($lead['id'], 'status', 'spam', false, true);
         $lead['status'] = 'spam';
     }
     /**
      * Fired after an entry is created
      *
      * @param array $lead The Entry object
      * @param array $form The Form object
      */
     do_action('gform_entry_created', $lead, $form);
     $lead = gf_apply_filters(array('gform_entry_post_save', $form['id']), $lead, $form);
     RGFormsModel::set_current_lead($lead);
     if (!$is_spam) {
         GFCommon::create_post($form, $lead);
         //send notifications
         GFCommon::send_form_submission_notifications($form, $lead);
     }
     self::clean_up_files($form);
     // remove incomplete submission and purge expired
     if (rgars($form, 'save/enabled')) {
         GFFormsModel::delete_incomplete_submission(rgpost('gform_resume_token'));
         GFFormsModel::purge_expired_incomplete_submissions();
     }
     //display confirmation message or redirect to confirmation page
     return self::handle_confirmation($form, $lead, $ajax);
 }
Beispiel #24
0
    public static function handle_submission($form, &$lead, $ajax=false){

        $lead_id = apply_filters("gform_entry_id_pre_save_lead{$form["id"]}", apply_filters("gform_entry_id_pre_save_lead", null, $form), $form);

        if(!empty($lead_id)){
            if(empty($lead))
                $lead = array();
            $lead["id"] = $lead_id;
        }

        //creating entry in DB
        RGFormsModel::save_lead($form, $lead);

        //reading entry that was just saved
        $lead = RGFormsModel::get_lead($lead["id"]);

		$lead = GFFormsModel::set_entry_meta($lead, $form);

        do_action('gform_entry_created', $lead, $form);
        $lead = apply_filters('gform_entry_post_save', $lead, $form);

        RGFormsModel::set_current_lead($lead);

        //if Akismet plugin is installed, run lead through Akismet and mark it as Spam when appropriate
        $is_spam = GFCommon::akismet_enabled($form['id']) && GFCommon::is_akismet_spam($form, $lead);

        GFCommon::log_debug("Checking for spam...");
        GFCommon::log_debug("Is entry considered spam? {$is_spam}.");

        if(!$is_spam){
            GFCommon::create_post($form, $lead);
            //send notifications
            GFCommon::send_form_submission_notifications($form, $lead);
        }
        else {
            //marking entry as spam
            RGFormsModel::update_lead_property($lead["id"], "status", "spam", false, true);
            $lead["status"] = "spam";
        }

        self::clean_up_files($form);

        //display confirmation message or redirect to confirmation page
        return self::handle_confirmation($form, $lead, $ajax);
    }
 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.');
 }
    public static function lead_detail_page()
    {
        global $current_user;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $form = RGFormsModel::get_form_meta(absint($_GET['id']));
        $form_id = absint($form['id']);
        $form = apply_filters('gform_admin_pre_render_' . $form_id, apply_filters('gform_admin_pre_render', $form));
        $lead_id = absint(rgget('lid'));
        $filter = rgget('filter');
        $status = in_array($filter, array('trash', 'spam')) ? $filter : 'active';
        $position = rgget('pos') ? rgget('pos') : 0;
        $sort_direction = rgget('dir') ? rgget('dir') : 'DESC';
        $sort_field = empty($_GET['sort']) ? 0 : $_GET['sort'];
        $sort_field_meta = RGFormsModel::get_field($form, $sort_field);
        $is_numeric = $sort_field_meta['type'] == 'number';
        $star = $filter == 'star' ? 1 : null;
        $read = $filter == 'unread' ? 0 : null;
        $search_criteria['status'] = $status;
        if ($star) {
            $search_criteria['field_filters'][] = array('key' => 'is_starred', 'value' => (bool) $star);
        }
        if (!is_null($read)) {
            $search_criteria['field_filters'][] = array('key' => 'is_read', 'value' => (bool) $read);
        }
        $search_field_id = rgget('field_id');
        if (isset($_GET['field_id']) && $_GET['field_id'] !== '') {
            $key = $search_field_id;
            $val = rgget('s');
            $strpos_row_key = strpos($search_field_id, '|');
            if ($strpos_row_key !== false) {
                //multi-row likert
                $key_array = explode('|', $search_field_id);
                $key = $key_array[0];
                $val = $key_array[1] . ':' . $val;
            }
            $search_criteria['field_filters'][] = array('key' => $key, 'operator' => rgempty('operator', $_GET) ? 'is' : rgget('operator'), 'value' => $val);
            $type = rgget('type');
            if (empty($type)) {
                if (rgget('field_id') == '0') {
                    $search_criteria['type'] = 'global';
                }
            }
        }
        $paging = array('offset' => $position, 'page_size' => 1);
        if (!empty($sort_field)) {
            $sorting = array('key' => $_GET['sort'], 'direction' => $sort_direction, 'is_numeric' => $is_numeric);
        } else {
            $sorting = array();
        }
        $total_count = 0;
        $leads = GFAPI::get_entries($form['id'], $search_criteria, $sorting, $paging, $total_count);
        $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
        $next_pos = !rgblank($position) && $position < $total_count - 1 ? $position + 1 : false;
        // unread filter requires special handling for pagination since entries are filter out of the query as they are read
        if ($filter == 'unread') {
            $next_pos = $position;
            if ($next_pos + 1 == $total_count) {
                $next_pos = false;
            }
        }
        if (!$lead_id) {
            $lead = !empty($leads) ? $leads[0] : false;
        } else {
            $lead = GFAPI::get_entry($lead_id);
        }
        if (!$lead) {
            esc_html_e("Oops! We couldn't find your entry. Please try again", 'gravityforms');
            return;
        }
        RGFormsModel::update_lead_property($lead['id'], 'is_read', 1);
        switch (RGForms::post('action')) {
            case 'update':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                //Loading files that have been uploaded to temp folder
                $files = GFCommon::json_decode(stripslashes(RGForms::post('gform_uploaded_files')));
                if (!is_array($files)) {
                    $files = array();
                }
                GFFormsModel::$uploaded_files[$form_id] = $files;
                GFFormsModel::save_lead($form, $lead);
                do_action('gform_after_update_entry', $form, $lead['id']);
                do_action("gform_after_update_entry_{$form['id']}", $form, $lead['id']);
                $lead = RGFormsModel::get_lead($lead['id']);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                break;
            case 'add_note':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['new_note']));
                //emailing notes if configured
                if (rgpost('gentry_email_notes_to')) {
                    GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Preparing to email entry notes.');
                    $email_to = $_POST['gentry_email_notes_to'];
                    $email_from = $current_user->user_email;
                    $email_subject = stripslashes($_POST['gentry_email_subject']);
                    $body = stripslashes($_POST['new_note']);
                    $headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Emailing notes - TO: {$email_to} SUBJECT: {$email_subject} BODY: {$body} HEADERS: {$headers}");
                    $is_success = wp_mail($email_to, $email_subject, $body, $headers);
                    $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Result from wp_mail(): {$result}");
                    if (!is_wp_error($is_success) && $is_success) {
                        GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Mail was passed from WordPress to the mail server.');
                    } else {
                        GFCommon::log_error('GFEntryDetail::lead_detail_page(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
                    }
                    if (has_filter('phpmailer_init')) {
                        GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
                    }
                    do_action('gform_post_send_entry_note', $result, $email_to, $email_from, $email_subject, $body, $form, $lead);
                }
                break;
            case 'add_quick_note':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['quick_note']));
                break;
            case 'bulk':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                if ($_POST['bulk_action'] == 'delete') {
                    if (!GFCommon::current_user_can_any('gravityforms_edit_entry_notes')) {
                        die(esc_html__("You don't have adequate permission to delete notes.", 'gravityforms'));
                    }
                    RGFormsModel::delete_notes($_POST['note']);
                }
                break;
            case 'trash':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'trash');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'restore':
            case 'unspam':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'active');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'spam':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'spam');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'delete':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                if (!GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    die(esc_html__("You don't have adequate permission to delete entries.", 'gravityforms'));
                }
                RGFormsModel::delete_lead($lead['id']);
                ?>
				<script type="text/javascript">
					document.location.href = '<?php 
                echo 'admin.php?page=gf_entries&view=entries&id=' . absint($form['id']);
                ?>
';
				</script>
				<?php 
                break;
        }
        $mode = empty($_POST['screen_mode']) ? 'view' : $_POST['screen_mode'];
        $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || isset($_GET['gform_debug']) ? '' : '.min';
        ?>
		<link rel="stylesheet" href="<?php 
        echo GFCommon::get_base_url();
        ?>
/css/admin<?php 
        echo $min;
        ?>
.css" />
		<script type="text/javascript">

			jQuery(document).ready(function () {
				toggleNotificationOverride(true);
				jQuery('#gform_update_button').prop('disabled', false);
			});

			function DeleteFile(leadId, fieldId, deleteButton) {
				if (confirm(<?php 
        echo json_encode(__("Would you like to delete this file? 'Cancel' to stop. 'OK' to delete", 'gravityforms'));
        ?>
)) {
					var fileIndex = jQuery(deleteButton).parent().index();
					var mysack = new sack("<?php 
        echo admin_url('admin-ajax.php');
        ?>
");
					mysack.execute = 1;
					mysack.method = 'POST';
					mysack.setVar("action", "rg_delete_file");
					mysack.setVar("rg_delete_file", "<?php 
        echo wp_create_nonce('rg_delete_file');
        ?>
");
					mysack.setVar("lead_id", leadId);
					mysack.setVar("field_id", fieldId);
					mysack.setVar("file_index", fileIndex);
					mysack.onError = function () {
						alert(<?php 
        echo json_encode(__('Ajax error while deleting field.', 'gravityforms'));
        ?>
)
					};
					mysack.runAJAX();

					return true;
				}
			}

			function EndDeleteFile(fieldId, fileIndex) {
				var previewFileSelector = "#preview_existing_files_" + fieldId + " .ginput_preview";
				var $previewFiles = jQuery(previewFileSelector);
				var rr = $previewFiles.eq(fileIndex);
				$previewFiles.eq(fileIndex).remove();
				var $visiblePreviewFields = jQuery(previewFileSelector);
				if ($visiblePreviewFields.length == 0) {
					jQuery('#preview_' + fieldId).hide();
					jQuery('#upload_' + fieldId).show('slow');
				}
			}

			function ToggleShowEmptyFields() {
				if (jQuery("#gentry_display_empty_fields").is(":checked")) {
					createCookie("gf_display_empty_fields", true, 10000);
					document.location = document.location.href;
				}
				else {
					eraseCookie("gf_display_empty_fields");
					document.location = document.location.href;
				}
			}

			function createCookie(name, value, days) {
				if (days) {
					var date = new Date();
					date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
					var expires = "; expires=" + date.toGMTString();
				}
				else var expires = "";
				document.cookie = name + "=" + value + expires + "; path=/";
			}

			function eraseCookie(name) {
				createCookie(name, "", -1);
			}

			function ResendNotifications() {

				var selectedNotifications = new Array();
				jQuery(".gform_notifications:checked").each(function () {
					selectedNotifications.push(jQuery(this).val());
				});

				var sendTo = jQuery('#notification_override_email').val();

				if (selectedNotifications.length <= 0) {
					displayMessage(<?php 
        echo json_encode(__('You must select at least one type of notification to resend.', 'gravityforms'));
        ?>
, 'error', '#notifications_container');
					return;
				}

				jQuery('#please_wait_container').fadeIn();

				jQuery.post(ajaxurl, {
						action                 : "gf_resend_notifications",
						gf_resend_notifications: '<?php 
        echo wp_create_nonce('gf_resend_notifications');
        ?>
',
						notifications          : jQuery.toJSON(selectedNotifications),
						sendTo                 : sendTo,
						leadIds                : '<?php 
        echo absint($lead['id']);
        ?>
',
						formId                 : '<?php 
        echo absint($form['id']);
        ?>
'
					},
					function (response) {
						if (response) {
							displayMessage(response, "error", "#notifications_container");
						} else {
							displayMessage(<?php 
        echo json_encode(esc_html__('Notifications were resent successfully.', 'gravityforms'));
        ?>
, "updated", "#notifications_container" );

							// reset UI
							jQuery(".gform_notifications").attr( 'checked', false );
							jQuery('#notification_override_email').val('');

							toggleNotificationOverride();

						}

						jQuery('#please_wait_container').hide();
						setTimeout(function () {
							jQuery('#notifications_container').find('.message').slideUp();
						}, 5000);
					}
				);

			}

			function displayMessage( message, messageClass, container ) {
				jQuery( container ).find( '.message' ).hide().html( message ).attr( 'class', 'message ' + messageClass ).slideDown();
			}

			function toggleNotificationOverride(isInit) {

				if (isInit)
					jQuery('#notification_override_email').val('');

				if (jQuery(".gform_notifications:checked").length > 0) {
					jQuery('#notifications_override_settings').slideDown();
				}
				else {
					jQuery('#notifications_override_settings').slideUp(function () {
						jQuery('#notification_override_email').val('');
					});
				}
			}

		</script>

		<form method="post" id="entry_form" enctype='multipart/form-data'>
		<?php 
        wp_nonce_field('gforms_save_entry', 'gforms_save_entry');
        ?>
		<input type="hidden" name="action" id="action" value="" />
		<input type="hidden" name="screen_mode" id="screen_mode" value="<?php 
        echo esc_attr(rgpost('screen_mode'));
        ?>
" />

		<div class="wrap gf_entry_wrap">
		<h2 class="gf_admin_page_title">
			<span><?php 
        echo esc_html__('Entry #', 'gravityforms') . absint($lead['id']);
        ?>
</span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php 
        echo absint($form['id']);
        ?>
</span><span class='gf_admin_page_formname'><?php 
        esc_html_e('Form Name', 'gravityforms');
        ?>
: <?php 
        echo esc_html($form['title']);
        $gf_entry_locking = new GFEntryLocking();
        $gf_entry_locking->lock_info($lead_id);
        ?>
</span></span></h2>

		<?php 
        if (isset($_GET['pos'])) {
            ?>
			<div class="gf_entry_detail_pagination">
				<ul>
					<li class="gf_entry_count">
						<span>entry <strong><?php 
            echo $position + 1;
            ?>
</strong> of <strong><?php 
            echo $total_count;
            ?>
</strong></span>
					</li>
					<li class="gf_entry_prev gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($prev_pos, 'Previous Entry', 'gf_entry_prev_link', 'fa fa-arrow-circle-o-left');
            ?>
</li>
					<li class="gf_entry_next gf_entry_pagination"><?php 
            echo GFEntryDetail::entry_detail_pagination_link($next_pos, 'Next Entry', 'gf_entry_next_link', 'fa fa-arrow-circle-o-right');
            ?>
</li>
				</ul>
			</div>
		<?php 
        }
        ?>

		<?php 
        RGForms::top_toolbar();
        ?>

		<div id="poststuff" class="metabox-holder has-right-sidebar">
		<div id="side-info-column" class="inner-sidebar">
		<?php 
        do_action('gform_entry_detail_sidebar_before', $form, $lead);
        ?>

		<!-- INFO BOX -->
		<div id="submitdiv" class="stuffbox">
			<h3 class="hndle" style="cursor:default;">
				<span><?php 
        esc_html_e('Entry', 'gravityforms');
        ?>
</span>
			</h3>

			<div class="inside">
				<div id="submitcomment" class="submitbox">
					<div id="minor-publishing" style="padding:10px;">
						<?php 
        esc_html_e('Entry Id', 'gravityforms');
        ?>
: <?php 
        echo absint($lead['id']);
        ?>
<br /><br />
						<?php 
        esc_html_e('Submitted on', 'gravityforms');
        ?>
: <?php 
        echo esc_html(GFCommon::format_date($lead['date_created'], false, 'Y/m/d'));
        ?>
						<br /><br />
						<?php 
        esc_html_e('User IP', 'gravityforms');
        ?>
: <?php 
        echo esc_html($lead['ip']);
        ?>
						<br /><br />
						<?php 
        if (!empty($lead['created_by']) && ($usermeta = get_userdata($lead['created_by']))) {
            ?>
							<?php 
            esc_html_e('User', 'gravityforms');
            ?>
:
							<a href="user-edit.php?user_id=<?php 
            echo absint($lead['created_by']);
            ?>
" alt="<?php 
            esc_attr_e('View user profile', 'gravityforms');
            ?>
" title="<?php 
            esc_attr_e('View user profile', 'gravityforms');
            ?>
"><?php 
            echo esc_html($usermeta->user_login);
            ?>
</a>
							<br /><br />
						<?php 
        }
        ?>

						<?php 
        esc_html_e('Embed Url', 'gravityforms');
        ?>
:
						<a href="<?php 
        echo esc_url($lead['source_url']);
        ?>
" target="_blank" alt="<?php 
        echo esc_attr($lead['source_url']);
        ?>
" title="<?php 
        echo esc_attr($lead['source_url']);
        ?>
">.../<?php 
        echo esc_html(GFCommon::truncate_url($lead['source_url']));
        ?>
</a>
						<br /><br />
						<?php 
        if (!empty($lead['post_id'])) {
            $post = get_post($lead['post_id']);
            ?>
							<?php 
            esc_html_e('Edit Post', 'gravityforms');
            ?>
:
							<a href="post.php?action=edit&post=<?php 
            echo absint($post->ID);
            ?>
" alt="<?php 
            esc_attr_e('Click to edit post', 'gravityforms');
            ?>
" title="<?php 
            esc_attr_e('Click to edit post', 'gravityforms');
            ?>
"><?php 
            echo esc_html($post->post_title);
            ?>
</a>
							<br /><br />
						<?php 
        }
        if (do_action('gform_enable_entry_info_payment_details', true, $lead)) {
            if (!empty($lead['payment_status'])) {
                echo $lead['transaction_type'] != 2 ? esc_html__('Payment Status', 'gravityforms') : esc_html__('Subscription Status', 'gravityforms');
                ?>
:
								<span id="gform_payment_status"><?php 
                echo apply_filters('gform_payment_status', $lead['payment_status'], $form, $lead);
                ?>
</span>
								<br /><br />
								<?php 
                if (!empty($lead['payment_date'])) {
                    echo $lead['transaction_type'] != 2 ? esc_html__('Payment Date', 'gravityforms') : esc_html__('Start Date', 'gravityforms');
                    ?>
: <?php 
                    echo GFCommon::format_date($lead['payment_date'], false, 'Y/m/d', $lead['transaction_type'] != 2);
                    ?>
									<br /><br />
								<?php 
                }
                if (!empty($lead['transaction_id'])) {
                    echo $lead['transaction_type'] != 2 ? esc_html__('Transaction Id', 'gravityforms') : esc_html__('Subscriber Id', 'gravityforms');
                    ?>
: <?php 
                    echo esc_html($lead['transaction_id']);
                    ?>
									<br /><br />
								<?php 
                }
                if (!rgblank($lead['payment_amount'])) {
                    echo $lead['transaction_type'] != 2 ? esc_html__('Payment Amount', 'gravityforms') : esc_html__('Subscription Amount', 'gravityforms');
                    ?>
: <?php 
                    echo GFCommon::to_money($lead['payment_amount'], $lead['currency']);
                    ?>
									<br /><br />
								<?php 
                }
            }
        }
        do_action('gform_entry_info', $form['id'], $lead);
        ?>
					</div>
					<div id="major-publishing-actions">
						<div id="delete-action">
							<?php 
        switch ($lead['status']) {
            case 'spam':
                if (GFCommon::spam_enabled($form['id'])) {
                    ?>
										<a onclick="jQuery('#action').val('unspam'); jQuery('#entry_form').submit()" href="#"><?php 
                    esc_html_e('Not Spam', 'gravityforms');
                    ?>
</a>
										<?php 
                    echo GFCommon::current_user_can_any('gravityforms_delete_entries') ? '|' : '';
                }
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
										<a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    echo esc_js(__("You are about to delete this entry. 'Cancel' to stop, 'OK' to delete.", 'gravityforms'));
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    esc_html_e('Delete Permanently', 'gravityforms');
                    ?>
</a>
									<?php 
                }
                break;
            case 'trash':
                ?>
									<a onclick="jQuery('#action').val('restore'); jQuery('#entry_form').submit()" href="#"><?php 
                esc_html_e('Restore', 'gravityforms');
                ?>
</a>
									<?php 
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
										|
										<a class="submitdelete deletion" onclick="if ( confirm('<?php 
                    echo esc_js(__("You are about to delete this entry. 'Cancel' to stop, 'OK' to delete.", 'gravityforms'));
                    ?>
') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php 
                    esc_html_e('Delete Permanently', 'gravityforms');
                    ?>
</a>
									<?php 
                }
                break;
            default:
                if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
                    ?>
										<a class="submitdelete deletion" onclick="jQuery('#action').val('trash'); jQuery('#entry_form').submit()" href="#"><?php 
                    esc_html_e('Move to Trash', 'gravityforms');
                    ?>
</a>
										<?php 
                    echo GFCommon::spam_enabled($form['id']) ? '|' : '';
                }
                if (GFCommon::spam_enabled($form['id'])) {
                    ?>
										<a class="submitdelete deletion" onclick="jQuery('#action').val('spam'); jQuery('#entry_form').submit()" href="#"><?php 
                    esc_html_e('Mark as Spam', 'gravityforms');
                    ?>
</a>
									<?php 
                }
        }
        ?>
						</div>
						<div id="publishing-action">
							<?php 
        if (GFCommon::current_user_can_any('gravityforms_edit_entries') && $lead['status'] != 'trash') {
            $button_text = $mode == 'view' ? __('Edit', 'gravityforms') : __('Update', 'gravityforms');
            $disabled = $mode == 'view' ? '' : ' disabled="disabled" ';
            $update_button_id = $mode == 'view' ? 'gform_edit_button' : 'gform_update_button';
            $button_click = $mode == 'view' ? "jQuery('#screen_mode').val('edit');" : "jQuery('#action').val('update'); jQuery('#screen_mode').val('view');";
            $update_button = '<input id="' . $update_button_id . '" ' . $disabled . ' class="button button-large button-primary" type="submit" tabindex="4" value="' . esc_attr($button_text) . '" name="save" onclick="' . $button_click . '"/>';
            echo apply_filters('gform_entrydetail_update_button', $update_button);
            if ($mode == 'edit') {
                echo '&nbsp;&nbsp;<input class="button button-large" type="submit" tabindex="5" value="' . esc_attr__('Cancel', 'gravityforms') . '" name="cancel" onclick="jQuery(\'#screen_mode\').val(\'view\');"/>';
            }
        }
        ?>
						</div>
						<div class="clear"></div>
					</div>
				</div>
			</div>
		</div>

		<?php 
        if (!empty($lead['payment_status']) && !apply_filters('gform_enable_entry_info_payment_details', true, $lead)) {
            self::payment_details_box($lead, $form);
        }
        ?>

		<?php 
        do_action('gform_entry_detail_sidebar_middle', $form, $lead);
        ?>

		<?php 
        if (GFCommon::current_user_can_any('gravityforms_edit_entry_notes')) {
            ?>
			<!-- start notifications -->
			<div class="postbox" id="notifications_container">
				<h3 class="hndle" style="cursor:default;">
					<span><?php 
            esc_html_e('Notifications', 'gravityforms');
            ?>
</span>
				</h3>

				<div class="inside">
					<div class="message" style="display:none;padding:10px;"></div>
					<div>
						<?php 
            $notifications = GFCommon::get_notifications('resend_notifications', $form);
            if (!is_array($notifications) || count($form['notifications']) <= 0) {
                ?>
							<p class="description"><?php 
                esc_html_e('You cannot resend notifications for this entry because this form does not currently have any notifications configured.', 'gravityforms');
                ?>
</p>

							<a href="<?php 
                echo admin_url("admin.php?page=gf_edit_forms&view=settings&subview=notification&id={$form_id}");
                ?>
" class="button"><?php 
                esc_html_e('Configure Notifications', 'gravityforms');
                ?>
</a>
						<?php 
            } else {
                foreach ($notifications as $notification) {
                    ?>
								<input type="checkbox" class="gform_notifications" value="<?php 
                    echo esc_attr($notification['id']);
                    ?>
" id="notification_<?php 
                    echo esc_attr($notification['id']);
                    ?>
" onclick="toggleNotificationOverride();" />
								<label for="notification_<?php 
                    echo esc_attr($notification['id']);
                    ?>
"><?php 
                    echo esc_html($notification['name']);
                    ?>
</label>
								<br /><br />
							<?php 
                }
                ?>

							<div id="notifications_override_settings" style="display:none;">

								<p class="description" style="padding-top:0; margin-top:0; width:99%;">You may override the default notification settings
									by entering a comma delimited list of emails to which the selected notifications should be sent.</p>
								<label for="notification_override_email"><?php 
                esc_html_e('Send To', 'gravityforms');
                ?>
 <?php 
                gform_tooltip('notification_override_email');
                ?>
</label><br />
								<input type="text" name="notification_override_email" id="notification_override_email" style="width:99%;" />
								<br /><br />

							</div>

							<input type="button" name="notification_resend" value="<?php 
                esc_attr_e('Resend Notifications', 'gravityforms');
                ?>
" class="button" style="" onclick="ResendNotifications();" />
							<span id="please_wait_container" style="display:none; margin-left: 5px;">
								<i class='gficon-gravityforms-spinner-icon gficon-spin'></i> <?php 
                esc_html_e('Resending...', 'gravityforms');
                ?>
                            </span>
						<?php 
            }
            ?>

					</div>
				</div>
			</div>
			<!-- / end notifications -->
		<?php 
        }
        ?>

		<!-- begin print button -->
		<div class="detail-view-print">
			<a href="javascript:;" onclick="var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '&notes=1' : ''; var url='<?php 
        echo trailingslashit(site_url());
        ?>
?gf_page=print-entry&fid=<?php 
        echo absint($form['id']);
        ?>
&lid=<?php 
        echo absint($lead['id']);
        ?>
' + notes_qs; window.open (url,'printwindow');" class="button"><?php 
        esc_html_e('Print', 'gravityforms');
        ?>
</a>
			<?php 
        if (GFCommon::current_user_can_any('gravityforms_view_entry_notes')) {
            ?>
				<input type="checkbox" name="print_notes" value="print_notes" checked="checked" id="gform_print_notes" />
				<label for="print_notes"><?php 
            esc_html_e('include notes', 'gravityforms');
            ?>
</label>
			<?php 
        }
        ?>
		</div>
		<!-- end print button -->
		<?php 
        do_action('gform_entry_detail_sidebar_after', $form, $lead);
        ?>
		</div>

		<div id="post-body" class="has-sidebar">
			<div id="post-body-content" class="has-sidebar-content">
				<?php 
        do_action('gform_entry_detail_content_before', $form, $lead);
        if ($mode == 'view') {
            self::lead_detail_grid($form, $lead, true);
        } else {
            self::lead_detail_edit($form, $lead);
        }
        do_action('gform_entry_detail', $form, $lead);
        if (GFCommon::current_user_can_any('gravityforms_view_entry_notes')) {
            ?>
					<div class="postbox">
						<h3>
							<label for="name"><?php 
            esc_html_e('Notes', 'gravityforms');
            ?>
</label>
						</h3>

						<form method="post">
							<?php 
            wp_nonce_field('gforms_update_note', 'gforms_update_note');
            ?>
							<div class="inside">
								<?php 
            $notes = RGFormsModel::get_lead_notes($lead['id']);
            //getting email values
            $email_fields = GFCommon::get_email_fields($form);
            $emails = array();
            foreach ($email_fields as $email_field) {
                if (!empty($lead[$email_field->id])) {
                    $emails[] = $lead[$email_field->id];
                }
            }
            //displaying notes grid
            $subject = '';
            self::notes_grid($notes, true, $emails, $subject);
            ?>
							</div>
						</form>
					</div>
				<?php 
        }
        do_action('gform_entry_detail_content_after', $form, $lead);
        ?>
			</div>
		</div>
		</div>
		</div>
		</form>
		<?php 
        if (rgpost('action') == 'update') {
            ?>
			<div class="updated fade" style="padding:6px;">
				<?php 
            esc_html_e('Entry Updated.', 'gravityforms');
            ?>
			</div>
		<?php 
        }
    }
 public function delete_signature($lead_id, $field_id)
 {
     global $wpdb;
     $lead = RGFormsModel::get_lead($lead_id);
     $this->delete_signature_file(rgar($lead, $field_id));
     $lead_detail_table = RGFormsModel::get_lead_details_table_name();
     $sql = $wpdb->prepare("UPDATE {$lead_detail_table} SET value = '' WHERE lead_id=%d AND field_number BETWEEN %s AND %s", $lead_id, doubleval($field_id) - 0.001, doubleval($field_id) + 0.001);
     return $wpdb->query($sql);
 }
} else {
    echo 'N/A';
}
?>
</div>
<div></div>
<hr></hr>
<div></div>


<?php 
// loop through all the returned results
$e_id = 0;
foreach ($all_entries as $entry) {
    $time_form = RGFormsModel::get_form_meta($the_form);
    $time_lead = RGFormsModel::get_lead($entry['id']);
    $time_form_data = GFPDFEntryDetail::lead_detail_grid_array($time_form, $time_lead);
    $time_lead_id = $_GET['lid'];
    $array = $time_form_data['list']['1'];
    //list field ID
    foreach ($array as $element) {
        if ($time_lead_id == $element['project']) {
            $task = $element['task'];
            if ($task == $_GET['task']) {
                $employees[$entry[2]]['name'] = $entry[2];
                $employees[$entry[2]]['date'][$element['date']] = $element['hours'];
                $employees[$entry[2]]['total_hours'] += $element['hours'];
                $e_id++;
            }
        }
    }
Beispiel #29
0
 public static function resend_notifications()
 {
     check_admin_referer('gf_resend_notifications', 'gf_resend_notifications');
     $form_id = absint(rgpost('formId'));
     $leads = rgpost('leadIds');
     // may be a single ID or an array of IDs
     if (0 == $leads) {
         // get all the lead ids for the current filter / search
         $filter = rgpost('filter');
         $search = rgpost('search');
         $star = $filter == 'star' ? 1 : null;
         $read = $filter == 'unread' ? 0 : null;
         $status = in_array($filter, array('trash', 'spam')) ? $filter : 'active';
         $search_criteria['status'] = $status;
         if ($star) {
             $search_criteria['field_filters'][] = array('key' => 'is_starred', 'value' => (bool) $star);
         }
         if (!is_null($read)) {
             $search_criteria['field_filters'][] = array('key' => 'is_read', 'value' => (bool) $read);
         }
         $search_field_id = rgpost('fieldId');
         if (isset($_POST['fieldId']) && $_POST['fieldId'] !== '') {
             $key = $search_field_id;
             $val = $search;
             $strpos_row_key = strpos($search_field_id, '|');
             if ($strpos_row_key !== false) {
                 //multi-row
                 $key_array = explode('|', $search_field_id);
                 $key = $key_array[0];
                 $val = $key_array[1] . ':' . $val;
             }
             $search_criteria['field_filters'][] = array('key' => $key, 'operator' => rgempty('operator', $_POST) ? 'is' : rgpost('operator'), 'value' => $val);
         }
         $leads = GFFormsModel::search_lead_ids($form_id, $search_criteria);
     } else {
         $leads = !is_array($leads) ? array($leads) : $leads;
     }
     $form = gf_apply_filters('gform_before_resend_notifications', $form_id, RGFormsModel::get_form_meta($form_id), $leads);
     if (empty($leads) || empty($form)) {
         _e('There was an error while resending the notifications.', 'gravityforms');
         die;
     }
     $notifications = json_decode(rgpost('notifications'));
     if (!is_array($notifications)) {
         die(esc_html__('No notifications have been selected. Please select a notification to be sent.', 'gravityforms'));
     }
     if (!rgempty('sendTo', $_POST) && !GFCommon::is_valid_email_list(rgpost('sendTo'))) {
         die(sprintf(esc_html__('The %sSend To%s email address provided is not valid.', 'gravityforms'), '<strong>', '</strong>'));
     }
     foreach ($leads as $lead_id) {
         $lead = RGFormsModel::get_lead($lead_id);
         foreach ($notifications as $notification_id) {
             $notification = $form['notifications'][$notification_id];
             if (!$notification) {
                 continue;
             }
             //overriding To email if one was specified
             if (rgpost('sendTo')) {
                 $notification['to'] = rgpost('sendTo');
                 $notification['toType'] = 'email';
             }
             GFCommon::send_notification($notification, $form, $lead);
         }
     }
     die;
 }
Beispiel #30
0
 public static function get_field_input($field, $value = "", $lead_id = 0, $form_id = 0)
 {
     $id = $field["id"];
     $field_id = IS_ADMIN || $form_id == 0 ? "input_{$id}" : "input_" . $form_id . "_{$id}";
     $form_id = IS_ADMIN && empty($form_id) ? rgget("id") : $form_id;
     $size = rgar($field, "size");
     $disabled_text = IS_ADMIN && RG_CURRENT_VIEW != "entry" ? "disabled='disabled'" : "";
     $class_suffix = RG_CURRENT_VIEW == "entry" ? "_admin" : "";
     $class = $size . $class_suffix;
     $currency = "";
     if (RG_CURRENT_VIEW == "entry") {
         $lead = RGFormsModel::get_lead($lead_id);
         $post_id = $lead["post_id"];
         $post_link = "";
         if (is_numeric($post_id) && self::is_post_field($field)) {
             $post_link = "You can <a href='post.php?action=edit&post={$post_id}'>edit this post</a> from the post page.";
         }
         $currency = $lead["currency"];
     }
     $field_input = apply_filters("gform_field_input", "", $field, $value, $lead_id, $form_id);
     if ($field_input) {
         return $field_input;
     }
     //product fields are not editable
     if (RG_CURRENT_VIEW == "entry" && self::is_product_field($field["type"])) {
         return "<div class='ginput_container'>" . __("Product fields are not editable", "gravityforms") . "</div>";
     } else {
         if (RG_CURRENT_VIEW == "entry" && $field["type"] == "donation") {
             return "<div class='ginput_container'>" . __("Donations are not editable", "gravityforms") . "</div>";
         }
     }
     // add categories as choices for Post Category field
     if ($field['type'] == 'post_category') {
         $field = self::add_categories_as_choices($field, $value);
     }
     $max_length = "";
     $html5_attributes = "";
     switch (RGFormsModel::get_input_type($field)) {
         case "total":
             if (RG_CURRENT_VIEW == "entry") {
                 return "<div class='ginput_container'><input type='text' name='input_{$id}' value='{$value}' /></div>";
             } else {
                 return "<div class='ginput_container'><span class='ginput_total ginput_total_{$form_id}'>" . self::to_money("0") . "</span><input type='hidden' name='input_{$id}' id='{$field_id}' class='gform_hidden'/></div>";
             }
             break;
         case "calculation":
         case "singleproduct":
             $product_name = !is_array($value) || empty($value[$field["id"] . ".1"]) ? esc_attr($field["label"]) : esc_attr($value[$field["id"] . ".1"]);
             $price = !is_array($value) || empty($value[$field["id"] . ".2"]) ? rgget("basePrice", $field) : esc_attr($value[$field["id"] . ".2"]);
             $quantity = is_array($value) ? esc_attr($value[$field["id"] . ".3"]) : "";
             if (empty($price)) {
                 $price = 0;
             }
             $form = RGFormsModel::get_form_meta($form_id);
             $has_quantity = sizeof(GFCommon::get_product_fields_by_type($form, array("quantity"), $field["id"])) > 0;
             if ($has_quantity) {
                 $field["disableQuantity"] = true;
             }
             $quantity_field = "";
             if (IS_ADMIN) {
                 $style = rgget("disableQuantity", $field) ? "style='display:none;'" : "";
                 $quantity_field = " <span class='ginput_quantity_label' {$style}>" . apply_filters("gform_product_quantity_{$form_id}", apply_filters("gform_product_quantity", __("Quantity:", "gravityforms"), $form_id), $form_id) . "</span> <input type='text' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' />";
             } else {
                 if (!rgget("disableQuantity", $field)) {
                     $tabindex = self::get_tabindex();
                     $quantity_field .= " <span class='ginput_quantity_label'>" . apply_filters("gform_product_quantity_{$form_id}", apply_filters("gform_product_quantity", __("Quantity:", "gravityforms"), $form_id), $form_id) . "</span> <input type='text' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$field["id"]}' class='ginput_quantity' size='10' {$tabindex}/>";
                 } else {
                     if (!is_numeric($quantity)) {
                         $quantity = 1;
                     }
                     if (!$has_quantity) {
                         $quantity_field .= "<input type='hidden' name='input_{$id}.3' value='{$quantity}' class='ginput_quantity_{$form_id}_{$field["id"]} gform_hidden' />";
                     }
                 }
             }
             return "<div class='ginput_container'><input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' /><span class='ginput_product_price_label'>" . apply_filters("gform_product_price_{$form_id}", apply_filters("gform_product_price", __("Price", "gravityforms"), $form_id), $form_id) . ":</span> <span class='ginput_product_price' id='{$field_id}'>" . esc_html(GFCommon::to_money($price, $currency)) . "</span><input type='hidden' name='input_{$id}.2' id='ginput_base_price_{$form_id}_{$field["id"]}' class='gform_hidden' value='" . esc_attr($price) . "'/>{$quantity_field}</div>";
             break;
         case "hiddenproduct":
             $form = RGFormsModel::get_form_meta($form_id);
             $has_quantity_field = sizeof(GFCommon::get_product_fields_by_type($form, array("quantity"), $field["id"])) > 0;
             $product_name = !is_array($value) || empty($value[$field["id"] . ".1"]) ? esc_attr($field["label"]) : esc_attr($value[$field["id"] . ".1"]);
             $quantity = is_array($value) ? esc_attr($value[$field["id"] . ".3"]) : "1";
             $price = !is_array($value) || empty($value[$field["id"] . ".2"]) ? rgget("basePrice", $field) : esc_attr($value[$field["id"] . ".2"]);
             if (empty($price)) {
                 $price = 0;
             }
             $quantity_field = $has_quantity_field ? "" : "<input type='hidden' name='input_{$id}.3' value='" . esc_attr($quantity) . "' id='ginput_quantity_{$form_id}_{$field["id"]}' class='gform_hidden' />";
             $product_name_field = "<input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' />";
             $field_type = IS_ADMIN ? "text" : "hidden";
             return $quantity_field . $product_name_field . sprintf("<input name='input_%d.2' id='ginput_base_price_{$form_id}_{$field["id"]}' type='{$field_type}' value='%s' class='gform_hidden ginput_amount' %s/>", $id, esc_attr($price), $disabled_text);
             break;
         case "singleshipping":
             $price = !empty($value) ? $value : rgget("basePrice", $field);
             if (empty($price)) {
                 $price = 0;
             }
             return "<div class='ginput_container'><input type='hidden' name='input_{$id}' value='{$price}' class='gform_hidden'/><span class='ginput_shipping_price' id='{$field_id}'>" . GFCommon::to_money($price, $currency) . "</span></div>";
             break;
         case "website":
             $is_html5 = RGFormsModel::is_html5_enabled();
             $value = empty($value) && !$is_html5 ? "http://" : $value;
             $html_input_type = $is_html5 ? "url" : "text";
             $html5_attributes = $is_html5 ? "placeholder='http://'" : "";
         case "text":
             if (empty($html_input_type)) {
                 $html_input_type = "text";
             }
             if (rgget("enablePasswordInput", $field) && RG_CURRENT_VIEW != "entry") {
                 $html_input_type = "password";
             }
             if (is_numeric(rgget("maxLength", $field))) {
                 $max_length = "maxlength='{$field["maxLength"]}'";
             }
             if (!empty($post_link)) {
                 return $post_link;
             }
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='%s' value='%s' class='%s' {$max_length} {$tabindex} {$logic_event} {$html5_attributes} %s/></div>", $id, $field_id, $html_input_type, esc_attr($value), esc_attr($class), $disabled_text);
             break;
         case "email":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $html_input_type = RGFormsModel::is_html5_enabled() ? "email" : "text";
             if (IS_ADMIN && RG_CURRENT_VIEW != "entry") {
                 $single_style = rgget("emailConfirmEnabled", $field) ? "style='display:none;'" : "";
                 $confirm_style = rgget("emailConfirmEnabled", $field) ? "" : "style='display:none;'";
                 return "<div class='ginput_container ginput_single_email' {$single_style}><input name='input_{$id}' type='{$html_input_type}' class='" . esc_attr($class) . "' disabled='disabled' /></div><div class='ginput_complex ginput_container ginput_confirm_email' {$confirm_style} id='{$field_id}_container'><span id='{$field_id}_1_container' class='ginput_left'><input type='text' name='input_{$id}' id='{$field_id}' disabled='disabled' /><label for='{$field_id}'>" . apply_filters("gform_email_{$form_id}", apply_filters("gform_email", __("Enter Email", "gravityforms"), $form_id), $form_id) . "</label></span><span id='{$field_id}_2_container' class='ginput_right'><input type='text' name='input_{$id}_2' id='{$field_id}_2' disabled='disabled' /><label for='{$field_id}_2'>" . apply_filters("gform_email_confirm_{$form_id}", apply_filters("gform_email_confirm", __("Confirm Email", "gravityforms"), $form_id), $form_id) . "</label></span></div>";
             } else {
                 $logic_event = self::get_logic_event($field, "keyup");
                 if (rgget("emailConfirmEnabled", $field) && RG_CURRENT_VIEW != "entry") {
                     $first_tabindex = self::get_tabindex();
                     $last_tabindex = self::get_tabindex();
                     return "<div class='ginput_complex ginput_container' id='{$field_id}_container'><span id='{$field_id}_1_container' class='ginput_left'><input type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='" . esc_attr($value) . "' {$first_tabindex} {$logic_event} {$disabled_text}/><label for='{$field_id}'>" . apply_filters("gform_email_{$form_id}", apply_filters("gform_email", __("Enter Email", "gravityforms"), $form_id), $form_id) . "</label></span><span id='{$field_id}_2_container' class='ginput_right'><input type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='" . esc_attr(rgpost("input_" . $id . "_2")) . "' {$last_tabindex} {$disabled_text}/><label for='{$field_id}_2'>" . apply_filters("gform_email_confirm_{$form_id}", apply_filters("gform_email_confirm", __("Confirm Email", "gravityforms"), $form_id), $form_id) . "</label></span></div>";
                 } else {
                     $tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='%s' value='%s' class='%s' {$max_length} {$tabindex} {$html5_attributes} {$logic_event} %s/></div>", $id, $field_id, $html_input_type, esc_attr($value), esc_attr($class), $disabled_text);
                 }
             }
             break;
         case "honeypot":
             $autocomplete = RGFormsModel::is_html5_enabled() ? "autocomplete='off'" : "";
             return "<div class='ginput_container'><input name='input_{$id}' id='{$field_id}' type='text' value='' {$autocomplete}/></div>";
             break;
         case "hidden":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $field_type = IS_ADMIN ? "text" : "hidden";
             $class_attribute = IS_ADMIN ? "" : "class='gform_hidden'";
             return sprintf("<input name='input_%d' id='%s' type='{$field_type}' {$class_attribute} value='%s' %s/>", $id, $field_id, esc_attr($value), $disabled_text);
             break;
         case "html":
             $content = IS_ADMIN ? "<img class='gfield_html_block' src='" . self::get_base_url() . "/images/gf_html_admin_placeholder.jpg' alt='HTML Block'/>" : $field["content"];
             $content = GFCommon::replace_variables_prepopulate($content);
             //adding support for merge tags
             $content = do_shortcode($content);
             //adding support for shortcodes
             return $content;
             break;
         case "adminonly_hidden":
             if (!is_array($field["inputs"])) {
                 return sprintf("<input name='input_%d' id='%s' class='gform_hidden' type='hidden' value='%s'/>", $id, $field_id, esc_attr($value));
             }
             $fields = "";
             foreach ($field["inputs"] as $input) {
                 $fields .= sprintf("<input name='input_%s' class='gform_hidden' type='hidden' value='%s'/>", $input["id"], esc_attr(rgar($value, $input["id"])));
             }
             return $fields;
             break;
         case "number":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $instruction = "";
             $read_only = "";
             if (!IS_ADMIN) {
                 if (GFCommon::has_field_calculation($field)) {
                     // calculation-enabled fields should be read only
                     $read_only = 'readonly="readonly"';
                 } else {
                     $message = self::get_range_message($field);
                     $validation_class = $field["failed_validation"] ? "validation_message" : "";
                     if (!$field["failed_validation"] && !empty($message) && empty($field["errorMessage"])) {
                         $instruction = "<div class='instruction {$validation_class}'>" . $message . "</div>";
                     }
                 }
             }
             $is_html5 = RGFormsModel::is_html5_enabled();
             $html_input_type = $is_html5 && !GFCommon::has_field_calculation($field) ? "number" : "text";
             // chrome does not allow number fields to have commas, calculations display numbers with commas
             $step_attr = $is_html5 ? "step='any'" : "";
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='{$html_input_type}' {$step_attr} value='%s' class='%s' {$tabindex} {$logic_event} {$read_only} %s/>%s</div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text, $instruction);
         case "donation":
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s ginput_donation_amount' {$tabindex} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "price":
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s ginput_amount' {$tabindex} {$logic_event} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "phone":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $instruction = $field["phoneFormat"] == "standard" ? __("Phone format:", "gravityforms") . " (###)###-####" : "";
             $instruction_div = rgget("failed_validation", $field) ? "<div class='instruction validation_message'>{$instruction}</div>" : "";
             $html_input_type = RGFormsModel::is_html5_enabled() ? "tel" : "text";
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='{$html_input_type}' value='%s' class='%s' {$tabindex} {$logic_event} %s/>{$instruction_div}</div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
         case "textarea":
             $max_chars = "";
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><textarea name='input_%d' id='%s' class='textarea %s' {$tabindex} {$logic_event} %s rows='10' cols='50'>%s</textarea></div>{$max_chars}", $id, $field_id, esc_attr($class), $disabled_text, esc_html($value));
         case "post_title":
         case "post_tags":
         case "post_custom_field":
             $tabindex = self::get_tabindex();
             $logic_event = self::get_logic_event($field, "keyup");
             return !empty($post_link) ? $post_link : sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s' {$tabindex} {$logic_event} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
             break;
         case "post_content":
         case "post_excerpt":
             $max_chars = "";
             $logic_event = self::get_logic_event($field, "keyup");
             $tabindex = self::get_tabindex();
             return !empty($post_link) ? $post_link : sprintf("<div class='ginput_container'><textarea name='input_%d' id='%s' class='textarea %s' {$tabindex} {$logic_event} %s rows='10' cols='50'>%s</textarea></div>{$max_chars}", $id, $field_id, esc_attr($class), $disabled_text, esc_html($value));
             break;
         case "post_category":
             if (!empty($post_link)) {
                 return $post_link;
             }
             if (rgget("displayAllCategories", $field) && !IS_ADMIN) {
                 $default_category = rgget("categoryInitialItemEnabled", $field) ? "-1" : get_option('default_category');
                 $selected = empty($value) ? $default_category : $value;
                 $args = array('echo' => 0, 'selected' => $selected, "class" => esc_attr($class) . " gfield_select", 'hide_empty' => 0, 'name' => "input_{$id}", 'orderby' => 'name', 'hierarchical' => true);
                 if (self::$tab_index > 0) {
                     $args["tab_index"] = self::$tab_index++;
                 }
                 if (rgget("categoryInitialItemEnabled", $field)) {
                     $args["show_option_none"] = empty($field["categoryInitialItem"]) ? " " : $field["categoryInitialItem"];
                 }
                 return "<div class='ginput_container'>" . wp_dropdown_categories($args) . "</div>";
             } else {
                 $tabindex = self::get_tabindex();
                 if (is_array(rgar($field, "choices"))) {
                     usort($field["choices"], create_function('$a,$b', 'return strcmp($a["text"], $b["text"]);'));
                 }
                 $choices = self::get_select_choices($field, $value);
                 //Adding first option
                 if (rgget("categoryInitialItemEnabled", $field)) {
                     $selected = empty($value) ? "selected='selected'" : "";
                     $choices = "<option value='-1' {$selected}>{$field["categoryInitialItem"]}</option>" . $choices;
                 }
                 return sprintf("<div class='ginput_container'><select name='input_%d' id='%s' class='%s gfield_select' {$tabindex} %s>%s</select></div>", $id, $field_id, esc_attr($class), $disabled_text, $choices);
             }
             break;
         case "post_image":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $title = esc_attr(rgget($field["id"] . ".1", $value));
             $caption = esc_attr(rgget($field["id"] . ".4", $value));
             $description = esc_attr(rgget($field["id"] . ".7", $value));
             //hidding meta fields for admin
             $hidden_style = "style='display:none;'";
             $title_style = !rgget("displayTitle", $field) && IS_ADMIN ? $hidden_style : "";
             $caption_style = !rgget("displayCaption", $field) && IS_ADMIN ? $hidden_style : "";
             $description_style = !rgget("displayDescription", $field) && IS_ADMIN ? $hidden_style : "";
             $file_label_style = IS_ADMIN && !(rgget("displayTitle", $field) || rgget("displayCaption", $field) || rgget("displayDescription", $field)) ? $hidden_style : "";
             $hidden_class = $preview = "";
             $file_info = RGFormsModel::get_temp_filename($form_id, "input_{$id}");
             if ($file_info) {
                 $hidden_class = " gform_hidden";
                 $file_label_style = $hidden_style;
                 $preview = "<span class='ginput_preview'><strong>" . esc_html($file_info["uploaded_filename"]) . "</strong> | <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$id});'>" . __("delete", "gravityforms") . "</a></span>";
             }
             //in admin, render all meta fields to allow for immediate feedback, but hide the ones not selected
             $file_label = IS_ADMIN || rgget("displayTitle", $field) || rgget("displayCaption", $field) || rgget("displayDescription", $field) ? "<label for='{$field_id}' class='ginput_post_image_file' {$file_label_style}>" . apply_filters("gform_postimage_file_{$form_id}", apply_filters("gform_postimage_file", __("File", "gravityforms"), $form_id), $form_id) . "</label>" : "";
             $tabindex = self::get_tabindex();
             $upload = sprintf("<span class='ginput_full{$class_suffix}'>{$preview}<input name='input_%d' id='%s' type='file' value='%s' class='%s' {$tabindex} %s/>{$file_label}</span>", $id, $field_id, esc_attr($value), esc_attr($class . $hidden_class), $disabled_text);
             $tabindex = self::get_tabindex();
             $title_field = rgget("displayTitle", $field) || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_title' {$title_style}><input type='text' name='input_%d.1' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1'>" . apply_filters("gform_postimage_title_{$form_id}", apply_filters("gform_postimage_title", __("Title", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $title, $disabled_text, $field_id) : "";
             $tabindex = self::get_tabindex();
             $caption_field = rgget("displayCaption", $field) || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_caption' {$caption_style}><input type='text' name='input_%d.4' id='%s_4' value='%s' {$tabindex} %s/><label for='%s_4'>" . apply_filters("gform_postimage_caption_{$form_id}", apply_filters("gform_postimage_caption", __("Caption", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $caption, $disabled_text, $field_id) : "";
             $tabindex = self::get_tabindex();
             $description_field = rgget("displayDescription", $field) || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_description' {$description_style}><input type='text' name='input_%d.7' id='%s_7' value='%s' {$tabindex} %s/><label for='%s_7'>" . apply_filters("gform_postimage_description_{$form_id}", apply_filters("gform_postimage_description", __("Description", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $description, $disabled_text, $field_id) : "";
             return "<div class='ginput_complex{$class_suffix} ginput_container'>" . $upload . $title_field . $caption_field . $description_field . "</div>";
             break;
         case "multiselect":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $placeholder = rgar($field, "enableEnhancedUI") ? "data-placeholder='" . esc_attr(apply_filters("gform_multiselect_placeholder_{$form_id}", apply_filters("gform_multiselect_placeholder", __("Click to select...", "gravityforms"), $form_id), $form_id)) . "'" : "";
             $logic_event = self::get_logic_event($field, "keyup");
             $css_class = trim(esc_attr($class) . " gfield_select");
             $size = rgar($field, "multiSelectSize");
             if (empty($size)) {
                 $size = 7;
             }
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><select multiple='multiple' {$placeholder} size='{$size}' name='input_%d[]' id='%s' {$logic_event} class='%s' {$tabindex} %s>%s</select></div>", $id, $field_id, $css_class, $disabled_text, self::get_select_choices($field, $value));
             break;
         case "select":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $logic_event = self::get_logic_event($field, "change");
             $css_class = trim(esc_attr($class) . " gfield_select");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><select name='input_%d' id='%s' {$logic_event} class='%s' {$tabindex} %s>%s</select></div>", $id, $field_id, $css_class, $disabled_text, self::get_select_choices($field, $value));
         case "checkbox":
             if (!empty($post_link)) {
                 return $post_link;
             }
             return sprintf("<div class='ginput_container'><ul class='gfield_checkbox' id='%s'>%s</ul></div>", $field_id, self::get_checkbox_choices($field, $value, $disabled_text));
         case "radio":
             if (!empty($post_link)) {
                 return $post_link;
             }
             return sprintf("<div class='ginput_container'><ul class='gfield_radio' id='%s'>%s</ul></div>", $field_id, self::get_radio_choices($field, $value, $disabled_text));
         case "password":
             $first_tabindex = self::get_tabindex();
             $last_tabindex = self::get_tabindex();
             $strength_style = !rgar($field, "passwordStrengthEnabled") ? "style='display:none;'" : "";
             $strength = rgar($field, "passwordStrengthEnabled") || IS_ADMIN ? "<div id='{$field_id}_strength_indicator' class='gfield_password_strength' {$strength_style}>" . __("Strength indicator", "gravityforms") . "</div><input type='hidden' class='gform_hidden' id='{$field_id}_strength' name='input_{$id}_strength' />" : "";
             $action = !IS_ADMIN ? "gformShowPasswordStrength(\"{$field_id}\");" : "";
             $onchange = rgar($field, "passwordStrengthEnabled") ? "onchange='{$action}'" : "";
             $onkeyup = rgar($field, "passwordStrengthEnabled") ? "onkeyup='{$action}'" : "";
             $pass = RGForms::post("input_" . $id . "_2");
             return sprintf("<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}_container'><span id='" . $field_id . "_1_container' class='ginput_left'><input type='password' name='input_%d' id='%s' {$onkeyup} {$onchange} value='%s' {$first_tabindex} %s/><label for='%s'>" . apply_filters("gform_password_{$form_id}", apply_filters("gform_password", __("Enter Password", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_2_container' class='ginput_right'><input type='password' name='input_%d_2' id='%s_2' {$onkeyup} {$onchange} value='%s' {$last_tabindex} %s/><label for='%s_2'>" . apply_filters("gform_password_confirm_{$form_id}", apply_filters("gform_password_confirm", __("Confirm Password", "gravityforms"), $form_id), $form_id) . "</label></span></div>{$strength}", $id, $field_id, esc_attr($value), $disabled_text, $field_id, $id, $field_id, esc_attr($pass), $disabled_text, $field_id);
         case "name":
             $prefix = "";
             $first = "";
             $last = "";
             $suffix = "";
             if (is_array($value)) {
                 $prefix = esc_attr(RGForms::get($field["id"] . ".2", $value));
                 $first = esc_attr(RGForms::get($field["id"] . ".3", $value));
                 $last = esc_attr(RGForms::get($field["id"] . ".6", $value));
                 $suffix = esc_attr(RGForms::get($field["id"] . ".8", $value));
             }
             switch (rgget("nameFormat", $field)) {
                 case "extended":
                     $prefix_tabindex = self::get_tabindex();
                     $first_tabindex = self::get_tabindex();
                     $last_tabindex = self::get_tabindex();
                     $suffix_tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'><span id='" . $field_id . "_2_container' class='name_prefix'><input type='text' name='input_%d.2' id='%s_2' value='%s' {$prefix_tabindex} %s/><label for='%s_2'>" . apply_filters("gform_name_prefix_{$form_id}", apply_filters("gform_name_prefix", __("Prefix", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_3_container' class='name_first'><input type='text' name='input_%d.3' id='%s_3' value='%s' {$first_tabindex} %s/><label for='%s_3'>" . apply_filters("gform_name_first_{$form_id}", apply_filters("gform_name_first", __("First", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_6_container' class='name_last'><input type='text' name='input_%d.6' id='%s_6' value='%s' {$last_tabindex} %s/><label for='%s_6'>" . apply_filters("gform_name_last_{$form_id}", apply_filters("gform_name_last", __("Last", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_8_container' class='name_suffix'><input type='text' name='input_%d.8' id='%s_8' value='%s' {$suffix_tabindex} %s/><label for='%s_8'>" . apply_filters("gform_name_suffix_{$form_id}", apply_filters("gform_name_suffix", __("Suffix", "gravityforms"), $form_id), $form_id) . "</label></span></div>", $id, $field_id, $prefix, $disabled_text, $field_id, $id, $field_id, $first, $disabled_text, $field_id, $id, $field_id, $last, $disabled_text, $field_id, $id, $field_id, $suffix, $disabled_text, $field_id);
                 case "simple":
                     $tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='%s' {$tabindex} %s/></div>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
                 default:
                     $first_tabindex = self::get_tabindex();
                     $last_tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'><span id='" . $field_id . "_3_container' class='ginput_left'><input type='text' name='input_%d.3' id='%s_3' value='%s' {$first_tabindex} %s/><label for='%s_3'>" . apply_filters("gform_name_first_{$form_id}", apply_filters("gform_name_first", __("First", "gravityforms"), $form_id), $form_id) . "</label></span><span id='" . $field_id . "_6_container' class='ginput_right'><input type='text' name='input_%d.6' id='%s_6' value='%s' {$last_tabindex} %s/><label for='%s_6'>" . apply_filters("gform_name_last_{$form_id}", apply_filters("gform_name_last", __("Last", "gravityforms"), $form_id), $form_id) . "</label></span></div>", $id, $field_id, $first, $disabled_text, $field_id, $id, $field_id, $last, $disabled_text, $field_id);
             }
         case "address":
             $street_value = "";
             $street2_value = "";
             $city_value = "";
             $state_value = "";
             $zip_value = "";
             $country_value = "";
             if (is_array($value)) {
                 $street_value = esc_attr(rgget($field["id"] . ".1", $value));
                 $street2_value = esc_attr(rgget($field["id"] . ".2", $value));
                 $city_value = esc_attr(rgget($field["id"] . ".3", $value));
                 $state_value = esc_attr(rgget($field["id"] . ".4", $value));
                 $zip_value = esc_attr(rgget($field["id"] . ".5", $value));
                 $country_value = esc_attr(rgget($field["id"] . ".6", $value));
             }
             $address_types = self::get_address_types($form_id);
             $addr_type = empty($field["addressType"]) ? "international" : $field["addressType"];
             $address_type = $address_types[$addr_type];
             $state_label = empty($address_type["state_label"]) ? __("State", "gravityforms") : $address_type["state_label"];
             $zip_label = empty($address_type["zip_label"]) ? __("Zip Code", "gravityforms") : $address_type["zip_label"];
             $hide_country = !empty($address_type["country"]) || rgget("hideCountry", $field);
             if (empty($country_value)) {
                 $country_value = rgget("defaultCountry", $field);
             }
             if (empty($state_value)) {
                 $state_value = rgget("defaultState", $field);
             }
             $country_list = self::get_country_dropdown($country_value);
             //changing css classes based on field format to ensure proper display
             $address_display_format = apply_filters("gform_address_display_format", "default");
             $city_location = $address_display_format == "zip_before_city" ? "right" : "left";
             $zip_location = $address_display_format != "zip_before_city" && rgar($field, "hideState") ? "right" : "left";
             $state_location = $address_display_format == "zip_before_city" ? "left" : "right";
             $country_location = rgar($field, "hideState") ? "left" : "right";
             //address field
             $tabindex = self::get_tabindex();
             $street_address = sprintf("<span class='ginput_full{$class_suffix}' id='" . $field_id . "_1_container'><input type='text' name='input_%d.1' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1' id='" . $field_id . "_1_label'>" . apply_filters("gform_address_street_{$form_id}", apply_filters("gform_address_street", __("Street Address", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $street_value, $disabled_text, $field_id);
             //address line 2 field
             $street_address2 = "";
             $style = IS_ADMIN && rgget("hideAddress2", $field) ? "style='display:none;'" : "";
             if (IS_ADMIN || !rgget("hideAddress2", $field)) {
                 $tabindex = self::get_tabindex();
                 $street_address2 = sprintf("<span class='ginput_full{$class_suffix}' id='" . $field_id . "_2_container' {$style}><input type='text' name='input_%d.2' id='%s_2' value='%s' {$tabindex} %s/><label for='%s_2' id='" . $field_id . "_2_label'>" . apply_filters("gform_address_street2_{$form_id}", apply_filters("gform_address_street2", __("Address Line 2", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $street2_value, $disabled_text, $field_id);
             }
             if ($address_display_format == "zip_before_city") {
                 //zip field
                 $tabindex = self::get_tabindex();
                 $zip = sprintf("<span class='ginput_{$zip_location}{$class_suffix}' id='" . $field_id . "_5_container'><input type='text' name='input_%d.5' id='%s_5' value='%s' {$tabindex} %s/><label for='%s_5' id='" . $field_id . "_5_label'>" . apply_filters("gform_address_zip_{$form_id}", apply_filters("gform_address_zip", $zip_label, $form_id), $form_id) . "</label></span>", $id, $field_id, $zip_value, $disabled_text, $field_id);
                 //city field
                 $tabindex = self::get_tabindex();
                 $city = sprintf("<span class='ginput_{$city_location}{$class_suffix}' id='" . $field_id . "_3_container'><input type='text' name='input_%d.3' id='%s_3' value='%s' {$tabindex} %s/><label for='%s_3' id='{$field_id}.3_label'>" . apply_filters("gform_address_city_{$form_id}", apply_filters("gform_address_city", __("City", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $city_value, $disabled_text, $field_id);
                 //state field
                 $style = IS_ADMIN && rgget("hideState", $field) ? "style='display:none;'" : "";
                 if (IS_ADMIN || !rgget("hideState", $field)) {
                     $state_field = self::get_state_field($field, $id, $field_id, $state_value, $disabled_text, $form_id);
                     $state = sprintf("<span class='ginput_{$state_location}{$class_suffix}' id='" . $field_id . "_4_container' {$style}>{$state_field}<label for='%s_4' id='" . $field_id . "_4_label'>" . apply_filters("gform_address_state_{$form_id}", apply_filters("gform_address_state", $state_label, $form_id), $form_id) . "</label></span>", $field_id);
                 } else {
                     $state = sprintf("<input type='hidden' class='gform_hidden' name='input_%d.4' id='%s_4' value='%s'/>", $id, $field_id, $state_value);
                 }
             } else {
                 //city field
                 $tabindex = self::get_tabindex();
                 $city = sprintf("<span class='ginput_{$city_location}{$class_suffix}' id='" . $field_id . "_3_container'><input type='text' name='input_%d.3' id='%s_3' value='%s' {$tabindex} %s/><label for='%s_3' id='{$field_id}.3_label'>" . apply_filters("gform_address_city_{$form_id}", apply_filters("gform_address_city", __("City", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $city_value, $disabled_text, $field_id);
                 //state field
                 $style = IS_ADMIN && rgget("hideState", $field) ? "style='display:none;'" : "";
                 if (IS_ADMIN || !rgget("hideState", $field)) {
                     $state_field = self::get_state_field($field, $id, $field_id, $state_value, $disabled_text, $form_id);
                     $state = sprintf("<span class='ginput_{$state_location}{$class_suffix}' id='" . $field_id . "_4_container' {$style}>{$state_field}<label for='%s_4' id='" . $field_id . "_4_label'>" . apply_filters("gform_address_state_{$form_id}", apply_filters("gform_address_state", $state_label, $form_id), $form_id) . "</label></span>", $field_id);
                 } else {
                     $state = sprintf("<input type='hidden' class='gform_hidden' name='input_%d.4' id='%s_4' value='%s'/>", $id, $field_id, $state_value);
                 }
                 //zip field
                 $tabindex = self::get_tabindex();
                 $zip = sprintf("<span class='ginput_{$zip_location}{$class_suffix}' id='" . $field_id . "_5_container'><input type='text' name='input_%d.5' id='%s_5' value='%s' {$tabindex} %s/><label for='%s_5' id='" . $field_id . "_5_label'>" . apply_filters("gform_address_zip_{$form_id}", apply_filters("gform_address_zip", $zip_label, $form_id), $form_id) . "</label></span>", $id, $field_id, $zip_value, $disabled_text, $field_id);
             }
             if (IS_ADMIN || !$hide_country) {
                 $style = $hide_country ? "style='display:none;'" : "";
                 $tabindex = self::get_tabindex();
                 $country = sprintf("<span class='ginput_{$country_location}{$class_suffix}' id='" . $field_id . "_6_container' {$style}><select name='input_%d.6' id='%s_6' {$tabindex} %s>%s</select><label for='%s_6' id='" . $field_id . "_6_label'>" . apply_filters("gform_address_country_{$form_id}", apply_filters("gform_address_country", __("Country", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $disabled_text, $country_list, $field_id);
             } else {
                 $country = sprintf("<input type='hidden' class='gform_hidden' name='input_%d.6' id='%s_6' value='%s'/>", $id, $field_id, $country_value);
             }
             $inputs = $address_display_format == "zip_before_city" ? $street_address . $street_address2 . $zip . $city . $state . $country : $street_address . $street_address2 . $city . $state . $zip . $country;
             return "<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'>" . $inputs . "</div>";
         case "date":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $format = empty($field["dateFormat"]) ? "mdy" : esc_attr($field["dateFormat"]);
             $field_position = substr($format, 0, 3);
             if (IS_ADMIN && RG_CURRENT_VIEW != "entry") {
                 $datepicker_display = in_array(rgget("dateType", $field), array("datefield", "datedropdown")) ? "none" : "inline";
                 $datefield_display = rgget("dateType", $field) == "datefield" ? "inline" : "none";
                 $dropdown_display = rgget("dateType", $field) == "datedropdown" ? "inline" : "none";
                 $icon_display = rgget("calendarIconType", $field) == "calendar" ? "inline" : "none";
                 $month_field = "<div class='gfield_date_month ginput_date' id='gfield_input_date_month' style='display:{$datefield_display}'><input name='ginput_month' type='text' disabled='disabled'/><label>" . __("MM", "gravityforms") . "</label></div>";
                 $day_field = "<div class='gfield_date_day ginput_date' id='gfield_input_date_day' style='display:{$datefield_display}'><input name='ginput_day' type='text' disabled='disabled'/><label>" . __("DD", "gravityforms") . "</label></div>";
                 $year_field = "<div class='gfield_date_year ginput_date' id='gfield_input_date_year' style='display:{$datefield_display}'><input type='text' name='ginput_year' disabled='disabled'/><label>" . __("YYYY", "gravityforms") . "</label></div>";
                 $month_dropdown = "<div class='gfield_date_dropdown_month ginput_date_dropdown' id='gfield_dropdown_date_month' style='display:{$dropdown_display}'>" . self::get_month_dropdown("", "", "", "", "disabled='disabled'") . "</div>";
                 $day_dropdown = "<div class='gfield_date_dropdown_day ginput_date_dropdown' id='gfield_dropdown_date_day' style='display:{$dropdown_display}'>" . self::get_day_dropdown("", "", "", "", "disabled='disabled'") . "</div>";
                 $year_dropdown = "<div class='gfield_date_dropdown_year ginput_date_dropdown' id='gfield_dropdown_date_year' style='display:{$dropdown_display}'>" . self::get_year_dropdown("", "", "", "", "disabled='disabled'") . "</div>";
                 $field_string = "<div class='ginput_container' id='gfield_input_datepicker' style='display:{$datepicker_display}'><input name='ginput_datepicker' type='text' /><img src='" . GFCommon::get_base_url() . "/images/calendar.png' id='gfield_input_datepicker_icon' style='display:{$icon_display}'/></div>";
                 switch ($field_position) {
                     case "dmy":
                         $field_string .= $day_field . $month_field . $year_field . $day_dropdown . $month_dropdown . $year_dropdown;
                         break;
                     case "ymd":
                         $field_string .= $year_field . $month_field . $day_field . $year_dropdown . $month_dropdown . $day_dropdown;
                         break;
                     default:
                         $field_string .= $month_field . $day_field . $year_field . $month_dropdown . $day_dropdown . $year_dropdown;
                         break;
                 }
                 return $field_string;
             } else {
                 $date_info = self::parse_date($value, $format);
                 $date_type = rgget("dateType", $field);
                 if (in_array($date_type, array("datefield", "datedropdown"))) {
                     switch ($field_position) {
                         case "dmy":
                             $tabindex = self::get_tabindex();
                             $field_str = $date_type == "datedropdown" ? "<div class='clear-multi'><div class='gfield_date_dropdown_day ginput_container' id='{$field_id}'>" . self::get_day_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "day"), $tabindex, $disabled_text) . "</div>" : sprintf("<div class='clear-multi'><div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_2' value='%s' {$tabindex} %s/><label for='%s_2'>" . __("DD", "gravityforms") . "</label></div>", $field_id, $id, $field_id, rgget("day", $date_info), $disabled_text, $field_id);
                             $tabindex = self::get_tabindex();
                             $field_str .= $date_type == "datedropdown" ? "<div class='gfield_date_dropdown_month ginput_container' id='{$field_id}'>" . self::get_month_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "month"), $tabindex, $disabled_text) . "</div>" : sprintf("<div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, rgget("month", $date_info), $disabled_text, $field_id);
                             $tabindex = self::get_tabindex();
                             $field_str .= $date_type == "datedropdown" ? "<div class='gfield_date_dropdown_year ginput_container' id='{$field_id}'>" . self::get_year_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "year"), $tabindex, $disabled_text) . "</div></div>" : sprintf("<div class='gfield_date_year ginput_container' id='%s'><input type='text' maxlength='4' name='input_%d[]' id='%s_3' value='%s' {$tabindex} %s/><label for='%s_3'>" . __("YYYY", "gravityforms") . "</label></div></div>", $field_id, $id, $field_id, rgget("year", $date_info), $disabled_text, $field_id);
                             break;
                         case "ymd":
                             $tabindex = self::get_tabindex();
                             $field_str = $date_type == "datedropdown" ? "<div class='clear-multi'><div class='gfield_date_dropdown_year ginput_container' id='{$field_id}'>" . self::get_year_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "year"), $tabindex, $disabled_text) . "</div>" : sprintf("<div class='clear-multi'><div class='gfield_date_year ginput_container' id='%s'><input type='text' maxlength='4' name='input_%d[]' id='%s_3' value='%s' {$tabindex} %s/><label for='%s_3'>" . __("YYYY", "gravityforms") . "</label></div>", $field_id, $id, $field_id, rgget("year", $date_info), $disabled_text, $field_id);
                             $field_str .= $date_type == "datedropdown" ? "<div class='gfield_date_dropdown_month ginput_container' id='{$field_id}'>" . self::get_month_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "month"), $tabindex, $disabled_text) . "</div>" : sprintf("<div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, rgar($date_info, "month"), $disabled_text, $field_id);
                             $tabindex = self::get_tabindex();
                             $field_str .= $date_type == "datedropdown" ? "<div class='gfield_date_dropdown_day ginput_container' id='{$field_id}'>" . self::get_day_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "day"), $tabindex, $disabled_text) . "</div></div>" : sprintf("<div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_2' value='%s' {$tabindex} %s/><label for='%s_2'>" . __("DD", "gravityforms") . "</label></div></div>", $field_id, $id, $field_id, rgar($date_info, "day"), $disabled_text, $field_id);
                             break;
                         default:
                             $tabindex = self::get_tabindex();
                             $field_str = $date_type == "datedropdown" ? "<div class='clear-multi'><div class='gfield_date_dropdown_month ginput_container' id='{$field_id}'>" . self::get_month_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "month"), $tabindex, $disabled_text) . "</div>" : sprintf("<div class='clear-multi'><div class='gfield_date_month ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1'>" . __("MM", "gravityforms") . "</label></div>", $field_id, $id, $field_id, rgar($date_info, "month"), $disabled_text, $field_id);
                             $tabindex = self::get_tabindex();
                             $field_str .= $date_type == "datedropdown" ? "<div class='gfield_date_dropdown_day ginput_container' id='{$field_id}'>" . self::get_day_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "day"), $tabindex, $disabled_text) . "</div>" : sprintf("<div class='gfield_date_day ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_2' value='%s' {$tabindex} %s/><label for='%s_2'>" . __("DD", "gravityforms") . "</label></div>", $field_id, $id, $field_id, rgar($date_info, "day"), $disabled_text, $field_id);
                             $tabindex = self::get_tabindex();
                             $field_str .= $date_type == "datedropdown" ? "<div class='gfield_date_dropdown_year ginput_container' id='{$field_id}'>" . self::get_year_dropdown("input_{$id}[]", "{$field_id}_1", rgar($date_info, "year"), $tabindex, $disabled_text) . "</div></div>" : sprintf("<div class='gfield_date_year ginput_container' id='%s'><input type='text' maxlength='4' name='input_%d[]' id='%s_3' value='%s' {$tabindex} %s/><label for='%s_3'>" . __("YYYY", "gravityforms") . "</label></div></div>", $field_id, $id, $field_id, rgget("year", $date_info), $disabled_text, $field_id);
                             break;
                     }
                     return $field_str;
                 } else {
                     $value = GFCommon::date_display($value, $format);
                     $icon_class = $field["calendarIconType"] == "none" ? "datepicker_no_icon" : "datepicker_with_icon";
                     $icon_url = empty($field["calendarIconUrl"]) ? GFCommon::get_base_url() . "/images/calendar.png" : $field["calendarIconUrl"];
                     $tabindex = self::get_tabindex();
                     return sprintf("<div class='ginput_container'><input name='input_%d' id='%s' type='text' value='%s' class='datepicker %s %s %s' {$tabindex} %s/> </div><input type='hidden' id='gforms_calendar_icon_{$field_id}' class='gform_hidden' value='{$icon_url}'/>", $id, $field_id, esc_attr($value), esc_attr($class), $format, $icon_class, $disabled_text);
                 }
             }
         case "time":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $hour = $minute = $am_selected = $pm_selected = "";
             if (!is_array($value) && !empty($value)) {
                 preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches);
                 $hour = esc_attr($matches[1]);
                 $minute = esc_attr($matches[2]);
                 $am_selected = rgar($matches, 3) == "am" ? "selected='selected'" : "";
                 $pm_selected = rgar($matches, 3) == "pm" ? "selected='selected'" : "";
             } else {
                 if (is_array($value)) {
                     $hour = esc_attr($value[0]);
                     $minute = esc_attr($value[1]);
                     $am_selected = rgar($value, 2) == "am" ? "selected='selected'" : "";
                     $pm_selected = rgar($value, 2) == "pm" ? "selected='selected'" : "";
                 }
             }
             $hour_tabindex = self::get_tabindex();
             $minute_tabindex = self::get_tabindex();
             $ampm_tabindex = self::get_tabindex();
             $ampm_field_style = is_admin() && rgar($field, "timeFormat") == "24" ? "style='display:none;'" : "";
             $ampm_field = is_admin() || rgar($field, "timeFormat") != "24" ? "<div class='gfield_time_ampm ginput_container' {$ampm_field_style}><select name='input_{$id}[]' id='{$field_id}_3' {$ampm_tabindex} {$disabled_text}><option value='am' {$am_selected}>" . __("AM", "gravityforms") . "</option><option value='pm' {$pm_selected}>" . __("PM", "gravityforms") . "</option></select></div>" : "";
             return sprintf("<div class='clear-multi'><div class='gfield_time_hour ginput_container' id='%s'><input type='text' maxlength='2' name='input_%d[]' id='%s_1' value='%s' {$hour_tabindex} %s/> : <label for='%s_1'>" . __("HH", "gravityforms") . "</label></div><div class='gfield_time_minute ginput_container'><input type='text' maxlength='2' name='input_%d[]' id='%s_2' value='%s' {$minute_tabindex} %s/><label for='%s_2'>" . __("MM", "gravityforms") . "</label></div>{$ampm_field}</div>", $field_id, $id, $field_id, $hour, $disabled_text, $field_id, $id, $field_id, $minute, $disabled_text, $field_id);
         case "fileupload":
             $tabindex = self::get_tabindex();
             $upload = sprintf("<input name='input_%d' id='%s' type='file' value='%s' size='20' class='%s' {$tabindex} %s/>", $id, $field_id, esc_attr($value), esc_attr($class), $disabled_text);
             if (IS_ADMIN && !empty($value)) {
                 $value = esc_attr($value);
                 $preview = sprintf("<div id='preview_%d'><a href='%s' target='_blank' alt='%s' title='%s'>%s</a><a href='%s' target='_blank' alt='" . __("Download file", "gravityforms") . "' title='" . __("Download file", "gravityforms") . "'><img src='%s' style='margin-left:10px;'/></a><a href='javascript:void(0);' alt='" . __("Delete file", "gravityforms") . "' title='" . __("Delete file", "gravityforms") . "' onclick='DeleteFile(%d,%d);' ><img src='%s' style='margin-left:10px;'/></a></div>", $id, $value, $value, $value, GFCommon::truncate_url($value), $value, GFCommon::get_base_url() . "/images/download.png", $lead_id, $id, GFCommon::get_base_url() . "/images/delete.png");
                 return $preview . "<div id='upload_{$id}' style='display:none;'>{$upload}</div>";
             } else {
                 $file_info = RGFormsModel::get_temp_filename($form_id, "input_{$id}");
                 if ($file_info && !$field["failed_validation"]) {
                     $preview = "<span class='ginput_preview'><strong>" . esc_html($file_info["uploaded_filename"]) . "</strong> | <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$id});'>" . __("delete", "gravityforms") . "</a></span>";
                     return "<div class='ginput_container'>" . str_replace(" class='", " class='gform_hidden ", $upload) . " {$preview}</div>";
                 } else {
                     return "<div class='ginput_container'>{$upload}</div>";
                 }
             }
         case "captcha":
             switch (rgget("captchaType", $field)) {
                 case "simple_captcha":
                     $size = rgempty("simpleCaptchaSize", $field) ? "medium" : $field["simpleCaptchaSize"];
                     $captcha = self::get_captcha($field);
                     $tabindex = self::get_tabindex();
                     $dimensions = IS_ADMIN ? "" : "width='" . rgar($captcha, "width") . "' height='" . rgar($captcha, "height") . "'";
                     return "<div class='gfield_captcha_container'><img class='gfield_captcha' src='" . rgar($captcha, "url") . "' alt='' {$dimensions} /><div class='gfield_captcha_input_container simple_captcha_{$size}'><input type='text' name='input_{$id}' id='{$field_id}' {$tabindex}/><input type='hidden' name='input_captcha_prefix_{$id}' value='" . rgar($captcha, "prefix") . "' /></div></div>";
                     break;
                 case "math":
                     $size = empty($field["simpleCaptchaSize"]) ? "medium" : $field["simpleCaptchaSize"];
                     $captcha_1 = self::get_math_captcha($field, 1);
                     $captcha_2 = self::get_math_captcha($field, 2);
                     $captcha_3 = self::get_math_captcha($field, 3);
                     $tabindex = self::get_tabindex();
                     $dimensions = IS_ADMIN ? "" : "width='{$captcha_1["width"]}' height='{$captcha_1["height"]}'";
                     return "<div class='gfield_captcha_container'><img class='gfield_captcha' src='{$captcha_1["url"]}' alt='' {$dimensions} /><img class='gfield_captcha' src='{$captcha_2["url"]}' alt='' {$dimensions} /><img class='gfield_captcha' src='{$captcha_3["url"]}' alt='' {$dimensions} /><div class='gfield_captcha_input_container math_{$size}'><input type='text' name='input_{$id}' id='input_{$field_id}' {$tabindex}/><input type='hidden' name='input_captcha_prefix_{$id}' value='{$captcha_1["prefix"]},{$captcha_2["prefix"]},{$captcha_3["prefix"]}' /></div></div>";
                     break;
                 default:
                     if (!function_exists("recaptcha_get_html")) {
                         require_once GFCommon::get_base_path() . '/recaptchalib.php';
                     }
                     $theme = empty($field["captchaTheme"]) ? "red" : esc_attr($field["captchaTheme"]);
                     $publickey = get_option("rg_gforms_captcha_public_key");
                     $privatekey = get_option("rg_gforms_captcha_private_key");
                     if (IS_ADMIN) {
                         if (empty($publickey) || empty($privatekey)) {
                             return "<div class='captcha_message'>" . __("To use the reCaptcha field you must first do the following:", "gravityforms") . "</div><div class='captcha_message'>1 - <a href='http://www.google.com/recaptcha/whyrecaptcha' target='_blank'>" . sprintf(__("Sign up%s for a free reCAPTCHA account", "gravityforms"), "</a>") . "</div><div class='captcha_message'>2 - " . sprintf(__("Enter your reCAPTCHA keys in the %ssettings page%s", "gravityforms"), "<a href='?page=gf_settings'>", "</a>") . "</div>";
                         } else {
                             return "<div class='ginput_container'><img class='gfield_captcha' src='" . GFCommon::get_base_url() . "/images/captcha_{$theme}.jpg' alt='reCAPTCHA' title='reCAPTCHA'/></div>";
                         }
                     } else {
                         $language = empty($field["captchaLanguage"]) ? "en" : esc_attr($field["captchaLanguage"]);
                         $options = "<script type='text/javascript'>" . apply_filters("gform_cdata_open", "") . " var RecaptchaOptions = {theme : '{$theme}'}; if(parseInt('" . self::$tab_index . "') > 0) {RecaptchaOptions.tabindex = " . self::$tab_index++ . ";}" . apply_filters("gform_recaptcha_init_script", "", $form_id, $field) . apply_filters("gform_cdata_close", "") . "</script>";
                         $is_ssl = !empty($_SERVER['HTTPS']);
                         return $options . "<div class='ginput_container' id='{$field_id}'>" . recaptcha_get_html($publickey, null, $is_ssl, $language) . "</div>";
                     }
             }
             break;
         case "creditcard":
             $card_number = "";
             $card_name = "";
             $expiration_date = "";
             $expiration_month = "";
             $expiration_year = "";
             $security_code = "";
             if (is_array($value)) {
                 $card_number = esc_attr(rgget($field["id"] . ".1", $value));
                 $card_name = esc_attr(rgget($field["id"] . ".5", $value));
                 $expiration_date = rgget($field["id"] . ".2", $value);
                 if (!is_array($expiration_date) && !empty($expiration_date)) {
                     $expiration_date = explode("/", $expiration_date);
                 }
                 if (is_array($expiration_date) && count($expiration_date) == 2) {
                     $expiration_month = $expiration_date[0];
                     $expiration_year = $expiration_date[1];
                 }
                 $security_code = esc_attr(rgget($field["id"] . ".3", $value));
             }
             $action = !IS_ADMIN ? "gformMatchCard(\"{$field_id}_1\");" : "";
             $onchange = "onchange='{$action}'";
             $onkeyup = "onkeyup='{$action}'";
             $card_icons = '';
             $cards = GFCommon::get_card_types();
             $card_style = rgar($field, 'creditCardStyle') ? rgar($field, 'creditCardStyle') : 'style1';
             foreach ($cards as $card) {
                 $style = "";
                 if (self::is_card_supported($field, $card["slug"])) {
                     $print_card = true;
                 } else {
                     if (IS_ADMIN) {
                         $print_card = true;
                         $style = "style='display:none;'";
                     } else {
                         $print_card = false;
                     }
                 }
                 if ($print_card) {
                     $card_icons .= "<div class='gform_card_icon gform_card_icon_{$card['slug']}' {$style}>{$card['name']}</div>";
                 }
             }
             $card_icons = "<div class='gform_card_icon_container gform_card_icon_{$card_style}'>{$card_icons}</div>";
             //card number fields
             $tabindex = self::get_tabindex();
             $card_field = sprintf("<span class='ginput_full{$class_suffix}' id='{$field_id}_1_container'>{$card_icons}<input type='text' name='input_%d.1' id='%s_1' value='%s' {$tabindex} %s {$onchange} {$onkeyup} /><label for='%s_1' id='{$field_id}_1_label'>" . apply_filters("gform_card_number_{$form_id}", apply_filters("gform_card_number", __("Card Number", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $card_number, $disabled_text, $field_id);
             //expiration date field
             $expiration_field = "<span class='ginput_full{$class_suffix} ginput_cardextras' id='{$field_id}_2_container'>" . "<span class='ginput_cardinfo_left{$class_suffix}' id='{$field_id}_2_container'>" . "<span class='ginput_card_expiration_container'>" . "<select name='input_{$id}.2[]' id='{$field_id}_2_month' " . self::get_tabindex() . " {$disabled_text} class='ginput_card_expiration ginput_card_expiration_month'>" . self::get_expiration_months($expiration_month) . "</select>" . "<select name='input_{$id}.2[]' id='{$field_id}_2_year' " . self::get_tabindex() . " {$disabled_text} class='ginput_card_expiration ginput_card_expiration_year'>" . self::get_expiration_years($expiration_year) . "</select>" . "<label for='{$field_id}_2_month' >" . apply_filters("gform_card_expiration_{$form_id}", apply_filters("gform_card_expiration", __("Expiration Date", "gravityforms"), $form_id), $form_id) . "</label>" . "</span>" . "</span>";
             //security code field
             $tabindex = self::get_tabindex();
             $security_field = "<span class='ginput_cardinfo_right{$class_suffix}' id='{$field_id}_2_container'>" . "<input type='text' name='input_{$id}.3' id='{$field_id}_3' {$tabindex} {$disabled_text} class='ginput_card_security_code' value='{$security_code}' />" . "<span class='ginput_card_security_code_icon'>&nbsp;</span>" . "<label for='{$field_id}_3' >" . apply_filters("gform_card_security_code_{$form_id}", apply_filters("gform_card_security_code", __("Security Code", "gravityforms"), $form_id), $form_id) . "</label>" . "</span>" . "</span>";
             $tabindex = self::get_tabindex();
             $card_name_field = sprintf("<span class='ginput_full{$class_suffix}' id='{$field_id}_5_container'><input type='text' name='input_%d.5' id='%s_5' value='%s' {$tabindex} %s /><label for='%s_5' id='{$field_id}_5_label'>" . apply_filters("gform_card_name_{$form_id}", apply_filters("gform_card_name", __("Cardholder Name", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $card_name, $disabled_text, $field_id);
             return "<div class='ginput_complex{$class_suffix} ginput_container' id='{$field_id}'>" . $card_field . $expiration_field . $security_field . $card_name_field . " </div>";
             break;
         case "list":
             if (!empty($value)) {
                 $value = maybe_unserialize($value);
             }
             if (!is_array($value)) {
                 $value = array(array());
             }
             $has_columns = is_array(rgar($field, "choices"));
             $columns = $has_columns ? rgar($field, "choices") : array(array());
             $list = "<div class='ginput_container ginput_list'>" . "<table class='gfield_list'>";
             $class_attr = "";
             if ($has_columns) {
                 $list .= "<colgroup>";
                 $colnum = 1;
                 foreach ($columns as $column) {
                     $odd_even = $colnum % 2 == 0 ? "even" : "odd";
                     $list .= "<col id='gfield_list_{$field["id"]}_col{$colnum}' class='gfield_list_col_{$odd_even}'></col>";
                     $colnum++;
                 }
                 $list .= "</colgroup>";
                 $list .= "<thead><tr>";
                 foreach ($columns as $column) {
                     $list .= "<th>" . esc_html($column["text"]) . "</th>";
                 }
                 $list .= "<th>&nbsp;</th></tr></thead>";
             } else {
                 $list .= "<colgroup><col id='gfield_list_{$field["id"]}_col1' class='gfield_list_col_odd'></col></colgroup>";
             }
             $delete_display = count($value) == 1 ? "visibility:hidden;" : "";
             $maxRow = intval(rgar($field, "maxRows"));
             $disabled_icon_class = !empty($maxRow) && count($value) >= $maxRow ? "gfield_icon_disabled" : "";
             $list .= "<tbody>";
             $rownum = 1;
             foreach ($value as $item) {
                 $odd_even = $rownum % 2 == 0 ? "even" : "odd";
                 $list .= "<tr class='gfield_list_row_{$odd_even}'>";
                 $colnum = 1;
                 foreach ($columns as $column) {
                     //getting value. taking into account columns being added/removed from form meta
                     if (is_array($item)) {
                         if ($has_columns) {
                             $val = rgar($item, $column["text"]);
                         } else {
                             $vals = array_values($item);
                             $val = rgar($vals, 0);
                         }
                     } else {
                         $val = $colnum == 1 ? $item : "";
                     }
                     $list .= "<td class='gfield_list_cell gfield_list_{$field["id"]}_cell{$colnum}'>" . self::get_list_input($field, $has_columns, $column, $val, $form_id) . "</td>";
                     $colnum++;
                 }
                 $add_icon = !rgempty("addIconUrl", $field) ? $field["addIconUrl"] : GFCommon::get_base_url() . "/images/add.png";
                 $delete_icon = !rgempty("deleteIconUrl", $field) ? $field["deleteIconUrl"] : GFCommon::get_base_url() . "/images/remove.png";
                 $on_click = IS_ADMIN && RG_CURRENT_VIEW != "entry" ? "" : "onclick='gformAddListItem(this, {$maxRow})'";
                 if (rgar($field, "maxRows") != 1) {
                     $list .= "<td class='gfield_list_icons'>";
                     $list .= "   <img src='{$add_icon}' class='add_list_item {$disabled_icon_class}' {$disabled_text} title='" . __("Add a row", "gravityforms") . "' alt='" . __("Add a row", "gravityforms") . "' {$on_click} style='cursor:pointer; margin:0 3px;' />" . "   <img src='{$delete_icon}' {$disabled_text} title='" . __("Remove this row", "gravityforms") . "' alt='" . __("Remove this row", "gravityforms") . "' class='delete_list_item' style='cursor:pointer; {$delete_display}' onclick='gformDeleteListItem(this, {$maxRow})' />";
                     $list .= "</td>";
                 }
                 $list .= "</tr>";
                 if (!empty($maxRow) && $rownum >= $maxRow) {
                     break;
                 }
                 $rownum++;
             }
             $list .= "</tbody></table></div>";
             return $list;
             break;
     }
 }