/**
 *  Creates a shortcode to displays a "nag" (which can be styled with CSS targeting a class of 'my-custom-nag')
 *
 *  Sample shortcodes:
 *
 *  [givetotal total_goal="10,000" link="http://example.com"] displays "So far, we have raised $0 toward our goal of $10,000! Donate now"
 *  (where "0" will be replaced with total earnings from all forms, and "Donate Now" is linked to http://example.com)
 *
 *  [givetotal form_id="34" total_goal="10,000"] will display earnings for just form with an ID of 34.
 *
 *  [givetotal total_goal="9,000" message_before="Hey! We've raised " message_between=" of the " message_after=" we are trying to raise for this campaign!" link="http://example.com" link_text="Help Us Reach Our Goal." form_id="245"]
 *
 *  [givetotal total_goal= "5,000" multi_id="34,114,141"] will display earnings for the three forms with IDs 34, 114, and 141.
 *
 *  Note that "multi_id" will override "form_id", so don't use both.
 */
function my_give_display_earnings_shortcode($atts)
{
    $total = get_option('give_earnings_total', false);
    $atts = shortcode_atts(array('total_goal' => '10,000', 'link' => false, 'form_id' => false, 'multi_id' => '', 'message_before' => 'So far, we have raised ', 'message_between' => ' toward our goal of ', 'message_after' => '! ', 'link_text' => 'Donate Now'), $atts, 'givetotal');
    $donate_link = '';
    if ($atts['link'] != false) {
        $donate_link = ' <a href="' . $atts['link'] . '">' . $atts['link_text'] . '</a>';
    }
    if ($atts['form_id'] != false && is_numeric($atts['form_id'])) {
        $total = get_post_meta($atts['form_id'], '_give_form_earnings', true);
    }
    if ($atts['multi_id'] != false) {
        $total = 0;
        $new_array = preg_split("/,/", $atts['multi_id']);
        foreach ($new_array as $value) {
            $total += get_post_meta($value, '_give_form_earnings', true);
        }
    }
    $custom_nag = "<div class='my-custom-nag'>" . $atts['message_before'] . "<span class='my-give-currency'>" . give_currency_symbol(give_get_currency()) . "</span><span class='my-give-raised my-give-amount'>" . give_format_amount($total) . "</span>" . $atts['message_between'] . "<span class='my-give-currency'>" . give_currency_symbol(give_get_currency()) . "</span><span class='my-give-total my-give-amount'>" . $atts['total_goal'] . "</span>" . $atts['message_after'] . $donate_link . "</div>";
    return $custom_nag;
}
Example #2
0
/**
 * Define the metabox and field configurations.
 *
 * @param  array $meta_boxes
 *
 * @return array
 */
