<div class="inside">
									<div class="edd-admin-box">

										<?php 
do_action('edd_view_order_details_totals_before', $payment_id);
?>

										<div class="edd-admin-box-inside">
											<p>
												<span class="label"><?php 
_e('Status:', 'edd');
?>
</span>&nbsp;
												<select name="edd-payment-status" class="medium-text">
													<?php 
foreach (edd_get_payment_statuses() as $key => $status) {
    ?>
														<option value="<?php 
    echo esc_attr($key);
    ?>
"<?php 
    selected(edd_get_payment_status($item, true), $status);
    ?>
><?php 
    echo esc_html($status);
    ?>
</option>
													<?php 
}
?>
												</select>
/**
 * Renders the 'Export' tab on the Reports Page
 *
 * @since 1.3
 * @return void
 */
function edd_reports_tab_export()
{
    if (!current_user_can('view_shop_reports')) {
        return;
    }
    ?>
	<div id="edd-dashboard-widgets-wrap">
		<div class="metabox-holder">
			<div id="post-body">
				<div id="post-body-content">

					<?php 
    do_action('edd_reports_tab_export_content_top');
    ?>

					<div class="postbox edd-export-pdf-sales-earnings">
						<h3><span><?php 
    _e('Export PDF of Sales and Earnings', 'easy-digital-downloads');
    ?>
</span></h3>
						<div class="inside">
							<p><?php 
    _e('Download a PDF of Sales and Earnings reports for all products for the current year.', 'easy-digital-downloads');
    ?>
 <?php 
    _e('Date range reports will be coming soon.', 'easy-digital-downloads');
    ?>
</p>
							<p><a class="button" href="<?php 
    echo wp_nonce_url(add_query_arg(array('edd-action' => 'generate_pdf')), 'edd_generate_pdf');
    ?>
"><?php 
    _e('Generate PDF', 'easy-digital-downloads');
    ?>
</a></p>
						</div><!-- .inside -->
					</div><!-- .postbox -->

					<div class="postbox edd-export-sales-earnings">
						<h3><span><?php 
    _e('Export Earnings and Sales Stats', 'easy-digital-downloads');
    ?>
</span></h3>
						<div class="inside">
							<p><?php 
    _e('Download a CSV of earnings and sales over time.', 'easy-digital-downloads');
    ?>
</p>
							<p>
								<form method="post">
									<?php 
    echo EDD()->html->year_dropdown('start_year');
    ?>
									<?php 
    echo EDD()->html->month_dropdown('start_month');
    ?>
									<?php 
    echo _x('to', 'Date one to date two', 'easy-digital-downloads');
    ?>
									<?php 
    echo EDD()->html->year_dropdown('end_year');
    ?>
									<?php 
    echo EDD()->html->month_dropdown('end_month');
    ?>
									<?php 
    wp_nonce_field('edd_ajax_export', 'edd_ajax_export');
    ?>
									<input type="hidden" name="edd-action" value="earnings_export"/>
									<input type="submit" value="<?php 
    _e('Generate CSV', 'easy-digital-downloads');
    ?>
" class="button-secondary"/>
								</form>
							</p>
						</div><!-- .inside -->
					</div><!-- .postbox -->

					<div class="postbox edd-export-payment-history">
						<h3><span><?php 
    _e('Export Payment History', 'easy-digital-downloads');
    ?>
</span></h3>
						<div class="inside">
							<p><?php 
    _e('Download a CSV of all payments recorded.', 'easy-digital-downloads');
    ?>
</p>
							<p>
								<form id="edd-export-payments" class="edd-export-form" method="post">
									<?php 
    echo EDD()->html->date_field(array('id' => 'edd-payment-export-start', 'name' => 'start', 'placeholder' => __('Choose start date', 'easy-digital-downloads')));
    ?>
									<?php 
    echo EDD()->html->date_field(array('id' => 'edd-payment-export-end', 'name' => 'end', 'placeholder' => __('Choose end date', 'easy-digital-downloads')));
    ?>
									<select name="status">
										<option value="any"><?php 
    _e('All Statuses', 'easy-digital-downloads');
    ?>
</option>
										<?php 
    $statuses = edd_get_payment_statuses();
    foreach ($statuses as $status => $label) {
        echo '<option value="' . $status . '">' . $label . '</option>';
    }
    ?>
									</select>
									<?php 
    wp_nonce_field('edd_ajax_export', 'edd_ajax_export');
    ?>
									<input type="hidden" name="edd-export-class" value="EDD_Batch_Payments_Export"/>
									<span>
										<input type="submit" value="<?php 
    _e('Generate CSV', 'easy-digital-downloads');
    ?>
" class="button-secondary"/>
										<span class="spinner"></span>
									</span>
								</form>
							</p>
						</div><!-- .inside -->
					</div><!-- .postbox -->

					<div class="postbox edd-export-customers">
						<h3><span><?php 
    _e('Export Customers in CSV', 'easy-digital-downloads');
    ?>
</span></h3>
						<div class="inside">
							<p><?php 
    _e('Download a CSV of customers.', 'easy-digital-downloads');
    ?>
</p>
							<p>
								<form id="edd-export-customers" class="edd-export-form" method="post">
									<?php 
    echo EDD()->html->product_dropdown(array('name' => 'download', 'id' => 'edd_customer_export_download', 'chosen' => true));
    ?>
									<?php 
    wp_nonce_field('edd_ajax_export', 'edd_ajax_export');
    ?>
									<input type="hidden" name="edd-export-class" value="EDD_Batch_Customers_Export"/>
									<input type="submit" value="<?php 
    _e('Generate CSV', 'easy-digital-downloads');
    ?>
" class="button-secondary"/>
								</form>
							</p>
						</div><!-- .inside -->
					</div><!-- .postbox -->

					<div class="postbox edd-export-downloads">
						<h3><span><?php 
    _e('Export Download Products in CSV', 'easy-digital-downloads');
    ?>
</span></h3>
						<div class="inside">
							<p><?php 
    _e('Download a CSV of download products.', 'easy-digital-downloads');
    ?>
</p>
							<p>
								<form id="edd-export-file-downloads" class="edd-export-form" method="post">
									<?php 
    wp_nonce_field('edd_ajax_export', 'edd_ajax_export');
    ?>
									<input type="hidden" name="edd-export-class" value="EDD_Batch_Downloads_Export"/>
									<input type="submit" value="<?php 
    _e('Generate CSV', 'easy-digital-downloads');
    ?>
" class="button-secondary"/>
								</form>
							</p>
						</div><!-- .inside -->
					</div><!-- .postbox -->

					<div class="postbox edd-export-download-history">
						<h3><span><?php 
    _e('Export Download History in CSV', 'easy-digital-downloads');
    ?>
</span></h3>
						<div class="inside">
							<p><?php 
    _e('Download a CSV of file downloads.', 'easy-digital-downloads');
    ?>
</p>
							<p>
								<form id="edd-export-file-downloads" class="edd-export-form" method="post">
									<?php 
    echo EDD()->html->date_field(array('id' => 'edd-file-download-export-start', 'name' => 'start', 'placeholder' => __('Choose start date', 'easy-digital-downloads')));
    ?>
									<?php 
    echo EDD()->html->date_field(array('id' => 'edd-file-download-export-end', 'name' => 'end', 'placeholder' => __('Choose end date', 'easy-digital-downloads')));
    ?>
									<?php 
    wp_nonce_field('edd_ajax_export', 'edd_ajax_export');
    ?>
									<input type="hidden" name="edd-export-class" value="EDD_Batch_File_Downloads_Export"/>
									<input type="submit" value="<?php 
    _e('Generate CSV', 'easy-digital-downloads');
    ?>
" class="button-secondary"/>
								</form>
							</p>
						</div><!-- .inside -->
					</div><!-- .postbox -->

					<?php 
    do_action('edd_reports_tab_export_content_bottom');
    ?>

				</div><!-- .post-body-content -->
			</div><!-- .post-body -->
		</div><!-- .metabox-holder -->
	</div><!-- #edd-dashboard-widgets-wrap -->
	<?php 
}
/**
 * Retrieves keys for all available statuses for payments
 *
 * @since 2.3
 * @return array $payment_status All the available payment statuses
 */
