コード例 #1
0
ファイル: paypal.php プロジェクト: bryanmonzon/jenjonesdirect
 public static function admin_edit_payment_status($payment_status, $form_id, $lead)
 {
     //allow the payment status to be edited when for paypal, not set to Approved, and not a subscription
     $payment_gateway = gform_get_meta($lead["id"], "payment_gateway");
     require_once self::get_base_path() . "/data.php";
     //get the transaction type out of the feed configuration, do not allow status to be changed when subscription
     $paypal_feed_id = gform_get_meta($lead["id"], "paypal_feed_id");
     $feed_config = GFPayPalData::get_feed($paypal_feed_id);
     $transaction_type = rgars($feed_config, "meta/type");
     if ($payment_gateway != "paypal" || strtolower(rgpost("save")) != "edit" || $payment_status == "Approved" || $transaction_type == "subscription") {
         return $payment_status;
     }
     //create drop down for payment status
     $payment_string = gform_tooltip("paypal_edit_payment_status", "", true);
     $payment_string .= '<select id="payment_status" name="payment_status">';
     $payment_string .= '<option value="' . $payment_status . '" selected>' . $payment_status . '</option>';
     $payment_string .= '<option value="Approved">Approved</option>';
     $payment_string .= '</select>';
     return $payment_string;
 }
