Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
Tz Tools
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
6894dc1c
authored
2011-04-21 21:38:33 +0000
by
Chris Boden
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Cleaned up reimbursment display, mapped calls to new API in CBV Invoice
1 parent
72db23b4
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
206 deletions
com/UserManager/UserManager.js
com/UserManager/UserManager.php
com/UserManager/views/edit_user_payhistory.php
com/UserManager/views/partials/edit_course.php
com/UserManager/views/partials/invoice-refund-view.php
com/UserManager/UserManager.js
View file @
6894dc1
...
...
@@ -205,35 +205,38 @@ jQuery(function($) {
var
iid
=
$
(
this
).
attr
(
'rel'
);
var
current_amount
=
$
(
this
).
attr
(
'amount'
);
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({
href
:
'/wp-admin/admin-ajax.php?ajax=yes&action=admin_refund_invoice_form&invoice_id='
+
iid
+
'&uid='
+
user_id
,
onComplete
:
function
()
{
jQuery
(
'#invoice_refund_form'
).
ajaxForm
({
url
:
'/wp-admin/admin-ajax.php'
, data: ({ajax:"yes", action: 'admin_refund_invoice',invoice_id:iid, amount:r})
, type: 'POST'
,
data
:
({
ajax
:
"yes"
,
action
:
'issue_invoice_refund'
,
invoice_id
:
iid
})
,
dataType
:
'json'
,
type
:
'POST'
,
success
:
function
(
data
)
{
document.location.reload();
if
(
data
.
success
==
'true'
)
{
document
.
location
.
href
=
document
.
location
.
href
;
}
else
{
jAlert
(
data
.
msg
,
'Server Error Encountered'
);
}
});
}
,
error
:
function
(
XMLHttpRequest
,
textStatus
,
errorThrown
)
{
jAlert
(
textStatus
,
'Server Error Encountered'
);
}
});
*/
$
(
'#refund_cancel_btn'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
$
.
colorbox
.
close
();
});
}
});
e
.
preventDefault
();
return
false
;
});
jQuery
(
'.invoice-cancel-btn'
).
live
(
'click'
,
function
(
e
)
{
var
iid
=
$
(
this
).
attr
(
'rel'
);
...
...
com/UserManager/UserManager.php
View file @
6894dc1
...
...
@@ -18,7 +18,8 @@ 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
Tz\WordPress\CBV\Invoice
,
Tz\WordPress\CBV\Invoice\Order\Item
as
OrderItem
;
use
Tz\WordPress\CBV\Beanstream\Card
as
CreditCard
;
use
Tz\WordPress\CBV\Courses
;
use
Tz\WordPress\CBV\CBVOptions
;
use
Exception
,
StdClass
,
ArrayAccess
,
Iterator
,
Countable
;
...
...
@@ -804,137 +805,38 @@ class Actions {
$user
=
new
User\Account
(
$_POST
[
'user_id'
]);
$course
=
new
Courses\Course
(
$_POST
[
'course_id'
]);
$enrolltype
=
$_POST
[
'enrolltype'
];
$tax_rate
=
$user
->
getLocTaxPct
();
// Apply user to course, sets group, set enrollment, etc.
$user
->
registerForCourse
(
$course
->
getID
(),
(
boolean
)
isset
(
$_POST
[
'exam'
]),
$enrolltype
);
$user
->
approveToCourse
(
$course
->
getID
());
// Do all the invoicey stuff
$items_subtotal
=
$items_taxes
=
$items_total
=
0
;
// Running totals...should be a class
$tax_rate
=
$user
->
getLocTaxPct
();
$calc_tax
=
function
(
$cost
,
$tax_rate
)
{
return
number_format
((
$cost
*
$tax_rate
*
0.01
),
2
,
'.'
,
''
);
};
$course_cost
=
$course
->
$enrolltype
;
$course_taxes
=
$calc_tax
(
$course_cost
,
$tax_rate
);
// Add course cost to running totals
$items_subtotal
+=
$course_cost
;
$items_taxes
+=
$course_taxes
;
$items_total
+=
(
$course_cost
+
$course_taxes
);
// Add the course its self to the receipt
$items
=
Array
(
Array
(
'post_id'
=>
$course
->
getID
()
,
'cost'
=>
$course_cost
,
'discount_label'
=>
""
,
'discount_amount'
=>
0
,
'tax_label'
=>
"Taxes"
,
'tax_rate'
=>
$tax_rate
,
'tax_amount'
=>
$course_taxes
,
'subtotal'
=>
$course_cost
,
'total'
=>
number_format
((
$course_cost
+
$course_taxes
),
2
,
'.'
,
''
)
,
'description'
=>
$course
->
post_title
,
'extras'
=>
array
()
));
$order
=
new
Invoice\Order
();
$order
->
addItem
(
new
OrderItem
(
$course
->
$enrolltype
,
$tax_rate
,
$course
->
post_title
,
$course
->
getID
()));
if
(
isset
(
$_POST
[
'studentfee'
])
&&
$_POST
[
'studentfee'
]
==
1
)
{
$fee
=
number_format
(
CBVOptions\GetOption
(
'student-fees'
,
'fees'
),
2
,
'.'
,
''
);
$taxes
=
$calc_tax
(
$fee
,
$tax_rate
);
$items_subtotal
+=
$fee
;
$items_taxes
+=
$taxes
;
$items_total
+=
$fee
+
$taxes
;
$items
[]
=
Array
(
'post_id'
=>
0
,
'cost'
=>
$fee
,
'discount_label'
=>
''
,
'discount_amount'
=>
''
,
'tax_label'
=>
'Taxes'
,
'tax_rate'
=>
$tax_rate
,
'tax_amount'
=>
$taxes
,
'subtotal'
=>
$fee
,
'total'
=>
(
$fee
+
$taxes
)
,
'description'
=>
'Annual Registration Fee'
,
'extras'
=>
Array
()
);
$order
->
addItem
(
new
OrderItem
(
$fee
,
$tax_rate
,
'Annual Registration Fee'
));
$user
->
setMeta
(
'fee_semester_paid'
,
$course
->
semester_id
);
}
// If the user paid for the casebook add to invoice and Casebook group
if
(
isset
(
$_POST
[
'casebook'
])
&&
$_POST
[
'casebook'
]
==
1
)
{
$book
=
UAM\getGroup
(
'Casebook'
);
$book
->
addUser
(
$user
->
ID
);
$cost
=
substr
(
$book
->
getDescription
(),
strpos
(
$book
->
getDescription
(),
':'
)
+
1
);
$taxes
=
$calc_tax
(
$cost
,
CBV\get_tax_pct
());
$items_subtotal
+=
$cost
;
$items_taxes
+=
$taxes
;
$items_total
+=
$cost
+
$taxes
;
$items
[]
=
Array
(
'post_id'
=>
CBV\CASEBOOK_POSTID
,
'cost'
=>
$cost
,
'discount_label'
=>
''
,
'discount_amount'
=>
''
,
'tax_label'
=>
'Taxes'
,
'tax_rate'
=>
CBV\get_tax_pct
()
,
'tax_amount'
=>
$taxes
,
'subtotal'
=>
$cost
,
'total'
=>
(
$cost
+
$taxes
)
,
'description'
=>
'Casebook'
,
'extras'
=>
Array
()
);
$order
->
addItem
(
new
OrderItem
(
$cost
,
CBV\get_tax_pct
(),
'Casebook'
,
CBV\CASEBOOK_POSTID
));
}
// If the user is overseas and CBV charged them for it, add item to receipt
if
(
isset
(
$_POST
[
'overseas'
])
&&
$_POST
[
'overseas'
]
==
1
)
{
$os_cost
=
number_format
(
CBVOptions\GetOption
(
'overseas-surcharge'
,
'fees'
),
2
,
'.'
,
''
);
$os_taxes
=
$calc_tax
(
$os_cost
,
$tax_rate
);
$items
[]
=
Array
(
'post_id'
=>
0
,
'cost'
=>
$os_cost
,
'discount_label'
=>
''
,
'discount_amount'
=>
''
,
'tax_label'
=>
'Taxes'
,
'tax_rate'
=>
$tax_rate
,
'tax_amount'
=>
$os_taxes
,
'subtotal'
=>
$os_cost
,
'total'
=>
(
$os_cost
+
$os_taxes
)
,
'description'
=>
'Overseas Surcharge'
,
'extras'
=>
Array
()
);
$items_subtotal
+=
$os_cost
;
$items_taxes
+=
$os_taxes
;
$items_total
+=
(
$os_cost
+
$os_taxes
);
$order
->
addItem
(
new
OrderItem
(
$os_cost
,
$tax_rate
,
'Overseas Surcharge'
));
}
$invoice_data
=
Array
();
$invoice_data
[
'items'
]
=
$items
;
$invoice_data
[
'payment'
]
=
Array
(
'total_cost'
=>
$items_subtotal
,
'total_discounts'
=>
""
,
'total_taxes'
=>
$items_taxes
,
'subtotal'
=>
$items_subtotal
,
'total'
=>
$items_total
,
'bt_address'
=>
""
,
'bt_address2'
=>
""
,
'bt_city'
=>
""
,
'bt_province'
=>
""
,
'bt_country'
=>
""
,
'bt_postal'
=>
""
,
'bt_card_holder'
=>
""
,
'bt_card_number'
=>
""
,
'bt_card_type'
=>
$_POST
[
'paid_by'
]
);
Invoice\create
(
$invoice_data
,
'course'
,
'Course Invoice'
,
$user
->
ID
,
'paid'
,
'publish'
,
$items_total
);
$cc
=
new
CreditCard
(
null
,
$_POST
[
'paid_by'
]);
$order
->
generateInvoice
(
$user
,
'course'
,
'Course Invoice'
,
$cc
);
die
(
json_encode
(
Array
(
'success'
=>
'true'
,
'refresh'
=>
'true'
)));
}
...
...
@@ -1437,8 +1339,7 @@ class Actions {
$user
=
new
User\Account
(
$_GET
[
'uid'
]);
ob_start
();
$invoice
=
get_post
(
$_GET
[
'invoice_id'
]);
$invoice
=
new
Invoice\Receipt
(
$_GET
[
'invoice_id'
]);
require_once
(
__DIR__
.
DIRECTORY_SEPARATOR
.
'views'
.
DIRECTORY_SEPARATOR
.
'partials'
.
DIRECTORY_SEPARATOR
.
'invoice-refund-view.php'
);
...
...
@@ -1448,13 +1349,16 @@ class Actions {
}
public
static
function
wp_ajax_issue_invoice_refund
()
{
$invoice
=
get_post
(
$_POST
[
'invoice_id'
]);
$user
=
new
User\Account
(
$invoice
->
post_author
);
$invoice
=
new
Invoice\Receipt
(
$_POST
[
'invoice_id'
]);
$user
=
new
User\Account
(
$invoice
->
getOwner
());
$items
=
$_POST
[
'keys'
];
// Chris, do what you need to do with this....
foreach
(
$items
as
$index
=>
$yes
)
{
$invoice
->
seek
(
$index
)
->
cancel
();
}
$invoice
->
runRefund
();
// Chris, do what you need to do with this....
// if there is an error, turn success to 'false' and set a msg.
$return
=
array
(
...
...
@@ -1462,8 +1366,6 @@ class Actions {
,
'msg'
=>
''
);
die
(
json_encode
(
$return
));
}
public
static
function
wp_ajax_admin_search_merge_users
()
{
...
...
com/UserManager/views/edit_user_payhistory.php
View file @
6894dc1
...
...
@@ -15,6 +15,7 @@ use Exception, StdClass;
use
WP_User
;
?>
<div
style=
"padding:10px 10px 0px 10px; min-width:760px;position:relative;"
>
<h2
style=
"margin-bottom:10px;padding-bottom:0px;"
>
Users' Invoice/Receipts...
<?php
if
(
!
isset
(
$_GET
[
'view'
]))
:?>
<
a
href
=
"#"
class
="
button
add
-
new
-
h2
" id="
creditNotBtn
">Create new Invoice/Credit Note</a>
...
...
com/UserManager/views/partials/edit_course.php
View file @
6894dc1
...
...
@@ -74,7 +74,7 @@
<div
class=
"dashboard-section"
style=
"margin-left:20px;margin-top:10px;"
>
<div
class=
"dashboard-section-title"
>
<input
type=
"checkbox"
name=
"exam"
id=
"exam"
value=
"1"
checked
/>
<label
for=
"
casebook
"
>
WRITING EXAM?
</label>
<label
for=
"
exam
"
>
WRITING EXAM?
</label>
</div>
</div>
...
...
@@ -100,7 +100,7 @@
<div
class=
"dashboard-section"
style=
"margin-left:20px;margin-top:10px;"
>
<div
class=
"dashboard-section-title"
>
<input
type=
"checkbox"
name=
"overseas"
id=
"overseas"
value=
"1"
checked
/>
<label
for=
"
casebook
"
>
PAID OVERSEAS SURCHARGE?
</label>
<label
for=
"
overseas
"
>
PAID OVERSEAS SURCHARGE?
</label>
</div>
</div>
<?php
endif
;
?>
...
...
com/UserManager/views/partials/invoice-refund-view.php
View file @
6894dc1
<!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>
<!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>
<title>
Refund:
<?php
echo
$invoice
->
getTitle
();
?>
</title>
<style
type=
"text/css"
>
html
,
body
{
margin
:
0px
;
padding
:
0
;}
.title-link
{
color
:
#f7bd55
;
color
:
#F7BD55
;
font-size
:
12px
;
font-weight
:
bold
;
text-align
:
left
;
line-height
:
1.75em
;
background
:
#3b0d
32
;
border
:
solid
1px
#FFF
;
border-bottom
:
solid
1px
#999
;
background
:
#3B0D
32
;
border
:
1px
solid
#FFF
;
border-bottom
:
1px
solid
#999
;
cursor
:
default
;
padding
:
0em
;
padding
:
3px
10px
3px
10px
;
padding
:
3px
10px
3px
10px
;
margin
:
0em
;
}
form
{
display
:
block
;
margin-right
:
20px
;
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
{
text-align
:
left
;
border-bottom
:
1px
solid
#CCC
;
}
table
.item-listings
tr
td
{
text-aling
:
left
;
border-bottom
:
1px
solid
#CCC
;
}
table
.item-listings
tbody
tr
.odd
td
{
background-color
:
#F5F5F5
;
}
table
.item-listings
tr
th
,
table
.item-listings
tr
td
{
padding
:
4px
5px
;
}
table
.item-listings
thead
tr
th
{
padding-bottom
:
10px
;
}
table
{
border-collapse
:
collapse
;
}
.dashboard-section-title
{
font-weight
:
bold
;
color
:
#3b0d32
;
}
label
.amount
{
color
:
#999
;
font-size
:
11px
;
}
</style>
</head>
<body>
<body
class=
"invoice-refund"
>
<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
class=
"title-link"
>
Refund:
<?php
echo
$invoice
->
getTitle
()
;
?>
</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>
<table
cellpadding=
"0"
cellspacing=
"0"
width=
"100%"
border=
"0"
class=
"item-listings"
>
<t
head><t
r>
<th>
Item Description
</th>
<th
width=
"140"
>
Refund?
</th>
</tr>
</tr>
</thead>
<tbody>
<?php
$items
=
get_post_meta
(
$invoice
->
ID
,
'items'
,
true
);
foreach
(
$items
as
$key
=>
$item
)
:
$i
=
0
;
foreach
(
$invoice
as
$key
=>
$item
)
:
$unq
=
"keys[
{
$key
}
]"
;
?>
<tr>
<tr
class=
"
<?php
echo
(
++
$i
&
1
?
'odd'
:
'even'
);
?>
"
>
<td><label
for=
"
<?php
echo
$unq
;
?>
"
>
<?php
echo
$item
->
getDescription
();
?>
</label></td>
<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'
];
}
?>
<input
type=
"checkbox"
checked=
"checked"
value=
"1"
id=
"
<?php
echo
$unq
;
?>
"
name=
"
<?php
echo
$unq
;
?>
"
/>
<label
for=
"
<?php
echo
$unq
;
?>
"
class=
"amount"
>
(-$
<?php
echo
$item
->
getTotal
();
?>
)
</label>
</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>
</t
body></t
able>
<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;"
>
<div
style=
"padding-top:8px;margin-top:25px;"
>
<table
cellpadding=
"0"
cellspacing=
"0"
width=
"100%"
border=
"0"
>
<tr>
<td>
<input
name=
"force_cancellation_fee"
value=
"on"
type=
"checkbox"
checked=
"checked"
/>
<label>
Apply cancellation fee?
</label>
<input
name=
"force_cancellation_fee"
id=
"force_cancellation_fee"
value=
"1"
type=
"checkbox"
checked=
"checked"
/>
<label
for=
"force_cancellation_fee"
>
Apply cancellation fee?
</label>
<label
for=
"force_cancellation_fee"
class=
"amount"
>
(
<?php
echo
'$150.00'
;
?>
)
</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
...
...
Please
register
or
sign in
to post a comment