b746e78d by Kevin Burton

User Manager updates from Kevin - Do not promote

1 parent f9f174a1
...@@ -846,8 +846,23 @@ class Actions { ...@@ -846,8 +846,23 @@ class Actions {
846 $uid = $_POST['uid']; 846 $uid = $_POST['uid'];
847 $event_id = $_POST['event_id']; 847 $event_id = $_POST['event_id'];
848 $type = $_POST['type']; 848 $type = $_POST['type'];
849
849 $status = $_POST['status']; 850 $status = $_POST['status'];
850 $paid_by = $_POST['paid_by']; 851
852 switch($status) {
853 case 'unpaid':
854 $status = 'unpaid';
855 $paid_by = '';
856 break;
857 case 'complementary':
858 $status = 'complementary';
859 $paid_by = '';
860 break;
861 default:
862 $status = 'paid';
863 $paid_by = $status;
864 break;
865 }
851 866
852 unset($_POST['action']); 867 unset($_POST['action']);
853 unset($_POST['ajax']); 868 unset($_POST['ajax']);
...@@ -879,155 +894,152 @@ class Actions { ...@@ -879,155 +894,152 @@ class Actions {
879 $user = new User\Account($uid); 894 $user = new User\Account($uid);
880 895
881 $cost = get_post_meta($event_id, 'cost', true); 896 $cost = get_post_meta($event_id, 'cost', true);
882
883 if ( empty($cost) OR $cost < 1 OR strtolower($cost) == "free" ) {
884 set_attending($user->ID,$event_id,"free","",$_POST);
885 } else {
886 897
887 //$user = new User\CurrentAccount(); 898 $role = $user->getRole();
888 $role = $user->getRole();
889
890 $event = get_post($event_id);
891 899
892 $cehours = get_post_meta($event_id,'worth_cehours',true); 900 $event = get_post($event_id);
893 $early_bird_deadline = get_post_meta($event_id,'early_bird_deadline',true); 901
894 $early_bird_discount = get_post_meta($event_id,'early_bird_discount',true); 902 $cehours = get_post_meta($event_id,'worth_cehours',true);
895 $member_discount = get_post_meta($event_id,'student_member_discount',true); 903 $early_bird_deadline = get_post_meta($event_id,'early_bird_deadline',true);
896 $reg_deadline = get_post_meta($event_id,'reg_deadline',true); 904 $early_bird_discount = get_post_meta($event_id,'early_bird_discount',true);
897 $event_date = get_post_meta($event_id,'event_date',true); 905 $member_discount = get_post_meta($event_id,'student_member_discount',true);
898 906 $reg_deadline = get_post_meta($event_id,'reg_deadline',true);
899 907 $event_date = get_post_meta($event_id,'event_date',true);
900 $event_term_slugs = array();
901 $terms = get_the_terms($event_id,'event_type');
902 if (!empty($terms)) {
903 foreach($terms as $types) {
904 $event_term_slugs[$types->slug] = $types->name;
905 }
906 }
907 908
908 909
909 $discounts = array(); 910 $event_term_slugs = array();
910 911 $terms = get_the_terms($event_id,'event_type');
911 $new_cost = $cost; 912 if (!empty($terms)) {
912 $total_discount = 0; 913 foreach($terms as $types) {
913 914 $event_term_slugs[$types->slug] = $types->name;
914 if ( ($user->getRole()=="member" || $user->getRole()=="student") && !empty($member_discount) ) {
915 $show_member_discount = true;
916
917 $discounts[] = Array(
918 'discount_label' => "Student/Member Discount"
919 , 'discount' => $member_discount
920 );
921
922 $new_cost = ($new_cost - $member_discount);
923 $total_discount = ($total_discount + $member_discount);
924
925 }
926 if (!empty($early_bird_deadline) && $early_bird_deadline > time()) {
927 $show_early_discount = true;
928
929 $discounts[] = Array(
930 'discount_label' => "Early Bird Discount"
931 , 'discount' => $early_bird_discount
932 );
933
934 $new_cost = ($new_cost - $early_bird_discount);
935 $total_discount = ($total_discount + $early_bird_discount);
936 }
937
938 $provstate = get_post_meta($event_id,'provstate',true);
939 if (empty($provstate) OR $provstate == "outside") {
940 $provstate = "ON";
941 }
942
943
944 if (isset($event_term_slugs['webinar'])) {
945 $tpp = get_user_meta($user->ID,'profile_preference',true);
946 $tpp = strtolower($tpp);
947 $province = get_user_meta($user->ID,$tpp."_province",true);
948 $tax_label = "Taxes-$province";
949 $tax = getTaxesByProvince($province);
950
951 } else {
952 $tax_label = "Taxes-$provstate";
953 $tax = getTaxesByProvince($provstate); // tax percentage (whole number)
954 } 915 }
916 }
917
918
919 $discounts = array();
920
921 $new_cost = $cost;
922 $total_discount = 0;
923
924 if ( ($user->getRole()=="member" || $user->getRole()=="student") && !empty($member_discount) ) {
925 $show_member_discount = true;
955 926
956 $taxes = ($new_cost * ($tax/100)); 927 $discounts[] = Array(
957 928 'discount_label' => "Student/Member Discount"
958 929 , 'discount' => $member_discount
959 930 );
960 931
932 $new_cost = ($new_cost - $member_discount);
933 $total_discount = ($total_discount + $member_discount);
934
935 }
936 if (!empty($early_bird_deadline) && $early_bird_deadline > time()) {
937 $show_early_discount = true;
961 938
962 $invoice_post = $_POST; 939 $discounts[] = Array(
940 'discount_label' => "Early Bird Discount"
941 , 'discount' => $early_bird_discount
942 );
963 943
964 944 $new_cost = ($new_cost - $early_bird_discount);
965 $details = Array('dietary', 945 $total_discount = ($total_discount + $early_bird_discount);
966 'mealopt_one','mealopt_two','mealopt_three','mealopt_four','mealopt_five','mealopt_six','mealopt_seven','mealopt_eight','mealopt_nine','mealopt_ten', 946 }
967 'session_one','session_two','session_three','session_four','session_five','session_six','session_seven','session_eight','session_nine','session_ten'); 947
968 948 $provstate = get_post_meta($event_id,'provstate',true);
969 $extras = array(); 949 if (empty($provstate) OR $provstate == "outside") {
970 foreach($details as $index) { 950 $provstate = "ON";
971 if ( isset($_POST[$index]) ) { 951 }
972 $extras[$index] = $_POST[$index]; 952
973 } 953
974 } 954 if (isset($event_term_slugs['webinar'])) {
955 $tpp = get_user_meta($user->ID,'profile_preference',true);
956 $tpp = strtolower($tpp);
957 $province = get_user_meta($user->ID,$tpp."_province",true);
958 $tax_label = "Taxes-$province";
959 $tax = getTaxesByProvince($province);
975 960
976 Events\set_attending($user->ID,$event_id,'paid',md5(rand()),$extras); 961 } else {
977 $items = array(); 962 $tax_label = "Taxes-$provstate";
978 963 $tax = getTaxesByProvince($provstate); // tax percentage (whole number)
979 $items[] = array( 964 }
980 'post_id' => $event_id 965
981 , 'cost' => get_post_meta($event_id,'cost',true) 966 $taxes = ($new_cost * ($tax/100));
982 , 'discounts' => $discounts 967
983 , 'tax_label' => $tax_label 968
984 , 'tax_rate' => $tax 969
985 , 'tax_amount' => $taxes 970
986 , 'subtotal' => $new_cost 971
987 , 'total' => number_format(($new_cost + $taxes),2) 972 $invoice_post = $_POST;
988 , 'description' => "" 973
989 , 'extras' => $extras 974
990 975 $details = Array('dietary',
991 ); 976 'mealopt_one','mealopt_two','mealopt_three','mealopt_four','mealopt_five','mealopt_six','mealopt_seven','mealopt_eight','mealopt_nine','mealopt_ten',
992 977 'session_one','session_two','session_three','session_four','session_five','session_six','session_seven','session_eight','session_nine','session_ten');
993 $pp = get_user_meta($user->ID,'profile_preference',true); 978
994 $pp = $pp . "_"; 979 $extras = array();
995 980 foreach($details as $index) {
996 $invoice_data = array(); 981 if ( isset($_POST[$index]) ) {
997 $invoice_data['items'] = $items; 982 $extras[$index] = $_POST[$index];
998 $invoice_data['payment'] = array(
999 'total_cost' => get_post_meta($event_id,'cost',true)
1000 , 'total_discounts' => $total_discount
1001 , 'total_taxes' => $taxes
1002 , 'subtotal' => $new_cost
1003 , 'total' => number_format(($new_cost + $taxes),2)
1004 , 'bt_address' => get_user_meta($user->ID, $pp.'address',true)
1005 , 'bt_address2' => get_user_meta($user->ID, $pp.'address2',true)
1006 , 'bt_city' => get_user_meta($user->ID, $pp.'city',true)
1007 , 'bt_province' => get_user_meta($user->ID, $pp.'province',true)
1008 , 'bt_country' => get_user_meta($user->ID, $pp.'country',true)
1009 , 'bt_postal' => get_user_meta($user->ID, $pp.'postal',true)
1010 , 'bt_card_holder' => ""
1011 , 'bt_card_number' => ""
1012 , 'bt_card_type' => ""
1013 );
1014
1015 $event_term_slugs = array();
1016 $terms = get_the_terms($event_id,'event_type');
1017
1018
1019 if (!empty($terms)) {
1020 foreach($terms as $types) {
1021 $event_term_slugs[$types->slug] = $types->name;
1022 } 983 }
1023 } 984 }
1024 985
1025 986
1026 987 $items = array();
1027 //create($items = array(), $invoice_type = 'event', $title = "Invoice", $user_id = 0, $status = 'pending', $reference = '', $publish = 'draft') 988
1028 Invoice\create($invoice_data, 'event', 'Registration for Event via CBV Admin: '.$event->post_title, $user->ID, $status, 'publish',number_format(($new_cost + $taxes),2)); 989 $items[] = array(
990 'post_id' => $event_id
991 , 'cost' => get_post_meta($event_id,'cost',true)
992 , 'discounts' => $discounts
993 , 'tax_label' => $tax_label
994 , 'tax_rate' => $tax
995 , 'tax_amount' => $taxes
996 , 'subtotal' => $new_cost
997 , 'total' => number_format(($new_cost + $taxes),2)
998 , 'description' => ""
999 , 'extras' => $extras
1000
1001 );
1002
1003 $pp = get_user_meta($user->ID,'profile_preference',true);
1004 $pp = $pp . "_";
1005
1006 $invoice_data = array();
1007 $invoice_data['items'] = $items;
1008 $invoice_data['payment'] = array(
1009 'total_cost' => get_post_meta($event_id,'cost',true)
1010 , 'total_discounts' => $total_discount
1011 , 'total_taxes' => $taxes
1012 , 'subtotal' => $new_cost
1013 , 'total' => number_format(($new_cost + $taxes),2)
1014 , 'bt_address' => get_user_meta($user->ID, $pp.'address',true)
1015 , 'bt_address2' => get_user_meta($user->ID, $pp.'address2',true)
1016 , 'bt_city' => get_user_meta($user->ID, $pp.'city',true)
1017 , 'bt_province' => get_user_meta($user->ID, $pp.'province',true)
1018 , 'bt_country' => get_user_meta($user->ID, $pp.'country',true)
1019 , 'bt_postal' => get_user_meta($user->ID, $pp.'postal',true)
1020 , 'bt_card_holder' => ""
1021 , 'bt_card_number' => ""
1022 , 'bt_card_type' => ""
1023 );
1029 1024
1025 $event_term_slugs = array();
1026 $terms = get_the_terms($event_id,'event_type');
1027
1028
1029 if (!empty($terms)) {
1030 foreach($terms as $types) {
1031 $event_term_slugs[$types->slug] = $types->name;
1032 }
1030 } 1033 }
1034
1035
1036
1037 //create($items = array(), $invoice_type = 'event', $title = "Invoice", $user_id = 0, $status = 'pending', $reference = '', $publish = 'draft')
1038 Invoice\create($invoice_data, 'event', 'Registration for Event via CBV Admin: '.$event->post_title, $user->ID, $status, 'publish',number_format(($new_cost + $taxes),2));
1039
1040 Events\set_attending($user->ID,$event_id,'paid',md5(rand()),$extras);
1041
1042
1031 1043
1032 1044
1033 } 1045 }
......
...@@ -49,27 +49,16 @@ ...@@ -49,27 +49,16 @@
49 <input type="hidden" name="type" value="<?php echo $action; ?>" /> 49 <input type="hidden" name="type" value="<?php echo $action; ?>" />
50 50
51 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> 51 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
52 <div class="dashboard-section-title">REGISTRATION STATUS</div> 52 <div class="dashboard-section-title">HOW TO PROCESS THE REGISTRATION:</div>
53 <div class="dashboard-section-links"></div> 53 <div class="dashboard-section-links"></div>
54 <div class="dashboard-section-content small"> 54 <div class="dashboard-section-content small">
55 <select name="status"> 55 <select name="status">
56 <option value="paid" <?php echo ($user_event_meta['status']=="paid") ? "selected" : ""; ?>>Paid/Free</option>
57 <option value="unpaid" <?php echo ($user_event_meta['status']=="unpaid") ? "selected" : ""; ?>>Invoice User</option> 56 <option value="unpaid" <?php echo ($user_event_meta['status']=="unpaid") ? "selected" : ""; ?>>Invoice User</option>
58 </select> 57 <option value="complementary" <?php echo ($user_event_meta['status']=="complementary") ? "selected" : ""; ?>>Complementary</option>
59 </div> 58 <option value="visa" <?php echo ($user_event_meta['status']=="paid" && $user_event_meta['extras']['paid_by']=="visa") ? "selected" : ""; ?>>Paid by Prepaid Visa</option>
60 </div> 59 <option value="mc" <?php echo ($user_event_meta['status']=="paid" && $user_event_meta['extras']['paid_by']=="mc") ? "selected" : ""; ?>>Paid by Prepaid Mastercard</option>
61 60 <option value="amex" <?php echo ($user_event_meta['status']=="paid" && $user_event_meta['extras']['paid_by']=="amex") ? "selected" : ""; ?>>Paid by Prepaid American Express</option>
62 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> 61 <option value="cheque" <?php echo ($user_event_meta['status']=="paid" && $user_event_meta['extras']['paid_by']=="cheque") ? "selected" : ""; ?>>Paid by Cheque</option>
63 <div class="dashboard-section-title">PAID BY</div>
64 <div class="dashboard-section-links"></div>
65 <div class="dashboard-section-content small">
66 <select name="paid_by">
67 <option value="">Select payment method...</option>
68 <option value="visa" <?php echo ($user_event_meta['extras']['paid_by']=="visa") ? "selected" : ""; ?>>Visa</option>
69 <option value="mc" <?php echo ($user_event_meta['extras']['paid_by']=="mc") ? "selected" : ""; ?>>Mastercard</option>
70 <option value="amex" <?php echo ($user_event_meta['extras']['paid_by']=="amex") ? "selected" : ""; ?>>American Express</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>
73 </select> 62 </select>
74 </div> 63 </div>
75 </div> 64 </div>
......