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
0181ba0d
authored
2011-02-25 05:49:01 +0000
by
Kevin Burton
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
user manager invoice updates
1 parent
f863f2bc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
52 deletions
com/UserManager/UserManager.js
com/UserManager/UserManager.php
com/UserManager/views/edit_user_payhistory.php
com/UserManager/UserManager.js
View file @
0181ba0
...
...
@@ -21,11 +21,27 @@ jQuery(function($) {
);
}
$
(
'#invoice_type'
).
change
(
function
()
{
if
(
$
(
'#invoice_type'
).
val
()
==
"invoice"
)
{
$
(
'.invoice_only'
).
show
();
}
else
{
$
(
'.invoice_only'
).
hide
();
}
});
jQuery
(
'#creditNotBtn'
).
click
(
function
(
e
)
{
jQuery
(
'#credit_note'
).
slideToggle
(
'fast'
);
var
InvoiceType
=
$
(
'#invoice_type'
);
if
(
InvoiceType
.
val
()
==
"invoice"
)
{
$
(
'.invoice_only'
).
show
();
}
else
{
$
(
'.invoice_only'
).
hide
();
}
jQuery
(
'#creditForm'
).
ajaxForm
({
url
:
'/wp-admin/admin-ajax.php'
,
data
:
({
ajax
:
"yes"
,
action
:
'
add_credit
_note'
})
,
data
:
({
ajax
:
"yes"
,
action
:
'
create_invoice
_note'
})
,
dateType
:
'json'
,
type
:
'POST'
,
success
:
function
(
data
)
{
...
...
com/UserManager/UserManager.php
View file @
0181ba0
...
...
@@ -678,12 +678,27 @@ class Actions {
die
(
json_encode
(
$return
));
}
public
static
function
wp_ajax_add_credit_note
()
{
public
static
function
wp_ajax_create_invoice_note
()
{
global
$wpdb
;
$uid
=
$_POST
[
'uid'
];
$amount
=
$_POST
[
'amount'
];
$invoice_type
=
$_POST
[
'invoice_type'
];
$paid_by
=
$_POST
[
'paid_by'
];
$title
=
$_POST
[
'title'
];
$amount
=
"-"
.
$_POST
[
'amount'
];
global
$wpdb
;
if
(
$invoice_type
==
"credit"
)
{
$amount
=
"-"
.
$amount
;
}
$paid
=
isset
(
$_POST
[
'paid'
])
?
true
:
false
;
if
(
$invoice_type
==
"invoice"
)
{
if
(
!
$paid
)
{
$paid_by
=
""
;
}
}
else
{
$paid_by
=
""
;
}
$items
=
array
();
...
...
@@ -692,18 +707,17 @@ class Actions {
'post_id'
=>
0
,
'cost'
=>
$amount
,
'discount_label'
=>
""
,
'discount_amount'
=>
""
,
'discount_amount'
=>
0
,
'tax_label'
=>
""
,
'tax_rate'
=>
""
,
'tax_amount'
=>
""
,
'tax_amount'
=>
"
0.00
"
,
'subtotal'
=>
$amount
,
'total'
=>
$amount
,
'description'
=>
"Credit Note"
,
'description'
=>
$title
,
'extras'
=>
array
()
);
$invoice_data
=
array
();
$invoice_data
[
'items'
]
=
$items
;
$invoice_data
[
'payment'
]
=
array
(
...
...
@@ -720,29 +734,23 @@ class Actions {
,
'bt_postal'
=>
""
,
'bt_card_holder'
=>
""
,
'bt_card_number'
=>
""
,
'bt_card_type'
=>
""
,
'bt_card_type'
=>
$paid_by
);
Invoice\create
(
$invoice_data
,
'credit'
,
$title
,
$uid
,
'credit'
,
'publish'
,
$amount
);
// return json object
$return
=
array
(
'success'
=>
'true'
);
die
(
json_encode
(
$return
));
}
public
static
function
wp_ajax_post_credit
()
{
$uid
=
$_POST
[
'uid'
];
$post_id
=
$_POST
[
'event_id'
];
// could be an event, or a course.
$amount
=
$_POST
[
'amount'
];
// post credit to their account.
if
(
$invoice_type
==
"credit"
)
{
$status
=
"credit"
;
}
else
{
$paid
=
isset
(
$_POST
[
'paid'
])
?
true
:
false
;
if
(
$paid
)
{
$status
=
"paid"
;
}
else
{
$status
=
"unpaid"
;
}
}
Invoice\create
(
$invoice_data
,
'generic'
,
$title
,
$uid
,
$status
,
'publish'
,
$amount
);
// return json object
$return
=
array
(
...
...
@@ -750,8 +758,7 @@ class Actions {
);
die
(
json_encode
(
$return
));
}
}
public
static
function
wp_ajax_update_registration
()
{
...
...
com/UserManager/views/edit_user_payhistory.php
View file @
0181ba0
...
...
@@ -15,10 +15,9 @@ use Exception, StdClass;
use
WP_User
;
?>
<div
style=
"padding:10px 10px 0px 10px; min-width:760px;position:relative;"
>
<div
style=
"position:absolute; width:200px; height:30px;right:20px; top:35px;text-align:right;font-size:16px;"
>
Balance:
<strong>
$
<?php
echo
get_user_meta
(
$_GET
[
'uid'
],
'balance'
,
true
);
?>
</strong></div>
<h2
style=
"margin-bottom:10px;padding-bottom:0px;"
>
Users' Invoices...
<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</a>
<
a
href
=
"#"
class
="
button
add
-
new
-
h2
" id="
creditNotBtn
">Creat new Invoice
/Credit Note
</a>
<?php endif; ?>
</h2>
...
...
@@ -26,19 +25,44 @@ use WP_User;
<div style="
border
:
1
px
solid
#e8e8e8; background-color:#f5f5f5;padding:10px;">
<
form
id
=
"creditForm"
method
=
"POST"
>
<
input
type
=
"hidden"
name
=
"uid"
value
=
"<?php echo
$_GET['uid']
; ?>"
/>
<
h3
style
=
"margin:0;padding:0;"
>
Invoice
...</
h3
>
<
h3
style
=
"margin:0;padding:0;"
>
Invoice
/
Credit
Note
...</
h3
>
<
table
width
=
"100%"
style
=
"margin-top:10px;"
>
<
tbody
>
<
tr
>
<
td
width
=
"130"
>
Invoice
Description
</
td
>
<
td
width
=
"130"
>
Description
</
td
>
<
td
><
input
type
=
"text"
name
=
"title"
style
=
"width:400px"
/></
td
>
</
tr
>
<
tr
>
<
td
width
=
"130"
>
Amount
(
$
)
</
td
>
<
td
>
Type
</
td
>
<
td
>
<
select
name
=
"invoice_type"
id
=
"invoice_type"
>
<
option
value
=
"invoice"
>
Invoice
</
option
>
<
option
value
=
"credit"
>
Credit
Note
</
option
>
</
select
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Amount
(
$
)
</
td
>
<
td
><
input
type
=
"text"
name
=
"amount"
/></
td
>
</
tr
>
<
tr
class
="
invoice_only
">
<td>Paid?</td>
<td><input type="
checkbox
" name="
paid
" value="
on
" /></td>
</tr>
<tr class="
invoice_only
">
<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>
</select>
</td>
</tr>
<tr>
<
td
colspan
=
"4"
style
=
"padding-top:5px;"
><
input
type
=
"submit"
value
=
"Apply Invoice"
/></
td
>
<td colspan="
4
" style="
padding
-
top
:
5
px
;
"><input type="
submit
" value="
Apply
Invoice
/
Credit
Note
" /></td>
</tr>
</tbody>
</table>
...
...
@@ -69,18 +93,16 @@ use WP_User;
$html
.= '<div style="
border
:
1
px
solid
#777;padding:20px;position:relative;" id="viewable-port">';
$html
.=
'
<p><img src="/wp-content/themes/cbv/assets/images/logo.gif" width="114" height="92" /></p>
<p><strong>The Canadian Institute of Chartered Business Valuators</strong><br />
$status
=
get_post_meta
(
$invoice
->
ID
,
'trans_status'
,
true
);
$html
.=
'<p>
<img src="/wp-content/themes/cbv/assets/images/logo.gif" width="114" height="92" /></p><p>
<strong>The Canadian Institute of Chartered Business Valuators</strong><br />
277 Wellington St. West, Suite 710<br />
Toronto, ON, Canada M5V 3H2
</p>'
;
$status
=
get_post_meta
(
$invoice
->
ID
,
'trans_status'
,
true
);
if
(
$status
==
"paid"
)
{
$html
.=
'<div class="status-paid"></div>'
;
}
$html
.=
'<h3 style="margin:0;padding:0;text-align:right;">Invoice No.: '
.
$invoice
->
ID
.
'</h3>'
;
$html
.=
'<p style="text-align:right;margin-top:0;padding-top:0;"><strong>Invoice Date:</strong> '
.
$date
.
'</p>'
;
$html
.=
'<h2>'
.
$invoice
->
post_title
.
'</h2>'
;
...
...
@@ -93,7 +115,7 @@ use WP_User;
$html
.=
'<tr>'
;
$html
.=
'<th>Item / Description</th>'
;
if
(
$
invoice_type
!=
"credit"
)
{
if
(
$
status
!=
"credit"
)
{
$html
.=
'<th width="80">Cost</th>'
;
$html
.=
'<th width="80">Discounts</th>'
;
$html
.=
'<th width="120">Amount</th>'
;
...
...
@@ -119,7 +141,7 @@ use WP_User;
$html
.=
'<tr class="'
.
$row_class
.
'">'
;
$html
.=
'<td>'
.
$description
.
'</td>'
;
if
(
$
invoice_type
!=
"credit"
)
{
if
(
$
status
!=
"credit"
)
{
$html
.=
'<td>$'
.
$item
[
'cost'
]
.
'</td>'
;
if
(
empty
(
$item
[
'discount_amount'
]))
{
$html
.=
'<td>$0.00</td>'
;
...
...
@@ -136,11 +158,12 @@ use WP_User;
}
$html
.=
'</tbody>'
;
$html
.=
'</table>'
;
if
(
$
invoice_type
!=
"credit"
)
{
if
(
$
status
!=
"credit"
)
{
$html
.=
'<table cellpadding="0" cellspacing="0" border="0" class="clean" id="invoice-table">'
;
$html
.=
'<tfoot>'
;
$html
.=
'<tr>'
;
$html
.=
'<td style="text-align:right;padding-right:10px;font-weight:bold;">Total Cost</td>'
;
$html
.=
'<td width="120">$'
.
number_format
(
$invoice
->
payment
[
'total_cost'
],
2
)
.
'</td>'
;
...
...
@@ -155,12 +178,19 @@ use WP_User;
$html
.=
'<td>$'
.
number_format
(
$invoice
->
payment
[
'subtotal'
],
2
)
.
'</td>'
;
$html
.=
'</tr>'
;
}
if
(
$invoice
->
payment
[
'total_taxes'
]
>
0
)
{
$html
.=
'<tr>'
;
$html
.=
'<td style="text-align:right;padding-right:10px;font-weight:bold;">Taxes</td>'
;
$html
.=
'<td>$'
.
number_format
(
$invoice
->
payment
[
'total_taxes'
],
2
)
.
'</td>'
;
$html
.=
'</tr>'
;
}
$amount_label
=
(
$status
==
"paid"
)
?
"Total"
:
"Amount Due"
;
$html
.=
'<tr>'
;
$html
.=
'<td style="text-align:right;padding-right:10px;font-weight:bold;">Taxes</td>'
;
$html
.=
'<td>$'
.
number_format
(
$invoice
->
payment
[
'total_taxes'
],
2
)
.
'</td>'
;
$html
.=
'</tr>'
;
$html
.=
'<tr>'
;
$html
.=
'<td style="text-align:right;padding-right:10px;font-weight:bold;">Total</td>'
;
$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
.=
'</tr>'
;
...
...
@@ -170,7 +200,7 @@ use WP_User;
}
$html
.=
'</p>'
;
if
(
$
invoice_type
!=
"credit
"
)
{
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 />"
;
...
...
@@ -179,6 +209,19 @@ use WP_User;
$html
.=
"<strong>"
.
ucwords
(
$invoice
->
payment
[
'bt_card_type'
])
.
"</strong> "
.
$invoice
->
payment
[
'bt_card_number'
];
}
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>'
;
}
elseif
(
$status
==
"unpaid"
)
{
$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>'
;
}
$html
.=
'</div>'
;
//$html .= '<div style="text-align:right;margin-top:5px;"><a href="/invoices/?view='.$_GET['view'].'&pagename=invoice-preview" class="label label-black-print print-invoice-handler" target="_blank"></a></div>';
...
...
Please
register
or
sign in
to post a comment