function edd_get_payment_status_keys()
{
    $statuses = array_keys(edd_get_payment_statuses());
    asort($statuses);
    return array_values($statuses);
}
/**
 * Record payment status change
 *
 * @since 1.4.3
 * @param int $payment_id the ID number of the payment
 * @param string $new_status the status of the payment, probably "publish"
 * @param string $old_status the status of the payment prior to being marked as "complete", probably "pending"
 * @return void
 */
function edd_record_status_change($payment_id, $new_status, $old_status)
{
    // Get the list of statuses so that status in the payment note can be translated
    $stati = edd_get_payment_statuses();
    $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status;
    $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status;
    $status_change = sprintf(__('Status changed from %s to %s', 'edd'), $old_status, $new_status);
    edd_insert_payment_note($payment_id, $status_change);
}
 /**
  * Set the payment status
  *
  * @since 2.5
  *
  * @param  string $status The status to set the payment to
  * @return bool Returns if the status was successfully updated
  */
 public function update_status($status = false)
 {
     if ($status == 'completed' || $status == 'complete') {
         $status = 'publish';
     }
     $old_status = !empty($this->old_status) ? $this->old_status : false;
     if ($old_status === $status) {
         return false;
         // Don't permit status changes that aren't changes
     }
     $do_change = apply_filters('edd_should_update_payment_status', true, $this->ID, $status, $old_status);
     $updated = false;
     if ($do_change) {
         do_action('edd_before_payment_status_change', $this->ID, $status, $old_status);
         $update_fields = array('ID' => $this->ID, 'post_status' => $status, 'edit_date' => current_time('mysql'));
         $updated = wp_update_post(apply_filters('edd_update_payment_status_fields', $update_fields));
         $all_payment_statuses = edd_get_payment_statuses();
         $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
         do_action('edd_update_payment_status', $this->ID, $status, $old_status);
     }
     return $updated;
 }
/**
 * Get Payment Status
 *
 * @since 1.0
 *
 * @param WP_Post $payment
 * @param bool   $return_label Whether to return the payment status or not
 *
 * @return bool|mixed if payment status exists, false otherwise
 */
function edd_get_payment_status($payment, $return_label = false)
{
    if (!is_object($payment) || !isset($payment->post_status)) {
        return false;
    }
    $statuses = edd_get_payment_statuses();
    if (!is_array($statuses) || empty($statuses)) {
        return false;
    }
    if (array_key_exists($payment->post_status, $statuses)) {
        if (true === $return_label) {
            return $statuses[$payment->post_status];
        } else {
            return array_search($payment->post_status, $statuses);
        }
    }
    return false;
}
/**
 * Renders the 'Export' tab on the Reports Page
 *
 * @since 1.3
 * @return void
 */