function give_single_forms_cmb2_metaboxes(array $meta_boxes)
{
    $post_id = give_get_admin_post_id();
    $price = give_get_form_price($post_id);
    $goal = give_get_form_goal($post_id);
    $variable_pricing = give_has_variable_prices($post_id);
    $prices = give_get_variable_prices($post_id);
    //No empty prices - min. 1.00 for new forms
    if (empty($price)) {
        $price = esc_attr(give_format_amount('1.00'));
    }
    // Start with an underscore to hide fields from custom fields list
    $prefix = '_give_';
    /**
     * Repeatable Field Groups
     */
    $meta_boxes['form_field_options'] = apply_filters('give_forms_field_options', array('id' => 'form_field_options', 'title' => __('Donation Options', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array(array('name' => __('Donation Option', 'give'), 'description' => __('Would you like this form to have one set donation price or multiple levels (for example, $10 silver, $20 gold, $50 platinum)?', 'give'), 'id' => $prefix . 'price_option', 'type' => 'radio_inline', 'default' => 'set', 'options' => apply_filters('give_forms_price_options', array('set' => __('Set Donation', 'give'), 'multi' => __('Multi-level Donation', 'give')))), array('name' => __('Set Donation', 'give'), 'description' => __('This is the set donation amount for this form.', 'give'), 'id' => $prefix . 'set_price', 'type' => 'text_small', 'row_classes' => 'give-subfield', 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', 'attributes' => array('placeholder' => give_format_amount('1.00'), 'value' => $price, 'class' => 'cmb-type-text-small give-money-field')), array('id' => $prefix . 'levels_header', 'type' => 'levels_repeater_header'), array('id' => $prefix . 'donation_levels', 'type' => 'group', 'row_classes' => 'give-subfield', 'options' => array('add_button' => __('Add Level', 'give'), 'remove_button' => __('<span class="dashicons dashicons-no"></span>', 'give'), 'sortable' => true), 'fields' => apply_filters('give_donation_levels_table_row', array(array('name' => __('ID', 'give'), 'id' => $prefix . 'id', 'type' => 'levels_id'), array('name' => __('Amount', 'give'), 'id' => $prefix . 'amount', 'type' => 'text_small', 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol  give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol  give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', 'attributes' => array('placeholder' => give_format_amount('1.00'), 'class' => 'cmb-type-text-small give-money-field'), 'before' => 'give_format_admin_multilevel_amount'), array('name' => __('Text', 'give'), 'id' => $prefix . 'text', 'type' => 'text', 'attributes' => array('placeholder' => __('Donation Level', 'give'), 'rows' => 3)), array('name' => __('Default', 'give'), 'id' => $prefix . 'default', 'type' => 'give_default_radio_inline')))), array('name' => __('Display Style', 'give'), 'description' => __('Set how the donations levels will display on the form.', 'give'), 'id' => $prefix . 'display_style', 'type' => 'radio_inline', 'default' => 'buttons', 'options' => array('buttons' => __('Buttons', 'give'), 'radios' => __('Radios', 'give'), 'dropdown' => __('Dropdown', 'give'))), array('name' => __('Custom Amount', 'give'), 'description' => __('Do you want the user to be able to input their own donation amount?', 'give'), 'id' => $prefix . 'custom_amount', 'type' => 'radio_inline', 'default' => 'no', 'options' => array('yes' => __('Yes', 'give'), 'no' => __('No', 'give'))), array('name' => __('Custom Amount Text', 'give'), 'description' => __('This text appears as a label next to the custom amount field for single level forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option). Add your own message or leave this field blank to prevent it from displaying within your form.', 'give'), 'id' => $prefix . 'custom_amount_text', 'type' => 'text', 'row_classes' => 'give-subfield', 'attributes' => array('rows' => 3, 'placeholder' => __('Give a Custom Amount', 'give'))), array('name' => __('Set Goal?', 'give'), 'description' => __('Do you want to set a donation goal for this form?', 'give'), 'id' => $prefix . 'goal_option', 'type' => 'radio_inline', 'default' => 'no', 'options' => array('yes' => __('Yes', 'give'), 'no' => __('No', 'give'))), array('name' => __('Set Goal', 'give'), 'description' => __('This is the goal you want to achieve for this form.', 'give'), 'id' => $prefix . 'set_goal', 'type' => 'text_small', 'row_classes' => 'give-subfield', 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', 'attributes' => array('placeholder' => give_format_amount('0.00'), 'value' => isset($goal) ? esc_attr(give_format_amount($goal)) : '', 'class' => 'cmb-type-text-small give-money-field')), array('name' => __('Goal Progress Bar Color', 'give'), 'id' => $prefix . 'goal_color', 'type' => 'colorpicker', 'row_classes' => 'give-subfield', 'default' => '#2bc253')))));
    /**
     * Content Field
     */
    $meta_boxes['form_content_options'] = apply_filters('give_forms_content_options', array('id' => 'form_content_options', 'title' => __('Form Content', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'fields' => apply_filters('give_forms_content_options_metabox_fields', array(array('name' => __('Display Content', 'give'), 'description' => __('Do you want to display content? If you select "Yes" a WYSIWYG editor will appear which you will be able to enter content to display above or below the form.', 'give'), 'id' => $prefix . 'content_option', 'type' => 'select', 'options' => apply_filters('give_forms_content_options_select', array('none' => __('No content', 'give'), 'give_pre_form' => __('Yes, display content ABOVE the form fields', 'give'), 'give_post_form' => __('Yes, display content BELOW the form fields', 'give'))), 'default' => 'none'), array('name' => __('Content', 'give'), 'description' => __('This content will display on the single give form page.', 'give'), 'id' => $prefix . 'form_content', 'row_classes' => 'give-subfield', 'type' => 'wysiwyg')))));
    /**
     * Display Options
     */
    $meta_boxes['form_display_options'] = apply_filters('give_form_display_options', array('id' => 'form_display_options', 'title' => __('Form Display Options', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => apply_filters('give_forms_display_options_metabox_fields', array(array('name' => __('Payment Fields', 'give'), 'desc' => __('How would you like to display payment information for this form? The "Show on Page" option will display the entire form when the page loads. "Reveal Upon Click" places a button below the donation fields and upon clicks slides into view the rest of the fields. "Modal Window Upon Click" is a similar option, rather than sliding into view the fields they will open in a shadow box or "modal" window.', 'give'), 'id' => $prefix . 'payment_display', 'type' => 'select', 'options' => array('onpage' => __('Show on Page', 'give'), 'reveal' => __('Reveal Upon Click', 'give'), 'modal' => __('Modal Window Upon Click', 'give')), 'default' => 'onpage'), array('id' => $prefix . 'reveal_label', 'name' => __('Reveal / Modal Open Text', 'give'), 'desc' => __('The button label for completing the donation.', 'give'), 'type' => 'text_small', 'row_classes' => 'give-subfield', 'attributes' => array('placeholder' => __('Donate Now', 'give'))), array('id' => $prefix . 'checkout_label', 'name' => __('Complete Donation Text', 'give'), 'desc' => __('The button label for completing a donation.', 'give'), 'type' => 'text_small', 'attributes' => array('placeholder' => __('Donate Now', 'give'))), array('name' => __('Default Gateway', 'give'), 'desc' => __('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'), 'id' => $prefix . 'default_gateway', 'type' => 'default_gateway'), array('name' => __('Disable Guest Donations', 'give'), 'desc' => __('Do you want to require users be logged-in to make donations?', 'give'), 'id' => $prefix . 'logged_in_only', 'type' => 'checkbox'), array('name' => __('Register / Login Form', 'give'), 'desc' => __('Display the registration and login forms in the checkout section for non-logged-in users. Note: this option will not require users to register or log in prior to completing a donation. It simply determines whether the login and/or registration form are displayed on the checkout page.', 'give'), 'id' => $prefix . 'show_register_form', 'type' => 'select', 'options' => array('both' => __('Registration and Login Forms', 'give'), 'registration' => __('Registration Form Only', 'give'), 'login' => __('Login Form Only', 'give'), 'none' => __('None', 'give')), 'default' => 'none'), array('name' => __('Floating Labels', 'give'), 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form.<br>Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url("http://bradfrost.com/blog/post/float-label-pattern/")), 'id' => $prefix . 'form_floating_labels', 'type' => 'select', 'options' => array('' => __('Use the global setting', 'give'), 'enabled' => __('Enabled', 'give'), 'disabled' => __('Disabled', 'give')), 'default' => 'none')))));
    /**
     * Terms & Conditions
     */
    $meta_boxes['form_terms_options'] = apply_filters('give_forms_terms_options', array('id' => 'form_terms_options', 'title' => __('Terms and Conditions', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array(array('name' => __('Terms and Conditions', 'give'), 'description' => __('Do you want to require the user to agree to terms and conditions prior to being able to complete their donation?', 'give'), 'id' => $prefix . 'terms_option', 'type' => 'select', 'options' => apply_filters('give_forms_content_options_select', array('none' => __('No', 'give'), 'yes' => __('Yes', 'give'))), 'default' => 'none'), array('id' => $prefix . 'agree_label', 'name' => __('Agree to Terms Label', 'give'), 'desc' => __('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'), 'type' => 'text', 'row_classes' => 'give-subfield', 'size' => 'regular', 'attributes' => array('placeholder' => __('Agree to Terms?', 'give'))), array('id' => $prefix . 'agree_text', 'row_classes' => 'give-subfield', 'name' => __('Agreement Text', 'give'), 'desc' => __('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), 'type' => 'wysiwyg')))));
    return $meta_boxes;
}
 /**
  * Get the Export Data.
  *
  * @access public
  * @since 1.5
  * @global object $wpdb Used to query the database using the WordPress database API.
  * @return array $data The data for the CSV file.
  */
 public function get_data()
 {
     global $wpdb;
     $data = array();
     $args = array('number' => 30, 'page' => $this->step, 'status' => $this->status);
     if (!empty($this->start) || !empty($this->end)) {
         $args['date_query'] = array(array('after' => date('Y-n-d 00:00:00', strtotime($this->start)), 'before' => date('Y-n-d 23:59:59', strtotime($this->end)), 'inclusive' => true));
     }
     //echo json_encode($args ); exit;
     $payments = give_get_payments($args);
     if ($payments) {
         foreach ($payments as $payment) {
             $payment_meta = give_get_payment_meta($payment->ID);
             $user_info = give_get_payment_meta_user_info($payment->ID);
             $total = give_get_payment_amount($payment->ID);
             $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email'];
             $products = '';
             $skus = '';
             if (is_numeric($user_id)) {
                 $user = get_userdata($user_id);
             } else {
                 $user = false;
             }
             $data[] = array('id' => $payment->ID, 'seq_id' => give_get_payment_number($payment->ID), 'email' => $payment_meta['email'], 'first' => $user_info['first_name'], 'last' => $user_info['last_name'], 'address1' => isset($user_info['address']['line1']) ? $user_info['address']['line1'] : '', 'address2' => isset($user_info['address']['line2']) ? $user_info['address']['line2'] : '', 'city' => isset($user_info['address']['city']) ? $user_info['address']['city'] : '', 'state' => isset($user_info['address']['state']) ? $user_info['address']['state'] : '', 'country' => isset($user_info['address']['country']) ? $user_info['address']['country'] : '', 'zip' => isset($user_info['address']['zip']) ? $user_info['address']['zip'] : '', 'form_id' => isset($payment_meta['form_id']) ? $payment_meta['form_id'] : '', 'form_name' => isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '', 'skus' => $skus, 'amount' => html_entity_decode(give_format_amount($total)), 'gateway' => give_get_gateway_admin_label(get_post_meta($payment->ID, '_give_payment_gateway', true)), 'trans_id' => give_get_payment_transaction_id($payment->ID), 'key' => $payment_meta['key'], 'date' => $payment->post_date, 'user' => $user ? $user->display_name : __('guest', 'give'), 'status' => give_get_payment_status($payment, true));
         }
         $data = apply_filters('give_export_get_data', $data);
         $data = apply_filters('give_export_get_data_' . $this->export_type, $data);
         return $data;
     }
     return false;
 }
Example #4
0
/**
 * Process Purchase Form
 *
 * Handles the purchase form process.
 *
 * @access      private
 * @since       1.0
 * @return      void
 */
function give_process_purchase_form()
{
    do_action('give_pre_process_purchase');
    // Validate the form $_POST data
    $valid_data = give_purchase_form_validate_fields();
    // Allow themes and plugins to hook to errors
    do_action('give_checkout_error_checks', $valid_data, $_POST);
    $is_ajax = isset($_POST['give_ajax']);
    // Process the login form
    if (isset($_POST['give_login_submit'])) {
        give_process_form_login();
    }
    // Validate the user
    $user = give_get_purchase_form_user($valid_data);
    if (give_get_errors() || !$user) {
        if ($is_ajax) {
            do_action('give_ajax_checkout_errors');
            give_die();
        } else {
            return false;
        }
    }
    if ($is_ajax) {
        echo 'success';
        give_die();
    }
    // Setup user information
    $user_info = array('id' => $user['user_id'], 'email' => $user['user_email'], 'first_name' => $user['user_first'], 'last_name' => $user['user_last'], 'address' => $user['address']);
    $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
    // Setup purchase information
    $purchase_data = array('price' => isset($_POST['give-amount']) ? (double) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00', 'purchase_key' => strtolower(md5($user['user_email'] . date('Y-m-d H:i:s') . $auth_key . uniqid('give', true))), 'user_email' => $user['user_email'], 'date' => date('Y-m-d H:i:s', current_time('timestamp')), 'user_info' => stripslashes_deep($user_info), 'post_data' => $_POST, 'gateway' => $valid_data['gateway'], 'card_info' => $valid_data['cc_info']);
    // Add the user data for hooks
    $valid_data['user'] = $user;
    // Allow themes and plugins to hook before the gateway
    do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
    // If the total amount in the cart is 0, send to the manual gateway. This emulates a free purchase
    if (!$purchase_data['price']) {
        // Revert to manual
        $purchase_data['gateway'] = 'manual';
        $_POST['give-gateway'] = 'manual';
    }
    // Allow the purchase data to be modified before it is sent to the gateway
    $purchase_data = apply_filters('give_purchase_data_before_gateway', $purchase_data, $valid_data);
    // Setup the data we're storing in the purchase session
    $session_data = $purchase_data;
    // Make sure credit card numbers are never stored in sessions
    unset($session_data['card_info']['card_number']);
    // Used for showing data to non logged-in users after purchase, and for other plugins needing purchase data.
    give_set_purchase_session($session_data);
    // Send info to the gateway for payment processing
    give_send_to_gateway($purchase_data['gateway'], $purchase_data);
    give_die();
}
 /**
  * This function renders most of the columns in the list table.
  *
  * @access public
  * @since  1.0
  *
  * @param array  $item        Contains all the data of the discount code
  * @param string $column_name The name of the column
  *
  * @return string Column Name
  */
 public function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'form':
             return '<a href="' . esc_url(add_query_arg('form', $item[$column_name])) . '" >' . get_the_title($item[$column_name]) . '</a>';
         case 'user_id':
             return '<a href="' . admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='******'user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))) . '">' . $item['user_name'] . '</a>';
         case 'amount':
             return give_currency_filter(give_format_amount($item['amount']));
         case 'payment_id':
             return '<a href="' . admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $item['payment_id']) . '">' . give_get_payment_number($item['payment_id']) . '</a>';
         default:
             return $item[$column_name];
     }
 }
 /**
  * This function renders most of the columns in the list table.
  *
  * @access public
  * @since  1.0
  *
  * @param array  $item        Contains all the data of the downloads
  * @param string $column_name The name of the column
  *
  * @return string Column Name
  */
 public function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'earnings':
             return give_currency_filter(give_format_amount($item[$column_name]));
         case 'average_sales':
             return round($item[$column_name]);
         case 'average_earnings':
             return give_currency_filter(give_format_amount($item[$column_name]));
         case 'details':
             return '<a href="' . admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $item['ID']) . '">' . __('View Detailed Report', 'give') . '</a>';
         default:
             return $item[$column_name];
     }
 }
/**
 * Validation donation amount. Note: Give handles validation minimum amount out-of-the-box.
 *
 * Check that a donation is above or below a maximum amount.
 *
 * @param $valid_data
 * @param $data
 */
function give_donations_validate_donation_amount($valid_data, $data)
{
    // Only validate the form with the IDs "754" and "586";
    // Remove "If" statement to validation for all forms
    // For a single form, use this instead:
    //	$forms = array( 1425 );
    //	if ( ! in_array( $data['give-form-id'], $forms ) ) {
    //		return;
    //	}
    $sanitized_amount = (int) give_sanitize_amount($data['give-amount']);
    $max_amount = 1000;
    //Check for message data
    if ($sanitized_amount >= $max_amount) {
        give_set_error('give_message', sprintf(__('Sorry, we can\'t accept donations more than %s.', 'give'), give_currency_filter(give_format_amount($max_amount))));
    }
}
 /**
  * This function renders most of the columns in the list table.
  *
  * @access public
  * @since  1.0
  *
  * @param array $item Contains all the data of the discount code
  * @param string $column_name The name of the column
  *
  * @return string Column Name
  */
 public function column_default($item, $column_name)
 {
     $payment = give_get_payment_by('id', $item['payment_id']);
     switch ($column_name) {
         case 'form':
             return '<a href="' . esc_url(add_query_arg('form', $item[$column_name])) . '" >' . get_the_title($item[$column_name]) . '</a>';
         case 'user_id':
             return '<a href="' . admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='******'user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))) . '">' . $item['user_name'] . '</a>';
         case 'amount':
             return give_currency_filter(give_format_amount($item['amount']));
         case 'status':
             $value = '<div class="give-donation-status status-' . sanitize_title(give_get_payment_status($payment, true)) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status($payment, true) . '</div>';
             if ($payment->mode == 'test') {
                 $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__('This payment was made in test mode', 'give') . '">' . esc_html__('Test', 'give') . '</span>';
             }
             return $value;
         case 'payment_id':
             return '<a href="' . admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $item['payment_id']) . '">' . give_get_payment_number($item['payment_id']) . '</a>';
         default:
             return $item[$column_name];
     }
 }
 /**
  * Zero out the data on step one
  *
  * @access public
  * @since 1.5
  * @return void
  */
 public function pre_fetch()
 {
     if ($this->step === 1) {
         $allowed_payment_status = apply_filters('give_recount_customer_payment_statuses', give_get_payment_status_keys());
         // Before we start, let's zero out the customer's data
         $customer = new Give_Customer($this->customer_id);
         $customer->update(array('purchase_value' => give_format_amount(0), 'purchase_count' => 0));
         $attached_payment_ids = explode(',', $customer->payment_ids);
         $attached_args = array('post__in' => $attached_payment_ids, 'number' => -1, 'status' => $allowed_payment_status);
         $attached_payments = give_get_payments($attached_args);
         $unattached_args = array('post__not_in' => $attached_payment_ids, 'number' => -1, 'status' => $allowed_payment_status, 'meta_query' => array(array('key' => '_give_payment_user_email', 'value' => $customer->email)));
         $unattached_payments = give_get_payments($unattached_args);
         $payments = array_merge($attached_payments, $unattached_payments);
         $this->store_data('give_recount_customer_payments_' . $customer->id, $payments);
     }
 }
