8a0f1789 by Kevin Burton

partial update - unfinished

1 parent f653cfac
...@@ -161,6 +161,64 @@ jQuery(function($) { ...@@ -161,6 +161,64 @@ jQuery(function($) {
161 }; 161 };
162 jQuery('#edit-event-form').ajaxForm(options); 162 jQuery('#edit-event-form').ajaxForm(options);
163 }}); 163 }});
164
165 jQuery('.invoice-refund-btn').live('click', function(e) {
166 var iid = $(this).attr('rel');
167
168 jConfirm('<strong>Are you sure</strong> you want to <em>refund</em> this invoice?', 'Refund Invoice', function(c) {
169 if (c) {
170 jQuery.ajax({
171 url: '/wp-admin/admin-ajax.php'
172 , data: ({ajax:"yes", action: 'admin_refund_invoice', invoice_id:iid })
173 , dataType: 'json'
174 , type: 'POST'
175 , success: function(data) {
176 document.location.reload();
177 }
178 });
179 }
180 });
181 e.preventDefault();
182 return false;
183 });
184
185
186 jQuery('.invoice-cancel-btn').live('click', function(e) {
187 var iid = $(this).attr('rel');
188
189 jConfirm('<strong>Are you sure</strong> you want to <em>cancel</em> the invoice?', 'Cancel Invoice', function(c) {
190 if (c) {
191 jQuery.ajax({
192 url: '/wp-admin/admin-ajax.php'
193 , data: ({ajax:"yes", action: 'admin_cancel_invoice',invoice_id:iid})
194 , dataType: 'json'
195 , type: 'POST'
196 , success: function(data) {
197 document.location.reload();
198 }
199 });
200 }
201 });
202 e.preventDefault();
203 return false;
204 });
205
206 jQuery('.admin-mark-invoice-paid').colorbox({onComplete: function() {
207 var cb = this;
208 var options = {
209 success: function(data) {
210 if (data.refresh == "true") {
211 document.location.href = document.location.href;
212 } else {
213 jQuery.colorbox.close();
214 }
215 }
216 , data: ({ajax:"yes", action: 'admin_update_invoice'})
217 , dataType: 'json'
218 , url: '/wp-admin/admin-ajax.php'
219 };
220 jQuery('#edit-invoice-form').ajaxForm(options);
221 }});
164 222
165 jQuery('.course-edit').colorbox({onComplete: function() { 223 jQuery('.course-edit').colorbox({onComplete: function() {
166 var cb = this; 224 var cb = this;
...@@ -261,7 +319,8 @@ jQuery(function($) { ...@@ -261,7 +319,8 @@ jQuery(function($) {
261 , data: ({ajax:"yes", action: 'cancel_registration', uid: user_id, eid: link.attr('rel')}) 319 , data: ({ajax:"yes", action: 'cancel_registration', uid: user_id, eid: link.attr('rel')})
262 , type: 'post' 320 , type: 'post'
263 , success: function(data) { 321 , success: function(data) {
264 322 document.location.href = document.location.href;
323 /*
265 if (data.ask_credit=="true") { 324 if (data.ask_credit=="true") {
266 // ask if they want to credit.... 325 // ask if they want to credit....
267 jPrompt('How much (if any) would you like to credit their account?', '0.00', 'Registration has been cancelled', function(r) { 326 jPrompt('How much (if any) would you like to credit their account?', '0.00', 'Registration has been cancelled', function(r) {
...@@ -278,6 +337,7 @@ jQuery(function($) { ...@@ -278,6 +337,7 @@ jQuery(function($) {
278 } else { 337 } else {
279 document.location.href = document.location.href; 338 document.location.href = document.location.href;
280 } 339 }
340 */
281 341
282 } 342 }
283 , dataType: 'json' 343 , dataType: 'json'
......
...@@ -705,8 +705,8 @@ class Actions { ...@@ -705,8 +705,8 @@ class Actions {
705 public static function wp_ajax_create_invoice_note($uid = 0) { 705 public static function wp_ajax_create_invoice_note($uid = 0) {
706 global $wpdb; 706 global $wpdb;
707 707
708 if ($uid = 0) { 708 if ($uid == 0) {
709 $uid = $_POST['uid']; 709 $uid = $_POST['uid'];
710 } 710 }
711 $amount = $_POST['amount']; 711 $amount = $_POST['amount'];
712 $invoice_type = $_POST['invoice_type']; 712 $invoice_type = $_POST['invoice_type'];
...@@ -717,7 +717,7 @@ class Actions { ...@@ -717,7 +717,7 @@ class Actions {
717 $amount = "-".$amount; 717 $amount = "-".$amount;
718 } 718 }
719 719
720 $paid = isset($_POST['paid']) ? true : false; 720 $paid = (isset($_POST['paid']) && $_POST['paid']=="on") ? true : false;
721 if ($invoice_type=="invoice") { 721 if ($invoice_type=="invoice") {
722 if (!$paid) { 722 if (!$paid) {
723 $paid_by = ""; 723 $paid_by = "";
...@@ -768,7 +768,7 @@ class Actions { ...@@ -768,7 +768,7 @@ class Actions {
768 if ($invoice_type=="credit") { 768 if ($invoice_type=="credit") {
769 $status = "credit"; 769 $status = "credit";
770 } else { 770 } else {
771 $paid = isset($_POST['paid']) ? true : false; 771 $paid = (isset($_POST['paid']) && $_POST['paid']=="on") ? true : false;
772 if ($paid) { 772 if ($paid) {
773 $status = "paid"; 773 $status = "paid";
774 } else { 774 } else {
...@@ -1097,6 +1097,36 @@ class Actions { ...@@ -1097,6 +1097,36 @@ class Actions {
1097 1097
1098 } 1098 }
1099 1099
1100 public static function wp_ajax_admin_cancel_invoice() {
1101 $invoice_id = $_POST['invoice_id'];
1102 update_post_meta($invoice_id, 'trans_status', 'cancelled');
1103 $return = array(
1104 'success' => 'true'
1105 );
1106 die(json_encode($return));
1107 }
1108
1109 public static function wp_ajax_admin_refund_invoice() {
1110 $invoice_id = $_POST['invoice_id'];
1111
1112 $invoice = get_post($invoice_id);
1113 $payment = get_post_meta($invoice_id, 'payment', true);
1114
1115
1116 $trans_amount = get_post_meta($invoice_id, 'trans_amount', true);
1117 $invoice_for = get_post_meta($invoice_id, 'invoice_for', true);
1118 $items = get_post_meta($invoice_id, 'items', true);
1119
1120 update_post_meta($invoice->ID, 'refunded', date('Y-m-d H:i:s'));
1121
1122 $invoice_data['items'] = $items;
1123 $invoice_data['payment'] = $payment;
1124 $new_invoice_id = Invoice\create($invoice_data, $invoice_for, $invoice->post_title, $invoice->post_author, 'credit', 'publish', $trans_amount);
1125
1126
1127
1128 }
1129
1100 public static function wp_ajax_build_cehour_form() { 1130 public static function wp_ajax_build_cehour_form() {
1101 $user = new User\Account($_GET['uid']); 1131 $user = new User\Account($_GET['uid']);
1102 $uid = $user->ID; 1132 $uid = $user->ID;
...@@ -1217,6 +1247,23 @@ class Actions { ...@@ -1217,6 +1247,23 @@ class Actions {
1217 1247
1218 1248
1219 } 1249 }
1250
1251 public static function wp_ajax_build_invoice_mark_paid_form() {
1252 $user = new User\Account($_GET['uid']);
1253 ob_start();
1254
1255 $invoice = get_post($_GET['invoice_id']);
1256
1257 $payment = get_post_meta($_GET['invoice_id'], 'payment', true);
1258 $trans_status = get_post_meta($_GET['invoice_id'], 'trans_status', true);
1259 $how_paid = strtolower($payment['bt_card_type']);
1260
1261 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_invoice.php');
1262
1263 $content = ob_get_contents();
1264 ob_end_clean();
1265 die($content);
1266 }
1220 1267
1221 public static function wp_ajax_admin_search_merge_users() { 1268 public static function wp_ajax_admin_search_merge_users() {
1222 global $wpdb; 1269 global $wpdb;
......
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
8 <title>Edit Event</title>
9 <style type="text/css">
10
11 html, body { margin:0px; padding:0;}
12 .title-link {
13 color:#f7bd55;
14 font-size: 12px;
15 font-weight: bold;
16 text-align: left;
17 line-height: 1.75em;
18 background: #3b0d32;
19 border: solid 1px #FFF;
20 border-bottom: solid 1px #999;
21 cursor: default;
22 padding: 0em; padding:3px 10px 3px 10px;
23 margin: 0em;
24 }
25
26 form {
27 display: block;
28 margin-right:20px;
29 }
30
31 .dashboard-section-title { font-weight:bold; color:#3b0d32; }
32 </style>
33 </head>
34
35 <body>
36
37 <div class="title-link" style="display:block;color:#f7bd55; font-size: 12px;font-weight: bold;text-align: left;line-height: 1.75em; background-color: #3b0d32; border: solid 1px #FFF; border-bottom: solid 1px #999; cursor: default; padding: 0em; padding:3px 10px 3px 10px; margin: 0em;">Mark Invoice Paid:</div>
38
39
40 <div style="padding: 0px 0px 10px 0px;">
41 <form method="post" action="" id="edit-invoice-form">
42
43 <input type="hidden" name="uid" value="<?php echo $uid; ?>" />
44 <input type="hidden" name="invoice_id" value="<?php echo $post->ID; ?>" />
45 <input type="hidden" name="type" value="<?php echo $action; ?>" />
46
47 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
48 <div class="dashboard-section-content small">
49 <select name="status">
50 <option value="">Select payment type...</option>
51 <option value="PPV">Pre-paid with Visa</option>
52 <option value="PPMC">Pre-paid with Mastercard</option>
53 <option value="PPAMEX">Pre-paid with American Express</option>
54 <option value="CHEQUE">Paid by Cheque</option>
55 </select>
56 </div>
57 </div>
58
59
60 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
61 <div class="dashboard-section-title"></div>
62 <div class="dashboard-section-links"></div>
63 <div class="dashboard-section-content small">
64 <div><input type="submit" value="Update" /></div>
65 </div>
66 </div>
67
68 </form>
69 </div>
70 </body>
71 </html>
...\ No newline at end of file ...\ No newline at end of file