function edd_reports_tab_export()
{
    ?>
	<div class="metabox-holder">
		<div id="post-body">
			<div id="post-body-content">

				<?php 
    do_action('edd_reports_tab_export_content_top');
    ?>

				<div class="postbox">
					<h3><span><?php 
    _e('Export PDF of Sales and Earnings', 'edd');
    ?>
</span></h3>
					<div class="inside">
						<p><?php 
    _e('Download a PDF of Sales and Earnings reports for all products for the current year.', 'edd');
    ?>
 <?php 
    _e('Date range reports will be coming soon.', 'edd');
    ?>
</p>
						<p><a class="button" href="<?php 
    echo wp_nonce_url(add_query_arg(array('edd-action' => 'generate_pdf')), 'edd_generate_pdf');
    ?>
"><?php 
    _e('Generate PDF', 'edd');
    ?>
</a></p>
					</div><!-- .inside -->
				</div><!-- .postbox -->

				<div class="postbox">
					<h3><span><?php 
    _e('Export Payment History', 'edd');
    ?>
</span></h3>
					<div class="inside">
						<p><?php 
    _e('Download a CSV of all payments recorded.', 'edd');
    ?>
</p>
						<p>
							<form method="post">
								<?php 
    echo EDD()->html->year_dropdown();
    ?>
								<?php 
    echo EDD()->html->month_dropdown();
    ?>
								<select name="edd_export_payment_status">
									<option value="0"><?php 
    _e('All Statuses', 'edd');
    ?>
</option>
									<?php 
    $statuses = edd_get_payment_statuses();
    foreach ($statuses as $status => $label) {
        echo '<option value="' . $status . '">' . $label . '</option>';
    }
    ?>
								</select>
								<input type="hidden" name="edd-action" value="payment_export"/>
								<input type="submit" value="<?php 
    _e('Generate CSV', 'edd');
    ?>
" class="button-secondary"/>
							</form>
						</p>
					</div><!-- .inside -->
				</div><!-- .postbox -->

				<div class="postbox">
					<h3><span><?php 
    _e('Export Customers in CSV', 'edd');
    ?>
</span></h3>
					<div class="inside">
						<p><?php 
    _e('Download a CSV of all customer emails. Optionally export only customers that have purchased a particular product. Note, if you have a large number of customers, exporting the purchase stats may fail.', 'edd');
    ?>
</p>
						<p>
							<form method="post" id="edd_customer_export">
								<select name="edd_export_download" id="edd_customer_export_download">
									<option value="0"><?php 
    printf(__('All %s', 'edd'), edd_get_label_plural());
    ?>
</option>
									<?php 
    $downloads = get_posts(array('post_type' => 'download', 'posts_per_page' => -1));
    if ($downloads) {
        foreach ($downloads as $download) {
            echo '<option value="' . $download->ID . '">' . get_the_title($download->ID) . '</option>';
        }
    }
    ?>
								</select>
								<select name="edd_export_option" id="edd_customer_export_option">
									<option value="emails"><?php 
    _e('Emails', 'edd');
    ?>
</option>
									<option value="emails_and_names"><?php 
    _e('Emails and Names', 'edd');
    ?>
</option>
									<option value="full"><?php 
    _e('Emails, Names, and Purchase Stats', 'edd');
    ?>
</option>
								</select>
								<input type="hidden" name="edd-action" value="email_export"/>
								<input type="submit" value="<?php 
    _e('Generate CSV', 'edd');
    ?>
" class="button-secondary"/>
							</form>
						</p>
					</div><!-- .inside -->
				</div><!-- .postbox -->

				<div class="postbox">
					<h3><span><?php 
    _e('Export Download History in CSV', 'edd');
    ?>
</span></h3>
					<div class="inside">
						<p><?php 
    _e('Download a CSV of all file downloads for a specific month and year.', 'edd');
    ?>
</p>
						<p>
							<form method="post">
								<?php 
    echo EDD()->html->year_dropdown();
    ?>
								<?php 
    echo EDD()->html->month_dropdown();
    ?>
								<input type="hidden" name="edd-action" value="downloads_history_export"/>
								<input type="submit" value="<?php 
    _e('Generate CSV', 'edd');
    ?>
" class="button-secondary"/>
							</form>
						</p>
					</div><!-- .inside -->
				</div><!-- .postbox -->

				<?php 
    do_action('edd_reports_tab_export_content_bottom');
    ?>

			</div><!-- .post-body-content -->
		</div><!-- .post-body -->
	</div><!-- .metabox-holder -->
	<?php 
}
</p>
					</td>
				</tr>
				<tr>
					<th scope="row" valign="top">
						<span><?php 
_e('Payment Status', 'edd');
?>
</span>
					</th>
					<td>
						<select name="edd-payment-status" id="edd_payment_status">
							<?php 
$status = $payment->post_status;
// current status
$statuses = edd_get_payment_statuses();
foreach ($statuses as $status_id => $label) {
    echo '<option value="' . $status_id . '" ' . selected($status, $status_id, false) . '>' . $label . '</option>';
}
?>
						</select>
					</td>
				</tr>
				<tr id="edd_payment_notification" style="display:none;">
					<th scope="row" valign="top">
						<span><?php 
