/** * Alias for GFFormsModel::add_note() with default note_type of 'gravityview' * @see GFFormsModel::add_note() * @since 1.15 * @param int $lead_id ID of the Entry * @param int $user_id ID of the user creating the note * @param string $user_name User name of the user creating the note * @param string $note Note content. * @param string $note_type Type of note. Default: `gravityview` */ public static function add_note($lead_id, $user_id, $user_name, $note = '', $note_type = 'gravityview') { $default_note = array('lead_id' => 0, 'user_id' => 0, 'user_name' => '', 'note' => '', 'note_type' => 'gravityview'); /** * @filter `gravityview/entry_notes/add_note` Modify note values before added using GFFormsModel::add_note() * @see GFFormsModel::add_note * @since 1.15.2 * @param array $note Array with `lead_id`, `user_id`, `user_name`, `note`, and `note_type` key value pairs */ $note = apply_filters('gravityview/entry_notes/add_note', compact('lead_id', 'user_id', 'user_name', 'note', 'note_type')); // Make sure the keys are all set $note = wp_parse_args($note, $default_note); GFFormsModel::add_note(intval($note['lead_id']), intval($note['user_id']), esc_attr($note['user_name']), $note['note'], esc_attr($note['note_type'])); }
/** * Alias for GFFormsModel::add_note() with default note_type of 'gravityview' * * @see GFFormsModel::add_note() * * @since 1.15 * @since 1.17 Added return value * * @param int $lead_id ID of the Entry * @param int $user_id ID of the user creating the note * @param string $user_name User name of the user creating the note * @param string $note Note content. * @param string $note_type Type of note. Default: `gravityview` * * @return int|WP_Error Note ID, if success. WP_Error with $wpdb->last_error message, if failed. */ public static function add_note($lead_id, $user_id, $user_name, $note = '', $note_type = 'gravityview') { global $wpdb; $default_note = array('lead_id' => 0, 'user_id' => 0, 'user_name' => '', 'note' => '', 'note_type' => 'gravityview'); /** * @filter `gravityview/entry_notes/add_note` Modify note values before added using GFFormsModel::add_note() * @see GFFormsModel::add_note * @since 1.15.2 * @param array $note Array with `lead_id`, `user_id`, `user_name`, `note`, and `note_type` key value pairs */ $note = apply_filters('gravityview/entry_notes/add_note', compact('lead_id', 'user_id', 'user_name', 'note', 'note_type')); // Make sure the keys are all set $note = wp_parse_args($note, $default_note); GFFormsModel::add_note(intval($note['lead_id']), intval($note['user_id']), esc_attr($note['user_name']), $note['note'], esc_attr($note['note_type'])); // If last_error is empty string, there was no error. if (empty($wpdb->last_error)) { $return = $wpdb->insert_id; } else { $return = new WP_Error('gravityview-add-note', $wpdb->last_error); } return $return; }
public function add_note($entry_id, $note, $note_type = null) { $user_id = 0; $user_name = $this->_short_title; GFFormsModel::add_note($entry_id, $user_id, $user_name, $note, $note_type); }
public function add_note($entry_id, $note, $user_id = false) { if ($user_id) { $user = new WP_User($user_id); $user_name = $user->get('display_name'); } else { $user_id = 0; $user_name = 'System'; } GFFormsModel::add_note($entry_id, $user_id, $user_name, $note); }
public function admin_update_payment($form, $entry_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 $entry = GFFormsModel::get_lead($entry_id); if ($this->payment_details_editing_disabled($entry, 'update')) { return; } //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 = $entry['payment_status']; } $payment_amount = GFCommon::to_number(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; } $entry['payment_status'] = $payment_status; $entry['payment_amount'] = $payment_amount; $entry['payment_date'] = $payment_date; $entry['transaction_id'] = $payment_transaction; // if payment status does not equal approved/paid or the lead has already been fulfilled, do not continue with fulfillment if (($payment_status == 'Approved' || $payment_status == 'Paid') && !$entry['is_fulfilled']) { $action['id'] = $payment_transaction; $action['type'] = 'complete_payment'; $action['transaction_id'] = $payment_transaction; $action['amount'] = $payment_amount; $action['entry_id'] = $entry['id']; $this->complete_payment($entry, $action); $this->fulfill_order($entry, $payment_transaction, $payment_amount); } //update lead, add a note GFAPI::update_entry($entry); GFFormsModel::add_note($entry['id'], $user_id, $user_name, sprintf(__('Payment information was manually updated. Status: %s. Amount: %s. Transaction Id: %s. Date: %s', 'gravityformspaypal'), $entry['payment_status'], GFCommon::to_money($entry['payment_amount'], $entry['currency']), $payment_transaction, $entry['payment_date'])); }
/** * Revoke referral on refund * * @access public * @uses GFFormsModel::add_note() * * @param array $entry * @param array $action */ public function revoke_referral_on_refund($entry, $action) { $this->reject_referral($entry['id']); $referral = affiliate_wp()->referrals->get_by('reference', $entry['id'], $this->context); $amount = affwp_currency_filter(affwp_format_amount($referral->amount)); $name = affiliate_wp()->affiliates->get_affiliate_name($referral->affiliate_id); $note = sprintf(__('Referral #%d for %s for %s rejected', 'affiliate-wp'), $referral->referral_id, $amount, $name); GFFormsModel::add_note($entry["id"], 0, 'AffiliateWP', $note); }
private static function update_entry($result, $entry, $config) { $entry["transaction_id"] = self::$transaction_response["auth_transaction_id"]; $entry["transaction_type"] = $config["meta"]["type"] == "product" ? "1" : "2"; $entry["is_fulfilled"] = true; $entry["currency"] = GFCommon::get_currency(); if ($result["is_success"]) { $entry["payment_amount"] = self::$transaction_response["amount"]; $entry["payment_status"] = $config["meta"]["type"] == "product" ? "Approved" : "Active"; $entry["payment_date"] = gmdate("Y-m-d H:i:s"); if ($config["meta"]["type"] == "product") { GFAuthorizeNetData::insert_transaction($entry["id"], "payment", $entry["transaction_id"], $entry["transaction_id"], $entry["payment_amount"]); } else { $entry["transaction_id"] = $result["subscription_id"]; GFFormsModel::add_note($entry["id"], 0, "System", __("Subscription has been successfully created. Subscription Id: {$entry["transaction_id"]}", "gravityformsauthorizenet")); //Add note for setup fee payment if completed $fee_amount = self::$transaction_response["setup_fee"]; if (!empty($fee_amount) && $fee_amount > 0) { RGFormsModel::add_note($entry["id"], 0, "System", sprintf(__("Setup fee payment has been made. Amount: %s. Subscription Id: %s", "gravityforms"), GFCommon::to_money($fee_amount, $entry["currency"]), self::$transaction_response["transaction_id"])); GFAuthorizeNetData::insert_transaction($entry["id"], "payment", self::$transaction_response["transaction_id"], $entry["transaction_id"], $fee_amount); } } } else { $entry["payment_status"] = "Failed"; $message = $config["meta"]["type"] == "product" ? sprintf(__("Transaction failed to be captured. Reason: %s", "gravityformsauthorizenet"), $result["error_message"]) . " (" . $result["error_code"] . ")" : sprintf(__("Subscription failed to be created. Reason: %s", "gravityformsauthorizenet"), $result["error_message"]) . "(" . $result["error_code"] . ")"; GFFormsModel::add_note($entry["id"], 0, "System", $message); } RGFormsModel::update_lead($entry); return $entry; }
protected function process_subscription($authorization, $feed, $submission_data, $form, $entry) { $subscription = rgar($authorization, "subscription"); if (empty($subscription)) { return; } //If setup fee / trial is captured as part of a separate transaction $payment = rgar($subscription, "captured_payment"); $payment_name = rgempty("name", $payment) ? __("Initial payment", "gravityforms") : $payment["name"]; if ($payment && $payment["is_success"]) { $this->insert_transaction($entry["id"], "payment", $payment["transaction_id"], $payment["amount"]); GFFormsModel::add_note($entry["id"], 0, "System", sprintf(__("%s has been captured successfully. Amount: %s. Transaction Id: %s", "gravityforms"), $payment_name, GFCommon::to_money($payment["amount"], $entry["currency"]), $payment["transaction_id"])); } else { if ($payment && !$payment["is_success"]) { GFFormsModel::add_note($entry["id"], 0, "System", sprintf(__("Failed to capture %s. Reason: %s.", "gravityforms"), $payment("error_message"), $payment_name)); } } //Updating subscription information if ($subscription["is_success"]) { $entry["transaction_id"] = $subscription["subscription_id"]; $entry["transaction_type"] = "2"; $entry["is_fulfilled"] = true; $entry["currency"] = GFCommon::get_currency(); $entry["payment_amount"] = $subscription["amount"]; $entry["payment_status"] = "Active"; $entry["payment_date"] = gmdate("Y-m-d H:i:s"); GFFormsModel::add_note($entry["id"], 0, "System", sprintf(__("Subscription successfully created. Subscription Id: %s.", "gravityforms"), $subscription["subscription_id"])); } else { $entry["payment_status"] = "Failed"; GFFormsModel::add_note($entry["id"], 0, "System", sprintf(__("Subscription failed to be created. Reason: %s", "gravityforms"), $subscription["error_message"])); } GFFormsModel::update_lead($entry); return $entry; }
/** * Adds a note to the timeline. The timeline is a filtered subset of the Gravity Forms Entry notes. * * @param $note * @param bool $user_id * @param bool $user_name */ public function add_note($note, $user_id = false, $user_name = false) { global $current_user; if (empty($user_id)) { $type = ''; if ($token = gravity_flow()->decode_access_token()) { $assignee_key = sanitize_text_field($token['sub']); list($type, $user_id) = rgexplode('|', $assignee_key, 2); } elseif (is_user_logged_in()) { $user_id = $current_user->ID; $type = 'user_id'; } if ($type == 'user_id') { $user = get_user_by('id', $user_id); $user_name = $user ? $user->display_name : ''; } } if (empty($user_name)) { $user_name = 'gravityflow'; } GFFormsModel::add_note($this->get_entry_id(), $user_id, $user_name, $note, 'gravityflow'); }
public function add_timeline_note($entry_id, $note, $user_id = false, $user_name = false) { global $current_user; if ($user_id === false) { $user_id = $current_user->ID; } if ($user_name === false) { global $current_user; $user_name = $current_user->display_name; } if (empty($user_name) && ($token = $this->decode_access_token())) { $user_name = $this->parse_token_assignee($token)->get_id(); } GFFormsModel::add_note($entry_id, $user_id, $user_name, $note, 'gravityflow'); }
public function handle_note_and_send_by_email($sendByEmail, $type, $id, $entry) { if ($type == 'invoice') { $invoice_estimate = new FreshBooks_Invoice(); $invoice_estimate->invoiceId = $id; } elseif ($type == 'estimate') { $invoice_estimate = new FreshBooks_Estimate(); $invoice_estimate->estimateId = $id; } else { // abort, no need to sendByEmail or add note. return; } // see if invoice/estimate should automatically be emailed. if ($sendByEmail) { $this->log_debug(__METHOD__ . '(): Sending invoice/estimate automatically by email.'); $sentByEmail = $invoice_estimate->sendByEmail(); if ($sentByEmail) { $this->log_debug(__METHOD__ . '(): The invoice/estimate was successfully scheduled to be automatically sent by FreshBooks.'); } else { $this->log_error(__METHOD__ . '(): Unable to schedule invoice/estimate to be automatically sent.'); } } // add note to entry. $invoice_estimate->get($id); $amount_formatted = GFCommon::to_money($invoice_estimate->amount, $entry['currency']); $note = sprintf(__('%s #%s has been successfully created. Amount: %s. Status: %s.', 'gravityformsfreshbooks'), ucfirst($type), $invoice_estimate->number, $amount_formatted, ucfirst($invoice_estimate->status)); GFFormsModel::add_note($entry['id'], 0, $this->_short_title, $note, 'success'); }
/** * Alias for GFFormsModel::add_note() with default note_type of 'gravityview' * @see GFFormsModel::add_note() * @since 1.15 * @param int $lead_id ID of the Entry * @param int $user_id ID of the user creating the note * @param string $user_name User name of the user creating the note * @param string $note Note content. * @param string $note_type Type of note. Default: `gravityview` */ public static function add_note($lead_id, $user_id, $user_name, $note, $note_type = 'gravityview') { GFFormsModel::add_note($lead_id, $user_id, $user_name, $note, $note_type); }