Example #10
0
/**
 * Show Give Goals
 * @since 1.0
 *
 * @param int $form_id
 *
 * @return bool
 */
function give_show_goal_progress($form_id)
{
    $goal_option = get_post_meta($form_id, '_give_goal_option', true);
    $form = new Give_Donate_Form($form_id);
    $goal = $form->goal;
    $income = $form->get_earnings();
    $color = get_post_meta($form_id, '_give_goal_color', true);
    if (empty($form->ID) || $goal_option !== 'yes' || $goal == 0) {
        return false;
    }
    $progress = round($income / $goal * 100, 2);
    if ($income > $goal) {
        $progress = 100;
    }
    $output = '<div class="goal-progress">';
    $output .= '<div class="raised">';
    $output .= sprintf(_x('%s of %s raised', 'give', 'This text displays the amount of income raised compared to the goal.'), '<span class="income">' . give_currency_filter(give_format_amount($income)) . '</span>', '<span class="goal-text">' . give_currency_filter(give_format_amount($goal))) . '</span>';
    $output .= '</div>';
    $output .= '<div class="progress-bar">';
    $output .= '<span style="width: ' . esc_attr($progress) . '%;';
    if (!empty($color)) {
        $output .= 'background-color:' . $color;
    }
    $output .= '"></span>';
    $output .= '</div></div><!-- /.goal-progress -->';
    echo apply_filters('give_goal_output', $output);
}
Example #11
0
/**
 * Retrieves a price from from low to high of a variable priced form
 *
 * @since 1.0
 *
 * @param int $form_id ID of the form
 *
 * @return string $range A fully formatted price range
 */
