/**
  * Set the CSV columns.
  *
  * @access public
  * @since 1.5
  * @return array $cols All the columns.
  */
 public function csv_cols()
 {
     $cols = array('id' => esc_html__('ID', 'give'), 'seq_id' => esc_html__('Payment Number', 'give'), 'email' => esc_html__('Email', 'give'), 'first' => esc_html__('First Name', 'give'), 'last' => esc_html__('Last Name', 'give'), 'address1' => esc_html__('Address', 'give'), 'address2' => esc_html__('Address (Line 2)', 'give'), 'city' => esc_html__('City', 'give'), 'state' => esc_html__('State', 'give'), 'country' => esc_html__('Country', 'give'), 'zip' => esc_html__('Zip / Postal Code', 'give'), 'form_id' => esc_html__('Form ID', 'give'), 'form_name' => esc_html__('Form Name', 'give'), 'amount' => esc_html__('Amount', 'give') . ' (' . html_entity_decode(give_currency_filter('')) . ')', 'gateway' => esc_html__('Payment Method', 'give'), 'trans_id' => esc_html__('Transaction ID', 'give'), 'key' => esc_html__('Purchase Key', 'give'), 'date' => esc_html__('Date', 'give'), 'user' => esc_html__('User', 'give'), 'status' => esc_html__('Status', 'give'));
     if (!give_get_option('enable_sequential')) {
         unset($cols['seq_id']);
     }
     return $cols;
 }
 /**
  * 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];
     }
 }
 /**
  * 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];
     }
 }
/**
 * 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))));
    }
}
 /**
  * Set the CSV columns
  *
  * @access public
  * @since  1.0
  * @return array $cols All the columns
  */
 public function csv_cols()
 {
     if (!empty($_POST['give_export_download'])) {
         $cols = array('first_name' => __('First Name', 'give'), 'last_name' => __('Last Name', 'give'), 'email' => __('Email', 'give'), 'date' => __('Date Donated', 'give'));
     } else {
         $cols = array();
         if ('emails' != $_POST['give_export_option']) {
             $cols['name'] = __('Name', 'give');
         }
         $cols['email'] = __('Email', 'give');
         if ('full' == $_POST['give_export_option']) {
             $cols['purchases'] = __('Total Donations', 'give');
             $cols['amount'] = __('Total Donated', 'give') . ' (' . html_entity_decode(give_currency_filter('')) . ')';
         }
     }
     return $cols;
 }
 /**
  * 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];
     }
 }
Beispiel #7
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);
}
/**
 * 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');
}
Beispiel #9
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 -->
    _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)) {
 /**
  * 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);
 }
Beispiel #12
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);
}
Beispiel #13
0
/**
 * Load Admin Scripts
 *
 * Enqueues the required admin scripts.
 *
 * @since 1.0
 *
 * @global       $post
 * @global       $give_options
 *
 * @param string $hook Page hook
 *
 * @return void
 */
