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
09cb9de7
authored
2011-04-05 18:07:13 +0000
by
Chris Boden
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Admin course registration bug fixes
1 parent
4b5ba596
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
30 deletions
com/UserManager/UserManager.php
com/UserManager/views/edit_user.php
com/UserManager/views/partials/edit_course.php
com/UserManager/UserManager.php
View file @
09cb9de
...
...
@@ -20,6 +20,7 @@ use Tz\WordPress\CBV\Events;
use
Tz\WordPress\CBV\CEHours
;
use
Tz\WordPress\CBV\Invoice
;
use
Tz\WordPress\CBV\Courses
;
use
Tz\WordPress\CBV\CBVOptions
;
use
Exception
,
StdClass
;
const
OPTION_NAME
=
"user_options"
;
...
...
@@ -400,11 +401,11 @@ class AccountValidation extends Common\Validation {
}
public
function
group
(
$val
)
{
$this
->
on_groups
=
$val
;
$this
->
setGroups
();
return
;
}
public
function
grpanch
(
$val
)
{
$this
->
on_groups
=
(
isset
(
$_POST
[
'group'
])
?
$_POST
[
'group'
]
:
Array
());
$this
->
all_groups
=
$val
;
$this
->
setGroups
();
}
...
...
@@ -848,39 +849,105 @@ class Actions {
}
public
static
function
wp_ajax_course_registration
()
{
// here
public
static
function
wp_ajax_course_registration
()
{
// Get given working classes
$user
=
new
User\Account
(
$_POST
[
'user_id'
]);
$course
=
new
Courses\Course
(
$_POST
[
'course_id'
]);
$enrolltype
=
$_POST
[
'enrolltype'
];
$amount
=
$course
->
$enrolltype
;
$user
->
registerForCourse
(
$_POST
[
'course_id'
],
(
boolean
)
isset
(
$_POST
[
'exam'
]),
$_POST
[
'enrolltype'
]);
$user
->
approveToCourse
(
$_POST
[
'course_id'
]);
$items
=
array
();
$items
[]
=
array
(
'post_id'
=>
$_POST
[
'course_id'
]
,
'cost'
=>
$amount
// 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'
=>
""
,
'tax_rate'
=>
""
,
'tax_amount'
=>
"0.00"
,
'subtotal'
=>
$
amoun
t
,
'total'
=>
$amount
,
'tax_label'
=>
"
Taxes
"
,
'tax_rate'
=>
$tax_rate
,
'tax_amount'
=>
$course_taxes
,
'subtotal'
=>
$
course_cos
t
,
'total'
=>
number_format
((
$course_cost
+
$course_taxes
),
2
,
'.'
,
''
)
,
'description'
=>
$course
->
post_title
,
'extras'
=>
array
()
);
));
// 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
()
);
}
// 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
);
}
$invoice_data
=
Array
();
$invoice_data
[
'items'
]
=
$items
;
$invoice_data
[
'payment'
]
=
a
rray
(
'total_cost'
=>
$
amount
$invoice_data
[
'payment'
]
=
A
rray
(
'total_cost'
=>
$
items_subtotal
,
'total_discounts'
=>
""
,
'total_taxes'
=>
""
,
'subtotal'
=>
$
amount
,
'total'
=>
$
amount
,
'total_taxes'
=>
$items_taxes
,
'subtotal'
=>
$
items_subtotal
,
'total'
=>
$
items_total
,
'bt_address'
=>
""
,
'bt_address2'
=>
""
,
'bt_city'
=>
""
...
...
@@ -892,7 +959,7 @@ class Actions {
,
'bt_card_type'
=>
$_POST
[
'paid_by'
]
);
Invoice\create
(
$invoice_data
,
'course'
,
'Course Invoice'
,
$user
->
ID
,
'paid'
,
'publish'
,
0
);
Invoice\create
(
$invoice_data
,
'course'
,
'Course Invoice'
,
$user
->
ID
,
'paid'
,
'publish'
,
$items_total
);
die
(
json_encode
(
Array
(
'success'
=>
'true'
,
'refresh'
=>
'true'
)));
}
...
...
@@ -1586,6 +1653,4 @@ HTML;
class
Vars
{
public
static
$validation
;
}
?>
}
\ No newline at end of file
...
...
com/UserManager/views/edit_user.php
View file @
09cb9de
...
...
@@ -19,7 +19,6 @@ use Exception, StdClass;
$fname
=
$user
->
first_name
;
$lname
=
$user
->
last_name
;
$member_id
=
$user
->
member_id
;
if
(
empty
(
$fname
)
||
empty
(
$lname
))
{
$name
=
$user
->
user_login
;
...
...
@@ -64,7 +63,7 @@ use Exception, StdClass;
<div
id=
""
class=
"wrap"
>
<div
id=
"icon-users"
class=
"icon32"
><br
/></div>
<h2>
Editing:
<?php
echo
$name
;
?>
<?php
if
(
$role
==
"member"
&&
!
empty
(
$member_id
))
{
echo
'<span class="admin-member-id"> ('
.
$member_id
.
')</span>'
;
}
?>
<?php
if
(
!
empty
(
$user
->
member_id
))
{
echo
'<span class="admin-member-id"> ('
.
$user
->
member_id
.
')</span>'
;
}
?>
<?php
if
(
in_array
(
$suser
->
getRole
(),
Array
(
'administrator'
,
'cbv_admin'
)))
:
?>
(
<a
href=
"
<?php
echo
get_author_posts_url
(
$user
->
ID
);
?>
?sulogin=1"
>
Login
</a>
)
<?php
endif
;
?>
...
...
@@ -74,7 +73,7 @@ use Exception, StdClass;
<div
id=
"menu-management"
style=
"margin-top:25px;"
>
<div
class=
"nav-tabs-nav"
>
<div
class=
"nav-tabs-wrapper"
class=
"section-
<?php
echo
$_GET
[
'section'
];
?>
"
>
<div
class=
"nav-tabs-wrapper"
class=
"section-
<?php
echo
@
$_GET
[
'section'
];
?>
"
>
<div
class=
"nav-tabs"
style=
"padding: 0px; margin-left: 0px;"
>
<a
id=
"overview"
class=
"nav-tab hide-if-no-js
<?php
echo
(
$section
==
"overview"
)
?
"nav-tab-active"
:
""
;
?>
"
href=
"/wp-admin/admin.php?page=cbv_users&action=edit&uid=
<?php
echo
$_GET
[
'uid'
];
?>
§ion=overview"
>
Overview
</a>
<a
id=
"profile"
class=
"nav-tab hide-if-no-js
<?php
echo
(
$section
==
"profile"
)
?
"nav-tab-active"
:
""
;
?>
"
href=
"/wp-admin/admin.php?page=cbv_users&action=edit&uid=
<?php
echo
$_GET
[
'uid'
];
?>
§ion=profile"
>
Profile
</a>
...
...
com/UserManager/views/partials/edit_course.php
View file @
09cb9de
...
...
@@ -79,6 +79,31 @@
</div>
<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>
</div>
</div>
<?php
if
(
!
$user
->
isMemberOf
(
'Casebook'
))
:
?>
<div
class=
"dashboard-section"
style=
"margin-left:20px;margin-top:10px;"
>
<div
class=
"dashboard-section-title"
>
<input
type=
"checkbox"
name=
"casebook"
id=
"casebook"
value=
"1"
checked
/>
<label
for=
"casebook"
>
PURCHASED CASEBOOK?
</label>
</div>
</div>
<?php
endif
;
?>
<?php
if
(
$user
->
isOverseas
())
:
?>
<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>
</div>
</div>
<?php
endif
;
?>
<div
class=
"dashboard-section"
style=
"margin-left:20px;margin-top:10px;"
>
<div
class=
"dashboard-section-title"
></div>
<div
class=
"dashboard-section-links"
></div>
<div
class=
"dashboard-section-content small"
>
...
...
Please
register
or
sign in
to post a comment