81dd287b by Kevin Burton

added the new popup window when re-embursing an invoice to allow you to de/selec…

…t items to refund from that invoice.  Chris will be doing the backend to finish it off.
1 parent 97f44ca0
...@@ -208,6 +208,11 @@ jQuery(function($) { ...@@ -208,6 +208,11 @@ jQuery(function($) {
208 jConfirm('<strong>Are you sure</strong> you want to <em>refund</em> this invoice?', 'Refund Invoice', function(c) { 208 jConfirm('<strong>Are you sure</strong> you want to <em>refund</em> this invoice?', 'Refund Invoice', function(c) {
209 if (c) { 209 if (c) {
210 210
211 // now we are going to pop up with invoice items.
212 $.colorbox({
213 href: '/wp-admin/admin-ajax.php?ajax=yes&action=admin_refund_invoice_form&invoice_id='+iid
214 });
215 /*
211 jPrompt('How much would you like to re-imburse?', current_amount, 'Re-imburse...', function(r) { 216 jPrompt('How much would you like to re-imburse?', current_amount, 'Re-imburse...', function(r) {
212 if( r ) { 217 if( r ) {
213 jQuery.ajax({ 218 jQuery.ajax({
...@@ -221,6 +226,7 @@ jQuery(function($) { ...@@ -221,6 +226,7 @@ jQuery(function($) {
221 }); 226 });
222 } 227 }
223 }); 228 });
229 */
224 } 230 }
225 }); 231 });
226 e.preventDefault(); 232 e.preventDefault();
......
...@@ -1489,6 +1489,39 @@ class Actions { ...@@ -1489,6 +1489,39 @@ class Actions {
1489 ob_end_clean(); 1489 ob_end_clean();
1490 die($content); 1490 die($content);
1491 } 1491 }
1492
1493 public static function wp_ajax_admin_refund_invoice_form() {
1494 $user = new User\Account($_GET['uid']);
1495 ob_start();
1496
1497 $invoice = get_post($_GET['invoice_id']);
1498
1499
1500 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'invoice-refund-view.php');
1501
1502 $content = ob_get_contents();
1503 ob_end_clean();
1504 die($content);
1505 }
1506
1507 public static function wp_ajax_issue_invoice_refund() {
1508
1509 $invoice = get_post($_POST['invoice_id']);
1510 $user = new User\Account($invoice->post_author);
1511 $items = $_POST['keys'];
1512
1513 // Chris, do what you need to do with this....
1514
1515
1516 // if there is an error, turn success to 'false' and set a msg.
1517 $return = array(
1518 'success' => 'true'
1519 , 'msg' => ''
1520 );
1521 die(json_encode($return));
1522
1523
1524 }
1492 1525
1493 public static function wp_ajax_admin_search_merge_users() { 1526 public static function wp_ajax_admin_search_merge_users() {
1494 global $wpdb; 1527 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 CE Hours</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
27
28 form {
29 display: block;
30 margin-right:20px;
31 }
32
33 table.item-listings tr th { text-align:left; border-bottom:1px solid #ccc; }
34 table.item-listings tr td { text-aling:left; border-bottom:1px solid #e8e8e8; }
35
36 table.item-listings tr th,
37 table.item-listings tr td { padding: 4px 5px; }
38
39 .dashboard-section-title { font-weight:bold; color:#3b0d32; }
40 </style>
41 </head>
42
43 <body>
44
45 <div style="display:block; width:750px; margin-bottom:0px;">
46 <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;">Refund: <?php echo $invoice->post_title; ?></div>
47 <div style="padding:10px;">
48
49 <form id="invoice_refund_form">
50
51 <table cellpadding="0" cellspacing="0" width="100%" border="0" style="border-collapse:collapse;" class="item-listings">
52 <tr>
53 <th>Item Description</th>
54 <th width="140">Refund?</th>
55 </tr>
56
57 <?php
58 $items = get_post_meta($invoice->ID, 'items', true);
59 foreach($items as $key=>$item):
60 ?>
61 <tr>
62 <td>
63 <?php
64 if ( isset($item['post_id']) && $item['post_id'] > 0) {
65 $p = get_post($item['post_id']);
66 echo $p->post_title;
67 } else {
68 echo $item['description'];
69 }
70 ?>
71 </td>
72 <td><input type="checkbox" checked="checked" name="keys[<?php echo $key?>]" /> <span style="color:#999;font-size:11px;">(-$<?php echo number_format($item['total'], 2, ".", "");?>)</span></td>
73 </tr>
74 <?php endforeach; ?>
75 </table>
76
77
78 <div style="border-top:1px solid #ccc;padding-top:8px;margin-top:25px;">
79
80 <table cellpadding="0" cellspacing="0" width="100%" border="0" style="border-collapse:collapse;">
81 <tr>
82 <td>
83 <input name="force_cancellation_fee" value="on" type="checkbox" checked="checked" />&nbsp;<label>Apply cancellation fee?</label>
84 </td>
85 <td width="400" style="text-align:right;">
86 <input type="submit" value="Apply Changes" /> <input type="button" value="Cancel Changes" id="refund_cancel_btn" />
87 </td>
88 </tr>
89 </table>
90
91
92 </div>
93
94 </form>
95
96 </div>
97
98 </div>
99
100 <script type="text/javascript">
101
102 jQuery(document).ready(function($) {
103 $('#invoice_refund_form').ajaxForm({
104 url: '/wp-admin/admin-ajax.php'
105 , data: ({ajax:"yes", action: 'issue_invoice_refund', invoice_id: <?php echo $invoice->ID?>})
106 , dataType: 'json'
107 , type: 'POST'
108 , success: function(data) {
109 if (data.success == 'true') {
110 document.location.href = document.location.href;
111 } else {
112 jAlert(data.msg, 'Server Error Encountered');
113 }
114 }
115 });
116
117
118 $('#refund_cancel_btn').click(function(e) {
119 e.preventDefault();
120 $.colorbox.close();
121 });
122 });
123
124 </script>
125
126 </body>
127 </html>
...\ No newline at end of file ...\ No newline at end of file