_e('Send Purchase Receipt', 'edd');
?>
</span>
					</th>
					<td>
    public static function payment_creation_form()
    {
        // Determine our float accuracy for the steps and rounding
        $decimals = edd_currency_decimal_filter();
        if (empty($decimals)) {
            $step = 1;
        } else {
            $i = 1;
            $step = '0.';
            while ($i < $decimals) {
                $step .= '0';
                $i++;
            }
            $step .= '1';
            $step = (double) $step;
        }
        $tax_included = 'false';
        if (edd_use_taxes() && edd_prices_include_tax()) {
            $tax_included = 'true';
        }
        $columns = 4;
        ?>
		<div class="wrap">
			<h2><?php 
        _e('Create New Payment', 'edd-manual-purchases');
        ?>
</h2>
			<script type="text/javascript">
				jQuery(document).ready(function($) {

					$(document.body).on('input', '.edd-mp-amount,.edd-mp-tax,.edd-mp-quantity', function() {
						eddmp_update_total();
					});

					// check for variable prices
					$('#edd_mp_create_payment').on('change', '.mp-downloads', function() {
						var $this = $(this);
						var selected_download = $('option:selected', this).val();
						$this.parent().parent().find('.download-price-option-wrap').html('');
						if( parseInt( selected_download ) != 0) {
							var edd_mp_nonce = $('#edd_create_payment_nonce').val();
							var key = $this.parent().parent().data('key');
							$.ajax({
								type: "POST",
								url: ajaxurl,
								data: {
									action: 'edd_mp_check_for_variations',
									download_id: selected_download,
									key: key,
									nonce: edd_mp_nonce
								},
								dataType: "json",
								success: function(response) {
									$this.parent().parent().find('.download-price-option-wrap').html( response.html );
									$this.parent().parent().find('input[name="downloads['+ key +'][amount]"]').val( response.amount );
									eddmp_update_total();
								}
							}).fail(function (data) {
								if ( window.console && window.console.log ) {
									console.log( data );
								}
							});
						} else {
							$this.parent().parent().find('.download-price-option-wrap').html('N/A');
						}
					});

					// Update the price when a variation changes
					$('#edd_mp_create_payment').on('change', '.edd-mp-price-select', function() {
						var $this        = $(this);
						var price_id     = $('option:selected', this).val();
						var edd_mp_nonce = $('#edd_create_payment_nonce').val();
						var key          = $this.parent().parent().data('key');
						var download_id  = $('select[name="downloads[' + key + '][id]"]').val();

						$.ajax({
							type: "POST",
							url: ajaxurl,
							data: {
								action: 'edd_mp_variation_change',
								download_id: download_id,
								price_id: price_id,
								key: key,
								nonce: edd_mp_nonce
							},
							dataType: "json",
							success: function(response) {
								$this.parent().parent().find('input[name="downloads['+ key +'][amount]"]').val( response.amount );
								eddmp_update_total();
							}
						}).fail(function (data) {
							if ( window.console && window.console.log ) {
								console.log( data );
							}
						});

					});

					$('.edd_add_repeatable').click(function() {
						setTimeout( function() {
							$('.edd_repeatable_row:last').find('.download-price-option-wrap').html('');
							$('.edd_repeatable_row:last').find('.edd-mp-quantity').val('1');
						}, 300 );
					});

					$(document.body).on('click', '.edd_remove_repeatable', function() {
						setTimeout( function() {
							var row_count = $('.edd_repeatable_row').length;
							if ( 1 === row_count ) {
								var current_quantity = $('.edd_repeatable_row:first').find('.edd-mp-quantity').val();
								if ( '' === current_quantity ) {
									$('.edd_repeatable_row:first').find('.edd-mp-quantity').val('1');
								}
							}

							eddmp_update_total();
						}, 100 );
					});

					if ($('.form-table .edd_datepicker').length > 0) {
						var dateFormat = 'mm/dd/yy';
						$('.edd_datepicker').datepicker({
							dateFormat: dateFormat
						});
					}

					function eddmp_update_total() {
						// Setup some place holder vars for each row
						var item_amount   = 0;
						var item_tax      = 0;
						var item_quantity = 1;
						var item_total    = 0;

						// Our final total to show to the customer
						var total      = 0;

						var prices_include_tax = <?php 
        echo $tax_included;
        ?>
;

						// Iterate over each line item and add amount + tax * quantity to get the total
						$('.edd_repeatable_row').each(function() {
							var row = $(this);

							item_amount   = parseFloat( row.find('.edd-mp-amount').val() );

							if (row.find('.edd-mp-tax').length) {
								item_tax      = parseFloat(row.find('.edd-mp-tax').val() );

								if (! isNaN(item_tax) && ! prices_include_tax) {
									item_amount = item_amount + item_tax;
								}
							}

							if (row.find('.edd-mp-quantity').length) {
								item_quantity = parseFloat(row.find('.edd-mp-quantity').val() );
							}

							item_total  = item_amount * item_quantity;

							total += item_total;
						});

						if ( isNaN( total ) ){
							total = 0;
						}

						$('#edd-mp-total-amount').html(total.toFixed(<?php 
        echo $decimals;
        ?>
));
					}
				});
			</script>

			<form id="edd_mp_create_payment" method="post">
				<table class="form-table" id="edd-customer-details">
					<tbody id="edd-mp-table-body">
						<tr class="form-field edd-mp-download-wrap">
							<th scope="row" valign="top">
								<label><?php 
        echo edd_get_label_plural();
        ?>
</label>
							</th>
							<td class="edd-mp-downloads">
								<div id="edd_file_fields" class="edd_meta_table_wrap">
									<table class="widefat edd_repeatable_table" style="width: auto;" cellpadding="0" cellspacing="0">
										<thead>
											<tr>
												<th style="padding: 10px;"><?php 
        echo edd_get_label_plural();
        ?>
</th>
												<th style="padding: 10px;"><?php 
        _e('Price Option', 'edd-manual-purchases');
        ?>
</th>
												<th style="padding: 10px; width: 150px;"><?php 
        _e('Amount', 'edd-manual-purchases');
        ?>
</th>
												<?php 
        if (edd_use_taxes()) {
            ?>
													<th style="padding: 10px; width: 150px;"><?php 
            _e('Tax', 'edd-manual-purchases');
            ?>
</th>
													<?php 
            $columns++;
            ?>
												<?php 
        }
        if (edd_item_quantities_enabled()) {
            ?>
													<th style="padding: 10px; width: 50px;"><?php 
            _e('Quantity', 'edd-manual-purchases');
            ?>
</th>
													<?php 
            $columns++;
            ?>
												<?php 
        }
        ?>
												<th style="padding: 10px; width: 5px;"
											</tr>
										</thead>
										<tbody>
											<tr class="edd_repeatable_product_wrapper edd_repeatable_row" data-key="1">
												<td>
													<?php 
        echo EDD()->html->product_dropdown(array('name' => 'downloads[1][id]', 'id' => 'downloads', 'class' => 'mp-downloads', 'multiple' => false, 'chosen' => true));
        ?>
												</td>
												<td class="download-price-option-wrap"><?php 
        _e('N/A', 'edd-manual-purchases');
        ?>
</td>
												<td>
													<input type="number" step="<?php 
        echo $step;
        ?>
" class="edd-mp-amount" name="downloads[1][amount]" value="" min="0" placeholder="<?php 
        esc_attr_e('Item price', 'edd-manual-purchases');
        ?>
"/>
												</td>
												<?php 
        if (edd_use_taxes()) {
            ?>
													<td>
														<?php 
            if (!edd_prices_include_tax()) {
                ?>
														&nbsp;&plus;&nbsp;
														<?php 
            }
            ?>
														<input type="number" style="width: 65%" step="<?php 
            echo $step;
            ?>
" class="edd-mp-tax" name="downloads[1][tax]" value="" min="0" placeholder="<?php 
            esc_attr_e('Item Tax', 'edd-manual-purchases');
            ?>
"/>
													</td>
												<?php 
        }
        ?>
												<?php 
        if (edd_item_quantities_enabled()) {
            ?>
													<td>
														&nbsp;&times;&nbsp;<input type="number" step="1" class="edd-mp-quantity" style="width: 65%" name="downloads[1][quantity]" value="1" min="1" placeholder="<?php 
            esc_attr_e('Enter quantity', 'edd-manual-purchases');
            ?>
"/>
													</td>
												<?php 
        }
        ?>
												<td>
													<a href="#" class="edd_remove_repeatable" data-type="file" style="background: url(<?php 
        echo admin_url('/images/xit.gif');
        ?>
) no-repeat;">&times;</a>
												</td>
											</tr>
											<tr>
												<td class="submit" colspan="<?php 
        echo $columns;
        ?>