function give_price_range($form_id = 0)
{
    $low = give_get_lowest_price_option($form_id);
    $high = give_get_highest_price_option($form_id);
    $range = '<span class="give_price_range_low">' . give_currency_filter(give_format_amount($low)) . '</span>';
    $range .= '<span class="give_price_range_sep">&nbsp;&ndash;&nbsp;</span>';
    $range .= '<span class="give_price_range_high">' . give_currency_filter(give_format_amount($high)) . '</span>';
    return apply_filters('give_price_range', $range, $form_id, $low, $high);
}
Example #12
0
 /**
  * Get the Export Data
  *
  * @access public
  * @since  1.0
  * @global object $wpdb Used to query the database using the WordPress
  *                      Database API
  * @return array $data The data for the CSV file
  */
 public function get_data()
 {
     global $wpdb, $give_options;
     $data = array();
     $payments = give_get_payments(array('offset' => 0, 'number' => -1, 'mode' => give_is_test_mode() ? 'test' : 'live', 'status' => isset($_POST['give_export_payment_status']) ? $_POST['give_export_payment_status'] : 'any', 'month' => isset($_POST['month']) ? absint($_POST['month']) : date('n'), 'year' => isset($_POST['year']) ? absint($_POST['year']) : date('Y')));
     foreach ($payments as $payment) {
         $payment_meta = give_get_payment_meta($payment->ID);
         $user_info = give_get_payment_meta_user_info($payment->ID);
         $total = give_get_payment_amount($payment->ID);
         $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email'];
         $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : '';
         $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
         if (is_numeric($user_id)) {
             $user = get_userdata($user_id);
         } else {
             $user = false;
         }
         $data[] = array('id' => $payment->ID, 'seq_id' => give_get_payment_number($payment->ID), 'email' => $payment_meta['email'], 'first' => $user_info['first_name'], 'last' => $user_info['last_name'], 'address1' => isset($user_info['address']['line1']) ? $user_info['address']['line1'] : '', 'address2' => isset($user_info['address']['line2']) ? $user_info['address']['line2'] : '', 'city' => isset($user_info['address']['city']) ? $user_info['address']['city'] : '', 'state' => isset($user_info['address']['state']) ? $user_info['address']['state'] : '', 'country' => isset($user_info['address']['country']) ? $user_info['address']['country'] : '', 'zip' => isset($user_info['address']['zip']) ? $user_info['address']['zip'] : '', 'amount' => html_entity_decode(give_format_amount($total)), 'form_id' => $form_id, 'form' => $form_title, 'gateway' => give_get_gateway_admin_label(get_post_meta($payment->ID, '_give_payment_gateway', true)), 'trans_id' => give_get_payment_transaction_id($payment->ID), 'key' => $payment_meta['key'], 'date' => $payment->post_date, 'user' => $user ? $user->display_name : __('guest', 'give'), 'status' => give_get_payment_status($payment, true));
     }
     $data = apply_filters('give_export_get_data', $data);
     $data = apply_filters('give_export_get_data_' . $this->export_type, $data);
     return $data;
 }
Example #13
0
											</td>
											<td>
												<a href="<?php 
echo get_permalink($payment_meta['form_id']);
?>
"><?php 
echo $payment_meta['form_title'];
?>
</a>
											</td>
											<td><?php 
echo date('m/d/Y', $payment_date) . ' ' . date_i18n('H:i', $payment_date);
?>
</td>
											<td><?php 
echo esc_html(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))));
?>
</td>
											<?php 
do_action('give_donation_details_tbody_after', $payment_id);
?>

										</tr>
									</table>

								</div>
								<!-- /.inside -->


							</div>
							<!-- /#give-donation-overview -->
/**
 * Email template tag: price
 * The total price of the donation
 *
 * @param int $payment_id
 *
 * @return string price
 */
function give_email_tag_price($payment_id)
{
    $price = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id)), give_get_payment_currency_code($payment_id));
    return html_entity_decode($price, ENT_COMPAT, 'UTF-8');
}
Example #15
0
/**
 * Show Give Goals
 * @since 1.0
 *
 * @param int   $form_id
 * @param array $args
 *
 * @return mixed
 */
function give_show_goal_progress($form_id, $args)
{
    $goal_option = get_post_meta($form_id, '_give_goal_option', true);
    $form = new Give_Donate_Form($form_id);
    $goal = $form->goal;
    $income = $form->get_earnings();
    $color = get_post_meta($form_id, '_give_goal_color', true);
    $show_text = (bool) isset($args['show_text']) ? filter_var($args['show_text'], FILTER_VALIDATE_BOOLEAN) : true;
    $show_bar = (bool) isset($args['show_bar']) ? filter_var($args['show_bar'], FILTER_VALIDATE_BOOLEAN) : true;
    //Sanity check - respect shortcode args
    if (isset($args['show_goal']) && $args['show_goal'] === false) {
        return false;
    }
    //Sanity check - ensure form has goal set to output
    if (empty($form->ID) || is_singular('give_forms') && $goal_option !== 'yes' || $goal_option !== 'yes' || $goal == 0) {
        //not this form, bail
        return false;
    }
    $progress = round($income / $goal * 100, 2);
    if ($income > $goal) {
        $progress = 100;
    }
    $output = '<div class="goal-progress">';
    //Goal Progress Text
    if (!empty($show_text)) {
        $output .= '<div class="raised">';
        $output .= sprintf(_x('%s of %s raised', 'This text displays the amount of income raised compared to the goal.', 'give'), '<span class="income">' . give_currency_filter(give_format_amount($income)) . '</span>', '<span class="goal-text">' . give_currency_filter(give_format_amount($goal))) . '</span>';
        $output .= '</div>';
    }
    //Goal Progress Bar
    if (!empty($show_bar)) {
        $output .= '<div class="progress-bar">';
        $output .= '<span style="width: ' . esc_attr($progress) . '%;';
        if (!empty($color)) {
            $output .= 'background-color:' . $color;
        }
        $output .= '"></span>';
        $output .= '</div><!-- /.progress-bar -->';
    }
    $output .= '</div><!-- /.goal-progress -->';
    echo apply_filters('give_goal_output', $output);
    return false;
}
Example #16
0
/**
 * Sale Notification Template Body
 *
 * @since  1.0
 *
 * @param int   $payment_id   Payment ID
 * @param array $payment_data Payment Data
 *
 * @return string $email_body Body of the email
 */
function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array())
{
    global $give_options;
    $user_info = maybe_unserialize($payment_data['user_info']);
    $email = give_get_payment_user_email($payment_id);
    if (isset($user_info['id']) && $user_info['id'] > 0) {
        $user_data = get_userdata($user_info['id']);
        $name = $user_data->display_name;
    } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
        $name = $user_info['first_name'] . ' ' . $user_info['last_name'];
    } else {
        $name = $email;
    }
    $gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true));
    $default_email_body = __('Hello', 'give') . "\n\n" . __('A donation has been made', 'give') . ".\n\n";
    $default_email_body .= sprintf(__('%s sold:', 'give'), give_get_forms_label_plural()) . "\n\n";
    $default_email_body .= __('Donor: ', 'give') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n";
    $default_email_body .= __('Amount: ', 'give') . " " . html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8') . "\n";
    $default_email_body .= __('Payment Method: ', 'give') . " " . $gateway . "\n\n";
    $default_email_body .= __('Thank you', 'give');
    $email = isset($give_options['donation_notification']) ? stripslashes($give_options['donation_notification']) : $default_email_body;
    $email_body = give_do_email_tags($email, $payment_id);
    return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data);
}
 /**
  * This function renders most of the columns in the list table.
  *
  * @access public
  * @since  1.0
  *
  * @param array  $item        Contains all the data of the donors
  * @param string $column_name The name of the column
  *
  * @return string Column Name
  */
 public function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'num_purchases':
             $value = '<a href="' . admin_url('/edit.php?post_type=give_forms&page=give-payment-history&user='******'email'])) . '">' . esc_html($item['num_purchases']) . '</a>';
             break;
         case 'amount_spent':
             $value = give_currency_filter(give_format_amount($item[$column_name]));
             break;
         default:
             $value = isset($item[$column_name]) ? $item[$column_name] : null;
             break;
     }
     return apply_filters('give_report_column_' . $column_name, $value, $item['id']);
 }
/**
 * Email template tag: give_amount.
 *
 * The total amount of the donation given.
 *
 * @param int $payment_id
 *
 * @return string amount
 */
function give_email_tag_amount($payment_id)
{
    $payment = new Give_Payment($payment_id);
    $give_amount = give_currency_filter(give_format_amount($payment->total), $payment->currency);
    return html_entity_decode($give_amount, ENT_COMPAT, 'UTF-8');
}
Example #19
0
/**
 * View a customer
 *
 * @since  1.0
 *
 * @param  $customer The Customer object being displayed
 *
 * @return void
 */
function give_customers_view($customer)
{
    $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
    ?>

	<?php 
    do_action('give_donor_card_top', $customer);
    ?>

	<div id="donor-summary" class="info-wrapper customer-section postbox">

		<form id="edit-customer-info" method="post" action="<?php 
    echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id);
    ?>
">

			<div class="customer-info">


				<div class="donor-bio-header clearfix">

					<div class="avatar-wrap left" id="customer-avatar">
						<?php 
    echo get_avatar($customer->email);
    ?>
					</div>

					<div class="customer-id" class="left">
						#<?php 
    echo $customer->id;
    ?>
					</div>
					<div id="customer-name-wrap" class="left">
						<span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php 
    echo esc_attr($customer->name);
    ?>
