updated the UserAdmin section now allows the admin to register a user for an arc…
…hived event - and now creates an invoice, paid or unpaid.
Showing
3 changed files
with
218 additions
and
10 deletions
| ... | @@ -64,6 +64,11 @@ function display_users() { | ... | @@ -64,6 +64,11 @@ function display_users() { |
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | function getTaxesByProvince($provstate = "ON") { | ||
| 68 | return CBV\get_tax_pct($provstate); | ||
| 69 | } | ||
| 70 | |||
| 71 | |||
| 67 | function search_special_status($key) { | 72 | function search_special_status($key) { |
| 68 | $special_statuses = get_user_meta($_GET['uid'], 'special_statuses',true); | 73 | $special_statuses = get_user_meta($_GET['uid'], 'special_statuses',true); |
| 69 | if (!empty($special_statuses)) { | 74 | if (!empty($special_statuses)) { |
| ... | @@ -832,6 +837,8 @@ class Actions { | ... | @@ -832,6 +837,8 @@ class Actions { |
| 832 | 837 | ||
| 833 | if (!isset($_POST['type'])) { die('Invalid Form Post'); } | 838 | if (!isset($_POST['type'])) { die('Invalid Form Post'); } |
| 834 | 839 | ||
| 840 | $post = get_post($_POST['event_id']); | ||
| 841 | |||
| 835 | $uid = $_POST['uid']; | 842 | $uid = $_POST['uid']; |
| 836 | $event_id = $_POST['event_id']; | 843 | $event_id = $_POST['event_id']; |
| 837 | $type = $_POST['type']; | 844 | $type = $_POST['type']; |
| ... | @@ -862,10 +869,165 @@ class Actions { | ... | @@ -862,10 +869,165 @@ class Actions { |
| 862 | $return = array('success' => 'true', 'refresh' => 'false'); | 869 | $return = array('success' => 'true', 'refresh' => 'false'); |
| 863 | 870 | ||
| 864 | } else { | 871 | } else { |
| 865 | Events\set_attending($uid,$event_id,$status,'',$_POST); | 872 | |
| 866 | $return = array('success' => 'true', 'refresh' => 'true'); | 873 | // KB |
| 867 | } | 874 | |
| 875 | $user = new User\Account($uid); | ||
| 876 | |||
| 877 | $cost = get_post_meta($event_id, 'cost', true); | ||
| 878 | |||
| 879 | if ( empty($cost) OR $cost < 1 OR strtolower($cost) == "free" ) { | ||
| 880 | set_attending($user->ID,$event_id,"free","",$_POST); | ||
| 881 | } else { | ||
| 882 | |||
| 883 | //$user = new User\CurrentAccount(); | ||
| 884 | $role = $user->getRole(); | ||
| 885 | |||
| 886 | $event = get_post($event_id); | ||
| 887 | |||
| 888 | $cehours = get_post_meta($event_id,'worth_cehours',true); | ||
| 889 | $early_bird_deadline = get_post_meta($event_id,'early_bird_deadline',true); | ||
| 890 | $early_bird_discount = get_post_meta($event_id,'early_bird_discount',true); | ||
| 891 | $member_discount = get_post_meta($event_id,'student_member_discount',true); | ||
| 892 | $reg_deadline = get_post_meta($event_id,'reg_deadline',true); | ||
| 893 | $event_date = get_post_meta($event_id,'event_date',true); | ||
| 894 | |||
| 895 | |||
| 896 | $event_term_slugs = array(); | ||
| 897 | $terms = get_the_terms($event_id,'event_type'); | ||
| 898 | if (!empty($terms)) { | ||
| 899 | foreach($terms as $types) { | ||
| 900 | $event_term_slugs[$types->slug] = $types->name; | ||
| 901 | } | ||
| 902 | } | ||
| 903 | |||
| 904 | |||
| 905 | $discounts = array(); | ||
| 906 | |||
| 907 | $new_cost = $cost; | ||
| 908 | $total_discount = 0; | ||
| 909 | |||
| 910 | if ( ($user->getRole()=="member" || $user->getRole()=="student") && !empty($member_discount) ) { | ||
| 911 | $show_member_discount = true; | ||
| 912 | |||
| 913 | $discounts[] = Array( | ||
| 914 | 'discount_label' => "Student/Member Discount" | ||
| 915 | , 'discount' => $member_discount | ||
| 916 | ); | ||
| 917 | |||
| 918 | $new_cost = ($new_cost - $member_discount); | ||
| 919 | $total_discount = ($total_discount + $member_discount); | ||
| 920 | |||
| 921 | } | ||
| 922 | if (!empty($early_bird_deadline) && $early_bird_deadline > time()) { | ||
| 923 | $show_early_discount = true; | ||
| 924 | |||
| 925 | $discounts[] = Array( | ||
| 926 | 'discount_label' => "Early Bird Discount" | ||
| 927 | , 'discount' => $early_bird_discount | ||
| 928 | ); | ||
| 929 | |||
| 930 | $new_cost = ($new_cost - $early_bird_discount); | ||
| 931 | $total_discount = ($total_discount + $early_bird_discount); | ||
| 932 | } | ||
| 868 | 933 | ||
| 934 | $provstate = get_post_meta($event_id,'provstate',true); | ||
| 935 | if (empty($provstate) OR $provstate == "outside") { | ||
| 936 | $provstate = "ON"; | ||
| 937 | } | ||
| 938 | |||
| 939 | |||
| 940 | if (isset($event_term_slugs['webinar'])) { | ||
| 941 | $tpp = get_user_meta($user->ID,'profile_preference',true); | ||
| 942 | $tpp = strtolower($tpp); | ||
| 943 | $province = get_user_meta($user->ID,$tpp."_province",true); | ||
| 944 | $tax_label = "Taxes-$province"; | ||
| 945 | $tax = getTaxesByProvince($province); | ||
| 946 | |||
| 947 | } else { | ||
| 948 | $tax_label = "Taxes-$provstate"; | ||
| 949 | $tax = getTaxesByProvince($provstate); // tax percentage (whole number) | ||
| 950 | } | ||
| 951 | |||
| 952 | $taxes = ($new_cost * ($tax/100)); | ||
| 953 | |||
| 954 | |||
| 955 | |||
| 956 | |||
| 957 | |||
| 958 | $invoice_post = $_POST; | ||
| 959 | |||
| 960 | |||
| 961 | $details = Array('dietary', | ||
| 962 | 'mealopt_one','mealopt_two','mealopt_three','mealopt_four','mealopt_five','mealopt_six','mealopt_seven','mealopt_eight','mealopt_nine','mealopt_ten', | ||
| 963 | 'session_one','session_two','session_three','session_four','session_five','session_six','session_seven','session_eight','session_nine','session_ten'); | ||
| 964 | |||
| 965 | $extras = array(); | ||
| 966 | foreach($details as $index) { | ||
| 967 | if ( isset($_POST[$index]) ) { | ||
| 968 | $extras[$index] = $_POST[$index]; | ||
| 969 | } | ||
| 970 | } | ||
| 971 | |||
| 972 | Events\set_attending($user->ID,$event_id,'paid',md5(rand()),$extras); | ||
| 973 | $items = array(); | ||
| 974 | |||
| 975 | $items[] = array( | ||
| 976 | 'post_id' => $event_id | ||
| 977 | , 'cost' => get_post_meta($event_id,'cost',true) | ||
| 978 | , 'discounts' => $discounts | ||
| 979 | , 'tax_label' => $tax_label | ||
| 980 | , 'tax_rate' => $tax | ||
| 981 | , 'tax_amount' => $taxes | ||
| 982 | , 'subtotal' => $new_cost | ||
| 983 | , 'total' => number_format(($new_cost + $taxes),2) | ||
| 984 | , 'description' => "" | ||
| 985 | , 'extras' => $extras | ||
| 986 | |||
| 987 | ); | ||
| 988 | |||
| 989 | $pp = get_user_meta($user->ID,'profile_preference',true); | ||
| 990 | $pp = $pp . "_"; | ||
| 991 | |||
| 992 | $invoice_data = array(); | ||
| 993 | $invoice_data['items'] = $items; | ||
| 994 | $invoice_data['payment'] = array( | ||
| 995 | 'total_cost' => get_post_meta($event_id,'cost',true) | ||
| 996 | , 'total_discounts' => $total_discount | ||
| 997 | , 'total_taxes' => $taxes | ||
| 998 | , 'subtotal' => $new_cost | ||
| 999 | , 'total' => number_format(($new_cost + $taxes),2) | ||
| 1000 | , 'bt_address' => get_user_meta($user->ID, $pp.'address',true) | ||
| 1001 | , 'bt_address2' => get_user_meta($user->ID, $pp.'address2',true) | ||
| 1002 | , 'bt_city' => get_user_meta($user->ID, $pp.'city',true) | ||
| 1003 | , 'bt_province' => get_user_meta($user->ID, $pp.'province',true) | ||
| 1004 | , 'bt_country' => get_user_meta($user->ID, $pp.'country',true) | ||
| 1005 | , 'bt_postal' => get_user_meta($user->ID, $pp.'postal',true) | ||
| 1006 | , 'bt_card_holder' => "" | ||
| 1007 | , 'bt_card_number' => "" | ||
| 1008 | , 'bt_card_type' => "" | ||
| 1009 | ); | ||
| 1010 | |||
| 1011 | $event_term_slugs = array(); | ||
| 1012 | $terms = get_the_terms($event_id,'event_type'); | ||
| 1013 | |||
| 1014 | |||
| 1015 | if (!empty($terms)) { | ||
| 1016 | foreach($terms as $types) { | ||
| 1017 | $event_term_slugs[$types->slug] = $types->name; | ||
| 1018 | } | ||
| 1019 | } | ||
| 1020 | |||
| 1021 | |||
| 1022 | |||
| 1023 | //create($items = array(), $invoice_type = 'event', $title = "Invoice", $user_id = 0, $status = 'pending', $reference = '', $publish = 'draft') | ||
| 1024 | Invoice\create($invoice_data, 'event', 'Registration for Event via CBV Admin: '.$event->post_title, $user->ID, $status, 'publish',number_format(($new_cost + $taxes),2)); | ||
| 1025 | |||
| 1026 | } | ||
| 1027 | |||
| 1028 | |||
| 1029 | } | ||
| 1030 | $return = array('success' => 'true', 'refresh' => 'true'); | ||
| 869 | die(json_encode($return)); | 1031 | die(json_encode($return)); |
| 870 | 1032 | ||
| 871 | } | 1033 | } | ... | ... |
| ... | @@ -50,16 +50,21 @@ else: ?> | ... | @@ -50,16 +50,21 @@ else: ?> |
| 50 | </tbody> | 50 | </tbody> |
| 51 | </table> | 51 | </table> |
| 52 | 52 | ||
| 53 | <h4 style="margin-bottom:5px;padding-bottom:0px; padding-left:10px;"><em>Not registered for...</em></h4> | 53 | <h4 style="margin-bottom:5px;padding-bottom:0px; padding-left:10px;"><em>Events not registered for...</em></h4> |
| 54 | <?php endif; ?> | 54 | <?php endif; ?> |
| 55 | <?php | 55 | <?php |
| 56 | $posts = query_posts(Array( | 56 | $posts = query_posts(Array( |
| 57 | 'post_type' => 'events' | 57 | 'post_type' => 'events' |
| 58 | , 'posts_per_page' => get_option('posts_per_page') | 58 | , 'posts_per_page' => -1 |
| 59 | , 'paged' => (get_query_var('paged') ? get_query_var('paged') : 1) | 59 | , 'paged' => (get_query_var('paged') ? get_query_var('paged') : 1) |
| 60 | |||
| 60 | , 'meta_key' => 'event_date' | 61 | , 'meta_key' => 'event_date' |
| 62 | /* | ||
| 61 | , 'meta_compare' => '>' | 63 | , 'meta_compare' => '>' |
| 62 | , 'meta_value' => (time() + (60*60*24)) // event date + 1 day, so that they can register the day of... | 64 | , 'meta_value' => (time() + (60*60*24)) // event date + 1 day, so that they can register the day of... |
| 65 | */ | ||
| 66 | , 'orderby' => 'meta_value' | ||
| 67 | |||
| 63 | , 'order' => 'DESC' | 68 | , 'order' => 'DESC' |
| 64 | )); | 69 | )); |
| 65 | ?> | 70 | ?> |
| ... | @@ -77,13 +82,51 @@ $posts = query_posts(Array( | ... | @@ -77,13 +82,51 @@ $posts = query_posts(Array( |
| 77 | <tbody> | 82 | <tbody> |
| 78 | <?php foreach($posts as $post): | 83 | <?php foreach($posts as $post): |
| 79 | if (!Events\is_attending($post->ID, $uid) && UAM\can_user_access($post->ID, $uid)): | 84 | if (!Events\is_attending($post->ID, $uid) && UAM\can_user_access($post->ID, $uid)): |
| 85 | |||
| 86 | |||
| 87 | // get categories.... | ||
| 88 | $event_term_slugs = array(); | ||
| 89 | $terms = get_the_terms($post->ID,'event_type'); | ||
| 90 | |||
| 91 | $external_only = false; | ||
| 92 | if (!empty($terms)) { | ||
| 93 | foreach($terms as $types) { | ||
| 94 | $event_term_slugs[$types->slug] = $types->name; | ||
| 95 | if ($types->slug == "externalevent") { | ||
| 96 | $external_only = true; | ||
| 97 | } | ||
| 98 | } | ||
| 99 | } | ||
| 100 | |||
| 101 | if ($external_only) { | ||
| 102 | continue; | ||
| 103 | } | ||
| 104 | |||
| 105 | $event_date = get_post_meta($post->ID, 'event_date', true); | ||
| 106 | |||
| 107 | if (isset($event_term_slugs['webinar'])) { | ||
| 108 | $is_archived = get_post_meta($post->ID, 'is_archived_webinar', true); | ||
| 109 | if (!$is_archived == "on") { continue; } | ||
| 110 | } else { | ||
| 111 | |||
| 112 | if ($event_date <= (time() + (60*60*24)) ) { | ||
| 113 | continue; | ||
| 114 | } | ||
| 115 | |||
| 116 | } | ||
| 117 | |||
| 118 | |||
| 119 | |||
| 120 | |||
| 80 | $event_date = get_post_meta($post->ID, 'event_date', true); | 121 | $event_date = get_post_meta($post->ID, 'event_date', true); |
| 81 | $register_date = get_post_meta($post->ID, 'reg_deadline', true); | 122 | $register_date = get_post_meta($post->ID, 'reg_deadline', true); |
| 82 | $cost = get_post_meta($post->ID,'cost',true); | 123 | $cost = get_post_meta($post->ID,'cost',true); |
| 83 | if (empty($cost) || $cost < 1 || strtolower($cost)=="free") { $cost = 0; } | 124 | if (empty($cost) || $cost < 1 || strtolower($cost)=="free") { $cost = 0; } |
| 84 | ?> | 125 | ?> |
| 85 | <tr> | 126 | <tr> |
| 86 | <td><?php echo $post->post_title;?></td> | 127 | <td><?php echo $post->post_title;?><br /> |
| 128 | <?php foreach($terms as $the_term) { echo $the_term->name; } ?> | ||
| 129 | </td> | ||
| 87 | <td><?php echo date('F j, Y',$event_date);?></td> | 130 | <td><?php echo date('F j, Y',$event_date);?></td> |
| 88 | <td><?php echo date('F j, Y',$register_date);?></td> | 131 | <td><?php echo date('F j, Y',$register_date);?></td> |
| 89 | <td>$<?php echo number_format($cost,2);?></td> | 132 | <td>$<?php echo number_format($cost,2);?></td> | ... | ... |
| ... | @@ -36,6 +36,8 @@ | ... | @@ -36,6 +36,8 @@ |
| 36 | 36 | ||
| 37 | <div class="title-link" style="display:block;color:#f7bd55; font-size: 12px;font-weight: bold;text-align: left;line-height: 1.75em; background-color: #3b0d32; border: solid 1px #FFF; border-bottom: solid 1px #999; cursor: default; padding: 0em; padding:3px 10px 3px 10px; margin: 0em;"><?php echo $post->post_title;?></div> | 37 | <div class="title-link" style="display:block;color:#f7bd55; font-size: 12px;font-weight: bold;text-align: left;line-height: 1.75em; background-color: #3b0d32; border: solid 1px #FFF; border-bottom: solid 1px #999; cursor: default; padding: 0em; padding:3px 10px 3px 10px; margin: 0em;"><?php echo $post->post_title;?></div> |
| 38 | 38 | ||
| 39 | |||
| 40 | <div style="padding: 0px 0px 10px 0px;"> | ||
| 39 | <?php | 41 | <?php |
| 40 | $extras = $user_event_meta['extras']; | 42 | $extras = $user_event_meta['extras']; |
| 41 | ?> | 43 | ?> |
| ... | @@ -51,9 +53,8 @@ | ... | @@ -51,9 +53,8 @@ |
| 51 | <div class="dashboard-section-links"></div> | 53 | <div class="dashboard-section-links"></div> |
| 52 | <div class="dashboard-section-content small"> | 54 | <div class="dashboard-section-content small"> |
| 53 | <select name="status"> | 55 | <select name="status"> |
| 54 | <option value="paid" <?php echo ($user_event_meta['status']=="paid") ? "selected" : ""; ?>>Paid</option> | 56 | <option value="paid" <?php echo ($user_event_meta['status']=="paid") ? "selected" : ""; ?>>Paid/Free</option> |
| 55 | <option value="invoice" <?php echo ($user_event_meta['status']=="invoice") ? "selected" : ""; ?>>Invoice</option> | 57 | <option value="unpaid" <?php echo ($user_event_meta['status']=="unpaid") ? "selected" : ""; ?>>Invoice User</option> |
| 56 | <option value="free" <?php echo ($user_event_meta['status']=="free") ? "selected" : ""; ?>>Free</option> | ||
| 57 | </select> | 58 | </select> |
| 58 | </div> | 59 | </div> |
| 59 | </div> | 60 | </div> |
| ... | @@ -63,10 +64,12 @@ | ... | @@ -63,10 +64,12 @@ |
| 63 | <div class="dashboard-section-links"></div> | 64 | <div class="dashboard-section-links"></div> |
| 64 | <div class="dashboard-section-content small"> | 65 | <div class="dashboard-section-content small"> |
| 65 | <select name="paid_by"> | 66 | <select name="paid_by"> |
| 67 | <option value="">Select payment method...</option> | ||
| 66 | <option value="visa" <?php echo ($user_event_meta['extras']['paid_by']=="visa") ? "selected" : ""; ?>>Visa</option> | 68 | <option value="visa" <?php echo ($user_event_meta['extras']['paid_by']=="visa") ? "selected" : ""; ?>>Visa</option> |
| 67 | <option value="mc" <?php echo ($user_event_meta['extras']['paid_by']=="mc") ? "selected" : ""; ?>>Mastercard</option> | 69 | <option value="mc" <?php echo ($user_event_meta['extras']['paid_by']=="mc") ? "selected" : ""; ?>>Mastercard</option> |
| 68 | <option value="amex" <?php echo ($user_event_meta['extras']['paid_by']=="amex") ? "selected" : ""; ?>>American Express</option> | 70 | <option value="amex" <?php echo ($user_event_meta['extras']['paid_by']=="amex") ? "selected" : ""; ?>>American Express</option> |
| 69 | <option value="cheque" <?php echo ($user_event_meta['extras']['paid_by']=="cheque") ? "selected" : ""; ?>>Cheque</option> | 71 | <option value="cheque" <?php echo ($user_event_meta['extras']['paid_by']=="cheque") ? "selected" : ""; ?>>Cheque</option> |
| 72 | <option value="other" <?php echo ($user_event_meta['extras']['paid_by']=="other") ? "selected" : ""; ?>>Other</option> | ||
| 70 | </select> | 73 | </select> |
| 71 | </div> | 74 | </div> |
| 72 | </div> | 75 | </div> |
| ... | @@ -263,6 +266,6 @@ | ... | @@ -263,6 +266,6 @@ |
| 263 | </div> | 266 | </div> |
| 264 | 267 | ||
| 265 | </form> | 268 | </form> |
| 266 | 269 | </div> | |
| 267 | </body> | 270 | </body> |
| 268 | </html> | 271 | </html> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment