33725e22 by Kevin Burton

user manager pay history

1 parent 33bf7108
......@@ -21,6 +21,23 @@ jQuery(function($) {
);
}
jQuery('#creditNotBtn').click(function(e) {
jQuery('#credit_note').slideToggle('fast');
jQuery('#creditForm').ajaxForm({
url: '/wp-admin/admin-ajax.php'
, data: ({ajax:"yes", action: 'add_credit_note'})
, dateType: 'json'
, type: 'POST'
, success: function(data) {
// reload, cannot use reload() because then the form values get re-applied.
document.location.href = document.location.href;
}
});
e.preventDefault();
return false;
});
jQuery('.remove-user').colorbox({onComplete: function() {
var cb = this;
......
......@@ -18,12 +18,14 @@ use Tz\WordPress\CBV;
use Tz\WordPress\CBV\User;
use Tz\WordPress\CBV\Events;
use Tz\WordPress\CBV\CEHours;
use Tz\WordPress\CBV\Invoice;
use Exception, StdClass;
use WP_User;
const OPTION_NAME = "user_options";
const CAPABILITY = "manage_cbv_users";
CBV\load('Invoice');
CBV\load('User');
Tools\import('HTML');
......@@ -661,6 +663,62 @@ class Actions {
die(json_encode($return));
}
public static function wp_ajax_add_credit_note() {
$uid = $_POST['uid'];
$title = $_POST['title'];
$amount = "-".$_POST['amount'];
global $wpdb;
$items = array();
$items[] = array(
'post_id' => 0
, 'cost' => $amount
, 'discount_label' => ""
, 'discount_amount' => ""
, 'tax_label' => ""
, 'tax_rate' => ""
, 'tax_amount' => ""
, 'subtotal' => $amount
, 'total' => $amount
, 'description' => "Credit Note"
, 'extras' => array()
);
$invoice_data = array();
$invoice_data['items'] = $items;
$invoice_data['payment'] = array(
'total_cost' => $amount
, 'total_discounts' => ""
, 'total_taxes' => ""
, 'subtotal' => $amount
, 'total' => $amount
, 'bt_address' => ""
, 'bt_address2' => ""
, 'bt_city' => ""
, 'bt_province' => ""
, 'bt_country' => ""
, 'bt_postal' => ""
, 'bt_card_holder' => ""
, 'bt_card_number' => ""
, 'bt_card_type' => ""
);
Invoice\create($invoice_data, 'credit', $title, $uid, 'credit', 'publish', $amount);
// return json object
$return = array(
'success' => 'true'
);
die(json_encode($return));
}
public static function wp_ajax_post_credit() {
$uid = $_POST['uid'];
......
......@@ -204,6 +204,7 @@ use WP_User, WP_Roles;
</div>
<div style="clear:both;"></div>
</div>
<div style="clear:both;"></div>
</div>
......