" placeholder="<?php 
    _e('Donor Name', 'give');
    ?>
" /></span>
						<span class="customer-name info-item editable"><span data-key="name"><?php 
    echo $customer->name;
    ?>
</span></span>
					</div>
					<p class="customer-since info-item">
						<?php 
    _e('Donor since', 'give');
    ?>
						<?php 
    echo date_i18n(get_option('date_format'), strtotime($customer->date_created));
    ?>
					</p>
					<?php 
    if (current_user_can($customer_edit_role)) {
        ?>
						<a title="<?php 
        _e('Edit Donor', 'give');
        ?>
" href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php 
        _e('Edit Donor', 'give');
        ?>
</a>
					<?php 
    }
    ?>
				</div>
				<!-- /donor-bio-header -->

				<div class="customer-main-wrapper">

					<table class="widefat">
						<tbody>
						<tr>
							<td><label for="tablecell"><?php 
    esc_attr_e('Email', 'give');
    ?>
</label></td>
							<td class="row-title">
								<span class="customer-name info-item edit-item"><input size="20" data-key="email" name="customerinfo[email]" type="text" value="<?php 
    echo $customer->email;
    ?>
" placeholder="<?php 
    _e('Donor Email', 'give');
    ?>
" /></span>
								<span class="customer-email info-item editable" data-key="email"><?php 
    echo $customer->email;
    ?>
</span>
							</td>
						</tr>
						<tr class="alternate">
							<td><label for="tablecell"><?php 
    esc_attr_e('User ID', 'give');
    ?>
</label></td>
							<td class="row-title">
								<span class="customer-user-id info-item edit-item">
									<?php 
    $user_id = $customer->user_id > 0 ? $customer->user_id : '';
    $data_atts = array('key' => 'user_login', 'exclude' => $user_id);
    $user_args = array('name' => 'customerinfo[user_login]', 'class' => 'give-user-dropdown', 'data' => $data_atts);
    if (!empty($user_id)) {
        $userdata = get_userdata($user_id);
        $user_args['value'] = $userdata->user_login;
    }
    echo Give()->html->ajax_user_search($user_args);
    ?>
									<input type="hidden" name="customerinfo[user_id]" data-key="user_id" value="<?php 
    echo $customer->user_id;
    ?>
" />
								</span>
			
								<span class="customer-user-id info-item editable">
									<?php 
    if (intval($customer->user_id) > 0) {
        ?>
										<span data-key="user_id"><?php 
        echo $customer->user_id;
        ?>
</span>
									<?php 
    } else {
        ?>
										<span data-key="user_id"><?php 
        _e('none', 'give');
        ?>
</span>
									<?php 
    }
    ?>
									<?php 
    if (current_user_can($customer_edit_role) && intval($customer->user_id) > 0) {
        ?>
										<span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" title="<?php 
        _e('Disconnects the current user ID from this customer record', 'give');
        ?>
"><?php 
        _e('Disconnect User', 'give');
        ?>
</a></span>
									<?php 
    }
    ?>
								</span>
							</td>
						</tr>
						<tr>
							<td><?php 
    esc_attr_e('Address', 'give');
    ?>
</td>
							<td class="row-title">

								<div class="customer-address-wrapper">

									<?php 
    if (isset($customer->user_id) && $customer->user_id > 0) {
        ?>

										<?php 
        $address = get_user_meta($customer->user_id, '_give_user_address', true);
        $defaults = array('line1' => '', 'line2' => '', 'city' => '', 'state' => '', 'country' => '', 'zip' => '');
        $address = wp_parse_args($address, $defaults);
        ?>

										<?php 
        if (!empty($address)) {
            ?>
											<span class="customer-address info-item editable">
												<span class="info-item" data-key="line1"><?php 
            echo $address['line1'];
            ?>
</span><br>
												<span class="info-item" data-key="line2"><?php 
            echo $address['line2'];
            ?>
</span><br>
												<span class="info-item" data-key="city">City: <?php 
            echo $address['city'];
            ?>
</span><br>
												<span class="info-item" data-key="state">State: <?php 
            echo $address['state'];
            ?>
</span><br>
												<span class="info-item" data-key="country">Country: <?php 
            echo $address['country'];
            ?>
</span><br>
												<span class="info-item" data-key="zip">Zip: <?php 
            echo $address['zip'];
            ?>
</span><br>
											</span>
										<?php 
        }
        ?>
										<span class="customer-address info-item edit-item">
											<input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php 
        _e('Address 1', 'give');
        ?>
" value="<?php 
        echo $address['line1'];
        ?>
" />
											<input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php 
        _e('Address 2', 'give');
        ?>
" value="<?php 
        echo $address['line2'];
        ?>
" />
											<input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php 
        _e('City', 'give');
        ?>
" value="<?php 
        echo $address['city'];
        ?>
" />
											<select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item">
												<?php 
        $selected_country = $address['country'];
        $countries = give_get_country_list();
        foreach ($countries as $country_code => $country) {
            echo '<option value="' . esc_attr($country_code) . '"' . selected($country_code, $selected_country, false) . '>' . $country . '</option>';
        }
        ?>
											</select>
											<?php 
        $selected_state = give_get_state();
        $states = give_get_states($selected_country);
        $selected_state = isset($address['state']) ? $address['state'] : $selected_state;
        if (!empty($states)) {
            ?>
												<select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item">
													<?php 
            foreach ($states as $state_code => $state) {
                echo '<option value="' . $state_code . '"' . selected($state_code, $selected_state, false) . '>' . $state . '</option>';
            }
            ?>
												</select>
											<?php 
        } else {
            ?>
												<input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php 
            _e('State / Province', 'give');
            ?>
" />
											<?php 
        }
        ?>
											<input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php 
        _e('Postal', 'give');
        ?>
" value="<?php 
        echo $address['zip'];
        ?>
" />
													</span>
									<?php 
    } else {
        echo "none";
    }
    ?>
								</div>


							</td>
						</tr>
						</tbody>
					</table>


				</div>


			</div>

			<span id="customer-edit-actions" class="edit-item">
				<input type="hidden" data-key="id" name="customerinfo[id]" value="<?php 
    echo $customer->id;
    ?>
" />
				<?php 
    wp_nonce_field('edit-customer', '_wpnonce', false, true);
    ?>
				<input type="hidden" name="give_action" value="edit-customer" />
				<input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php 
    _e('Update Donor', 'give');
    ?>
" />
				<a id="give-edit-customer-cancel" href="" class="delete"><?php 
    _e('Cancel', 'give');
    ?>
</a>
			</span>

		</form>
	</div>

	<?php 
    do_action('give_donor_before_stats', $customer);
    ?>

	<div id="customer-stats-wrapper" class="customer-section postbox clear">
		<ul>
			<li>
				<a title="<?php 
    _e('View All Purchases', 'give');
    ?>
" href="<?php 
    echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='******'%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give'), $customer->purchase_count);
    ?>
				</a>
			</li>
			<li>
				<span class="dashicons dashicons-chart-area"></span>
				<?php 
    echo give_currency_filter(give_format_amount($customer->purchase_value));
    ?>
 <?php 
    _e('Lifetime Donations', 'give');
    ?>
			</li>
			<?php 
    do_action('give_donor_stats_list', $customer);
    ?>
		</ul>
	</div>

	<?php 
    do_action('give_donor_before_tables_wrapper', $customer);
    ?>

	<div id="customer-tables-wrapper" class="customer-section">

		<?php 
    do_action('give_donor_before_tables', $customer);
    ?>

		<h3><?php 
    _e('Recent Donations', 'give');
    ?>
</h3>
		<?php 
    $payment_ids = explode(',', $customer->payment_ids);
    $payments = give_get_payments(array('post__in' => $payment_ids));
    $payments = array_slice($payments, 0, 10);
    ?>
		<table class="wp-list-table widefat striped payments">
			<thead>
			<tr>
				<th><?php 
    _e('ID', 'give');
    ?>
</th>
				<th><?php 
    _e('Amount', 'give');
    ?>
</th>
				<th><?php 
    _e('Date', 'give');
    ?>
</th>
				<th><?php 
    _e('Status', 'give');
    ?>
</th>
				<th><?php 
    _e('Actions', 'give');
    ?>
