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
3bf9453c
authored
2011-03-22 18:10:05 +0000
by
Kevin Burton
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
User Manager Updates for invoices
1 parent
91e5e2eb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
217 deletions
com/UserManager/UserManager.js
com/UserManager/UserManager.php
com/UserManager/views/edit_user_payhistory.php
com/UserManager/UserManager.js
View file @
3bf9453
...
...
@@ -22,11 +22,24 @@ jQuery(function($) {
}
$
(
'#invoice_type'
).
change
(
function
()
{
if
(
$
(
'#invoice_type'
).
val
()
==
"invoice"
)
{
$
(
'.invoice_only'
).
show
();
}
else
{
$
(
'.invoice_only'
).
hide
();
var
invoice_type
=
$
(
this
).
val
();
switch
(
invoice_type
)
{
case
'invoice'
:
$
(
'tr.invoice_credit_only'
).
show
();
$
(
'tr.invoice_only'
).
show
();
break
;
case
'membership'
:
$
(
'tr.invoice_credit_only'
).
hide
();
$
(
'tr.invoice_only'
).
show
();
break
;
default
:
$
(
'tr.invoice_credit_only'
).
show
();
$
(
'tr.invoice_only'
).
hide
();
}
});
jQuery
(
'#creditNotBtn'
).
click
(
function
(
e
)
{
...
...
com/UserManager/UserManager.php
View file @
3bf9453
...
...
@@ -713,6 +713,14 @@ class Actions {
if
(
$uid
==
0
)
{
$uid
=
$_POST
[
'uid'
];
}
// All this for tax purposes....
$pp
=
strtolower
(
get_user_meta
(
$uid
,
'profile_preference'
,
true
));
if
(
empty
(
$pp
))
{
$pp
=
"home"
;
}
$pp
=
$pp
.
"_"
;
$amount
=
$_POST
[
'amount'
];
$invoice_type
=
$_POST
[
'invoice_type'
];
$paid_by
=
$_POST
[
'paid_by'
];
...
...
@@ -728,6 +736,27 @@ class Actions {
}
// if membership....
if
(
$invoice_type
==
"membership"
)
{
$paid
=
(
isset
(
$_POST
[
'paid'
])
&&
$_POST
[
'paid'
]
==
"on"
)
?
true
:
false
;
if
(
$paid
)
{
$status
=
"paid"
;
}
else
{
$status
=
"unpaid"
;
}
Invoice\GenerateMembershipInvoice
(
$uid
,
$status
,
$paid_by
,
false
);
// return json object
$return
=
array
(
'success'
=>
'true'
);
die
(
json_encode
(
$return
));
}
// if not membership.....
$items
=
array
();
$items
[]
=
array
(
...
...
@@ -753,12 +782,12 @@ class Actions {
,
'total_taxes'
=>
""
,
'subtotal'
=>
$amount
,
'total'
=>
$amount
,
'bt_address'
=>
""
,
'bt_address2'
=>
""
,
'bt_city'
=>
""
,
'bt_province'
=>
""
,
'bt_country'
=>
""
,
'bt_postal'
=>
""
,
'bt_address'
=>
get_user_meta
(
$uid
,
$pp
.
'address'
,
true
)
,
'bt_address2'
=>
get_user_meta
(
$uid
,
$pp
.
'address2'
,
true
)
,
'bt_city'
=>
get_user_meta
(
$uid
,
$pp
.
'city'
,
true
)
,
'bt_province'
=>
get_user_meta
(
$uid
,
$pp
.
'province'
,
true
)
,
'bt_country'
=>
get_user_meta
(
$uid
,
$pp
.
'country'
,
true
)
,
'bt_postal'
=>
get_user_meta
(
$uid
,
$pp
.
'postal'
,
true
)
,
'bt_card_holder'
=>
""
,
'bt_card_number'
=>
""
,
'bt_card_type'
=>
$paid_by
...
...
com/UserManager/views/edit_user_payhistory.php
View file @
3bf9453
...
...
@@ -29,19 +29,20 @@ use WP_User;
<
table
width
=
"100%"
style
=
"margin-top:10px;"
>
<
tbody
>
<
tr
>
<
td
width
=
"130"
>
Description
</
td
>
<
td
><
input
type
=
"text"
name
=
"title"
style
=
"width:400px"
/></
td
>
</
tr
>
<
tr
>
<
td
>
Type
</
td
>
<
td
width
=
"130"
>
Type
</
td
>
<
td
>
<
select
name
=
"invoice_type"
id
=
"invoice_type"
>
<
option
value
=
"invoice"
>
Invoice
</
option
>
<
option
value
=
"membership"
>
Membership
Fees
</
option
>
<
option
value
=
"credit"
>
Credit
Note
</
option
>
</
select
>
</
td
>
</
tr
>
<
tr
>
<
tr
class
="
invoice_credit_only
">
<td>Description</td>
<td><input type="
text
" name="
title
" style="
width
:
400
px
" /></td>
</tr>
<tr class="
invoice_credit_only
">
<td>Amount ($)</td>
<td><input type="
text
" name="
amount
" /></td>
</tr>
...
...
@@ -91,207 +92,7 @@ use WP_User;
//
$html
.= '<div style="
text
-
align
:
right
;
margin
-
bottom
:
5
px
;
"><a href="
/
invoices
/?
view
=
'.$invoice->ID.'
&
pagename
=
invoice
-
preview
" class="
label
label
-
black
-
print
print
-
invoice
-
handler
" target="
_blank
"></a></div>';
$html
.= '<div style="
border
:
1
px
solid
#777;padding:20px;position:relative;" id="viewable-port">';
$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>'
;
if
(
$status
==
'unpaid'
)
{
// Get the user's profile preference
$preference
=
strtolower
(
$user
->
profile_preference
);
// Build the 'Bill To:' info array
$user_fields
=
array
(
'address'
,
'address2'
,
'city'
,
'province'
,
'country'
,
'postal'
);
$bill_to
=
array
();
foreach
(
$user_fields
as
$field
)
{
// Use the preference to get the user's address info
$bill_to
[
$field
]
=
get_user_meta
(
$user
->
ID
,
"
{
$preference
}
_
{
$field
}
"
,
TRUE
);
}
// Finish it off with first and last name
$bill_to
[
'first_name'
]
=
get_user_meta
(
$user
->
ID
,
'first_name'
,
TRUE
);
$bill_to
[
'last_name'
]
=
get_user_meta
(
$user
->
ID
,
'last_name'
,
TRUE
);
// Now build the html
$html
.=
'<p><br /><h3>BILL TO:</h3>'
;
$html
.=
"
{
$bill_to
[
'first_name'
]
}
{
$bill_to
[
'last_name'
]
}
<br />"
;
$html
.=
"
{
$bill_to
[
'address'
]
}
,
{
$bill_to
[
'address2'
]
}
<br />"
;
$html
.=
"
{
$bill_to
[
'city'
]
}
,
{
$bill_to
[
'province'
]
}
,
{
$bill_to
[
'country'
]
}
{
$bill_to
[
'postal'
]
}
</p>"
;
}
$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>'
;
$invoice_type
=
get_post_meta
(
$invoice
->
ID
,
'invoice_for'
,
true
);
$html
.=
'<p>'
;
$html
.=
'<table cellpadding="0" cellspacing="0" border="0" class="invoice-table">'
;
$html
.=
'<thead>'
;
$html
.=
'<tr>'
;
$html
.=
'<th>Item / Description</th>'
;
//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>';
//}
$html
.=
'</tr>'
;
$html
.=
'</thead>'
;
$html
.=
'<tbody>'
;
$i
=
9
;
foreach
(
$invoice
->
items
as
$item
)
{
$row_class
=
(
$i
%
2
)
?
"odd"
:
""
;
if
(
$item
[
'post_id'
]
>
0
)
{
$post
=
get_post
(
$item
[
'post_id'
]);
$description
=
$item
[
'description'
];
if
(
$post
->
post_type
==
"events"
)
{
$event_term_slugs
=
array
();
$terms
=
get_the_terms
(
$item
[
'post_id'
],
'event_type'
);
if
(
!
empty
(
$terms
))
{
foreach
(
$terms
as
$types
)
{
$event_term_slugs
[
$types
->
slug
]
=
$types
->
name
;
}
}
}
if
(
isset
(
$event_term_slugs
[
'webinar'
])
)
{
$description
=
$post
->
post_title
.
" | "
.
date
(
"M d, Y"
,
get_post_meta
(
$item
[
'post_id'
],
'event_date'
,
true
));
}
else
{
$description
=
$post
->
post_title
.
" | "
.
get_post_meta
(
$item
[
'post_id'
],
'location'
,
true
);
}
if
(
count
(
$item
[
'discounts'
])
>
0
)
{
$item
[
'discount_amount'
]
=
""
;
$discount_text
=
"<br /><span>"
;
for
(
$i
=
0
;
$i
<
count
(
$item
[
'discounts'
]);
$i
++
)
{
if
(
$i
>
0
)
{
$discount_text
.=
"<br />"
;
}
$discount_text
.=
"- $"
.
$item
[
'discounts'
][
$i
][
'discount'
]
.
" OFF <em>"
.
$item
[
'discounts'
][
$i
][
'discount_label'
]
.
"</em>"
;
$item
[
'discount_amount'
]
+=
$item
[
'discounts'
][
$i
][
'discount'
];
}
$discount_text
.=
"</span>"
;
$description
=
"<strong>"
.
$description
.
"</strong>"
.
$discount_text
;
}
}
else
{
$description
=
$item
[
'description'
];
}
$html
.=
'<tr>'
;
$html
.=
'<td>'
.
$description
.
'</td>'
;
//if ($status!="credit") {
$html
.=
'<td>$'
.
$item
[
'cost'
]
.
'</td>'
;
if
(
empty
(
$item
[
'discount_amount'
]))
{
$html
.=
'<td>$0.00</td>'
;
}
else
{
$html
.=
'<td>-$'
.
$item
[
'discount_amount'
]
.
'</td>'
;
}
//}
$html
.=
'<td>$'
.
$item
[
'subtotal'
]
.
'</td>'
;
$html
.=
'</tr>'
;
$i
++
;
}
$html
.=
'</tbody>'
;
$html
.=
'</table>'
;
//if ($status != "credit") {
$html
.=
'<table cellpadding="0" cellspacing="0" border="0" class="clean 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>'
;
$html
.=
'</tr>'
;
if
(
$invoice
->
payment
[
'total_discounts'
]
>
0
)
{
$html
.=
'<tr>'
;
$html
.=
'<td style="text-align:right;padding-right:10px;font-weight:bold;">Total Discounts</td>'
;
$html
.=
'<td>$'
.
number_format
(
$invoice
->
payment
[
'total_discounts'
],
2
)
.
'</td>'
;
$html
.=
'</tr>'
;
$html
.=
'<tr>'
;
$html
.=
'<td style="text-align:right;padding-right:10px;font-weight:bold;">Sub Total</td>'
;
$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
=
$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
(
$amount
,
2
)
.
'</strong></td>'
;
$html
.=
'</tr>'
;
$html
.=
'</tfoot>'
;
$html
.=
'</table>'
;
//}
$html
.=
'</p>'
;
$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") {
$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>'
;
}
elseif
(
$status
==
"cancelled"
)
{
$html
.=
'<div style="text-align:center; font-size:14px; color:green;">-- THIS INVOICE IS <strong>CANCELLED</strong> --</div>'
;
}
$html
.=
'</div>'
;
$html
.= Invoice\DrawInvoice(
$invoice
,true);
//
$html
.= '<div style="
text
-
align
:
right
;
margin
-
top
:
5
px
;
"><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