コード例 #2
0
ファイル: paypal.php プロジェクト: hscale/webento
    private static function edit_page()
    {
        ?>
        <style>
            #paypal_submit_container{clear:both;}
            .paypal_col_heading{padding-bottom:2px; border-bottom: 1px solid #ccc; font-weight:bold; width:120px;}
            .paypal_field_cell {padding: 6px 17px 0 0; margin-right:15px;}

            .paypal_validation_error{ background-color:#FFDFDF; margin-top:4px; margin-bottom:6px; padding-top:6px; padding-bottom:6px; border:1px dotted #C89797;}
            .paypal_validation_error span {color: red;}
            .left_header{float:left; width:200px;}
            .margin_vertical_10{margin: 10px 0; padding-left:5px;}
            .margin_vertical_30{margin: 30px 0; padding-left:5px;}
            .width-1{width:300px;}
            .gf_paypal_invalid_form{margin-top:30px; background-color:#FFEBE8;border:1px solid #CC0000; padding:10px; width:600px;}
        </style>
        <script type="text/javascript">
            var form = Array();
        </script>
        <div class="wrap">
            <img alt="<?php 
        _e("PayPal", "gravityformspaypal");
        ?>
" style="margin: 15px 7px 0pt 0pt; float: left;" src="<?php 
        echo self::get_base_url();
        ?>
/images/paypal_wordpress_icon_32.png"/>
            <h2><?php 
        _e("PayPal Transaction Settings", "gravityformspaypal");
        ?>
</h2>

        <?php 
        //getting setting id (0 when creating a new one)
        $id = !empty($_POST["paypal_setting_id"]) ? $_POST["paypal_setting_id"] : absint($_GET["id"]);
        $config = empty($id) ? array("meta" => array(), "is_active" => true) : GFPayPalData::get_feed($id);
        $is_validation_error = false;
        //updating meta information
        if (rgpost("gf_paypal_submit")) {
            $config["form_id"] = absint(rgpost("gf_paypal_form"));
            $config["meta"]["email"] = trim(rgpost("gf_paypal_email"));
            $config["meta"]["mode"] = rgpost("gf_paypal_mode");
            $config["meta"]["type"] = rgpost("gf_paypal_type");
            $config["meta"]["style"] = rgpost("gf_paypal_page_style");
            $config["meta"]["continue_text"] = rgpost("gf_paypal_continue_text");
            $config["meta"]["cancel_url"] = rgpost("gf_paypal_cancel_url");
            $config["meta"]["disable_note"] = rgpost("gf_paypal_disable_note");
            $config["meta"]["disable_shipping"] = rgpost('gf_paypal_disable_shipping');
            $config["meta"]["delay_autoresponder"] = rgpost('gf_paypal_delay_autoresponder');
            $config["meta"]["delay_notification"] = rgpost('gf_paypal_delay_notification');
            $config["meta"]["delay_post"] = rgpost('gf_paypal_delay_post');
            $config["meta"]["update_post_action"] = rgpost('gf_paypal_update_action');
            // paypal conditional
            $config["meta"]["paypal_conditional_enabled"] = rgpost('gf_paypal_conditional_enabled');
            $config["meta"]["paypal_conditional_field_id"] = rgpost('gf_paypal_conditional_field_id');
            $config["meta"]["paypal_conditional_operator"] = rgpost('gf_paypal_conditional_operator');
            $config["meta"]["paypal_conditional_value"] = rgpost('gf_paypal_conditional_value');
            //recurring fields
            $config["meta"]["recurring_amount_field"] = rgpost("gf_paypal_recurring_amount");
            $config["meta"]["billing_cycle_number"] = rgpost("gf_paypal_billing_cycle_number");
            $config["meta"]["billing_cycle_type"] = rgpost("gf_paypal_billing_cycle_type");
            $config["meta"]["recurring_times"] = rgpost("gf_paypal_recurring_times");
            $config["meta"]["trial_period_enabled"] = rgpost('gf_paypal_trial_period');
            $config["meta"]["trial_amount"] = rgpost('gf_paypal_trial_amount');
            $config["meta"]["trial_period_number"] = rgpost('gf_paypal_trial_period_number');
            $config["meta"]["trial_period_type"] = rgpost('gf_paypal_trial_period_type');
            $config["meta"]["recurring_retry"] = rgpost('gf_paypal_recurring_retry');
            //-----------------
            $customer_fields = self::get_customer_fields();
            $config["meta"]["customer_fields"] = array();
            foreach ($customer_fields as $field) {
                $config["meta"]["customer_fields"][$field["name"]] = $_POST["paypal_customer_field_{$field["name"]}"];
            }
            $config = apply_filters('gform_paypal_save_config', $config);
            $is_validation_error = apply_filters("gform_paypal_config_validation", false, $config);
            if (GFCommon::is_valid_email($config["meta"]["email"]) && !$is_validation_error) {
                $id = GFPayPalData::update_feed($id, $config["form_id"], $config["is_active"], $config["meta"]);
                ?>
                <div class="updated fade" style="padding:6px"><?php 
                echo sprintf(__("Feed Updated. %sback to list%s", "gravityformspaypal"), "<a href='?page=gf_paypal'>", "</a>");
                ?>
</div>
                <?php 
            } else {
                $is_validation_error = true;
            }
        }
        $form = isset($config["form_id"]) && $config["form_id"] ? $form = RGFormsModel::get_form_meta($config["form_id"]) : array();
        ?>
        <form method="post" action="">
            <input type="hidden" name="paypal_setting_id" value="<?php 
        echo $id;
        ?>
" />

            <div class="margin_vertical_10 <?php 
        echo $is_validation_error ? "paypal_validation_error" : "";
        ?>
">
                <?php 
        if ($is_validation_error) {
            ?>
                    <span><?php 
            _e('There was an issue saving your feed. Please address the errors below and try again.');
            ?>
</span>
                    <?php 
        }
        ?>
            </div> <!-- / validation message -->

            <div class="margin_vertical_10<?php 
        echo $is_validation_error && !GFCommon::is_valid_email($config["meta"]["email"]) ? " paypal_validation_error" : "";
        ?>
">
                <label class="left_header" for="gf_paypal_email"><?php 
        _e("PayPal Email Address", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_email_address");
        ?>
</label>
                <input type="text" name="gf_paypal_email" id="gf_paypal_email" value="<?php 
        echo rgar($config['meta'], 'email');
        ?>
" class="width-1"/>
                <?php 
        if ($is_validation_error && !GFCommon::is_valid_email($config["meta"]["email"])) {
            ?>
                    <span>Please enter a valid email address.</span>
                    <?php 
        }
        ?>
            </div>
            <div class="margin_vertical_10">
                <label class="left_header"><?php 
        _e("Mode", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_mode");
        ?>
</label>

                <input type="radio" name="gf_paypal_mode" id="gf_paypal_mode_production" value="production" <?php 
        echo rgar($config['meta'], 'mode') != "test" ? "checked='checked'" : "";
        ?>
/>
                <label class="inline" for="gf_paypal_mode_production"><?php 
        _e("Production", "gravityformspaypal");
        ?>
</label>
                &nbsp;&nbsp;&nbsp;
                <input type="radio" name="gf_paypal_mode" id="gf_paypal_mode_test" value="test" <?php 
        echo rgar($config['meta'], 'mode') == "test" ? "checked='checked'" : "";
        ?>
/>
                <label class="inline" for="gf_paypal_mode_test"><?php 
        _e("Test", "gravityformspaypal");
        ?>
</label>
            </div>
            <div class="margin_vertical_10">
                <label class="left_header" for="gf_paypal_type"><?php 
        _e("Transaction Type", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_transaction_type");
        ?>
</label>

                <select id="gf_paypal_type" name="gf_paypal_type" onchange="SelectType(jQuery(this).val());">
                    <option value=""><?php 
        _e("Select a transaction type", "gravityformspaypal");
        ?>
</option>
                    <option value="product" <?php 
        echo rgar($config['meta'], 'type') == "product" ? "selected='selected'" : "";
        ?>
><?php 
        _e("Products and Services", "gravityformspaypal");
        ?>
</option>
                    <option value="donation" <?php 
        echo rgar($config['meta'], 'type') == "donation" ? "selected='selected'" : "";
        ?>
><?php 
        _e("Donations", "gravityformspaypal");
        ?>
</option>
                    <option value="subscription" <?php 
        echo rgar($config['meta'], 'type') == "subscription" ? "selected='selected'" : "";
        ?>
><?php 
        _e("Subscriptions", "gravityformspaypal");
        ?>
</option>
                </select>
            </div>
            <div id="paypal_form_container" valign="top" class="margin_vertical_10" <?php 
        echo empty($config["meta"]["type"]) ? "style='display:none;'" : "";
        ?>
>
                <label for="gf_paypal_form" class="left_header"><?php 
        _e("Gravity Form", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_gravity_form");
        ?>
</label>

                <select id="gf_paypal_form" name="gf_paypal_form" onchange="SelectForm(jQuery('#gf_paypal_type').val(), jQuery(this).val(), '<?php 
        echo rgar($config, 'id');
        ?>
');">
                    <option value=""><?php 
        _e("Select a form", "gravityformspaypal");
        ?>
 </option>
                    <?php 
        $active_form = rgar($config, 'form_id');
        $available_forms = GFPayPalData::get_available_forms($active_form);
        foreach ($available_forms as $current_form) {
            $selected = absint($current_form->id) == rgar($config, 'form_id') ? 'selected="selected"' : '';
            ?>

                            <option value="<?php 
            echo absint($current_form->id);
            ?>
" <?php 
            echo $selected;
            ?>
><?php 
            echo esc_html($current_form->title);
            ?>
</option>

                        <?php 
        }
        ?>
                </select>
                &nbsp;&nbsp;
                <img src="<?php 
        echo GFPayPal::get_base_url();
        ?>
/images/loading.gif" id="paypal_wait" style="display: none;"/>

                <div id="gf_paypal_invalid_product_form" class="gf_paypal_invalid_form"  style="display:none;">
                    <?php 
        _e("The form selected does not have any Product fields. Please add a Product field to the form and try again.", "gravityformspaypal");
        ?>
                </div>
                <div id="gf_paypal_invalid_donation_form" class="gf_paypal_invalid_form" style="display:none;">
                    <?php 
        _e("The form selected does not have any Donation fields. Please add a Donation field to the form and try again.", "gravityformspaypal");
        ?>
                </div>
            </div>
            <div id="paypal_field_group" valign="top" <?php 
        echo empty($config["meta"]["type"]) || empty($config["form_id"]) ? "style='display:none;'" : "";
        ?>
>

                <div id="paypal_field_container_subscription" class="paypal_field_container" valign="top" <?php 
        echo rgars($config, "meta/type") != "subscription" ? "style='display:none;'" : "";
        ?>
>
                    <div class="margin_vertical_10">
                        <label class="left_header" for="gf_paypal_recurring_amount"><?php 
        _e("Recurring Amount", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_recurring_amount");
        ?>
</label>
                        <select id="gf_paypal_recurring_amount" name="gf_paypal_recurring_amount">
                            <?php 
        echo self::get_product_options($form, $config["meta"]["recurring_amount_field"]);
        ?>
                        </select>
                    </div>

                    <div class="margin_vertical_10">
                        <label class="left_header" for="gf_paypal_billing_cycle_number"><?php 
        _e("Billing Cycle", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_billing_cycle");
        ?>
</label>
                        <select id="gf_paypal_billing_cycle_number" name="gf_paypal_billing_cycle_number">
                            <?php 
        for ($i = 1; $i <= 100; $i++) {
            ?>
                                <option value="<?php 
            echo $i;
            ?>
" <?php 
            echo $config["meta"]["billing_cycle_number"] == $i ? "selected='selected'" : "";
            ?>
><?php 
            echo $i;
            ?>
</option>
                            <?php 
        }
        ?>
                        </select>&nbsp;
                        <select id="gf_paypal_billing_cycle_type" name="gf_paypal_billing_cycle_type" onchange="SetPeriodNumber('#gf_paypal_billing_cycle_number', jQuery(this).val());">
                            <option value="D" <?php 
        echo rgars($config, "meta/billing_cycle_type") == "D" ? "selected='selected'" : "";
        ?>
><?php 
        _e("day(s)", "gravityformspaypal");
        ?>
</option>
                            <option value="W" <?php 
        echo rgars($config, "meta/billing_cycle_type") == "W" ? "selected='selected'" : "";
        ?>
><?php 
        _e("week(s)", "gravityformspaypal");
        ?>
</option>
                            <option value="M" <?php 
        echo rgars($config, "meta/billing_cycle_type") == "M" || strlen(rgars($config, "meta/billing_cycle_type")) == 0 ? "selected='selected'" : "";
        ?>
><?php 
        _e("month(s)", "gravityformspaypal");
        ?>
</option>
                            <option value="Y" <?php 
        echo rgars($config, "meta/billing_cycle_type") == "Y" ? "selected='selected'" : "";
        ?>
><?php 
        _e("year(s)", "gravityformspaypal");
        ?>
</option>
                        </select>
                    </div>

                    <div class="margin_vertical_10">
                        <label class="left_header" for="gf_paypal_recurring_times"><?php 
        _e("Recurring Times", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_recurring_times");
        ?>
</label>
                        <select id="gf_paypal_recurring_times" name="gf_paypal_recurring_times">
                            <option value=""><?php 
        _e("Infinite", "gravityformspaypal");
        ?>
</option>
                            <?php 
        for ($i = 2; $i <= 30; $i++) {
            $selected = $i == $config["meta"]["recurring_times"] ? 'selected="selected"' : '';
            ?>
                                <option value="<?php 
            echo $i;
            ?>
" <?php 
            echo $selected;
            ?>
><?php 
            echo $i;
            ?>
</option>
                                <?php 
        }
        ?>
                        </select>&nbsp;&nbsp;
                        <input type="checkbox" name="gf_paypal_recurring_retry" id="gf_paypal_recurring_retry" value="1" <?php 
        echo rgars($config, "meta/recurring_retry") ? "checked='checked'" : "";
        ?>
 />
                        <label class="inline" for="gf_paypal_recurring_retry"><?php 
        _e("Try to bill again after failed attempt.", "gravityformspaypal");
        ?>
</label>
                    </div>

                    <div class="margin_vertical_10">
                        <label class="left_header" for="gf_paypal_trial_period"><?php 
        _e("Trial Period", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_trial_period_enable");
        ?>
</label>
                        <input type="checkbox" name="gf_paypal_trial_period" id="gf_paypal_trial_period" value="1" onclick="if(jQuery(this).is(':checked')) jQuery('#paypal_trial_period_container').show('slow'); else jQuery('#paypal_trial_period_container').hide('slow');" <?php 
        echo rgars($config, "meta/trial_period_enabled") ? "checked='checked'" : "";
        ?>
 />
                        <label class="inline" for="gf_paypal_trial_period"><?php 
        _e("Enable", "gravityformspaypal");
        ?>
</label>
                    </div>

                    <div id="paypal_trial_period_container" <?php 
        echo rgars($config, "meta/trial_period_enabled") ? "" : "style='display:none;'";
        ?>
>
                        <div class="margin_vertical_10">
                            <label class="left_header" for="gf_paypal_trial_amount"><?php 
        _e("Trial Amount", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_trial_amount");
        ?>
</label>
                            <input type="text" name="gf_paypal_trial_amount" id="gf_paypal_trial_amount" value="<?php 
        echo rgars($config, "meta/trial_amount");
        ?>
"/>
                        </div>
                        <div class="margin_vertical_10">
                            <label class="left_header" for="gf_paypal_trial_period_number"><?php 
        _e("Trial Period", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_trial_period");
        ?>
</label>
                            <select id="gf_paypal_trial_period_number" name="gf_paypal_trial_period_number">
                                <?php 
        for ($i = 1; $i <= 100; $i++) {
            ?>
                                    <option value="<?php 
            echo $i;
            ?>
" <?php 
            echo rgars($config, "meta/trial_period_number") == $i ? "selected='selected'" : "";
            ?>
><?php 
            echo $i;
            ?>
</option>
                                <?php 
        }
        ?>
                            </select>&nbsp;
                            <select id="gf_paypal_trial_period_type" name="gf_paypal_trial_period_type" onchange="SetPeriodNumber('#gf_paypal_trial_period_number', jQuery(this).val());">
                                <option value="D" <?php 
        echo rgars($config, "meta/trial_period_type") == "D" ? "selected='selected'" : "";
        ?>
><?php 
        _e("day(s)", "gravityformspaypal");
        ?>
</option>
                                <option value="W" <?php 
        echo rgars($config, "meta/trial_period_type") == "W" ? "selected='selected'" : "";
        ?>
><?php 
        _e("week(s)", "gravityformspaypal");
        ?>
</option>
                                <option value="M" <?php 
        echo rgars($config, "meta/trial_period_type") == "M" || empty($config["meta"]["trial_period_type"]) ? "selected='selected'" : "";
        ?>
><?php 
        _e("month(s)", "gravityformspaypal");
        ?>
</option>
                                <option value="Y" <?php 
        echo rgars($config, "meta/trial_period_type") == "Y" ? "selected='selected'" : "";
        ?>
><?php 
        _e("year(s)", "gravityformspaypal");
        ?>
</option>
                            </select>
                        </div>

                    </div>
                </div>

                <div class="margin_vertical_10">
                    <label class="left_header"><?php 
        _e("Customer", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_customer");
        ?>
</label>

                    <div id="paypal_customer_fields">
                        <?php 
        if (!empty($form)) {
            echo self::get_customer_information($form, $config);
        }
        ?>
                    </div>
                </div>

                <div class="margin_vertical_10">
                    <label class="left_header" for="gf_paypal_page_style"><?php 
        _e("Page Style", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_page_style");
        ?>
</label>
                    <input type="text" name="gf_paypal_page_style" id="gf_paypal_page_style" class="width-1" value="<?php 
        echo rgars($config, "meta/style");
        ?>
"/>
                </div>
                <div class="margin_vertical_10">
                    <label class="left_header" for="gf_paypal_continue_text"><?php 
        _e("Continue Button Label", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_continue_button_label");
        ?>
</label>
                    <input type="text" name="gf_paypal_continue_text" id="gf_paypal_continue_text" class="width-1" value="<?php 
        echo rgars($config, "meta/continue_text");
        ?>
"/>
                </div>
                <div class="margin_vertical_10">
                    <label class="left_header" for="gf_paypal_cancel_url"><?php 
        _e("Cancel URL", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_cancel_url");
        ?>
</label>
                    <input type="text" name="gf_paypal_cancel_url" id="gf_paypal_cancel_url" class="width-1" value="<?php 
        echo rgars($config, "meta/cancel_url");
        ?>
"/>
                </div>

                <div class="margin_vertical_10">
                    <label class="left_header"><?php 
        _e("Options", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_options");
        ?>
</label>

                    <ul style="overflow:hidden;">
                        <li>
                            <input type="checkbox" name="gf_paypal_disable_shipping" id="gf_paypal_disable_shipping" value="1" <?php 
        echo rgar($config['meta'], 'disable_shipping') ? "checked='checked'" : "";
        ?>
 />
                            <label class="inline" for="gf_paypal_disable_shipping"><?php 
        _e("Do not prompt buyer to include a shipping address.", "gravityformspaypal");
        ?>
</label>
                        </li>
                        <li>
                            <input type="checkbox" name="gf_paypal_disable_note" id="gf_paypal_disable_note" value="1" <?php 
        echo rgar($config['meta'], 'disable_note') ? "checked='checked'" : "";
        ?>
 />
                            <label class="inline" for="gf_paypal_disable_note"><?php 
        _e("Do not prompt buyer to include a note with payment.", "gravityformspaypal");
        ?>
</label>
                        </li>
                        <li id="paypal_delay_notification">
                            <input type="checkbox" name="gf_paypal_delay_notification" id="gf_paypal_delay_notification" value="1" <?php 
        echo rgar($config["meta"], 'delay_notification') ? "checked='checked'" : "";
        ?>
 />
                            <label class="inline" for="gf_paypal_delay_notification"><?php 
        _e("Send admin notification only when payment is received.", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_delay_admin_notification");
        ?>
</label>
                        </li>
                        <li id="paypal_delay_autoresponder">
                            <input type="checkbox" name="gf_paypal_delay_autoresponder" id="gf_paypal_delay_autoresponder" value="1" <?php 
        echo rgar($config["meta"], 'delay_autoresponder') ? "checked='checked'" : "";
        ?>
 />
                            <label class="inline" for="gf_paypal_delay_autoresponder"><?php 
        _e("Send user notification only when payment is received.", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_delay_user_notification");
        ?>
</label>
                        </li>
                        <?php 
        $display_post_fields = !empty($form) ? GFCommon::has_post_field($form["fields"]) : false;
        ?>
                        <li id="paypal_post_action" <?php 
        echo $display_post_fields ? "" : "style='display:none;'";
        ?>
>
                            <input type="checkbox" name="gf_paypal_delay_post" id="gf_paypal_delay_post" value="1" <?php 
        echo rgar($config["meta"], "delay_post") ? "checked='checked'" : "";
        ?>
 />
                            <label class="inline" for="gf_paypal_delay_post"><?php 
        _e("Create post only when payment is received.", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_delay_post");
        ?>
</label>
                        </li>

                        <li id="paypal_post_update_action" <?php 
        echo $display_post_fields && $config["meta"]["type"] == "subscription" ? "" : "style='display:none;'";
        ?>
>
                            <input type="checkbox" name="gf_paypal_update_post" id="gf_paypal_update_post" value="1" <?php 
        echo $config["meta"]["update_post_action"] ? "checked='checked'" : "";
        ?>
 onclick="var action = this.checked ? 'draft' : ''; jQuery('#gf_paypal_update_action').val(action);" />
                            <label class="inline" for="gf_paypal_update_post"><?php 
        _e("Update Post when subscription is cancelled.", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_update_post");
        ?>
</label>
                            <select id="gf_paypal_update_action" name="gf_paypal_update_action" onchange="var checked = jQuery(this).val() ? 'checked' : false; jQuery('#gf_paypal_update_post').attr('checked', checked);">
                                <option value=""></option>
                                <option value="draft" <?php 
        echo $config["meta"]["update_post_action"] == "draft" ? "selected='selected'" : "";
        ?>
><?php 
        _e("Mark Post as Draft", "gravityformspaypal");
        ?>
</option>
                                <option value="delete" <?php 
        echo $config["meta"]["update_post_action"] == "delete" ? "selected='selected'" : "";
        ?>
><?php 
        _e("Delete Post", "gravityformspaypal");
        ?>
</option>
                            </select>
                        </li>

                        <?php 
        do_action("gform_paypal_action_fields", $config, $form);
        ?>
                    </ul>
                </div>

                <?php 
        do_action("gform_paypal_add_option_group", $config, $form);
        ?>

                <div id="gf_paypal_conditional_section" valign="top" class="margin_vertical_10">
                    <label for="gf_paypal_conditional_optin" class="left_header"><?php 
        _e("PayPal Condition", "gravityformspaypal");
        ?>
 <?php 
        gform_tooltip("paypal_conditional");
        ?>
</label>

                    <div id="gf_paypal_conditional_option">
                        <table cellspacing="0" cellpadding="0">
                            <tr>
                                <td>
                                    <input type="checkbox" id="gf_paypal_conditional_enabled" name="gf_paypal_conditional_enabled" value="1" onclick="if(this.checked){jQuery('#gf_paypal_conditional_container').fadeIn('fast');} else{ jQuery('#gf_paypal_conditional_container').fadeOut('fast'); }" <?php 
        echo rgar($config['meta'], 'paypal_conditional_enabled') ? "checked='checked'" : "";
        ?>
/>
                                    <label for="gf_paypal_conditional_enable"><?php 
        _e("Enable", "gravityformspaypal");
        ?>
</label>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div id="gf_paypal_conditional_container" <?php 
        echo !rgar($config['meta'], 'paypal_conditional_enabled') ? "style='display:none'" : "";
        ?>
>

                                        <div id="gf_paypal_conditional_fields" <?php 
        echo empty($selection_fields) ? "style='display:none'" : "";
        ?>
>
                                            <?php 
        _e("Send to PayPal if ", "gravityformspaypal");
        ?>

                                            <select id="gf_paypal_conditional_field_id" name="gf_paypal_conditional_field_id" class="optin_select" onchange='jQuery("#gf_paypal_conditional_value").html(GetFieldValues(jQuery(this).val(), "", 20));'>
                                                <?php 
        echo empty($selection_fields) ? "" : $selection_fields;
        ?>
                                            </select>
                                            <select id="gf_paypal_conditional_operator" name="gf_paypal_conditional_operator">
                                                <option value="is" <?php 
        echo rgar($config['meta'], 'paypal_conditional_operator') == "is" ? "selected='selected'" : "";
        ?>
><?php 
        _e("is", "gravityformspaypal");
        ?>
</option>
                                                <option value="isnot" <?php 
        echo rgar($config['meta'], 'paypal_conditional_operator') == "isnot" ? "selected='selected'" : "";
        ?>
><?php 
        _e("is not", "gravityformspaypal");
        ?>
</option>
                                            </select>
                                            <select id="gf_paypal_conditional_value" name="gf_paypal_conditional_value" class='optin_select'></select>

                                        </div>

                                        <div id="gf_paypal_conditional_message" <?php 
        echo !empty($selection_fields) ? "style='display:none'" : "";
        ?>
>
                                            <?php 
        _e("To create a registration condition, your form must have a drop down, checkbox or multiple choice field", "gravityform");
        ?>
                                        </div>

                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>

                </div> <!-- / paypal conditional -->

                <div id="paypal_submit_container" class="margin_vertical_30">
                    <input type="submit" name="gf_paypal_submit" value="<?php 
        echo empty($id) ? __("  Save  ", "gravityformspaypal") : __("Update", "gravityformspaypal");
        ?>
" class="button-primary"/>
                    <input type="button" value="<?php 
        _e("Cancel", "gravityformspaypal");
        ?>
" class="button" onclick="javascript:document.location='admin.php?page=gf_paypal'" />
                </div>
            </div>
        </form>
        </div>

        <script type="text/javascript">
            jQuery(document).ready(function(){
                SetPeriodNumber('#gf_paypal_billing_cycle_number', jQuery("#gf_paypal_billing_cycle_type").val());
                SetPeriodNumber('#gf_paypal_trial_period_number', jQuery("#gf_paypal_trial_period_type").val());
            });

            function SelectType(type){
                jQuery("#paypal_field_group").slideUp();

                jQuery("#paypal_field_group input[type=\"text\"], #paypal_field_group select").val("");
                jQuery("#gf_paypal_trial_period_type, #gf_paypal_billing_cycle_type").val("M");

                jQuery("#paypal_field_group input:checked").attr("checked", false);

                if(type){
                    jQuery("#paypal_form_container").slideDown();
                    jQuery("#gf_paypal_form").val("");
                }
                else{
                    jQuery("#paypal_form_container").slideUp();
                }
            }

            function SelectForm(type, formId, settingId){
                if(!formId){
                    jQuery("#paypal_field_group").slideUp();
                    return;
                }

                jQuery("#paypal_wait").show();
                jQuery("#paypal_field_group").slideUp();

                var mysack = new sack("<?php 
        bloginfo('wpurl');
        ?>
/wp-admin/admin-ajax.php" );
                mysack.execute = 1;
                mysack.method = 'POST';
                mysack.setVar( "action", "gf_select_paypal_form" );
                mysack.setVar( "gf_select_paypal_form", "<?php 
        echo wp_create_nonce("gf_select_paypal_form");
        ?>
" );
                mysack.setVar( "type", type);
                mysack.setVar( "form_id", formId);
                mysack.setVar( "setting_id", settingId);
                mysack.encVar( "cookie", document.cookie, false );
                mysack.onError = function() {jQuery("#paypal_wait").hide(); alert('<?php 
        _e("Ajax error while selecting a form", "gravityformspaypal");
        ?>
' )};
                mysack.runAJAX();

                return true;
            }

            function EndSelectForm(form_meta, customer_fields, recurring_amount_options){
                //setting global form object
                form = form_meta;

                var type = jQuery("#gf_paypal_type").val();

                jQuery(".gf_paypal_invalid_form").hide();
                if( (type == "product" || type =="subscription") && GetFieldsByType(["product"]).length == 0){
                    jQuery("#gf_paypal_invalid_product_form").show();
                    jQuery("#paypal_wait").hide();
                    return;
                }
                else if(type == "donation" && GetFieldsByType(["product", "donation"]).length == 0){
                    jQuery("#gf_paypal_invalid_donation_form").show();
                    jQuery("#paypal_wait").hide();
                    return;
                }

                jQuery(".paypal_field_container").hide();
                jQuery("#paypal_customer_fields").html(customer_fields);
                jQuery("#gf_paypal_recurring_amount").html(recurring_amount_options);

                //displaying delayed post creation setting if current form has a post field
                var post_fields = GetFieldsByType(["post_title", "post_content", "post_excerpt", "post_category", "post_custom_field", "post_image", "post_tag"]);
                if(post_fields.length > 0){
                    jQuery("#paypal_post_action").show();
                }
                else{
                    jQuery("#gf_paypal_delay_post").attr("checked", false);
                    jQuery("#paypal_post_action").hide();
                }

                if(type == "subscription" && post_fields.length > 0){
                    jQuery("#paypal_post_update_action").show();
                }
                else{
                    jQuery("#gf_paypal_update_post").attr("checked", false);
                    jQuery("#paypal_post_update_action").hide();
                }

                SetPeriodNumber('#gf_paypal_billing_cycle_number', jQuery("#gf_paypal_billing_cycle_type").val());
                SetPeriodNumber('#gf_paypal_trial_period_number', jQuery("#gf_paypal_trial_period_type").val());

                //Calling callback functions
                jQuery(document).trigger('paypalFormSelected', [form]);

                jQuery("#gf_paypal_conditional_enabled").attr('checked', false);
                SetPayPalCondition("","");

                jQuery("#paypal_field_container_" + type).show();
                jQuery("#paypal_field_group").slideDown();
                jQuery("#paypal_wait").hide();
            }

            function SetPeriodNumber(element, type){
                var prev = jQuery(element).val();

                var min = 1;
                var max = 0;
                switch(type){
                    case "D" :
                        max = 100;
                    break;
                    case "W" :
                        max = 52;
                    break;
                    case "M" :
                        max = 12;
                    break;
                    case "Y" :
                        max = 5;
                    break;
                }
                var str="";
                for(var i=min; i<=max; i++){
                    var selected = prev == i ? "selected='selected'" : "";
                    str += "<option value='" + i + "' " + selected + ">" + i + "</option>";
                }
                jQuery(element).html(str);
            }

            function GetFieldsByType(types){
                var fields = new Array();
                for(var i=0; i<form["fields"].length; i++){
                    if(IndexOf(types, form["fields"][i]["type"]) >= 0)
                        fields.push(form["fields"][i]);
                }
                return fields;
            }

            function IndexOf(ary, item){
                for(var i=0; i<ary.length; i++)
                    if(ary[i] == item)
                        return i;

                return -1;
            }

        </script>

        <script type="text/javascript">

            // Paypal Conditional Functions

            <?php 
        if (!empty($config["form_id"])) {
            ?>

                // initilize form object
                form = <?php 
            echo GFCommon::json_encode($form);
            ?>
 ;

                // initializing registration condition drop downs
                jQuery(document).ready(function(){
                    var selectedField = "<?php 
            echo str_replace('"', '\\"', $config["meta"]["paypal_conditional_field_id"]);
            ?>
";
                    var selectedValue = "<?php 
            echo str_replace('"', '\\"', $config["meta"]["paypal_conditional_value"]);
            ?>
";
                    SetPayPalCondition(selectedField, selectedValue);
                });

                <?php 
        }
        ?>

            function SetPayPalCondition(selectedField, selectedValue){

                // load form fields
                jQuery("#gf_paypal_conditional_field_id").html(GetSelectableFields(selectedField, 20));
                var optinConditionField = jQuery("#gf_paypal_conditional_field_id").val();
                var checked = jQuery("#gf_paypal_conditional_enabled").attr('checked');

                if(optinConditionField){
                    jQuery("#gf_paypal_conditional_message").hide();
                    jQuery("#gf_paypal_conditional_fields").show();
                    jQuery("#gf_paypal_conditional_value").html(GetFieldValues(optinConditionField, selectedValue, 20));
                }
                else{
                    jQuery("#gf_paypal_conditional_message").show();
                    jQuery("#gf_paypal_conditional_fields").hide();
                }

                if(!checked) jQuery("#gf_paypal_conditional_container").hide();

            }

            function GetFieldValues(fieldId, selectedValue, labelMaxCharacters){
                if(!fieldId)
                    return "";

                var str = "";
                var field = GetFieldById(fieldId);
                if(!field || !field.choices)
                    return "";

                var isAnySelected = false;

                for(var i=0; i<field.choices.length; i++){
                    var fieldValue = field.choices[i].value ? field.choices[i].value : field.choices[i].text;
                    var isSelected = fieldValue == selectedValue;
                    var selected = isSelected ? "selected='selected'" : "";
                    if(isSelected)
                        isAnySelected = true;

                    str += "<option value='" + fieldValue.replace(/'/g, "&#039;") + "' " + selected + ">" + TruncateMiddle(field.choices[i].text, labelMaxCharacters) + "</option>";
                }

                if(!isAnySelected && selectedValue){
                    str += "<option value='" + selectedValue.replace(/'/g, "&#039;") + "' selected='selected'>" + TruncateMiddle(selectedValue, labelMaxCharacters) + "</option>";
                }

                return str;
            }

            function GetFieldById(fieldId){
                for(var i=0; i<form.fields.length; i++){
                    if(form.fields[i].id == fieldId)
                        return form.fields[i];
                }
                return null;
            }

            function TruncateMiddle(text, maxCharacters){
                if(!text)
                    return "";

                if(text.length <= maxCharacters)
                    return text;
                var middle = parseInt(maxCharacters / 2);
                return text.substr(0, middle) + "..." + text.substr(text.length - middle, middle);
            }

            function GetSelectableFields(selectedFieldId, labelMaxCharacters){
                var str = "";
                var inputType;
                for(var i=0; i<form.fields.length; i++){
                    fieldLabel = form.fields[i].adminLabel ? form.fields[i].adminLabel : form.fields[i].label;
                    inputType = form.fields[i].inputType ? form.fields[i].inputType : form.fields[i].type;
                    if(inputType == "checkbox" || inputType == "radio" || inputType == "select"){
                        var selected = form.fields[i].id == selectedFieldId ? "selected='selected'" : "";
                        str += "<option value='" + form.fields[i].id + "' " + selected + ">" + TruncateMiddle(fieldLabel, labelMaxCharacters) + "</option>";
                    }
                }
                return str;
            }

        </script>

        <?php 
    }