</th>
			</tr>
			</thead>
			<tbody>
			<?php 
    if (!empty($payments)) {
        ?>
				<?php 
        foreach ($payments as $payment) {
            ?>
					<tr>
						<td><?php 
            echo $payment->ID;
            ?>
</td>
						<td><?php 
            echo give_payment_amount($payment->ID);
            ?>
</td>
						<td><?php 
            echo date_i18n(get_option('date_format'), strtotime($payment->post_date));
            ?>
</td>
						<td><?php 
            echo give_get_payment_status($payment, true);
            ?>
</td>
						<td>
							<a title="<?php 
            _e('View Details for Donation', 'give');
            echo ' ' . $payment->ID;
            ?>
" href="<?php 
            echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment->ID);
            ?>
">
								<?php 
            _e('View Details', 'give');
            ?>
							</a>
							<?php 
            do_action('give_donor_recent_purchases_actions', $customer, $payment);
            ?>
						</td>
					</tr>
				<?php 
        }
        ?>
			<?php 
    } else {
        ?>
				<tr>
					<td colspan="5"><?php 
        _e('No Donations Found', 'give');
        ?>
</td>
				</tr>
			<?php 
    }
    ?>
			</tbody>
		</table>

		<h3><?php 
    _e('Completed Donations', 'give');
    ?>
</h3>
		<?php 
    $donations = give_get_users_completed_donations($customer->email);
    ?>
		<table class="wp-list-table widefat striped downloads">
			<thead>
			<tr>
				<th><?php 
    echo give_get_forms_label_singular();
    ?>
</th>
				<th width="120px"><?php 
    _e('Actions', 'give');
    ?>
</th>
			</tr>
			</thead>
			<tbody>
			<?php 
    if (!empty($donations)) {
        ?>
				<?php 
        foreach ($donations as $donation) {
            ?>
					<tr>
						<td><?php 
            echo $donation->post_title;
            ?>
</td>
						<td>
							<a title="<?php 
            echo esc_attr(sprintf(__('View %s', 'give'), $donation->post_title));
            ?>
" href="<?php 
            echo esc_url(admin_url('post.php?action=edit&post=' . $donation->ID));
            ?>
">
								<?php 
            printf(__('View %s', 'give'), give_get_forms_label_singular());
            ?>
							</a>
						</td>
					</tr>
				<?php 
        }
        ?>
			<?php 
    } else {
        ?>
				<tr>
					<td colspan="2"><?php 
        _e('No Completed Donations Found', 'give');
        ?>
</td>
				</tr>
			<?php 
    }
    ?>
			</tbody>
		</table>

		<?php 
    do_action('give_donor_after_tables', $customer);
    ?>

	</div>

	<?php 
    do_action('give_donor_card_bottom', $customer);
    ?>

<?php 
}
Example #20
0
    /**
     * This function renders most of the columns in the list table.
     *
     * @access public
     * @since  1.0
     *
     * @param Give_Payment $payment Payment ID.
     * @param string       $column_name The name of the column
     *
     * @return string Column Name
     */
    public function column_default($payment, $column_name)
    {
        $single_donation_url = esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details')));
        $row_actions = $this->get_row_actions($payment);
        switch ($column_name) {
            case 'donation':
                ob_start();
                ?>
				<a href="<?php 
                echo $single_donation_url;
                ?>
" data-tooltip="<?php 
                esc_html_e('View details', 'give');
                ?>
">#<?php 
                echo $payment->ID;
                ?>
</a>&nbsp;<?php 
                _e('by', 'give');
                ?>
&nbsp;<?php 
                echo $this->get_donor($payment);
                ?>
				<br>
				<?php 
                echo $this->get_donor_email($payment);
                ?>
				<?php 
                echo $this->row_actions($row_actions);
                ?>
				<?php 
                $value = ob_get_clean();
                break;
            case 'amount':
                $amount = !empty($payment->total) ? $payment->total : 0;
                $value = give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment->ID));
                break;
            case 'donation_form':
                $value = '<a href="' . admin_url('post.php?post=' . $payment->form_id . '&action=edit') . '">' . $payment->form_title . '</a>';
                $level = give_get_payment_form_title($payment->meta, true);
                if (!empty($level)) {
                    $value .= $level;
                }
                break;
            case 'date':
                $date = strtotime($payment->date);
                $value = date_i18n(get_option('date_format'), $date);
                break;
            case 'status':
                $value = $this->get_payment_status($payment);
                break;
            case 'details':
                $value = '<div class="give-payment-details-link-wrap"><a href="' . $single_donation_url . '" data-tooltip="' . __('View details', 'give') . '" class="give-payment-details-link button button-small" title="' . __('View Details', 'give') . '"><span class="dashicons dashicons-visibility"></span></a></div>';
                break;
            default:
                $value = isset($payment->{$column_name}) ? $payment->{$column_name} : '';
                break;
        }
        return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name);
    }
Example #21
0
/**
 * Sales Summary Dashboard Widget
 *
 * @descriptions: Builds and renders the statistics dashboard widget. This widget displays the current month's donations.
 *
 * @since       1.0
 * @return void
 */
function give_dashboard_sales_widget()
{
    if (!current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) {
        return;
    }
    $stats = new Give_Payment_Stats();
    ?>

	<div class="give-dashboard-widget">

		<div class="give-dashboard-today give-clearfix">
			<h3 class="give-dashboard-date-today"><?php 
    echo date('F j, Y');
    ?>
</h3>

			<p class="give-dashboard-happy-day"><?php 
    printf(__('Happy %1$s!', 'give'), date('l', current_time('timestamp')));
    ?>
</p>

			<?php 
    $earnings_today = $stats->get_earnings(0, 'today', false);
    ?>

			<p class="give-dashboard-today-earnings"><?php 
    echo give_currency_filter(give_format_amount($earnings_today));
    ?>
</p>

			<p class="give-orders-today"><?php 
    $donations_today = $stats->get_sales(0, 'today', false, array('publish', 'revoked'));
    echo give_format_amount($donations_today, false);
    ?>
				<span><?php 
    echo _x('donations today', 'Displays in WP admin dashboard widget after the day\'s total donations', 'give');
    ?>
</span>
			</p>


		</div>


		<table class="give-table-stats">
			<thead style="display: none;">
			<tr>
				<th><?php 
    _e('This Week', 'give');
    ?>
</th>
				<th><?php 
    _e('This Month', 'give');
    ?>
</th>
				<th><?php 
    _e('Past 30 Days', 'give');
    ?>
</th>
			</tr>
			</thead>
			<tbody>
			<tr id="give-table-stats-tr-1">
				<td>
					<p class="give-dashboard-stat-total"><?php 
    echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week')));
    ?>
</p>

					<p class="give-dashboard-stat-total-label"><?php 
    _e('this week', 'give');
    ?>
</p>
				</td>
				<td>
					<p class="give-dashboard-stat-total"><?php 
    echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month')));
    ?>
</p>

					<p class="give-dashboard-stat-total-label"><?php 
    _e('this month', 'give');
    ?>
</p>
				</td>
			</tr>
			<tr id="give-table-stats-tr-2">
				<td>
					<p class="give-dashboard-stat-total"><?php 
    echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month')));
    ?>
</p>

					<p class="give-dashboard-stat-total-label"><?php 
    _e('last month', 'give');
    ?>
</p>
				</td>
				<td>
					<p class="give-dashboard-stat-total"><?php 
    echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_year', false)));
    ?>
</p>

					<p class="give-dashboard-stat-total-label"><?php 
    _e('this year', 'give');
    ?>
</p>
				</td>
			</tr>
			</tbody>
		</table>

	</div>

<?php 
}
Example #22
0
/**
 * Show report graphs of a specific product
 *
 * @since 1.0
 * @return void
 */
