Merging changes into live for course registration. (207:211) refs #1083, refs #1091
Showing
6 changed files
with
154 additions
and
38 deletions
| ... | @@ -21,7 +21,6 @@ class Actions { | ... | @@ -21,7 +21,6 @@ class Actions { |
| 21 | _enqueue_script('date', Tools\url('scripts/date.js', __FILE__)); | 21 | _enqueue_script('date', Tools\url('scripts/date.js', __FILE__)); |
| 22 | _enqueue_script('jquery-datepicker', Tools\url('scripts/jquery.datePicker.js', __FILE__), Array('jquery','date')); | 22 | _enqueue_script('jquery-datepicker', Tools\url('scripts/jquery.datePicker.js', __FILE__), Array('jquery','date')); |
| 23 | _enqueue_script('jquery-admin-uploadify', Tools\url('uploadify/jquery.uploadify.v2.1.4.js', __FILE__), Array('jquery','swfobject')); | 23 | _enqueue_script('jquery-admin-uploadify', Tools\url('uploadify/jquery.uploadify.v2.1.4.js', __FILE__), Array('jquery','swfobject')); |
| 24 | _enqueue_script('jquery-branding', Tools\url('scripts/branding.js', __FILE__), Array('jquery')); | ||
| 25 | } | 24 | } |
| 26 | 25 | ||
| 27 | public static function admin_head() { | 26 | public static function admin_head() { | ... | ... |
com/Branding/scripts/branding.js
deleted
100644 → 0
| ... | @@ -20,6 +20,7 @@ use Tz\WordPress\CBV\Events; | ... | @@ -20,6 +20,7 @@ use Tz\WordPress\CBV\Events; |
| 20 | use Tz\WordPress\CBV\CEHours; | 20 | use Tz\WordPress\CBV\CEHours; |
| 21 | use Tz\WordPress\CBV\Invoice; | 21 | use Tz\WordPress\CBV\Invoice; |
| 22 | use Tz\WordPress\CBV\Courses; | 22 | use Tz\WordPress\CBV\Courses; |
| 23 | use Tz\WordPress\CBV\CBVOptions; | ||
| 23 | use Exception, StdClass; | 24 | use Exception, StdClass; |
| 24 | 25 | ||
| 25 | const OPTION_NAME = "user_options"; | 26 | const OPTION_NAME = "user_options"; |
| ... | @@ -389,7 +390,6 @@ class AccountValidation extends Common\Validation { | ... | @@ -389,7 +390,6 @@ class AccountValidation extends Common\Validation { |
| 389 | return false; | 390 | return false; |
| 390 | } | 391 | } |
| 391 | 392 | ||
| 392 | // here | ||
| 393 | foreach ($this->all_groups as $id => $one) { | 393 | foreach ($this->all_groups as $id => $one) { |
| 394 | if (isset($this->on_groups[$id])) { | 394 | if (isset($this->on_groups[$id])) { |
| 395 | UAM\getGroupByID($id)->addUser($_POST['uid']); | 395 | UAM\getGroupByID($id)->addUser($_POST['uid']); |
| ... | @@ -400,11 +400,11 @@ class AccountValidation extends Common\Validation { | ... | @@ -400,11 +400,11 @@ class AccountValidation extends Common\Validation { |
| 400 | } | 400 | } |
| 401 | 401 | ||
| 402 | public function group($val) { | 402 | public function group($val) { |
| 403 | $this->on_groups = $val; | 403 | return; |
| 404 | $this->setGroups(); | ||
| 405 | } | 404 | } |
| 406 | 405 | ||
| 407 | public function grpanch($val) { | 406 | public function grpanch($val) { |
| 407 | $this->on_groups = (isset($_POST['group']) ? $_POST['group'] : Array()); | ||
| 408 | $this->all_groups = $val; | 408 | $this->all_groups = $val; |
| 409 | $this->setGroups(); | 409 | $this->setGroups(); |
| 410 | } | 410 | } |
| ... | @@ -848,39 +848,130 @@ class Actions { | ... | @@ -848,39 +848,130 @@ class Actions { |
| 848 | 848 | ||
| 849 | } | 849 | } |
| 850 | 850 | ||
| 851 | public static function wp_ajax_course_registration() { // here | 851 | public static function wp_ajax_course_registration() { |
| 852 | // Get given working classes | ||
| 852 | $user = new User\Account($_POST['user_id']); | 853 | $user = new User\Account($_POST['user_id']); |
| 853 | $course = new Courses\Course($_POST['course_id']); | 854 | $course = new Courses\Course($_POST['course_id']); |
| 854 | $enrolltype = $_POST['enrolltype']; | 855 | $enrolltype = $_POST['enrolltype']; |
| 855 | $amount = $course->$enrolltype; | ||
| 856 | |||
| 857 | $user->registerForCourse($_POST['course_id'], (boolean)isset($_POST['exam']), $_POST['enrolltype']); | ||
| 858 | $user->approveToCourse($_POST['course_id']); | ||
| 859 | 856 | ||
| 860 | $items = array(); | 857 | // Apply user to course, sets group, set enrollment, etc. |
| 861 | 858 | $user->registerForCourse($course->getID(), (boolean)isset($_POST['exam']), $enrolltype); | |
| 862 | $items[] = array( | 859 | $user->approveToCourse($course->getID()); |
| 863 | 'post_id' => $_POST['course_id'] | 860 | |
| 864 | , 'cost' => $amount | 861 | // Do all the invoicey stuff |
| 862 | $items_subtotal = $items_taxes = $items_total = 0; // Running totals...should be a class | ||
| 863 | $tax_rate = $user->getLocTaxPct(); | ||
| 864 | $calc_tax = function($cost, $tax_rate) { | ||
| 865 | return number_format(($cost * $tax_rate * 0.01), 2, '.', ''); | ||
| 866 | }; | ||
| 867 | |||
| 868 | $course_cost = $course->$enrolltype; | ||
| 869 | $course_taxes = $calc_tax($course_cost, $tax_rate); | ||
| 870 | |||
| 871 | // Add course cost to running totals | ||
| 872 | $items_subtotal += $course_cost; | ||
| 873 | $items_taxes += $course_taxes; | ||
| 874 | $items_total += ($course_cost + $course_taxes); | ||
| 875 | |||
| 876 | // Add the course its self to the receipt | ||
| 877 | $items = Array(Array( | ||
| 878 | 'post_id' => $course->getID() | ||
| 879 | , 'cost' => $course_cost | ||
| 865 | , 'discount_label' => "" | 880 | , 'discount_label' => "" |
| 866 | , 'discount_amount' => 0 | 881 | , 'discount_amount' => 0 |
| 867 | , 'tax_label' => "" | 882 | , 'tax_label' => "Taxes" |
| 868 | , 'tax_rate' => "" | 883 | , 'tax_rate' => $tax_rate |
| 869 | , 'tax_amount' => "0.00" | 884 | , 'tax_amount' => $course_taxes |
| 870 | , 'subtotal' => $amount | 885 | , 'subtotal' => $course_cost |
| 871 | , 'total' => $amount | 886 | , 'total' => number_format(($course_cost + $course_taxes), 2, '.', '') |
| 872 | , 'description' => $course->post_title | 887 | , 'description' => $course->post_title |
| 873 | , 'extras' => array() | 888 | , 'extras' => array() |
| 874 | ); | 889 | )); |
| 890 | |||
| 891 | if (isset($_POST['studentfee']) && $_POST['studentfee'] == 1) { | ||
| 892 | $fee = number_format(CBVOptions\GetOption('overseas-surcharge', 'fees'), 2, '.', ''); | ||
| 893 | $taxes = $calc_tax($fee, $tax_rate); | ||
| 894 | |||
| 895 | $items_subtotal += $fee; | ||
| 896 | $items_taxes += $taxes; | ||
| 897 | $items_total += $fee + $taxes; | ||
| 898 | |||
| 899 | $items[] = Array( | ||
| 900 | 'post_id' => 0 | ||
| 901 | , 'cost' => $fee | ||
| 902 | , 'discount_label' => '' | ||
| 903 | , 'discount_amount' => '' | ||
| 904 | , 'tax_label' => 'Taxes' | ||
| 905 | , 'tax_rate' => $tax_rate | ||
| 906 | , 'tax_amount' => $taxes | ||
| 907 | , 'subtotal' => $fee | ||
| 908 | , 'total' => ($fee + $taxes) | ||
| 909 | , 'description' => 'Annual Registration Fee' | ||
| 910 | , 'extras' => Array() | ||
| 911 | ); | ||
| 912 | |||
| 913 | $user->setMeta('fee_semester_paid', $course->semester_id); | ||
| 914 | } | ||
| 915 | |||
| 916 | // If the user paid for the casebook add to invoice and Casebook group | ||
| 917 | if (isset($_POST['casebook']) && $_POST['casebook'] == 1) { | ||
| 918 | $book = UAM\getGroup('Casebook'); | ||
| 919 | $book->addUser($user->ID); | ||
| 920 | |||
| 921 | $cost = substr($book->getDescription(), strpos($book->getDescription(), ':') + 1); | ||
| 922 | $taxes = $calc_tax($cost, CBV\get_tax_pct()); | ||
| 923 | |||
| 924 | $items_subtotal += $cost; | ||
| 925 | $items_taxes += $taxes; | ||
| 926 | $items_total += $cost + $taxes; | ||
| 927 | |||
| 928 | $items[] = Array( | ||
| 929 | 'post_id' => CBV\CASEBOOK_POSTID | ||
| 930 | , 'cost' => $cost | ||
| 931 | , 'discount_label' => '' | ||
| 932 | , 'discount_amount' => '' | ||
| 933 | , 'tax_label' => 'Taxes' | ||
| 934 | , 'tax_rate' => CBV\get_tax_pct() | ||
| 935 | , 'tax_amount' => $taxes | ||
| 936 | , 'subtotal' => $cost | ||
| 937 | , 'total' => ($cost + $taxes) | ||
| 938 | , 'description' => 'Casebook' | ||
| 939 | , 'extras' => Array() | ||
| 940 | ); | ||
| 941 | } | ||
| 942 | |||
| 943 | // If the user is overseas and CBV charged them for it, add item to receipt | ||
| 944 | if (isset($_POST['overseas']) && $_POST['overseas'] == 1) { | ||
| 945 | $os_cost = number_format(CBVOptions\GetOption('overseas-surcharge', 'fees'), 2, '.', ''); | ||
| 946 | $os_taxes = $calc_tax($os_cost, $tax_rate); | ||
| 947 | |||
| 948 | $items[] = Array( | ||
| 949 | 'post_id' => 0 | ||
| 950 | , 'cost' => $os_cost | ||
| 951 | , 'discount_label' => '' | ||
| 952 | , 'discount_amount' => '' | ||
| 953 | , 'tax_label' => 'Taxes' | ||
| 954 | , 'tax_rate' => $tax_rate | ||
| 955 | , 'tax_amount' => $os_taxes | ||
| 956 | , 'subtotal' => $os_cost | ||
| 957 | , 'total' => ($os_cost + $os_taxes) | ||
| 958 | , 'description' => 'Overseas Surcharge' | ||
| 959 | , 'extras' => Array() | ||
| 960 | ); | ||
| 961 | |||
| 962 | $items_subtotal += $os_cost; | ||
| 963 | $items_taxes += $os_taxes; | ||
| 964 | $items_total += ($os_cost + $os_taxes); | ||
| 965 | } | ||
| 875 | 966 | ||
| 876 | $invoice_data = Array(); | 967 | $invoice_data = Array(); |
| 877 | $invoice_data['items'] = $items; | 968 | $invoice_data['items'] = $items; |
| 878 | $invoice_data['payment'] = array( | 969 | $invoice_data['payment'] = Array( |
| 879 | 'total_cost' => $amount | 970 | 'total_cost' => $items_subtotal |
| 880 | , 'total_discounts' => "" | 971 | , 'total_discounts' => "" |
| 881 | , 'total_taxes' => "" | 972 | , 'total_taxes' => $items_taxes |
| 882 | , 'subtotal' => $amount | 973 | , 'subtotal' => $items_subtotal |
| 883 | , 'total' => $amount | 974 | , 'total' => $items_total |
| 884 | , 'bt_address' => "" | 975 | , 'bt_address' => "" |
| 885 | , 'bt_address2' => "" | 976 | , 'bt_address2' => "" |
| 886 | , 'bt_city' => "" | 977 | , 'bt_city' => "" |
| ... | @@ -892,7 +983,7 @@ class Actions { | ... | @@ -892,7 +983,7 @@ class Actions { |
| 892 | , 'bt_card_type' => $_POST['paid_by'] | 983 | , 'bt_card_type' => $_POST['paid_by'] |
| 893 | ); | 984 | ); |
| 894 | 985 | ||
| 895 | Invoice\create($invoice_data, 'course', 'Course Invoice', $user->ID, 'paid', 'publish', 0); | 986 | Invoice\create($invoice_data, 'course', 'Course Invoice', $user->ID, 'paid', 'publish', $items_total); |
| 896 | 987 | ||
| 897 | die(json_encode(Array('success' => 'true', 'refresh' => 'true'))); | 988 | die(json_encode(Array('success' => 'true', 'refresh' => 'true'))); |
| 898 | } | 989 | } |
| ... | @@ -1586,6 +1677,4 @@ HTML; | ... | @@ -1586,6 +1677,4 @@ HTML; |
| 1586 | 1677 | ||
| 1587 | class Vars { | 1678 | class Vars { |
| 1588 | public static $validation; | 1679 | public static $validation; |
| 1589 | } | 1680 | } |
| 1590 | |||
| 1591 | ?> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -19,7 +19,6 @@ use Exception, StdClass; | ... | @@ -19,7 +19,6 @@ use Exception, StdClass; |
| 19 | 19 | ||
| 20 | $fname = $user->first_name; | 20 | $fname = $user->first_name; |
| 21 | $lname = $user->last_name; | 21 | $lname = $user->last_name; |
| 22 | $member_id = $user->member_id; | ||
| 23 | 22 | ||
| 24 | if (empty($fname) || empty($lname)) { | 23 | if (empty($fname) || empty($lname)) { |
| 25 | $name = $user->user_login; | 24 | $name = $user->user_login; |
| ... | @@ -64,7 +63,7 @@ use Exception, StdClass; | ... | @@ -64,7 +63,7 @@ use Exception, StdClass; |
| 64 | <div id="" class="wrap"> | 63 | <div id="" class="wrap"> |
| 65 | <div id="icon-users" class="icon32"><br /></div> | 64 | <div id="icon-users" class="icon32"><br /></div> |
| 66 | <h2>Editing: <?php echo $name; ?> | 65 | <h2>Editing: <?php echo $name; ?> |
| 67 | <?php if ($role=="member" && !empty($member_id)) { echo '<span class="admin-member-id"> ('.$member_id.')</span>'; }?> | 66 | <?php if (!empty($user->member_id)) { echo '<span class="admin-member-id"> (' . $user->member_id . ')</span>'; }?> |
| 68 | <?php if (in_array($suser->getRole(), Array('administrator', 'cbv_admin'))): ?> | 67 | <?php if (in_array($suser->getRole(), Array('administrator', 'cbv_admin'))): ?> |
| 69 | (<a href="<?php echo get_author_posts_url($user->ID); ?>?sulogin=1">Login</a>) | 68 | (<a href="<?php echo get_author_posts_url($user->ID); ?>?sulogin=1">Login</a>) |
| 70 | <?php endif; ?> | 69 | <?php endif; ?> |
| ... | @@ -74,7 +73,7 @@ use Exception, StdClass; | ... | @@ -74,7 +73,7 @@ use Exception, StdClass; |
| 74 | 73 | ||
| 75 | <div id="menu-management" style="margin-top:25px;"> | 74 | <div id="menu-management" style="margin-top:25px;"> |
| 76 | <div class="nav-tabs-nav"> | 75 | <div class="nav-tabs-nav"> |
| 77 | <div class="nav-tabs-wrapper" class="section-<?php echo $_GET['section'];?>"> | 76 | <div class="nav-tabs-wrapper" class="section-<?php echo @$_GET['section'];?>"> |
| 78 | <div class="nav-tabs" style="padding: 0px; margin-left: 0px;"> | 77 | <div class="nav-tabs" style="padding: 0px; margin-left: 0px;"> |
| 79 | <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> | 78 | <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> |
| 80 | <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> | 79 | <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> | ... | ... |
| ... | @@ -98,7 +98,7 @@ use WP_User, WP_Roles; | ... | @@ -98,7 +98,7 @@ use WP_User, WP_Roles; |
| 98 | <?php if (!empty($email)): ?> | 98 | <?php if (!empty($email)): ?> |
| 99 | <tr> | 99 | <tr> |
| 100 | <th>Email:</th> | 100 | <th>Email:</th> |
| 101 | <td><?php echo $email; ?></td> | 101 | <td><a href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a></td> |
| 102 | </tr> | 102 | </tr> |
| 103 | <?php endif; ?> | 103 | <?php endif; ?> |
| 104 | 104 | ... | ... |
| ... | @@ -79,6 +79,40 @@ | ... | @@ -79,6 +79,40 @@ |
| 79 | </div> | 79 | </div> |
| 80 | 80 | ||
| 81 | <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> | 81 | <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> |
| 82 | <div class="dashboard-section-title"> | ||
| 83 | <input type="checkbox" name="exam" id="exam" value="1" checked /> | ||
| 84 | <label for="casebook">WRITING EXAM?</label> | ||
| 85 | </div> | ||
| 86 | </div> | ||
| 87 | |||
| 88 | <?php if ($user->isStudentFeeDue()): ?> | ||
| 89 | <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> | ||
| 90 | <div class="dashboard-section-title"> | ||
| 91 | <input type="checkbox" name="studentfee" id="studentfee" value="1" checked /> | ||
| 92 | <label for="studentfee">PAID ANNUAL REGISTRATION FEE?</label> | ||
| 93 | </div> | ||
| 94 | </div> | ||
| 95 | <?php endif; ?> | ||
| 96 | |||
| 97 | <?php if (!$user->isMemberOf('Casebook')): ?> | ||
| 98 | <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> | ||
| 99 | <div class="dashboard-section-title"> | ||
| 100 | <input type="checkbox" name="casebook" id="casebook" value="1" checked /> | ||
| 101 | <label for="casebook">PURCHASED CASEBOOK?</label> | ||
| 102 | </div> | ||
| 103 | </div> | ||
| 104 | <?php endif; ?> | ||
| 105 | |||
| 106 | <?php if ($user->isOverseas()): ?> | ||
| 107 | <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> | ||
| 108 | <div class="dashboard-section-title"> | ||
| 109 | <input type="checkbox" name="overseas" id="overseas" value="1" checked /> | ||
| 110 | <label for="casebook">PAID OVERSEAS SURCHARGE?</label> | ||
| 111 | </div> | ||
| 112 | </div> | ||
| 113 | <?php endif; ?> | ||
| 114 | |||
| 115 | <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> | ||
| 82 | <div class="dashboard-section-title"></div> | 116 | <div class="dashboard-section-title"></div> |
| 83 | <div class="dashboard-section-links"></div> | 117 | <div class="dashboard-section-links"></div> |
| 84 | <div class="dashboard-section-content small"> | 118 | <div class="dashboard-section-content small"> | ... | ... |
-
Please register or sign in to post a comment