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
5f4155a1
authored
2011-03-11 06:25:51 +0000
by
Kevin Burton
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
invoicing updates
1 parent
8a0f1789
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
49 deletions
com/UserManager/UserManager.js
com/UserManager/UserManager.php
com/UserManager/views/edit_user_overview.php
com/UserManager/views/edit_user_payhistory.php
com/UserManager/views/partials/edit_invoice.php
com/UserManager/UserManager.js
View file @
5f4155a
...
...
@@ -164,20 +164,26 @@ jQuery(function($) {
jQuery
(
'.invoice-refund-btn'
).
live
(
'click'
,
function
(
e
)
{
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
)
{
jPrompt
(
'How much would you like to re-imburse?'
,
current_amount
,
'Re-imburse...'
,
function
(
r
)
{
if
(
r
)
{
jQuery
.
ajax
({
url
:
'/wp-admin/admin-ajax.php'
,
data
:
({
ajax
:
"yes"
,
action
:
'admin_refund_invoice'
,
invoice_id
:
iid
})
,
dataType
:
'json'
,
data
:
({
ajax
:
"yes"
,
action
:
'admin_refund_invoice'
,
invoice_id
:
iid
,
amount
:
r
})
,
type
:
'POST'
,
dataType
:
'json'
,
success
:
function
(
data
)
{
document
.
location
.
reload
();
}
});
}
});
}
});
e
.
preventDefault
();
return
false
;
});
...
...
@@ -207,11 +213,7 @@ jQuery(function($) {
var
cb
=
this
;
var
options
=
{
success
:
function
(
data
)
{
if
(
data
.
refresh
==
"true"
)
{
document
.
location
.
href
=
document
.
location
.
href
;
}
else
{
jQuery
.
colorbox
.
close
();
}
document
.
location
.
reload
();
}
,
data
:
({
ajax
:
"yes"
,
action
:
'admin_update_invoice'
})
,
dataType
:
'json'
...
...
com/UserManager/UserManager.php
View file @
5f4155a
...
...
@@ -713,10 +713,6 @@ class Actions {
$paid_by
=
$_POST
[
'paid_by'
];
$title
=
$_POST
[
'title'
];
if
(
$invoice_type
==
"credit"
)
{
$amount
=
"-"
.
$amount
;
}
$paid
=
(
isset
(
$_POST
[
'paid'
])
&&
$_POST
[
'paid'
]
==
"on"
)
?
true
:
false
;
if
(
$invoice_type
==
"invoice"
)
{
if
(
!
$paid
)
{
...
...
@@ -776,7 +772,10 @@ class Actions {
}
}
Invoice\create
(
$invoice_data
,
'generic'
,
$title
,
$uid
,
$status
,
'publish'
,
$amount
);
$new_invoice_id
=
Invoice\create
(
$invoice_data
,
'generic'
,
$title
,
$uid
,
$status
,
'publish'
,
$amount
);
if
(
$invoice_type
==
"credit"
)
{
update_post_meta
(
$new_invoice_id
,
'credit_amount'
,
$amount
);
}
// return json object
$return
=
array
(
...
...
@@ -1106,24 +1105,45 @@ class Actions {
die
(
json_encode
(
$return
));
}
public
static
function
wp_ajax_admin_
refund
_invoice
()
{
public
static
function
wp_ajax_admin_
update
_invoice
()
{
$invoice_id
=
$_POST
[
'invoice_id'
];
$user_id
=
$_POST
[
'uid'
];
$invoice
=
get_post
(
$invoice_id
);
update_post_meta
(
$invoice_id
,
'trans_status'
,
'paid'
);
$payment
=
get_post_meta
(
$invoice_id
,
'payment'
,
true
);
$payment
[
'bt_card_type'
]
=
$_POST
[
'paid_by'
];
update_post_meta
(
$invoice_id
,
'payment'
,
$payment
);
$invoice_for
=
get_post_meta
(
$invoice_id
,
'invoice_for'
,
true
);
if
(
!
empty
(
$invoice_for
)
&&
$invoice_for
==
"membership"
)
{
$next_year
=
(
int
)
date
(
"Y"
);
$next_year
=
(
$next_year
+
1
);
update_user_meta
(
$user_id
,
'membership_valid_until'
,
$next_year
);
}
$return
=
array
(
'success'
=>
'true'
);
die
(
json_encode
(
$return
));
}
public
static
function
wp_ajax_admin_refund_invoice
()
{
$invoice_id
=
$_POST
[
'invoice_id'
];
$amount
=
$_POST
[
'amount'
];
$invoice
=
get_post
(
$invoice_id
);
$payment
=
get_post_meta
(
$invoice_id
,
'payment'
,
true
);
$trans_amount
=
get_post_meta
(
$invoice_id
,
'trans_amount'
,
true
);
$invoice_for
=
get_post_meta
(
$invoice_id
,
'invoice_for'
,
true
);
$items
=
get_post_meta
(
$invoice_id
,
'items'
,
true
);
update_post_meta
(
$invoice
->
ID
,
'refunded'
,
date
(
'Y-m-d H:i:s'
));
$invoice_data
[
'items'
]
=
$items
;
$invoice_data
[
'payment'
]
=
$payment
;
$new_invoice_id
=
Invoice\create
(
$invoice_data
,
$invoice_for
,
$invoice
->
post_title
,
$invoice
->
post_author
,
'credit'
,
'publish'
,
$trans_amount
);
update_post_meta
(
$new_invoice_id
,
'original_invoice_id'
,
$invoice_id
);
update_post_meta
(
$new_invoice_id
,
'credit_amount'
,
$amount
);
}
...
...
com/UserManager/views/edit_user_overview.php
View file @
5f4155a
...
...
@@ -155,8 +155,8 @@ use WP_User, WP_Roles;
<td><label
for=
"status_retired"
>
Retired status
</label></td>
</tr>
<tr>
<td
width=
"20"
><input
type=
"checkbox"
id=
"status_disab
ility"
name=
"special_status[]"
value=
"status_disability"
<?php
search_special_status
(
'status_disability
'
);
?>
/></td>
<td><label
for=
"status_disab
ility
"
>
Disability status
</label></td>
<td
width=
"20"
><input
type=
"checkbox"
id=
"status_disab
led"
name=
"special_status[]"
value=
"status_disabled"
<?php
search_special_status
(
'status_disabled
'
);
?>
/></td>
<td><label
for=
"status_disab
led
"
>
Disability status
</label></td>
</tr>
<tr>
<td
width=
"20"
><input
type=
"checkbox"
id=
"status_parental"
name=
"special_status[]"
value=
"status_parental"
<?php
search_special_status
(
'status_parental'
);
?>
/></td>
...
...
com/UserManager/views/edit_user_payhistory.php
View file @
5f4155a
...
...
@@ -17,7 +17,7 @@ use WP_User;
<div
style=
"padding:10px 10px 0px 10px; min-width:760px;position:relative;"
>
<h2
style=
"margin-bottom:10px;padding-bottom:0px;"
>
Users' Payment History...
<?php
if
(
!
isset
(
$_GET
[
'view'
]))
:?>
<
a
href
=
"#"
class
="
button
add
-
new
-
h2
" id="
creditNotBtn
">Creat new Invoice/Credit Note</a>
<
a
href
=
"#"
class
="
button
add
-
new
-
h2
" id="
creditNotBtn
">Creat
e
new Invoice/Credit Note</a>
<?php endif; ?>
</h2>
...
...
@@ -53,11 +53,11 @@ use WP_User;
<td>Paid By</td>
<td>
<select name="
paid_by
">
<option value="">
(none)
</option>
<option value="
visa
">
Visa</option>
<option value="
mc
">
Mastercard</option>
<option value="
amex
">
American Express</option>
<option value="
cheque
">
Cheque</option>
<option value="">
Select payment type...
</option>
<option value="
PPV
">Pre-paid with
Visa</option>
<option value="
PPMC
">Pre-paid with
Mastercard</option>
<option value="
PPAMEX
">Pre-paid with
American Express</option>
<option value="
CHEQUE
">Paid by
Cheque</option>
</select>
</td>
</tr>
...
...
@@ -115,13 +115,13 @@ use WP_User;
$html
.=
'<tr>'
;
$html
.=
'<th>Item / Description</th>'
;
if
(
$status
!=
"credit"
)
{
//
if ($status!="credit") {
$html
.=
'<th width="80">Cost</th>'
;
$html
.=
'<th width="80">Discounts</th>'
;
$html
.=
'<th width="120">Amount</th>'
;
}
else
{
$html
.=
'<th width="120">Credit</th>'
;
}
//
} else {
//
$html .= '<th width="120">Credit</th>';
//
}
$html
.=
'</tr>'
;
$html
.=
'</thead>'
;
...
...
@@ -176,7 +176,7 @@ use WP_User;
$html
.=
'<tr class="'
.
$row_class
.
'">'
;
$html
.=
'<td>'
.
$description
.
'</td>'
;
if
(
$status
!=
"credit"
)
{
//
if ($status!="credit") {
$html
.=
'<td>$'
.
$item
[
'cost'
]
.
'</td>'
;
if
(
empty
(
$item
[
'discount_amount'
]))
{
$html
.=
'<td>$0.00</td>'
;
...
...
@@ -184,7 +184,7 @@ use WP_User;
$html
.=
'<td>-$'
.
$item
[
'discount_amount'
]
.
'</td>'
;
}
}
//
}
$html
.=
'<td>$'
.
$item
[
'subtotal'
]
.
'</td>'
;
...
...
@@ -193,7 +193,7 @@ use WP_User;
}
$html
.=
'</tbody>'
;
$html
.=
'</table>'
;
if
(
$status
!=
"credit"
)
{
//
if ($status != "credit") {
$html
.=
'<table cellpadding="0" cellspacing="0" border="0" class="clean" id="invoice-table">'
;
$html
.=
'<tfoot>'
;
...
...
@@ -222,31 +222,47 @@ use WP_User;
}
$amount_label
=
(
$status
==
"paid"
)
?
"Total"
:
"Amount Due"
;
$amount
=
$invoice
->
payment
[
'total'
];
$credit
=
get_post_meta
(
$invoice
->
ID
,
'credit_amount'
,
true
);
if
(
!
empty
(
$credit
)
&&
$status
==
"credit"
)
{
$html
.=
'<tr>'
;
$html
.=
'<td style="text-align:right;padding-right:10px;font-weight:bold; color:green;">Credit</td>'
;
$html
.=
'<td style="color:green;">-$'
.
number_format
(
$credit
,
2
)
.
'</td>'
;
$html
.=
'</tr>'
;
$amount
=
(
$amount
-
$credit
);
}
$amount_label
=
(
$status
==
"unpaid"
)
?
"Amount Due"
:
"Total"
;
$html
.=
'<tr>'
;
$html
.=
'<td style="text-align:right;padding-right:10px;font-weight:bold;">'
.
$amount_label
.
'</td>'
;
$html
.=
'<td><strong>$'
.
number_format
(
$
invoice
->
payment
[
'total'
]
,
2
)
.
'</strong></td>'
;
$html
.=
'<td><strong>$'
.
number_format
(
$
amount
,
2
)
.
'</strong></td>'
;
$html
.=
'</tr>'
;
$html
.=
'</tfoot>'
;
$html
.=
'</table>'
;
}
//
}
$html
.=
'</p>'
;
if
(
$status
!=
"credit"
&&
$invoice
->
payment
[
'bt_address'
]
!=
""
&&
$invoice
->
payment
[
'bt_card_holder'
]
!=
""
)
{
$html
.=
'<h3>BILLED TO:</h3>'
;
$html
.=
$invoice
->
payment
[
'bt_card_holder'
]
.
"<br />
"
;
$html
.=
$invoice
->
payment
[
'bt_address'
]
.
" "
.
$invoice
->
payment
[
'bt_address2'
]
.
"<br />
"
;
$html
.=
$invoice
->
payment
[
'bt_city'
]
.
", "
.
$invoice
->
payment
[
'bt_province'
]
.
"<br />
"
;
$html
.=
$invoice
->
payment
[
'bt_country'
]
.
" "
.
$invoice
->
payment
[
'bt_postal'
]
.
"<br /><br />
"
;
$html
.=
"<strong>"
.
ucwords
(
$invoice
->
payment
[
'bt_card_type'
])
.
"</strong> "
.
$invoice
->
payment
[
'bt_card_number'
]
;
}
//
if ($status != "credit" && $invoice->payment['bt_address'] != "" && $invoice->payment['bt_card_holder'] != "") {
$html
.=
(
!
empty
(
$invoice
->
payment
[
'bt_card_holder'
]))
?
'<h3>BILLED TO:</h3>'
:
""
;
$html
.=
(
!
empty
(
$invoice
->
payment
[
'bt_card_holder'
]))
?
$invoice
->
payment
[
'bt_card_holder'
]
.
"<br />"
:
"
"
;
$html
.=
(
!
empty
(
$invoice
->
payment
[
'bt_address'
]))
?
$invoice
->
payment
[
'bt_address'
]
.
" "
.
$invoice
->
payment
[
'bt_address2'
]
.
"<br />"
:
"
"
;
$html
.=
(
!
empty
(
$invoice
->
payment
[
'bt_city'
]))
?
$invoice
->
payment
[
'bt_city'
]
.
", "
.
$invoice
->
payment
[
'bt_province'
]
.
"<br />"
:
"
"
;
$html
.=
(
!
empty
(
$invoice
->
payment
[
'bt_country'
]))
?
$invoice
->
payment
[
'bt_country'
]
.
" "
.
$invoice
->
payment
[
'bt_postal'
]
.
"<br /><br />"
:
"
"
;
$html
.=
(
!
empty
(
$invoice
->
payment
[
'bt_card_type'
]))
?
"Paid using: <strong>"
.
CBV\get_payment_string
(
$invoice
->
payment
[
'bt_card_type'
])
.
"</strong> "
.
$invoice
->
payment
[
'bt_card_number'
]
:
""
;
//
}
if
(
$status
!=
"credit"
)
{
//
if ($status != "credit") {
$html
.=
'<p>GST/HST# R108075334</p>'
;
}
//
}
if
(
$status
==
"paid"
)
{
$html
.=
'<div style="text-align:center; font-size:14px; color:green;">-- <strong>PAID</strong> --</div>'
;
...
...
@@ -254,6 +270,8 @@ use WP_User;
$html
.=
'<div style="text-align:center; font-size:14px; color:red;">-- THIS INVOICE IS <strong>UNPAID</strong> --</div>'
;
}
elseif
(
$status
==
"credit"
)
{
$html
.=
'<div style="text-align:center; font-size:14px; color:green;">-- <strong>CREDIT NOTE</strong> --</div>'
;
}
elseif
(
$status
==
"cancelled"
)
{
$html
.=
'<div style="text-align:center; font-size:14px; color:green;">-- THIS INVOICE IS <strong>CANCELLED</strong> --</div>'
;
}
...
...
com/UserManager/views/partials/edit_invoice.php
View file @
5f4155a
...
...
@@ -40,13 +40,12 @@
<div
style=
"padding: 0px 0px 10px 0px;"
>
<form
method=
"post"
action=
""
id=
"edit-invoice-form"
>
<input
type=
"hidden"
name=
"uid"
value=
"
<?php
echo
$uid
;
?>
"
/>
<input
type=
"hidden"
name=
"invoice_id"
value=
"
<?php
echo
$post
->
ID
;
?>
"
/>
<input
type=
"hidden"
name=
"type"
value=
"
<?php
echo
$action
;
?>
"
/>
<input
type=
"hidden"
name=
"uid"
value=
"
<?php
echo
$_GET
[
'uid'
];
?>
"
/>
<input
type=
"hidden"
name=
"invoice_id"
value=
"
<?php
echo
$_GET
[
'invoice_id'
];
?>
"
/>
<div
class=
"dashboard-section"
style=
"margin-left:20px;margin-top:10px;"
>
<div
class=
"dashboard-section-content small"
>
<select
name=
"
status
"
>
<select
name=
"
paid_by
"
>
<option
value=
""
>
Select payment type...
</option>
<option
value=
"PPV"
>
Pre-paid with Visa
</option>
<option
value=
"PPMC"
>
Pre-paid with Mastercard
</option>
...
...
Please
register
or
sign in
to post a comment