function give_reports_graph_of_form($form_id = 0)
{
    // Retrieve the queried dates
    $dates = give_get_report_dates();
    // Determine graph options
    switch ($dates['range']) {
        case 'today':
        case 'yesterday':
            $day_by_day = true;
            break;
        case 'last_year':
            $day_by_day = false;
            break;
        case 'this_year':
            $day_by_day = false;
            break;
        case 'last_quarter':
            $day_by_day = false;
            break;
        case 'this_quarter':
            $day_by_day = false;
            break;
        case 'other':
            if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) {
                $day_by_day = false;
            } else {
                $day_by_day = true;
            }
            break;
        default:
            $day_by_day = true;
            break;
    }
    $earnings_totals = (double) 0.0;
    // Total earnings for time period shown
    $sales_totals = 0;
    // Total sales for time period shown
    $earnings_data = array();
    $sales_data = array();
    $stats = new Give_Payment_Stats();
    if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
        // Hour by hour
        $month = $dates['m_start'];
        $hour = 1;
        $minute = 0;
        $second = 0;
        while ($hour <= 23) {
            if ($hour == 23) {
                $minute = $second = 59;
            }
            $date = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']);
            $date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']);
            $sales = $stats->get_sales($form_id, $date, $date_end);
            $sales_totals += $sales;
            $earnings = $stats->get_earnings($form_id, $date, $date_end);
            $earnings_totals += $earnings;
            $sales_data[] = array($date * 1000, $sales);
            $earnings_data[] = array($date * 1000, $earnings);
            $hour++;
        }
    } elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
        //Day by day
        $day = $dates['day'];
        $day_end = $dates['day_end'];
        $month = $dates['m_start'];
        while ($day <= $day_end) {
            $date = mktime(0, 0, 0, $month, $day, $dates['year']);
            $date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']);
            $sales = $stats->get_sales($form_id, $date, $date_end);
            $sales_totals += $sales;
            $earnings = $stats->get_earnings($form_id, $date, $date_end);
            $earnings_totals += $earnings;
            $sales_data[] = array($date * 1000, $sales);
            $earnings_data[] = array($date * 1000, $earnings);
            $day++;
        }
    } else {
        $y = $dates['year'];
        while ($y <= $dates['year_end']) {
            $last_year = false;
            if ($dates['year'] == $dates['year_end']) {
                $month_start = $dates['m_start'];
                $month_end = $dates['m_end'];
                $last_year = true;
            } elseif ($y == $dates['year']) {
                $month_start = $dates['m_start'];
                $month_end = 12;
            } else {
                $month_start = 1;
                $month_end = 12;
            }
            $i = $month_start;
            while ($i <= $month_end) {
                if ($day_by_day) {
                    if ($i == $month_end && $last_year) {
                        $num_of_days = $dates['day_end'];
                    } else {
                        $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
                    }
                    $d = $dates['day'];
                    while ($d <= $num_of_days) {
                        $date = mktime(0, 0, 0, $i, $d, $y);
                        $end_date = mktime(23, 59, 59, $i, $d, $y);
                        $sales = $stats->get_sales($form_id, $date, $end_date);
                        $sales_totals += $sales;
                        $earnings = $stats->get_earnings($form_id, $date, $end_date);
                        $earnings_totals += $earnings;
                        $sales_data[] = array($date * 1000, $sales);
                        $earnings_data[] = array($date * 1000, $earnings);
                        $d++;
                    }
                } else {
                    $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
                    $date = mktime(0, 0, 0, $i, 1, $y);
                    $end_date = mktime(23, 59, 59, $i, $num_of_days, $y);
                    $sales = $stats->get_sales($form_id, $date, $end_date);
                    $sales_totals += $sales;
                    $earnings = $stats->get_earnings($form_id, $date, $end_date);
                    $earnings_totals += $earnings;
                    $sales_data[] = array($date * 1000, $sales);
                    $earnings_data[] = array($date * 1000, $earnings);
                }
                $i++;
            }
            $y++;
        }
    }
    $data = array(__('Income', 'give') => $earnings_data, __('Donations', 'give') => $sales_data);
    ?>
	<h3><span><?php 
    printf(__('Income Over Time for %s', 'give'), get_the_title($form_id));
    ?>
</span></h3>

	<div class="metabox-holder" style="padding-top: 0;">
		<div class="postbox">
			<div class="inside">
				<?php 
    $graph = new Give_Graph($data);
    $graph->set('x_mode', 'time');
    $graph->set('multiple_y_axes', true);
    $graph->display();
    ?>
			</div>
		</div>
		<!--/.postbox -->
		<table class="widefat reports-table alignleft" style="max-width:450px">
			<tbody>
			<tr>
				<td class="row-title">
					<label for="tablecell"><?php 
    _e('Total income for period: ', 'give');
    ?>
</label></td>
				<td><?php 
    echo give_currency_filter(give_format_amount($earnings_totals));
    ?>
</td>
			</tr>
			<tr class="alternate">
				<td class="row-title">
					<label for="tablecell"><?php 
    _e('Total donations for period: ', 'give');
    ?>
</label>
				</td>
				<td><?php 
    echo $sales_totals;
    ?>
</td>
			</tr>
			<tr>
				<td class="row-title">
					<label for="tablecell"><?php 
    _e('Average monthly income: %s', 'give');
    ?>
</label>
				</td>
				<td><?php 
    echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id)));
    ?>
</td>
			</tr>
			<tr class="alternate">
				<td class="row-title">
					<label for="tablecell"><?php 
    _e('Average monthly donations: %s', 'give');
    ?>
</label>
				</td>
				<td><?php 
    echo number_format(give_get_average_monthly_form_sales($form_id), 0);
    ?>
</td>
			</tr>
			</tbody>
		</table>
		<?php 
    give_reports_graph_controls();
    ?>
	</div>
	<?php 
    echo ob_get_clean();
}
Example #23
0
/**
 * Purchase Form Validate Gateway
 *
 * Validate the gateway and donation amount
 *
 * @access      private
 * @since       1.0
 * @return      string
 */
function give_purchase_form_validate_gateway()
{
    $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
    $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
    $gateway = give_get_default_gateway($form_id);
    // Check if a gateway value is present
    if (!empty($_REQUEST['give-gateway'])) {
        $gateway = sanitize_text_field($_REQUEST['give-gateway']);
        //Is amount being donated in LIVE mode 0.00? If so, error:
        if ($amount == 0 && !give_is_test_mode()) {
            give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give'));
        } elseif (!give_verify_minimum_price()) {
            give_set_error('invalid_donation_minimum', sprintf(esc_html__('This form has a minimum donation amount of %s.', 'give'), give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))));
        } elseif ($amount == 0 && give_is_test_mode()) {
            $gateway = 'manual';
        } elseif (!give_is_gateway_active($gateway)) {
            give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give'));
        }
    }
    return $gateway;
}
 /**
  * Build all the reports data
  *
  * @access public
  * @since  1.0
  * @return array $reports_data All the data for donor reports
  */
 public function reports_data()
 {
     $reports_data = array();
     $gateways = give_get_payment_gateways();
     $stats = new Give_Payment_Stats();
     foreach ($gateways as $gateway_id => $gateway) {
         $complete_count = give_count_sales_by_gateway($gateway_id, 'publish');
         $pending_count = give_count_sales_by_gateway($gateway_id, array('pending', 'failed'));
         $reports_data[] = array('ID' => $gateway_id, 'label' => $gateway['admin_label'], 'complete_sales' => give_format_amount($complete_count, false), 'pending_sales' => give_format_amount($pending_count, false), 'total_sales' => give_format_amount($complete_count + $pending_count, false), 'total_donations' => give_currency_filter(give_format_amount($stats->get_earnings(0, 0, 0, $gateway_id))));
     }
     return $reports_data;
 }
Example #25
0
/**
 * Check for Price Variations (Multi-level donation forms)
 *
 * @since  1.5
 *
 * @return void
 */
