33725e22 by Kevin Burton

user manager pay history

1 parent 33bf7108
...@@ -21,6 +21,23 @@ jQuery(function($) { ...@@ -21,6 +21,23 @@ jQuery(function($) {
21 ); 21 );
22 } 22 }
23 23
24 jQuery('#creditNotBtn').click(function(e) {
25 jQuery('#credit_note').slideToggle('fast');
26 jQuery('#creditForm').ajaxForm({
27 url: '/wp-admin/admin-ajax.php'
28 , data: ({ajax:"yes", action: 'add_credit_note'})
29 , dateType: 'json'
30 , type: 'POST'
31 , success: function(data) {
32 // reload, cannot use reload() because then the form values get re-applied.
33 document.location.href = document.location.href;
34
35 }
36 });
37 e.preventDefault();
38 return false;
39 });
40
24 jQuery('.remove-user').colorbox({onComplete: function() { 41 jQuery('.remove-user').colorbox({onComplete: function() {
25 42
26 var cb = this; 43 var cb = this;
......
...@@ -18,12 +18,14 @@ use Tz\WordPress\CBV; ...@@ -18,12 +18,14 @@ use Tz\WordPress\CBV;
18 use Tz\WordPress\CBV\User; 18 use Tz\WordPress\CBV\User;
19 use Tz\WordPress\CBV\Events; 19 use Tz\WordPress\CBV\Events;
20 use Tz\WordPress\CBV\CEHours; 20 use Tz\WordPress\CBV\CEHours;
21 use Tz\WordPress\CBV\Invoice;
21 use Exception, StdClass; 22 use Exception, StdClass;
22 use WP_User; 23 use WP_User;
23 24
24 const OPTION_NAME = "user_options"; 25 const OPTION_NAME = "user_options";
25 const CAPABILITY = "manage_cbv_users"; 26 const CAPABILITY = "manage_cbv_users";
26 27
28 CBV\load('Invoice');
27 CBV\load('User'); 29 CBV\load('User');
28 Tools\import('HTML'); 30 Tools\import('HTML');
29 31
...@@ -661,6 +663,62 @@ class Actions { ...@@ -661,6 +663,62 @@ class Actions {
661 die(json_encode($return)); 663 die(json_encode($return));
662 } 664 }
663 665
666 public static function wp_ajax_add_credit_note() {
667 $uid = $_POST['uid'];
668 $title = $_POST['title'];
669 $amount = "-".$_POST['amount'];
670
671 global $wpdb;
672
673
674 $items = array();
675
676 $items[] = array(
677 'post_id' => 0
678 , 'cost' => $amount
679 , 'discount_label' => ""
680 , 'discount_amount' => ""
681 , 'tax_label' => ""
682 , 'tax_rate' => ""
683 , 'tax_amount' => ""
684 , 'subtotal' => $amount
685 , 'total' => $amount
686 , 'description' => "Credit Note"
687 , 'extras' => array()
688
689 );
690
691
692 $invoice_data = array();
693 $invoice_data['items'] = $items;
694 $invoice_data['payment'] = array(
695 'total_cost' => $amount
696 , 'total_discounts' => ""
697 , 'total_taxes' => ""
698 , 'subtotal' => $amount
699 , 'total' => $amount
700 , 'bt_address' => ""
701 , 'bt_address2' => ""
702 , 'bt_city' => ""
703 , 'bt_province' => ""
704 , 'bt_country' => ""
705 , 'bt_postal' => ""
706 , 'bt_card_holder' => ""
707 , 'bt_card_number' => ""
708 , 'bt_card_type' => ""
709 );
710
711
712
713 Invoice\create($invoice_data, 'credit', $title, $uid, 'credit', 'publish', $amount);
714
715 // return json object
716 $return = array(
717 'success' => 'true'
718 );
719 die(json_encode($return));
720 }
721
664 public static function wp_ajax_post_credit() { 722 public static function wp_ajax_post_credit() {
665 723
666 $uid = $_POST['uid']; 724 $uid = $_POST['uid'];
......
...@@ -204,6 +204,7 @@ use WP_User, WP_Roles; ...@@ -204,6 +204,7 @@ use WP_User, WP_Roles;
204 204
205 205
206 </div> 206 </div>
207 <div style="clear:both;"></div>
207 </div> 208 </div>
208 <div style="clear:both;"></div> 209 <div style="clear:both;"></div>
209 </div> 210 </div>
......