static function directory_update_approved($lead_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { global $wpdb, $_gform_directory_approvedcolumn, $current_user; $current_user = wp_get_current_user(); $user_data = get_userdata($current_user->ID); if (!empty($approvedcolumn)) { $_gform_directory_approvedcolumn = $approvedcolumn; } if (empty($_gform_directory_approvedcolumn)) { return false; } $lead_detail_table = RGFormsModel::get_lead_details_table_name(); // This will be faster in the 1.6+ future. if (function_exists('gform_update_meta')) { gform_update_meta($lead_id, 'is_approved', $approved); } if (empty($approved)) { //Deleting details for this field $sql = $wpdb->prepare("DELETE FROM {$lead_detail_table} WHERE lead_id=%d AND field_number BETWEEN %f AND %f ", $lead_id, $_gform_directory_approvedcolumn - 0.001, $_gform_directory_approvedcolumn + 0.001); $wpdb->query($sql); RGFormsModel::add_note($lead_id, $current_user->ID, $user_data->display_name, stripslashes(__('Disapproved the lead', 'gravity-forms-addons'))); } else { // Get the fields for the lead $current_fields = $wpdb->get_results($wpdb->prepare("SELECT id, field_number FROM {$lead_detail_table} WHERE lead_id=%d", $lead_id)); $lead_detail_id = RGFormsModel::get_lead_detail_id($current_fields, $_gform_directory_approvedcolumn); // If there's already a field for the approved column, then we update it. if ($lead_detail_id > 0) { $update = $wpdb->update($lead_detail_table, array("value" => $approved), array("lead_id" => $lead_id, 'form_id' => $form_id, 'field_number' => $_gform_directory_approvedcolumn), array("%s"), array("%d", "%d", "%f")); } else { $update = $wpdb->insert($lead_detail_table, array("lead_id" => $lead_id, "form_id" => $form_id, "field_number" => $_gform_directory_approvedcolumn, "value" => $approved), array("%d", "%d", "%f", "%s")); } RGFormsModel::add_note($lead_id, $current_user->ID, $user_data->display_name, stripslashes(__('Approved the lead', 'gravity-forms-addons'))); } }
function directory_update_approved($lead_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { global $wpdb, $_gform_directory_approvedcolumn; if (!empty($approvedcolumn)) { $_gform_directory_approvedcolumn = $approvedcolumn; } if (empty($_gform_directory_approvedcolumn)) { return false; } $lead_detail_table = RGFormsModel::get_lead_details_table_name(); // This will be faster in the 1.6+ future. if (function_exists('gform_update_meta')) { gform_update_meta($lead_id, 'is_approved', $approved); } if (empty($approved)) { //Deleting details for this field $sql = $wpdb->prepare("DELETE FROM {$lead_detail_table} WHERE lead_id=%d AND field_number BETWEEN %f AND %f ", $lead_id, $_gform_directory_approvedcolumn - 0.001, $_gform_directory_approvedcolumn + 0.001); $wpdb->query($sql); } else { $current_fields = $wpdb->get_results($wpdb->prepare("SELECT id, field_number FROM {$lead_detail_table} WHERE lead_id=%d", $lead_id)); $lead_detail_id = RGFormsModel::get_lead_detail_id($current_fields, $_gform_directory_approvedcolumn); if ($lead_detail_id > 0) { $update = $wpdb->update($lead_detail_table, array("value" => $approved), array("lead_id" => $lead_id, 'form_id' => $form_id, 'field_number' => $_gform_directory_approvedcolumn), array("%s"), array("%d", "%d", "%f")); } else { $update = $wpdb->insert($lead_detail_table, array("lead_id" => $lead_id, "form_id" => $form_id, "field_number" => $_gform_directory_approvedcolumn, "value" => $approved), array("%d", "%d", "%f", "%s")); } } }
/** * Save payment information to DB * * @since 1.7.9.1 * * @uses rgar() * @uses GFCommon::get_currency() * @uses rgpost() * @uses RGFormsModel::get_lead_details_table_name() * @uses wpdb->prepare() * @uses wpdb->get_results() * @uses RGFormsModel::get_lead_detail_id() * @uses wpdb->update() * @uses wpdb->insert() * @uses RGFormsModel::update_lead() * @uses apply_filters() * @uses GFP_Stripe::get_feed() * @uses gform_update_meta() * @uses GFP_Stripe_Data::insert_transaction() * * @param $entry * @param $form * * @return void */ public function gform_entry_created($entry, $form) { global $wpdb; $entry_id = rgar($entry, 'id'); if (!empty(self::$transaction_response)) { //Current Currency $currency = GFCommon::get_currency(); $transaction_id = self::$transaction_response['transaction_id']; $transaction_type = self::$transaction_response['transaction_type']; $amount = array_key_exists('amount', self::$transaction_response) ? self::$transaction_response['amount'] : null; $payment_date = gmdate('Y-m-d H:i:s'); $entry['currency'] = $currency; if ('1' == $transaction_type) { $entry['payment_status'] = 'Approved'; } else { $entry['payment_status'] = 'Active'; } $entry['payment_amount'] = $amount; $entry['payment_date'] = $payment_date; $entry['transaction_id'] = $transaction_id; $entry['transaction_type'] = $transaction_type; $entry['is_fulfilled'] = true; //save card type since it gets stripped $form_id = $entry['form_id']; foreach ($form['fields'] as $field) { if ('creditcard' == $field['type']) { $creditcard_field_id = $field['id']; } } $card_type_name = "input_" . $creditcard_field_id . "_4"; $card_type_id = $creditcard_field_id . ".4"; $card_type_value = rgpost($card_type_name); $card_type_value = substr($card_type_value, 0, GFORMS_MAX_FIELD_LENGTH); $lead_detail_table = RGFormsModel::get_lead_details_table_name(); $current_fields = $wpdb->get_results($wpdb->prepare("SELECT id, field_number FROM {$lead_detail_table} WHERE lead_id=%d", $entry_id)); $lead_detail_id = RGFormsModel::get_lead_detail_id($current_fields, $card_type_id); if ($lead_detail_id > 0) { $wpdb->update($lead_detail_table, array('value' => $card_type_value), array('id' => $lead_detail_id), array("%s"), array("%d")); } else { $wpdb->insert($lead_detail_table, array('lead_id' => $entry_id, 'form_id' => $form['id'], 'field_number' => $card_type_id, 'value' => $card_type_value), array("%d", "%d", "%f", "%s")); } $entry = apply_filters('gfp_stripe_entry_created_update_lead', $entry, self::$transaction_response); RGFormsModel::update_lead($entry); //saving feed id $feed = self::$_this->get_feed($form); gform_update_meta($entry_id, 'Stripe_feed_id', $feed['id']); //updating form meta with current payment gateway gform_update_meta($entry_id, 'payment_gateway', 'stripe'); $subscriber_id = apply_filters('gfp_stripe_entry_created_subscriber_id', '', self::$transaction_response, $entry); GFP_Stripe_Data::insert_transaction($entry['id'], apply_filters('gfp_stripe_entry_created_insert_transaction_type', 'payment', $transaction_type), $subscriber_id, $transaction_id, $amount); } }