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($) {
jConfirm('<strong>Are you sure</strong> you want to <em>refund</em> this invoice?', 'Refund Invoice', function(c) {
if (c) {
// now we are going to pop up with invoice items.
$.colorbox({
href: '/wp-admin/admin-ajax.php?ajax=yes&action=admin_refund_invoice_form&invoice_id='+iid
});
/*
jPrompt('How much would you like to re-imburse?', current_amount, 'Re-imburse...', function(r) {
if( r ) {
jQuery.ajax({
......@@ -221,6 +226,7 @@ jQuery(function($) {
});
}
});
*/
}
});
e.preventDefault();
......
......@@ -1490,6 +1490,39 @@ class Actions {
die($content);
}
public static function wp_ajax_admin_refund_invoice_form() {
$user = new User\Account($_GET['uid']);
ob_start();
$invoice = get_post($_GET['invoice_id']);
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'invoice-refund-view.php');
$content = ob_get_contents();
ob_end_clean();
die($content);
}
public static function wp_ajax_issue_invoice_refund() {
$invoice = get_post($_POST['invoice_id']);
$user = new User\Account($invoice->post_author);
$items = $_POST['keys'];
// Chris, do what you need to do with this....
// if there is an error, turn success to 'false' and set a msg.
$return = array(
'success' => 'true'
, 'msg' => ''
);
die(json_encode($return));
}
public static function wp_ajax_admin_search_merge_users() {
global $wpdb;
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Edit CE Hours</title>
<style type="text/css">
html, body { margin:0px; padding:0;}
.title-link {
color:#f7bd55;
font-size: 12px;
font-weight: bold;
text-align: left;
line-height: 1.75em;
background: #3b0d32;
border: solid 1px #FFF;
border-bottom: solid 1px #999;
cursor: default;
padding: 0em; padding:3px 10px 3px 10px;
margin: 0em;
}
form {
display: block;
margin-right:20px;
}
table.item-listings tr th { text-align:left; border-bottom:1px solid #ccc; }
table.item-listings tr td { text-aling:left; border-bottom:1px solid #e8e8e8; }
table.item-listings tr th,
table.item-listings tr td { padding: 4px 5px; }
.dashboard-section-title { font-weight:bold; color:#3b0d32; }
</style>
</head>
<body>
<div style="display:block; width:750px; margin-bottom:0px;">
<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>
<div style="padding:10px;">
<form id="invoice_refund_form">
<table cellpadding="0" cellspacing="0" width="100%" border="0" style="border-collapse:collapse;" class="item-listings">
<tr>
<th>Item Description</th>
<th width="140">Refund?</th>
</tr>
<?php
$items = get_post_meta($invoice->ID, 'items', true);
foreach($items as $key=>$item):
?>
<tr>
<td>
<?php
if ( isset($item['post_id']) && $item['post_id'] > 0) {
$p = get_post($item['post_id']);
echo $p->post_title;
} else {
echo $item['description'];
}
?>
</td>
<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>
</tr>
<?php endforeach; ?>
</table>
<div style="border-top:1px solid #ccc;padding-top:8px;margin-top:25px;">
<table cellpadding="0" cellspacing="0" width="100%" border="0" style="border-collapse:collapse;">
<tr>
<td>
<input name="force_cancellation_fee" value="on" type="checkbox" checked="checked" />&nbsp;<label>Apply cancellation fee?</label>
</td>
<td width="400" style="text-align:right;">
<input type="submit" value="Apply Changes" /> <input type="button" value="Cancel Changes" id="refund_cancel_btn" />
</td>
</tr>
</table>
</div>
</form>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#invoice_refund_form').ajaxForm({
url: '/wp-admin/admin-ajax.php'
, data: ({ajax:"yes", action: 'issue_invoice_refund', invoice_id: <?php echo $invoice->ID?>})
, dataType: 'json'
, type: 'POST'
, success: function(data) {
if (data.success == 'true') {
document.location.href = document.location.href;
} else {
jAlert(data.msg, 'Server Error Encountered');
}
}
});
$('#refund_cancel_btn').click(function(e) {
e.preventDefault();
$.colorbox.close();
});
});
</script>
</body>
</html>
\ No newline at end of file