" style="float: none; clear:both; background: #fff;">
													<a class="button-secondary edd_add_repeatable" style="margin: 6px 0 10px;"><?php 
        _e('Add New', 'edd-manual-purchases');
        ?>
</a>
													<span style="line-height: 38px;">
														Total: <?php 
        echo edd_currency_symbol();
        ?>
<span id="edd-mp-total-amount">0.00</span>
														<?php 
        if (edd_use_taxes()) {
            ?>
															<sup>&dagger;</sup>
														<?php 
        }
        ?>
													</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
								<span>
									<small>
									<?php 
        if (edd_use_taxes()) {
            ?>
<sup>&dagger;</sup>
										<?php 
            if (!edd_prices_include_tax()) {
                ?>
											<em><?php 
                _e('Total is based on prices exclusive of tax.', 'edd-manual-purchases');
                ?>
</em>
										<?php 
            } else {
                ?>
											<em><?php 
                _e('Total is based on prices inclusive of tax.', 'edd-manual-purchases');
                ?>
</em>
										<?php 
            }
            ?>
									<?php 
        }
        ?>
									</small>
								</span>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-user"><?php 
        _e('Customer', 'edd-manual-purchases');
        ?>
</label>
							</th>
							<td class="edd-mp-email">
								<div class="customer-info">
									<?php 
        echo EDD()->html->customer_dropdown(array('name' => 'customer'));
        ?>
								</div>
								<div class="description customer-info">
									<a href="#new" class="edd-payment-new-customer" title="<?php 
        _e('New Customer', 'edd-manual-purchases');
        ?>
"><?php 
        _e('Create new customer', 'edd-manual-purchases');
        ?>
</a>
								</div>
								<div class="description new-customer" style="display: none">
									<a href="#cancel" class="edd-payment-new-customer-cancel" title="<?php 
        _e('Existing Customer', 'edd-manual-purchases');
        ?>
"><?php 
        _e('Select existing customer', 'edd-manual-purchases');
        ?>
</a>
								</div>
							</td>
						</tr>
						<tr class="form-field new-customer" style="display: none">
							<th scope="row" valign="top">
								<label for="edd-mp-user"><?php 
        _e('Customer Email', 'edd-manual-purchases');
        ?>
</label>
							</th>
							<td class="edd-mp-email">
								<input type="text" class="small-text" id="edd-mp-email" name="email" style="width: 180px;"/>
								<div class="description"><?php 
        _e('Enter the email address of the customer.', 'edd-manual-purchases');
        ?>
</div>
							</td>
						</tr>
						<tr class="form-field new-customer" style="display: none">
							<th scope="row" valign="top">
								<label for="edd-mp-last"><?php 
        _e('Customer First Name', 'edd-manual-purchases');
        ?>
</label>
							</th>
							<td class="edd-mp-last">
								<input type="text" class="small-text" id="edd-mp-last" name="first" style="width: 180px;"/>
								<div class="description"><?php 
        _e('Enter the first name of the customer (optional).', 'edd-manual-purchases');
        ?>