function give_load_admin_scripts($hook)
{
    global $wp_version, $post, $post_type, $give_options;
    //Directories of assets
    $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/';
    $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
    $css_dir = GIVE_PLUGIN_URL . 'assets/css/';
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    //Global Admin:
    wp_register_style('give-admin-bar-notification', $css_dir . 'adminbar-style.css');
    wp_enqueue_style('give-admin-bar-notification');
    //Give Admin Only:
    if (!apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) {
        return;
    }
    //CSS
    wp_register_style('jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css');
    wp_enqueue_style('jquery-ui-css');
    wp_register_style('give-admin', $css_dir . 'give-admin' . $suffix . '.css', GIVE_VERSION);
    wp_enqueue_style('give-admin');
    wp_register_style('jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION);
    wp_enqueue_style('jquery-chosen');
    wp_enqueue_style('thickbox');
    //JS
    wp_register_script('jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array('jquery'), GIVE_VERSION);
    wp_enqueue_script('jquery-chosen');
    wp_register_script('give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
    wp_enqueue_script('give-accounting');
    wp_register_script('give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
    wp_enqueue_script('give-admin-scripts');
    wp_register_script('jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js');
    wp_enqueue_script('jquery-flot');
    wp_register_script('give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
    wp_enqueue_script('give-qtip');
    wp_enqueue_script('jquery-ui-datepicker');
    wp_enqueue_script('thickbox');
    // Forms CPT Script.
    if ($post_type === 'give_forms') {
        wp_register_script('give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
        wp_enqueue_script('give-admin-forms-scripts');
    }
    //Settings Scripts
    if (isset($_GET['page']) && $_GET['page'] == 'give-settings') {
        wp_register_script('give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
        wp_enqueue_script('give-admin-settings-scripts');
    }
    // Price Separators.
    $thousand_separator = give_get_price_thousand_separator();
    $decimal_separator = give_get_price_decimal_separator();
    //Localize strings & variables for JS
    wp_localize_script('give-admin-scripts', 'give_vars', array('post_id' => isset($post->ID) ? $post->ID : null, 'give_version' => GIVE_VERSION, 'thousands_separator' => $thousand_separator, 'decimal_separator' => $decimal_separator, 'quick_edit_warning' => esc_html__('Sorry, not available for variable priced forms.', 'give'), 'delete_payment' => esc_html__('Are you sure you wish to delete this payment?', 'give'), 'delete_payment_note' => esc_html__('Are you sure you wish to delete this note?', 'give'), 'revoke_api_key' => esc_html__('Are you sure you wish to revoke this API key?', 'give'), 'regenerate_api_key' => esc_html__('Are you sure you wish to regenerate this API key?', 'give'), 'resend_receipt' => esc_html__('Are you sure you wish to resend the donation receipt?', 'give'), 'copy_download_link_text' => esc_html__('Copy these links to your clipboard and give them to your donor.', 'give'), 'delete_payment_download' => sprintf(esc_html__('Are you sure you wish to delete this %s?', 'give'), give_get_forms_label_singular()), 'one_price_min' => esc_html__('You must have at least one price.', 'give'), 'one_file_min' => esc_html__('You must have at least one file.', 'give'), 'one_field_min' => esc_html__('You must have at least one field.', 'give'), 'one_option' => sprintf(esc_html__('Choose a %s', 'give'), give_get_forms_label_singular()), 'one_or_more_option' => sprintf(esc_html__('Choose one or more %s', 'give'), give_get_forms_label_plural()), 'numeric_item_price' => esc_html__('Item price must be numeric.', 'give'), 'numeric_quantity' => esc_html__('Quantity must be numeric.', 'give'), 'currency_sign' => give_currency_filter(''), 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', 'currency_decimals' => give_currency_decimal_filter(give_get_price_decimals()), 'new_media_ui' => apply_filters('give_use_35_media_ui', 1), 'remove_text' => esc_html__('Remove', 'give'), 'type_to_search' => sprintf(esc_html__('Type to search %s', 'give'), give_get_forms_label_plural()), 'batch_export_no_class' => esc_html__('You must choose a method.', 'give'), 'batch_export_no_reqs' => esc_html__('Required fields not completed.', 'give'), 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), 'price_format_guide' => sprintf(esc_html__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator)));
    if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) {
        //call for new media manager
        wp_enqueue_media();
    }
}
/**
 * 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');
}
Beispiel #15
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 
}
 /**
  * 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;
 }
Beispiel #17
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;
}
 /**
  * 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']);
 }
 /**
  * Set the CSV columns
  *
  * @access public
  * @since  1.0
  * @return array $cols All the columns
  */
 public function csv_cols()
 {
     $cols = array('date' => esc_html__('Date', 'give'), 'donations' => esc_html__('Donations', 'give'), 'earnings' => sprintf(esc_html__('Income (%s)', 'give'), html_entity_decode(give_currency_filter(''))));
     return $cols;
 }
 /**
  * Set the CSV columns
  *
  * @access public
  * @since  1.0
  * @return array $cols All the columns
  */
 public function csv_cols()
 {
     $cols = array('date' => __('Date', 'give'), 'donations' => __('Donations', 'give'), 'earnings' => __('Income', 'give') . ' (' . html_entity_decode(give_currency_filter('')) . ')');
     return $cols;
 }
Beispiel #21
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);
}
Beispiel #22
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;
}
Beispiel #23
0
/**
 * Load Admin Scripts
 *
 * Enqueues the required admin scripts.
 *
 * @since 1.0
 * @global       $post
 *
 * @param string $hook Page hook
 *
 * @return void
 */
function give_load_admin_scripts($hook)
{
    global $wp_version, $post, $post_type;
    //Directories of assets
    $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/';
    $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
    $css_dir = GIVE_PLUGIN_URL . 'assets/css/';
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    //Global Admin:
    wp_register_style('give-admin-bar-notification', $css_dir . 'adminbar-style.css');
    wp_enqueue_style('give-admin-bar-notification');
    //Give Admin Only:
    if (!apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) {
        return;
    }
    //CSS
    wp_register_style('jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css');
    wp_enqueue_style('jquery-ui-css');
    wp_register_style('give-admin', $css_dir . 'give-admin' . $suffix . '.css', GIVE_VERSION);
    wp_enqueue_style('give-admin');
    wp_register_style('jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION);
    wp_enqueue_style('jquery-chosen');
    wp_enqueue_style('thickbox');
    //JS
    wp_register_script('jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array('jquery'), GIVE_VERSION);
    wp_enqueue_script('jquery-chosen');
    wp_register_script('give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
    wp_enqueue_script('give-admin-scripts');
    wp_register_script('jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js');
    wp_enqueue_script('jquery-flot');
    wp_register_script('give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
    wp_enqueue_script('give-qtip');
    wp_enqueue_script('jquery-ui-datepicker');
    wp_enqueue_script('thickbox');
    //Forms CPT Script
    if ($post_type === 'give_forms') {
        wp_register_script('give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array('jquery'), GIVE_VERSION, false);
        wp_enqueue_script('give-admin-forms-scripts');
    }
    //Localize strings & variables for JS
    wp_localize_script('give-admin-scripts', 'give_vars', array('post_id' => isset($post->ID) ? $post->ID : null, 'give_version' => GIVE_VERSION, 'quick_edit_warning' => __('Sorry, not available for variable priced forms.', 'give'), 'delete_payment' => __('Are you sure you wish to delete this payment?', 'give'), 'delete_payment_note' => __('Are you sure you wish to delete this note?', 'give'), 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'give'), 'revoke_api_key' => __('Are you sure you wish to revoke this API key?', 'give'), 'regenerate_api_key' => __('Are you sure you wish to regenerate this API key?', 'give'), 'resend_receipt' => __('Are you sure you wish to resend the donation receipt?', 'give'), 'copy_download_link_text' => __('Copy these links to your clipboard and give them to your donor', 'give'), 'delete_payment_download' => sprintf(__('Are you sure you wish to delete this %s?', 'give'), give_get_forms_label_singular()), 'one_price_min' => __('You must have at least one price', 'give'), 'one_file_min' => __('You must have at least one file', 'give'), 'one_field_min' => __('You must have at least one field', 'give'), 'one_option' => sprintf(__('Choose a %s', 'give'), give_get_forms_label_singular()), 'one_or_more_option' => sprintf(__('Choose one or more %s', 'give'), give_get_forms_label_plural()), 'numeric_item_price' => __('Item price must be numeric', 'give'), 'numeric_quantity' => __('Quantity must be numeric', 'give'), 'currency_sign' => give_currency_filter(''), 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', 'currency_decimals' => give_currency_decimal_filter(), 'new_media_ui' => apply_filters('give_use_35_media_ui', 1), 'remove_text' => __('Remove', 'give'), 'type_to_search' => sprintf(__('Type to search %s', 'give'), give_get_forms_label_plural())));
    if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) {
        //call for new media manager
        wp_enqueue_media();
    }
}
Beispiel #24
0
/**
 * Send Offline Donation Admin Notice
 *
 * @description Sends a notice to site admins about the pending donation
 *
 * @since       1.0
 *
 * @param int $payment_id
 *
 * @return void
 *
 */
function give_offline_send_admin_notice($payment_id = 0)
{
    /* Send an email notification to the admin */
    $admin_email = give_get_admin_notice_emails();
    $user_info = give_get_payment_meta_user_info($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 = $user_info['email'];
    }
    $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id)));
    $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id);
    $admin_message = __('Dear Admin,', 'give') . "\n\n" . __('An offline donation has been made', 'give') . ".\n\n";
    $order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id);
    $admin_message .= __('Donor: ', 'give') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n";
    $admin_message .= __('Amount: ', 'give') . " " . html_entity_decode($amount, ENT_COMPAT, 'UTF-8') . "\n\n";
    $admin_message .= __('There is a new pending donation awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give') . "\n\n";
    $admin_message .= sprintf(__('View Donation Details: %s.', 'give'), $order_url) . "\n\n";
    $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id);
    $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id);
    $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id);
    wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers, $attachments);
}
Beispiel #25
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();
}
Beispiel #26
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();
}
Beispiel #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">
            <span style="width: <?php 
/**
 * 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 
}
Beispiel #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 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);
    }