function give_check_for_form_price_variations()
{
    if (!current_user_can('edit_give_forms', get_current_user_id())) {
        die('-1');
    }
    $form_id = intval($_POST['form_id']);
    $form = get_post($form_id);
    if ('give_forms' != $form->post_type) {
        die('-2');
    }
    if (give_has_variable_prices($form_id)) {
        $variable_prices = give_get_variable_prices($form_id);
        if ($variable_prices) {
            $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
            if (isset($_POST['all_prices'])) {
                $ajax_response .= '<option value="">' . esc_html__('All Levels', 'give') . '</option>';
            }
            foreach ($variable_prices as $key => $price) {
                $level_text = !empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount']));
                $ajax_response .= '<option value="' . esc_attr($price['_give_id']['level_id']) . '">' . $level_text . '</option>';
            }
            $ajax_response .= '</select>';
            echo $ajax_response;
        }
    }
    give_die();
}
 /**
  * Get the Export Data
  *
  * @access public
  * @since  1.0
  * @return array $data The data for the CSV file
  */
 public function get_data()
 {
     $start_year = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y');
     $end_year = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y');
     $start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n');
     $end_month = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n');
     $data = array();
     $year = $start_year;
     $stats = new Give_Payment_Stats();
     while ($year <= $end_year) {
         if ($year == $start_year && $year == $end_year) {
             $m1 = $start_month;
             $m2 = $end_month;
         } elseif ($year == $start_year) {
             $m1 = $start_month;
             $m2 = 12;
         } elseif ($year == $end_year) {
             $m1 = 1;
             $m2 = $end_month;
         } else {
             $m1 = 1;
             $m2 = 12;
         }
         while ($m1 <= $m2) {
             $date1 = mktime(0, 0, 0, $m1, 1, $year);
             $date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year);
             $data[] = array('date' => date_i18n('F Y', $date1), 'donations' => $stats->get_sales(0, $date1, $date2), 'earnings' => give_format_amount($stats->get_earnings(0, $date1, $date2)));
             $m1++;
         }
         $year++;
     }
     $data = apply_filters('give_export_get_data', $data);
     $data = apply_filters('give_export_get_data_' . $this->export_type, $data);
     return $data;
 }
Example #27
0
}
$progress = round($income / $goal * 100, 2);
if ($income >= $goal) {
    $progress = 100;
}
?>
<div class="give-goal-progress">
    <?php 
if (!empty($show_text)) {
    ?>
        <div class="raised">
            <?php 
    if ($goal_format !== 'percentage') {
        // Get formatted amount.
        $income = give_human_format_large_amount(give_format_amount($income));
        $goal = give_human_format_large_amount(give_format_amount($goal));
        echo sprintf(__('%1$s of %2$s raised', 'give'), '<span class="income">' . apply_filters('give_goal_amount_raised_output', give_currency_filter($income)) . '</span>', '<span class="goal-text">' . apply_filters('give_goal_amount_target_output', give_currency_filter($goal)) . '</span>');
    } elseif ($goal_format == 'percentage') {
        echo sprintf(__('%s%% funded', 'give'), '<span class="give-percentage">' . apply_filters('give_goal_amount_funded_percentage_output', round($progress)) . '</span>');
    }
    ?>
        </div>
    <?php 
}
?>


    <?php 
if (!empty($show_bar)) {
    ?>
        <div class="give-progress-bar">
    _e('Fees', 'give');
    ?>
:</strong></td>
				<td>
					<ul class="give_receipt_fees">
						<?php 
    foreach ($fees as $fee) {
        ?>
							<li>
								<span class="give_fee_label"><?php 
        echo esc_html($fee['label']);
        ?>
</span>
								<span class="give_fee_sep">&nbsp;&ndash;&nbsp;</span>
								<span class="give_fee_amount"><?php 
        echo give_currency_filter(give_format_amount($fee['amount']));
        ?>
</span>
							</li>
						<?php 
    }
    ?>
					</ul>
				</td>
			</tr>
		<?php 
}
?>

		<?php 
if (filter_var($give_receipt_args['price'], FILTER_VALIDATE_BOOLEAN)) {
Example #29
0
/**
 * Generate PDF Reports.
 *
 * Generates PDF report on donations and income for all forms for the current year.
 *
 * @since  1.0
 *
 * @param string $data
 *
 * @uses   give_pdf
 */
function give_generate_pdf($data)
{
    if (!current_user_can('view_give_reports')) {
        wp_die(esc_html__('You do not have permission to generate PDF sales reports.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
    }
    if (!wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) {
        wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
    }
    require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php';
    require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/give_pdf.php';
    $daterange = utf8_decode(sprintf(esc_html__('%1$s to %2$s', 'give'), date_i18n(get_option('date_format'), mktime(0, 0, 0, 1, 1, date('Y'))), date_i18n(get_option('date_format'))));
    $pdf = new give_pdf();
    $pdf->AddPage('L', 'A4');
    $pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give')));
    $pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give')));
    $pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give')));
    $pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png'), 247, 8);
    $pdf->SetMargins(8, 8, 8);
    $pdf->SetX(8);
    $pdf->SetFont('Helvetica', '', 16);
    $pdf->SetTextColor(50, 50, 50);
    $pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false);
    $pdf->SetFont('Helvetica', '', 13);
    $pdf->Ln();
    $pdf->SetTextColor(150, 150, 150);
    $pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')) . $daterange, 0, 2, 'L', false);
    $pdf->Ln();
    $pdf->SetTextColor(50, 50, 50);
    $pdf->SetFont('Helvetica', '', 14);
    $pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false);
    $pdf->SetFont('Helvetica', '', 12);
    $pdf->SetFillColor(238, 238, 238);
    $pdf->Cell(70, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true);
    $pdf->Cell(30, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true);
    $pdf->Cell(50, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true);
    $pdf->Cell(50, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true);
    $pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true);
    $pdf->Cell(35, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true);
    $year = date('Y');
    $give_forms = get_posts(array('post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => -1));
    if ($give_forms) {
        $pdf->SetWidths(array(70, 30, 50, 50, 45, 35));
        foreach ($give_forms as $form) {
            $pdf->SetFillColor(255, 255, 255);
            $title = $form->post_title;
            if (give_has_variable_prices($form->ID)) {
                $prices = give_get_variable_prices($form->ID);
                $first = $prices[0]['_give_amount'];
                $last = array_pop($prices);
                $last = $last['_give_amount'];
                if ($first < $last) {
                    $min = $first;
                    $max = $last;
                } else {
                    $min = $last;
                    $max = $first;
                }
                $price = html_entity_decode(give_currency_filter(give_format_amount($min)) . ' - ' . give_currency_filter(give_format_amount($max)));
            } else {
                $price = html_entity_decode(give_currency_filter(give_get_form_price($form->ID)));
            }
            $categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', '');
            $categories = !is_wp_error($categories) ? strip_tags($categories) : '';
            $tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', '');
            $tags = !is_wp_error($tags) ? strip_tags($tags) : '';
            $sales = give_get_form_sales_stats($form->ID);
            $link = get_permalink($form->ID);
            $earnings = html_entity_decode(give_currency_filter(give_get_form_earnings_stats($form->ID)));
            if (function_exists('iconv')) {
                // Ensure characters like euro; are properly converted.
                $price = iconv('UTF-8', 'windows-1252', utf8_encode($price));
                $earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings));
            }
            $pdf->Row(array($title, $price, $categories, $tags, $sales, $earnings));
        }
    } else {
        $pdf->SetWidths(array(280));
        $title = utf8_decode(sprintf(esc_html__('No %s found.', 'give'), give_get_forms_label_plural()));
        $pdf->Row(array($title));
    }
    $pdf->Ln();
    $pdf->SetTextColor(50, 50, 50);
    $pdf->SetFont('Helvetica', '', 14);
    $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false);
    $pdf->SetFont('Helvetica', '', 12);
    $image = html_entity_decode(urldecode(give_draw_chart_image()));
    $image = str_replace(' ', '%20', $image);
    $pdf->SetX(25);
    $pdf->Image($image . '&file=.png');
    $pdf->Ln(7);
    $pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n('Y-m-d')) . '.pdf', 'D');
}
 /**
  * This function renders most of the columns in the list table.
  *
  * @access public
  * @since  1.0
  *
  * @param array  $item        Contains all the data of the discount code
  * @param string $column_name The name of the column
  *
  * @return string Column Name
  */
 public function column_default($payment, $column_name)
 {
     switch ($column_name) {
         case 'amount':
             $amount = !empty($payment->total) ? $payment->total : 0;
             $value = give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment->ID));
             break;
         case 'date':
             $date = strtotime($payment->date);
             $value = date_i18n(get_option('date_format'), $date);
             break;
         case 'status':
             $payment = get_post($payment->ID);
             $value = '<div class="give-donation-status status-' . sanitize_title(give_get_payment_status($payment, true)) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status($payment, true) . '</div>';
             break;
         case 'details':
             $value = '<div class="give-payment-details-link-wrap"><a href="' . esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details'))) . '" class="give-payment-details-link button button-small">' . __('View Donation Details', 'give') . '</a></div>';
             break;
         default:
             $value = isset($payment->{$column_name}) ? $payment->{$column_name} : '';
             break;
     }
     return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name);
 }