</div>
							</td>
						</tr>
						<tr class="form-field new-customer" style="display: none">
							<th scope="row" valign="top">
								<label for="edd-mp-last"><?php 
        _e('Customer Last Name', 'edd-manual-purchases');
        ?>
</label>
							</th>
							<td class="edd-mp-last">
								<input type="text" class="small-text" id="edd-mp-last" name="last" style="width: 180px;"/>
								<div class="description"><?php 
        _e('Enter the last name of the customer (optional).', 'edd-manual-purchases');
        ?>
</div>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-amount"><?php 
        _e('Amount', 'edd-manual-purchases');
        ?>
</label>
							</th>
							<td class="edd-mp-downloads">
								<input type="text" class="small-text" id="edd-mp-amount" name="amount" style="width: 180px;"/>
								<?php 
        if (edd_item_quantities_enabled()) {
            ?>
									<div class="description"><?php 
            _e('Enter the total purchase amount, or leave blank to auto calculate price based on the selected items and quantities above. Use 0.00 for 0.', 'edd-manual-purchases');
            ?>
</div>
								<?php 
        } else {
            ?>
									<div class="description"><?php 
            _e('Enter the total purchase amount, or leave blank to auto calculate price based on the selected items above. Use 0.00 for 0.', 'edd-manual-purchases');
            ?>
</div>
								<?php 
        }
        ?>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<?php 
        _e('Payment status', 'edd-manual-purchases');
        ?>
							</th>
							<td class="edd-mp-status">
								<?php 
        echo EDD()->html->select(array('name' => 'status', 'options' => edd_get_payment_statuses(), 'selected' => 'publish', 'show_option_all' => false, 'show_option_none' => false));
        ?>
								<label for="edd-mp-status" class="description"><?php 
        _e('Select the status of this payment.', 'edd-manual-purchases');
        ?>
</label>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-payment-method"><?php 
        _e('Payment Method', 'edd-manual-purchases');
        ?>
</label>
							</th>
							<td class="edd-mp-gateways">
								<select name="gateway" id="edd-mp-payment-method">
									<option value="manual_purchases"><?php 
        esc_html_e('Manual Payment', 'edd-manual-purchases');
        ?>
</option>
									<?php 
        foreach (edd_get_payment_gateways() as $gateway_id => $gateway) {
            ?>
										<option value="<?php 
            echo esc_attr($gateway_id);
            ?>
"><?php 
            echo esc_html($gateway['admin_label']);
            ?>
</option>
									<?php 
        }
        ?>
								</select>
								<div class="description"><?php 
        _e('Select the payment method used.', 'edd-manual-purchases');
        ?>
</div>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-transaction-id"><?php 
        _e('Transaction ID', 'edd-manual-purchases');
        ?>
</label>
							</th>
							<td class="edd-mp-downloads">
								<input type="text" class="small-text" id="edd-mp-transaction-id" name="transaction_id" style="width: 180px;"/>
								<div class="description"><?php 
        _e('Enter the transaction ID, if any.', 'edd-manual-purchases');
        ?>
</div>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-date"><?php 
        _e('Date', 'edd-manual-purchases');
        ?>
</label>
							</th>
							<td class="edd-mp-downloads">
								<input type="text" class="small-text edd_datepicker" id="edd-mp-date" name="date" style="width: 180px;"/>
								<div class="description"><?php 
        _e('Enter the purchase date, or leave blank for today\'s date.', 'edd-manual-purchases');
        ?>
</div>
							</td>
						</tr>
						<?php 
        if (function_exists('eddc_record_commission')) {
            ?>
						<tr class="form-field">
							<th scope="row" valign="top">
								<?php 
            _e('Commission', 'edd-manual-purchases');
            ?>
							</th>
							<td class="edd-mp-downloads">
								<label for="edd-mp-commission">
									<input type="checkbox" id="edd-mp-commission" name="commission" style="width: auto;"/>
									<?php 
            _e('Record commissions (if any) for this manual purchase?', 'edd-manual-purchases');
            ?>
								</label>
							</td>
						</tr>
						<?php 
        }
        ?>
						<?php 
        if (class_exists('EDD_Simple_Shipping')) {
            ?>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-shipped"><?php 
            _e('Shipped', 'edd-manual-purchases');
            ?>
</label>
							</th>
							<td class="edd-mp-shipped">
								<label for="edd-mp-shipped">
									<input type="checkbox" id="edd-mp-shipped" name="shipped" style="width: auto;"/>
									<?php 
            _e('Mark order as shipped?', 'edd-manual-purchases');
            ?>
								</label>
							</td>
						</tr>
						<?php 
        }
        ?>
						<?php 
        if (class_exists('EDD_Wallet')) {
            ?>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-wallet"><?php 
            _e('Pay From Wallet', 'edd-manual-purchases');
            ?>
</label>
							</th>
							<td class="edd-mp-wallet">
								<label for="edd-mp-wallet">
									<input type="checkbox" id="edd-mp-wallet" name="wallet" style="width: auto;"/>
									<?php 
            _e('Use funds from the customers\' wallet to pay for this payment.', 'edd-manual-purchases');
            ?>
								</label>
							</td>
						</tr>
						<?php 
        }
        ?>
						<tr class="form-field">
							<th scope="row" valign="top">
								<?php 
        _e('Send Receipt', 'edd-manual-purchases');
        ?>
							</th>
							<td class="edd-mp-receipt">
								<label for="edd-mp-receipt">
									<input type="checkbox" id="edd-mp-receipt" name="receipt" style="width: auto;" checked="1" value="1"/>
									<?php 
        _e('Send the purchase receipt to the buyer?', 'edd-manual-purchases');
        ?>
								</label>
							</td>
						</tr>
					</tbody>
				</table>
				<?php 
        wp_nonce_field('edd_create_payment_nonce', 'edd_create_payment_nonce');
        ?>
				<input type="hidden" name="edd-gateway" value="manual_purchases"/>
				<input type="hidden" name="edd-action" value="create_payment" />
				<?php 
        submit_button(__('Create Payment', 'edd-manual-purchases'));
        ?>
			</form>
		</div>
		<?php 
    }
/**
 * Adds metabox for exporting upsells from the reports -> export page
 *
 * @since 1.1
*/
function edd_csau_reports_export_upsells()
{
    ?>
	<div class="postbox">
		<h3><span><?php 
    _e('Export Upsell History', 'edd-csau');
    ?>
</span></h3>
		<div class="inside">
			<p><?php 
    _e('Download a CSV of all upsells recorded.', 'edd-csau');
    ?>
</p>
			<p>
				<form method="post">
					<?php 
    echo EDD()->html->year_dropdown();
    ?>
					<?php 
    echo EDD()->html->month_dropdown();
    ?>
					<select name="edd_export_payment_status">
						<option value="0"><?php 
    _e('All Statuses', 'edd-csau');
    ?>
</option>
						<?php 
    $statuses = edd_get_payment_statuses();
    foreach ($statuses as $status => $label) {
        echo '<option value="' . $status . '">' . $label . '</option>';
    }
    ?>
					</select>
					<input type="hidden" name="edd-action" value="upsells_export" />
					<input type="submit" value="<?php 
    _e('Generate CSV', 'edd-csau');
    ?>
" class="button-secondary" />
				</form>
			</p>
		</div><!-- .inside -->
	</div><!-- .postbox -->
<?php 
}
    public static function payment_creation_form()
    {
        ?>
		<div class="wrap">
			<h2><?php 
        _e('Create New Payment', 'edd-manual-purchases');
        ?>
</h2>
			<script type="text/javascript">
				jQuery(document).ready(function($) {
					// clone a download row
					$('#edd_mp_create_payment').on('click', '.edd-mp-add-download', function() {
						var row = $(this).closest('tr').clone();

						var count = $('tr.edd-mp-download-wrap').size();

						$('select.edd-mp-download-select', row).prop('name', 'downloads[' + count + '][id]');

						$('select.edd-mp-price-select', row).remove();

						if( ! $('.edd-mp-remove', row).length )
							$('.edd-mp-downloads', row).append('<a href="#" class="edd-mp-remove">Remove</a>');

						row.insertAfter( '#edd-mp-table-body tr.edd-mp-download-wrap:last' );
						return false;
					});
					// remove a download row
					$('#edd_mp_create_payment').on('click', '.edd-mp-remove', function() {
						$(this).closest('tr').remove();
						return false;
					});
					// check for variable prices
					$('#edd_mp_create_payment').on('change', '.edd-mp-download-select', function() {
						var $this = $(this);
						var selected_download = $('option:selected', this).val();
						if( parseInt( selected_download ) != 0) {
							var edd_mp_nonce = $('#edd_create_payment_nonce').val();
							var data = {
								action: 'edd_mp_check_for_variations',
								download_id: selected_download,
								key: $('tr.edd-mp-download-wrap').size() - 1,
								nonce: edd_mp_nonce
							}
							$this.parent().find('img').show();
							$.post(ajaxurl, data, function(response) {
								$this.next('select').remove();
								$this.after( response );
								$this.parent().find('img').hide();
							});
						} else {
							$this.next('select').remove();
							$this.parent().find('img').hide();
						}
					});
					if ($('.form-table .edd_datepicker').length > 0) {
						var dateFormat = 'mm/dd/yy';
						$('.edd_datepicker').datepicker({
							dateFormat: dateFormat
						});
					}
				});
			</script>
			<form id="edd_mp_create_payment" method="post">
				<table class="form-table">
					<tbody id="edd-mp-table-body">
						<tr class="form-field edd-mp-download-wrap">
							<th scope="row" valign="top">
								<label><?php 
        echo edd_get_label_singular();
        ?>
</label>
							</th>
							<td class="edd-mp-downloads">
								<select name="downloads[0][id]" class="edd-mp-download-select">
									<?php 
        $args = array('post_type' => 'download', 'nopaging' => true, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any');
        $downloads = get_posts(apply_filters('edd_mp_downloads_query', $args));
        if ($downloads) {
            echo '<option value="0">' . sprintf(__('Choose %s', 'edd-manual-purchases'), esc_html(edd_get_label_plural())) . '</option>';
            foreach ($downloads as $download) {
                if ($download->post_status != 'publish') {
                    $prefix = strtoupper($download->post_status) . ' - ';
                } else {
                    $prefix = '';
                }
                echo '<option value="' . $download->ID . '">' . $prefix . esc_html(get_the_title($download->ID)) . '</option>';
            }
        } else {
            echo '<option value="0">' . sprintf(__('No %s created yet', 'edd-manual-purchases'), edd_get_label_plural()) . '</option>';
        }
        ?>
								</select>
								<a href="#" class="edd-mp-add-download"><?php 
        _e('Add another', 'edd-manual-purchases');
        ?>
</a>
								<img src="<?php 
        echo admin_url('/images/wpspin_light.gif');
        ?>
" class="waiting edd_mp_loading" style="display:none;"/>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-user"><?php 
        _e('Buyer ID or Email', 'edd-manual-purchases');
        ?>
</label>
							</th>
							<td class="edd-mp-user">
								<input type="text" class="small-text" id="edd-mp-user" name="user" style="width: 180px;"/>
								<div class="description"><?php 
        _e('Enter the user ID or email of the buyer.', 'edd-manual-purchases');
        ?>
</div>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-last"><?php 
        _e('Buyer First Name', 'edd-manual-purchases');
        ?>
</label>
							</th>
							<td class="edd-mp-last">
								<input type="text" class="small-text" id="edd-mp-last" name="first" style="width: 180px;"/>
								<div class="description"><?php 
        _e('Enter the first name of the buyer (optional).', 'edd-manual-purchases');
        ?>
</div>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-last"><?php 
        _e('Buyer Last Name', 'edd-manual-purchases');
        ?>
</label>
							</th>
							<td class="edd-mp-last">
								<input type="text" class="small-text" id="edd-mp-last" name="last" style="width: 180px;"/>
								<div class="description"><?php 
        _e('Enter the last name of the buyer (optional).', 'edd-manual-purchases');
        ?>
</div>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-amount"><?php 
        _e('Amount', 'edd-manual-purchases');
        ?>
</label>
							</th>
							<td class="edd-mp-downloads">
								<input type="text" class="small-text" id="edd-mp-amount" name="amount" style="width: 180px;"/>
								<div class="description"><?php 
        _e('Enter the total purchase amount, or leave blank to auto calculate price based on the selected items above. Use 0.00 for 0.', 'edd-manual-purchases');
        ?>
</div>
							</td>
						</tr>
						<?php 
        if (edd_use_taxes()) {
            ?>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-tax"><?php 
            _e('Tax', 'edd-manual-purchases');
            ?>
</label>
							</th>
							<td class="edd-mp-downloads">
								<input type="text" class="small-text" id="edd-mp-tax" name="tax" value="0" style="width: 180px;"/>
								<div class="description"><?php 
            _e('Enter the total tax charged on the purchase.', 'edd-manual-purchases');
            ?>
</div>
							</td>
						</tr>
						<?php 
        }
        ?>
						<tr class="form-field">
							<th scope="row" valign="top">
								<?php 
        _e('Payment status', 'edd-manual-purchases');
        ?>
							</th>
							<td class="edd-mp-status">
								<?php 
        echo EDD()->html->select(array('name' => 'status', 'options' => edd_get_payment_statuses(), 'selected' => 'publish', 'show_option_all' => false, 'show_option_none' => false));
        ?>
								<label for="edd-mp-status" class="description"><?php 
        _e('Select the status of this payment.', 'edd-manual-purchases');
        ?>
</label>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<?php 
        _e('Send Receipt', 'edd-manual-purchases');
        ?>
							</th>
							<td class="edd-mp-receipt">
								<label for="edd-mp-receipt">
									<input type="checkbox" id="edd-mp-receipt" name="receipt" style="width: auto;" checked="1" value="1"/>
									<?php 
        _e('Send the purchase receipt to the buyer?', 'edd-manual-purchases');
        ?>
								</label>
							</td>
						</tr>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-date"><?php 
        _e('Date', 'edd-manual-purchases');
        ?>
</label>
							</th>
							<td class="edd-mp-downloads">
								<input type="text" class="small-text edd_datepicker" id="edd-mp-date" name="date" style="width: 180px;"/>
								<div class="description"><?php 
        _e('Enter the purchase date. Leave blank for today\'s date.', 'edd-manual-purchases');
        ?>
</div>
							</td>
						</tr>
						<?php 
        if (function_exists('eddc_record_commission')) {
            ?>
						<tr class="form-field">
							<th scope="row" valign="top">
								<?php 
            _e('Commission', 'edd-manual-purchases');
            ?>
							</th>
							<td class="edd-mp-downloads">
								<label for="edd-mp-commission">
									<input type="checkbox" id="edd-mp-commission" name="commission" style="width: auto;"/>
									<?php 
            _e('Record commissions (if any) for this manual purchase?', 'edd-manual-purchases');
            ?>
								</label>
							</td>
						</tr>
						<?php 
        }
        ?>
						<?php 
        if (class_exists('EDD_Recurring')) {
            ?>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-date"><?php 
            _e('Customer Expiration', 'edd-manual-purchases');
            ?>
</label>
							</th>
							<td class="edd-mp-downloads">
								<input type="text" class="small-text edd_datepicker" id="edd-mp-expiration" name="expiration" style="width: 180px;"/>
								<div class="description"><?php 
            _e('Set the customer\'s status to Active and set their expiration date. Leave blank to leave customer as is.', 'edd-manual-purchases');
            ?>
</div>
							</td>
						</tr>
						<?php 
        }
        ?>
						<?php 
        if (class_exists('EDD_Simple_Shipping')) {
            ?>
						<tr class="form-field">
							<th scope="row" valign="top">
								<label for="edd-mp-shipped"><?php 
            _e('Shipped', 'edd-manual-purchases');
            ?>
</label>
							</th>
							<td class="edd-mp-shipped">
								<label for="edd-mp-shipped">
									<input type="checkbox" id="edd-mp-shipped" name="shipped" style="width: auto;"/>
									<?php 
            _e('Mark order as shipped?', 'edd-manual-purchases');
            ?>
								</label>
							</td>
						</tr>
						<?php 
        }
        ?>
					</tbody>
				</table>
				<?php 
        wp_nonce_field('edd_create_payment_nonce', 'edd_create_payment_nonce');
        ?>
				<input type="hidden" name="edd-gateway" value="manual_purchases"/>
				<input type="hidden" name="edd-action" value="create_payment" />
				<?php 
        submit_button(__('Create Payment', 'edd-manual-purchases'));
        ?>
			</form>
		</div>
		<?php 
    }