bd69a0c6 by Chris Boden

Removed UserManager from repository

1 parent 7eb0331b
1 function submitMark(e) {
2 if (e.keyCode == 27) {
3 document.getElementById(e.target.getAttribute('data-ref')).style.display = 'inline';
4 e.target.parentNode.removeChild(e.target);
5
6 return;
7 }
8
9 if (e.keyCode == 13) {
10 jQuery.ajax({
11 url: '/wp-admin/admin-ajax.php'
12 , data: {ajax: 'yes', action: 'update_mark', uid: user_id, course_id: e.target.getAttribute('data-course-id'), value: e.target.value}
13 , type: 'POST'
14 , dataType: 'json'
15 , success: function() {
16 var oLink = document.getElementById(e.target.getAttribute('data-ref'));
17 oLink.setAttribute('data-mark-value', e.target.value);
18 oLink.firstChild.nodeValue = e.target.value;
19 oLink.style.display = 'inline';
20
21 e.target.parentNode.removeChild(e.target);
22 }
23 });
24 }
25 }
26
27 function update_listing_preference() {
28 var pref = jQuery('#profile_preference').val();
29 if (pref == "Work") {
30 jQuery('.work-only').show();
31 } else {
32 jQuery('.work-only').hide();
33 }
34 }
35
36 jQuery(function($) {
37
38 Date.firstDayOfWeek = 0;
39 Date.format = 'yyyy-mm-dd';
40
41 if (jQuery('.datepicker').length > 0) {
42 jQuery('.datepicker').datePicker(
43 {
44 startDate: '1920-01-01',
45 endDate: (new Date()).asString()
46 }
47 );
48 }
49
50 $('#invoice_type').change(function() {
51
52 var invoice_type = $(this).val();
53
54 switch(invoice_type) {
55 case 'invoice':
56 $('tr.invoice_credit_only').show();
57 $('tr.invoice_only').show();
58 break;
59 case 'membership':
60 $('tr.invoice_credit_only').hide();
61 $('tr.invoice_only').show();
62 break;
63 default:
64 $('tr.invoice_credit_only').show();
65 $('tr.invoice_only').hide();
66 }
67
68
69 });
70
71 jQuery('#creditNotBtn').click(function(e) {
72 jQuery('#credit_note').slideToggle('fast');
73
74 var InvoiceType = $('#invoice_type');
75 if (InvoiceType.val() == "invoice") {
76 $('.invoice_only').show();
77 } else {
78 $('.invoice_only').hide();
79 }
80
81 jQuery('#creditForm').ajaxForm({
82 url: '/wp-admin/admin-ajax.php'
83 , data: ({ajax:"yes", action: 'create_invoice_note'})
84 , dateType: 'json'
85 , type: 'POST'
86 , success: function(data) {
87 // reload, cannot use reload() because then the form values get re-applied.
88 document.location.href = document.location.href;
89
90 }
91 });
92 e.preventDefault();
93 return false;
94 });
95
96 jQuery('.remove-user').colorbox({onComplete: function() {
97
98 var cb = this;
99 var options = {
100 beforeSubmit: function() {}
101 , success: function(data) {
102 document.location.href = document.location.href;
103 }
104 , error: function(XMLHttpRequest, textStatus, errorThrown) {
105 document.location.href = document.location.href;
106 }
107 , data: ({ajax:"yes", action: 'remove_user'})
108 , dataType: 'json'
109 , url: '/wp-admin/admin-ajax.php'
110 };
111 jQuery('#remove-user-form').ajaxForm(options);
112
113 }});
114
115 jQuery('#edit_user_notes').ajaxForm({
116 url: '/wp-admin/admin-ajax.php'
117 , data: ({ajax:"yes", action: 'update_edit_notes'})
118 , type: 'POST'
119 , dataType: 'json'
120 , success: function(data) {
121 jQuery('.update-placeholder').html('Update Successful.');
122 }
123 });
124
125
126 jQuery('#admin-edit-user-profile').ajaxForm({
127 url: '/wp-admin/admin-ajax.php'
128 , data: ({ajax:"yes", action: 'update_edit_profile'})
129 , dataType: 'json'
130 , type: 'post'
131 , beforeSubmit: function(formData, jqForm, options) {
132 var $error_container = jQuery('.validation-errors');
133 $error_container.hide();
134 }
135 , success: function(data) {
136 if (data.success == "true") {
137 jQuery('.update-placeholder').html('Update Successful.');
138 } else {
139 //$('.register-form :input').removeAttr('disabled');
140 var $error_container = jQuery('.validation-errors');
141 jQuery('h6',$error_container).html("OOPS...");
142 jQuery('ul',$error_container).html(data.msg);
143 $error_container.show();
144 }
145 }
146 , error: function(XMLHttpRequest, textStatus, errorThrown) {
147 var $error_container = jQuery('.validation-errors');
148 jQuery('h6',$error_container).html("OOPS...");
149 jQuery('ul',$error_container).html("<li>Please check all required fields and be sure they are the right format.</li>");
150 $error_container.show();
151 }
152 });
153
154 // overview ajaxForm...
155 jQuery('#overview_form').ajaxForm({
156 url: '/wp-admin/admin-ajax.php'
157 , data: ({ajax:"yes", action: 'update_account'})
158 , dataType: 'json'
159 , type: 'post'
160 , beforeSubmit: function(formData, jqForm, options) {
161 var $error_container = jQuery('.validation-errors');
162 $error_container.hide();
163 }
164 , success: function(data) {
165
166 if (data.success == "true") {
167 jQuery('.update-placeholder').html('Update Successful.');
168 } else {
169 //$('.register-form :input').removeAttr('disabled');
170 var $error_container = jQuery('.validation-errors');
171 jQuery('h6',$error_container).html("OOPS...");
172 jQuery('ul',$error_container).html(data.msg);
173 $error_container.show();
174 }
175 }
176 , error: function(XMLHttpRequest, textStatus, errorThrown) {
177 var $error_container = jQuery('.validation-errors');
178 jQuery('h6',$error_container).html("A server error has occurred.");
179 jQuery('ul',$error_container).html("<li>"+errorThrown+"</li>");
180 $error_container.show();
181 }
182 });
183
184 jQuery('.event-edit').colorbox({onComplete: function() {
185 var cb = this;
186 var options = {
187 beforeSubmit: function() {}
188 , success: function(data) {
189
190 if (data.refresh == "true") {
191 document.location.href = document.location.href;
192 } else {
193 jQuery.colorbox.close();
194 }
195
196 }
197 , data: ({ajax:"yes", action: 'update_registration'})
198 , dataType: 'json'
199 , url: '/wp-admin/admin-ajax.php'
200 };
201 jQuery('#edit-event-form').ajaxForm(options);
202 }});
203
204 jQuery('.invoice-refund-btn').live('click', function(e) {
205 var iid = $(this).attr('rel');
206 var current_amount = $(this).attr('amount');
207
208 // now we are going to pop up with invoice items.
209 $.colorbox({
210 href: '/wp-admin/admin-ajax.php?ajax=yes&action=admin_refund_invoice_form&invoice_id='+iid+'&uid='+user_id
211 , onComplete: function() {
212 jQuery('#invoice_refund_form').ajaxForm({
213 url: '/wp-admin/admin-ajax.php'
214 , data: ({ajax:"yes", action: 'issue_invoice_refund', invoice_id: iid})
215 , dataType: 'json'
216 , type: 'POST'
217 , success: function(data) {
218 if (data.success == 'true') {
219 document.location.href = document.location.href;
220 } else {
221 jAlert(data.msg, 'Server Error Encountered');
222 }
223 }
224 , error: function(XMLHttpRequest, textStatus, errorThrown) {
225 jAlert(textStatus, 'Server Error Encountered');
226 }
227 });
228
229 $('#refund_cancel_btn').click(function(e) {
230 e.preventDefault();
231 $.colorbox.close();
232 });
233 }
234 });
235
236 e.preventDefault();
237 return false;
238 });
239
240 jQuery('.invoice-cancel-btn').live('click', function(e) {
241 var iid = $(this).attr('rel');
242
243 jConfirm('<strong>Are you sure</strong> you want to <em>cancel</em> the invoice?', 'Cancel Invoice', function(c) {
244 if (c) {
245 jQuery.ajax({
246 url: '/wp-admin/admin-ajax.php'
247 , data: ({ajax:"yes", action: 'admin_cancel_invoice',invoice_id:iid})
248 , dataType: 'json'
249 , type: 'POST'
250 , success: function(data) {
251 document.location.reload();
252 }
253 });
254 }
255 });
256 e.preventDefault();
257 return false;
258 });
259
260 jQuery('.admin-mark-invoice-paid').colorbox({onComplete: function() {
261 var cb = this;
262 var options = {
263 success: function(data) {
264 document.location.reload();
265 }
266 , data: ({ajax:"yes", action: 'admin_update_invoice'})
267 , dataType: 'json'
268 , url: '/wp-admin/admin-ajax.php'
269 };
270 jQuery('#edit-invoice-form').ajaxForm(options);
271 }});
272
273 jQuery('.course-edit').colorbox({onComplete: function() {
274 var cb = this;
275 var options = {
276 beforeSubmit: function() {}
277 , success: function(data) {
278
279 if (data.refresh == "true") {
280 document.location.href = document.location.href;
281 } else {
282 jQuery.colorbox.close();
283 }
284
285 }
286 , data: ({ajax:"yes", action: 'course_registration'})
287 , dataType: 'json'
288 , url: '/wp-admin/admin-ajax.php'
289 };
290 jQuery('#edit-course-form').ajaxForm(options);
291 }});
292
293 jQuery('#admin_add_new_cehours').colorbox({onComplete: function() {
294 jQuery('.datepicker').datePicker(
295 {
296 startDate: '1920-01-01',
297 endDate: (new Date()).asString()
298 }
299 );
300
301 var options = {
302 success: function(data) {
303 document.location.href = document.location.href;
304 }
305 , data: ({ajax:"yes", action: 'admin_update_cehours'})
306 , dataType: 'json'
307 , url: '/wp-admin/admin-ajax.php'
308 };
309 jQuery('#edit-cehours-form').ajaxForm(options);
310
311 }});
312
313
314 jQuery('.cehours-edit').colorbox({onComplete: function() {
315 jQuery('.datepicker').datePicker(
316 {
317 startDate: '1920-01-01',
318 endDate: (new Date()).asString()
319 }
320 );
321
322 var options = {
323 success: function(data) {
324 document.location.href = document.location.href;
325 }
326 , data: ({ajax:"yes", action: 'admin_update_cehours'})
327 , dataType: 'json'
328 , url: '/wp-admin/admin-ajax.php'
329 };
330 jQuery('#edit-cehours-form').ajaxForm(options);
331
332 }});
333
334
335 jQuery('.cehours-remove').click(function(e) {
336
337 var ds = jQuery(this).attr('rel');
338
339 jConfirm('Are you sure?', 'Remove CE Hours?', function(c) {
340 if (c) {
341 jQuery.ajax({
342 url: '/wp-admin/admin-ajax.php'
343 , data: ({ajax:"yes", action: 'admin_remove_cehours', uid:user_id, indexed: ds})
344 , type: 'post'
345 , dataType: 'json'
346 , success: function(data) {
347 document.location.href = document.location.href;
348 }
349 });
350 }
351 });
352
353 e.preventDefault();
354 return false;
355
356 });
357
358 jQuery('.event-cancel').click(function(e) {
359 var eventcontainer = jQuery(this).parent();
360 var link = jQuery(this);
361
362 jConfirm('Are you sure?', 'Cancel Registration', function(c) {
363
364 if (c) {
365 eventcontainer.empty().addClass('spinner');
366
367 jQuery.ajax({
368 url: '/wp-admin/admin-ajax.php'
369 , data: ({ajax:"yes", action: 'cancel_registration', uid: user_id, eid: link.attr('rel')})
370 , type: 'post'
371 , success: function(data) {
372 document.location.href = document.location.href;
373 /*
374 if (data.ask_credit=="true") {
375 // ask if they want to credit....
376 jPrompt('How much (if any) would you like to credit their account?', '0.00', 'Registration has been cancelled', function(r) {
377 if( r ) {
378 jQuery.ajax({
379 url: '/wp-admin/admin-ajax.php'
380 , data: ({ajax:"yes", action: 'post_credit', uid:user_id, post_id: link.attr('rel'), amount:r})
381 , type: 'POST'
382 , dataType: 'json'
383 });
384 }
385 document.location.href = document.location.href;
386 });
387 } else {
388 document.location.href = document.location.href;
389 }
390 */
391
392 }
393 , dataType: 'json'
394 });
395
396 }
397
398 });
399
400 e.preventDefault();
401 return false;
402 });
403
404 jQuery('#TzFQActions input').click(function(e) {
405 jQuery.ajax({
406 url: '/wp-admin/admin-ajax.php'
407 , data: {ajax: 'yes', action: 'update_fq_status', uid: user_id, status: e.target.value}
408 , type: 'POST'
409 , dataType: 'json'
410 , success: function() {
411 jQuery("#Tz4QContainer").remove();
412 }
413 });
414 });
415
416 jQuery('#mark_history a[data-mark="editable"]').click(function(e) {
417 var oEdit = document.createElement('input');
418 oEdit.type = 'text';
419 oEdit.size = 3;
420 oEdit.value = e.target.getAttribute('data-mark-value');
421
422 e.target.parentNode.appendChild(oEdit);
423
424 oEdit.setAttribute('data-ref', e.target.id);
425 oEdit.setAttribute('data-course-id', e.target.getAttribute('data-course-id'));
426 oEdit.focus();
427
428 jQuery(oEdit).keydown(submitMark);
429
430 e.target.style.display = 'none';
431 }).each(function(i, o) {
432 o.onclick = function() { return false; };
433 });
434 });
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /*
3 Plugin Name: CBV User Manager
4 Description: All-In-One User Management for CBV
5 Version: 1.0
6 Author: Tenzing Communications Inc.
7 Author URI: http://www.gotenzing.com
8 */
9 namespace Tz\WordPress\Tools\UserManager;
10
11 use Tz\Common;
12 use Tz\WordPress\Tools;
13 use Tz\WordPress\Tools\Auth;
14 use Tz\WordPress\Tools\Sequencer;
15 use Tz\WordPress\UAM;
16 use Tz\WordPress\Tools\HTML;
17 use Tz\WordPress\CBV;
18 use Tz\WordPress\CBV\User;
19 use Tz\WordPress\CBV\Events;
20 use Tz\WordPress\CBV\CEHours;
21 use Tz\WordPress\CBV\Invoice, Tz\WordPress\CBV\Invoice\Order\Item as OrderItem;
22 use Tz\WordPress\CBV\Beanstream\Card as CreditCard;
23 use Tz\WordPress\CBV\Courses;
24 use Tz\WordPress\CBV\CBVOptions;
25 use Exception, StdClass, ArrayAccess, Iterator, Countable;
26
27 const OPTION_NAME = "user_options";
28 const CAPABILITY = "manage_cbv_users";
29
30
31 CBV\load('Invoice');
32 CBV\load('User');
33 Tools\import('HTML');
34
35
36 call_user_func(function() {
37 $role = get_role('administrator');
38 $role->add_cap(CAPABILITY);
39 Tools\add_actions(__NAMESPACE__ . '\Actions');
40
41 Vars::$validation = new StdClass;
42 Vars::$validation->errors = Array();
43 });
44
45 function fix_unpaid() {
46 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'fix_unpaid.php');
47 }
48
49 function display_users() {
50 /*
51 global $wpdb;
52 // temporary - remove when done...
53 $query = $wpdb->get_results("SELECT ID FROM {$wpdb->users}");
54 foreach($query as $user) {
55 $status = get_user_meta($user->ID, 'status', true);
56 if (empty($status)) {
57 update_user_meta($user->ID, 'status', 'active');
58 }
59 }
60 */
61
62 // end temporary.
63
64
65 if ( isset($_GET['action']) && ($_GET['action']=="edit") && isset($_GET['uid']) && ($_GET['uid'] > 0) ) {
66 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'edit_user.php');
67 } elseif (isset($_GET['action']) && $_GET['action']=="edit-partial") {
68 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_'.$_GET['section'].'.php');
69 } else {
70 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'display_users.php');
71 }
72 }
73
74 function getTaxesByProvince($provstate = "ON") {
75 return CBV\get_tax_pct($provstate);
76 }
77
78
79 function search_special_status($key) {
80 $special_statuses = get_user_meta($_GET['uid'], 'special_statuses',true);
81 if (!empty($special_statuses)) {
82 foreach($special_statuses as $stat) {
83 if ($stat == $key) {
84 echo 'checked';
85 break;
86 }
87 }
88 }
89 }
90
91 function create_instant_invoice($id = 0) {
92 Actions::wp_ajax_create_invoice_note($id);
93 }
94
95 function get_users($role = null, $pagenum=1, $records_per_page=0, $return_count_only = false, $search = null) {
96 $fs = Array();
97 if (!is_null($role)) {
98 $len = strlen($role);
99 $fs = Array('wp_capabilities' => "a:1:{s:{$len}:\\\\\\\\\"{$role}\\\\\\\\\"");
100 }
101
102 $users = new Tools\UserSearch(
103 Array('member_id', 'first_name', 'last_name', 'home_email', 'work_email', 'email_address_preference', 'status', 'wp_capabilities')
104 , $records_per_page
105 , $pagenum
106 , 'last_name'
107 , 'ASC'
108 , $fs
109 , $search
110 );
111
112 $users->setUserClass('Tz\WordPress\CBV\User\Account');
113 return $users;
114 }
115
116 function create_user() {
117 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create_user.php');
118 }
119
120 function signups() {
121 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'signups.php');
122 }
123
124 function _get_signups() {
125 global $wpdb;
126 $users = $wpdb->get_results("SELECT * FROM wp_signups WHERE active = 0 ORDER BY registered ASC");
127 return $users;
128 }
129
130 function merge_users() {
131 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'merge_users.php');
132 }
133
134 class ProfileValidation extends Common\Validation {
135 public function prefix($val) {
136 update_user_meta($_POST['uid'], __FUNCTION__, $val);
137 }
138
139 public function member_since($val) {
140 update_user_meta($_POST['uid'], __FUNCTION__, $val);
141 }
142
143 public function first_name($val) {
144 if(empty($val)) {
145 throw new Exception('First name cannot be blank');
146 } else {
147 update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
148 }
149 }
150
151 public function initial($val) {
152 update_user_meta($_POST['uid'], __FUNCTION__, $val);
153 }
154
155 public function last_name($val) {
156 if(empty($val)) {
157 throw new Exception('Last name cannot be blank');
158 } else {
159 update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
160 }
161 }
162
163 public function degrees($val) {
164 update_user_meta($_POST['uid'], __FUNCTION__, $val);
165 }
166
167 public function designations($val) {
168 update_user_meta($_POST['uid'], __FUNCTION__, $val);
169 }
170
171 public function company_type($val) {
172 update_user_meta($_POST['uid'], __FUNCTION__, $val);
173 }
174
175 public function description($val) {
176 update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
177 }
178
179 public function date_of_birth($val) {
180 update_user_meta($_POST['uid'], __FUNCTION__, $val);
181 }
182
183 public function home_address($val) {
184 update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
185 }
186
187 public function home_address2($val) {
188 update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
189 }
190
191 public function home_city($val) {
192 update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
193 }
194
195 public function home_province($val) {
196 if ( $_POST['profile_preference']=="Home" ) {
197 if (empty($val)) {
198 throw new Exception('Home Province field can not be empty');
199 }
200 }
201 update_user_meta($_POST['uid'], __FUNCTION__, $val);
202 }
203
204 public function home_postal($val) {
205 update_user_meta($_POST['uid'], __FUNCTION__, $val);
206 }
207
208 public function home_country($val) {
209 if ( $_POST['profile_preference']=="Home" ) {
210 if (empty($val)) {
211 throw new Exception('Home Country field can not be empty');
212 }
213 }
214 update_user_meta($_POST['uid'], __FUNCTION__, $val);
215 }
216
217 public function home_phone($val) {
218 update_user_meta($_POST['uid'], __FUNCTION__, $val);
219 }
220
221
222 public function home_mobile($val) {
223 update_user_meta($_POST['uid'], __FUNCTION__, $val);
224 }
225
226 public function home_email($val) {
227 if (!empty($val)) {
228 if (!(boolean)preg_match(CBV\VALID_EMAIL, (string)$val)) {
229 throw new Exception('An invalid email address was entered in Email');
230 }
231 }
232
233 if ($_POST['profile_preference']=="Home") {
234 _update_user( Array ('ID'=>$_POST['uid'] , 'user_email'=>$val) );
235 }
236
237 update_user_meta($_POST['uid'], 'home_email', $val);
238 }
239
240 public function work_address($val) {
241 update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
242 }
243
244 public function work_address2($val) {
245 update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
246 }
247
248 public function work_city($val) {
249 update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
250 }
251
252 public function work_province($val) {
253 if ($_POST['profile_preference']=="Work") {
254 if (empty($val)) {
255 throw new Exception('Work Province field can not be empty');
256 }
257 }
258 update_user_meta($_POST['uid'], __FUNCTION__, $val);
259 }
260
261 public function work_postal($val) {
262 update_user_meta($_POST['uid'], __FUNCTION__, $val);
263 }
264
265 public function work_country($val) {
266 if ($_POST['profile_preference']=="Work") {
267 if (empty($val)) {
268 throw new Exception('Work Country field can not be empty');
269 }
270 }
271 update_user_meta($_POST['uid'], __FUNCTION__, $val);
272 }
273
274 public function work_phone($val) {
275 update_user_meta($_POST['uid'], __FUNCTION__, $val);
276 }
277
278 public function work_extension($val) {
279 update_user_meta($_POST['uid'], __FUNCTION__, $val);
280 }
281
282
283 public function work_mobile($val) {
284 update_user_meta($_POST['uid'], __FUNCTION__, $val);
285 }
286
287 public function work_email($val) {
288 if (!empty($val)) {
289 if (!(boolean)preg_match(CBV\VALID_EMAIL, (string)$val)) {
290 throw new Exception('An invalid email address was entered in Email');
291 }
292 }
293
294 if ($_POST['profile_preference']=="Work") {
295 _update_user( Array ('ID'=>$_POST['uid'] , 'user_email'=>$val) );
296 }
297
298 update_user_meta($_POST['uid'], 'work_email', $val);
299 }
300
301
302 public function company($val) {
303 update_user_meta($_POST['uid'],'company', User\clean_string($val));
304 }
305
306 public function title($val) {
307 update_user_meta($_POST['uid'], 'title', User\clean_string($val));
308 }
309
310 public function fax($val) {
311 update_user_meta($_POST['uid'], __FUNCTION__, $val);
312 }
313
314 public function website($val) {
315
316 if (!empty($val)) {
317
318 if (substr($val, 0, 7) != 'http://' && substr($val, 0, 8) != 'https://') {
319 $val = 'http://' . $val;
320 }
321
322 if (!(boolean)filter_var($val, FILTER_VALIDATE_URL)) {
323 throw new Exception('An invalid url was entered in website');
324 }
325 }
326 update_user_meta($_POST['uid'], 'website', User\clean_string($val));
327 }
328
329 public function profile_preference($val) {
330 update_user_meta($_POST['uid'], 'profile_preference', $val);
331 }
332
333 public function email_address_preference($val) {
334 update_user_meta($_POST['uid'], 'email_address_preference', $val);
335 }
336
337
338 }
339
340 class AccountValidation extends Common\Validation {
341 protected $on_groups = false;
342 protected $all_groups = false;
343
344 protected function setGroups() {
345 if (false === $this->on_groups || false === $this->all_groups) {
346 return false;
347 }
348
349 foreach ($this->all_groups as $id => $one) {
350 if (isset($this->on_groups[$id])) {
351 UAM\getGroupByID($id)->addUser($_POST['uid']);
352 } else {
353 UAM\getGroupByID($id)->removeUser($_POST['uid']);
354 }
355 }
356 }
357
358 public function group($val) {
359 return;
360 }
361
362 public function grpanch($val) {
363 $this->on_groups = (isset($_POST['group']) ? $_POST['group'] : Array());
364 $this->all_groups = $val;
365 $this->setGroups();
366 }
367
368 public function status($val) {
369 /*
370 $account = new User\Account($_POST['uid']);
371 $account->setStatus($val);
372 */
373
374 update_user_meta($_POST['uid'], 'status',$val);
375 }
376
377 public function special_status_active($vals) {
378 delete_usermeta($_POST['uid'], 'special_statuses');
379 if (isset($_POST['special_status'])) {
380 $s = $_POST['special_status'];
381 if (count($s) > 0) {
382 update_user_meta($_POST['uid'], 'special_statuses', $s);
383 }
384
385 }
386 }
387
388 public function user_role($val) {
389 /*
390 $user = new User\Account($_POST['uid']);
391 try {
392 $user->set_role($val);
393 } catch (Exception $e) {
394 throw new Exception($e->getMessage());
395 }
396 */
397 CBV\user_change_role($val, $_POST['uid']);
398 }
399
400 public function password1($val) {
401 if (!empty($_POST['password1']) || !empty($_POST['password2'])) {
402 if ($_POST['password1']==$_POST['password2']) {
403 // update the user's password...
404 _update_user(Array('ID' => $_POST['uid'], 'user_pass' => $_POST['password1']));
405 } else {
406 throw new Exception('Passwords must match.');
407 }
408 }
409 }
410
411 public function membership_valid_until($val) {
412 update_user_meta($_POST['uid'], 'membership_valid_until',$val);
413 }
414
415 }
416
417 class CreateValidation extends Common\Validation {
418
419
420 public function first_name($val) {
421 if(empty($val)) {
422 throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
423 }
424 }
425
426 public function last_name($val) {
427 if(empty($val)) {
428 throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
429 }
430 }
431
432 public function username($val) {
433 if(empty($val)) {
434 throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
435 }
436 }
437
438 public function email($val) {
439 if (!empty($val)) {
440 if (!(boolean)preg_match(CBV\VALID_EMAIL, (string)$val)) {
441 throw new Exception('An invalid email address was entered in ' . User\Vars::$field_lookup[__FUNCTION__]);
442 }
443 } else {
444 throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' field can not be empty');
445 }
446 }
447
448 public function country($val) {
449 if(empty($val)) {
450 throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
451 }
452 }
453
454 public function province($val) {
455 if(empty($val)) {
456 throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
457 }
458 }
459
460 public function user_role($val) {
461 if(empty($val)) {
462 throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
463 }
464 }
465
466 public function password($val) {
467 if(!empty($val)) {
468 if ($_POST['password'] != $_POST['password2']) {
469 throw new Exception('Passwords do not match');
470 }
471 } else {
472 throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
473 }
474 }
475
476 }
477
478 function run_validation() {
479 $section = $_POST['section'];
480 $class = __NAMESPACE__ . '\\' . ucwords(array_shift(explode('-', $section))) . 'Validation';
481
482 Vars::$validation = new $class($_POST);
483 return (count(Vars::$validation->errors) > 0 ? false : true);
484 }
485
486 class Actions {
487 public static function wp_ajax_update_mark() {
488 $account = new User\Account($_POST['uid']);
489 $marks = $account->marks;
490
491 $marks['history'][$_POST['course_id']]['mark'] = $_POST['value'];
492
493 update_user_meta($account->ID, 'marks', $marks);
494 }
495
496 public static function wp_ajax_update_fq_status() {
497 $return = Array('success' => 'false');
498 $status = trim(strtolower($_POST['status']));
499 $lookup = Array(
500 'approve' => 'A'
501 , 'decline' => 'D'
502 );
503
504 if (isset($lookup[$status])) {
505 update_user_meta($_POST['uid'], 'course_4q_approvals', $lookup[$status]);
506 $return['success'] = 'true';
507 }
508
509 die(json_encode($return));
510 }
511
512 public static function wp_ajax_update_edit_notes() {
513 global $wpdb;
514 $uid = $_POST['uid'];
515 $note = $_POST['note'];
516 update_user_meta($uid, 'admin_notes', $note);
517 }
518
519 public static function wp_ajax_override_activate() {
520 global $wpdb;
521 $activation_key = $_POST['akey'];
522 Auth\activate($_POST['akey']);
523 $return = array(
524 'success' => 'true'
525 );
526 die(json_encode($return));
527 }
528
529 public static function wp_ajax_override_remove() {
530 global $wpdb;
531 $activation_key = $_POST['akey'];
532 $wpdb->query("DELETE FROM wp_signups WHERE activation_key='$activation_key' LIMIT 1");
533 $return = array(
534 'success' => 'true'
535 );
536 die(json_encode($return));
537 }
538
539 public static function wp_ajax_remove_user() {
540
541 $remove_action = $_POST['remove_action'];
542 if ($remove_action=="remove_all") {
543 // oh boy....
544 @wp_delete_user( $_POST['uid'] );
545 } else {
546 update_user_meta($_POST['uid'], 'status', 'terminated');
547 }
548
549 $return = array(
550 'success' => 'true'
551 );
552 die(json_encode($return));
553
554 }
555
556 public static function wp_ajax_build_user_remove() {
557 $uid = $_GET['uid'];
558
559 ob_start();
560 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'remove_user.php');
561
562 $content = ob_get_contents();
563 ob_end_clean();
564 die($content);
565 }
566
567 public static function wp_ajax_admin_create_user() {
568 run_validation();
569
570 Tools\import('Auth');
571
572 $valid = (count(Vars::$validation->errors) > 0) ? false : true;
573 if ($valid) {
574
575 $user_role = $_POST['user_role']; unset($_POST['user_role']);
576 $username = $_POST['username']; unset($_POST['username']);
577 $email = $_POST['email']; unset($_POST['email']);
578 if ($user_role != "member") { unset($_POST['member_id']); }
579 $password = $_POST['password']; unset($_POST['password']); unset($_POST['password2']);
580
581 $fp = strtolower($_POST['profile_preference'])."_";
582
583 // register the user.
584 $user_details = Array(
585 'first_name' => User\clean_string($_POST['first_name'])
586 , 'last_name' => User\clean_string($_POST['last_name'])
587 , $fp.'province' => $_POST['province']
588 , $fp.'country' => $_POST['country']
589 , $fp.'email' => $email
590 );
591 unset($user_details['email']);
592
593 if (isset($_POST['member_id'])) { $user_details['member_id'] = $_POST['member_id']; }
594 $user_details = array_merge(User\Vars::$meta_defaults, $user_details);
595
596 try {
597 $user_key = Auth\register($username, $email, $password, $user_details);
598 $uid = Auth\activate($user_key, $password);
599 $u = new User\Account($uid);
600 $u->set_role($user_role);
601 update_user_meta($uid, 'validated', time());
602 } catch (Exception $e) {
603 $return = array(
604 'success' => false
605 , 'msg' => $e->getMessage()
606 );
607 die(json_encode($return));
608 }
609
610 $return = array(
611 'success' => 'true'
612 , 'edit_profile' => '/wp-admin/admin.php?page=cbv_users&action=edit&uid='.$uid.'&section=profile'
613 , 'msg' => '<li>' . implode('</li><li>', Vars::$validation->errors) . '</li>'
614 );
615
616 } else {
617 $return = array(
618 'success' => 'false'
619 , 'msg' => '<li>' . implode('</li><li>', Vars::$validation->errors) . '</li>'
620 );
621 }
622
623 die(json_encode($return));
624 }
625
626 public static function wp_ajax_admin_create_member_id() {
627
628 // do logic here to create the user's member id.
629 $member_id = $_POST['last_name'] . time();
630
631 $return = array(
632 'member_id' => $member_id
633 );
634 die(json_encode($return));
635 }
636
637 public static function wp_ajax_admin_remove_cehours() {
638 CBV\load('CEHours');
639 $cehours = CEHours\get_user_cehours($_POST['uid']);
640 $compare = $_POST['indexed'];
641
642 if (isset($cehours[$compare])) {
643 unset($cehours[$compare]);
644 }
645
646 update_user_meta($_POST['uid'], 'cehours',$cehours);
647
648 $return = array(
649 'success' => 'true'
650 );
651 die(json_encode($return));
652 }
653
654 public static function wp_ajax_update_edit_profile() {
655
656 run_validation();
657
658 $return = array(
659 'success' => (count(Vars::$validation->errors) > 0 ? 'false' : 'true')
660 , 'msg' => '<li>' . implode('</li><li>', Vars::$validation->errors) . '</li>'
661 );
662
663 die(json_encode($return));
664 }
665
666 public static function wp_ajax_cancel_registration() {
667
668 CBV\load('Events');
669 Events\cancel_registration($_POST['uid'], $_POST['eid']);
670
671 $event = get_post($_POST['eid']);
672 $cost = get_post_meta($_POST['eid'], 'cost', true);
673 if (empty($cost) || $cost < 1 || strtolower($cost)=="free") {
674 $cost = 0;
675 }
676
677 $return = array(
678 'success' => 'true',
679 'ask_credit' => (($cost > 0) ? 'true' : 'false')
680 );
681 die(json_encode($return));
682 }
683
684 public static function wp_ajax_update_account() {
685 run_validation();
686
687 $return = array(
688 'success' => (count(Vars::$validation->errors) > 0 ? 'false' : 'true')
689 , 'msg' => '<li>' . implode('</li><li>', Vars::$validation->errors) . '</li>'
690 );
691
692 die(json_encode($return));
693 }
694
695 public static function wp_ajax_create_invoice_note($uid = 0) {
696 global $wpdb;
697
698 if ($uid == 0) {
699 $uid = $_POST['uid'];
700 }
701
702 // All this for tax purposes....
703 $pp = strtolower(get_user_meta($uid, 'profile_preference', true));
704 if (empty($pp)) {
705 $pp = "home";
706 }
707 $pp = $pp . "_";
708
709 $amount = $_POST['amount'];
710 $invoice_type = $_POST['invoice_type'];
711 $paid_by = $_POST['paid_by'];
712 $title = $_POST['title'];
713
714 $paid = (isset($_POST['paid']) && $_POST['paid']=="on") ? true : false;
715 if ($invoice_type=="invoice") {
716 if (!$paid) {
717 $paid_by = "";
718 }
719 } else {
720 $paid_by = "";
721 }
722
723
724 // if membership....
725 if ($invoice_type=="membership") {
726
727 $paid = (isset($_POST['paid']) && $_POST['paid']=="on") ? true : false;
728 if ($paid) {
729 $status = "paid";
730 } else {
731 $status = "unpaid";
732 }
733
734
735 Invoice\GenerateMembershipInvoice($uid, $status, $paid_by, true);
736 // return json object
737 $return = array(
738 'success' => 'true'
739 );
740 die(json_encode($return));
741 }
742
743 // if not membership.....
744
745 $items = array();
746
747 $items[] = array(
748 'post_id' => 0
749 , 'cost' => $amount
750 , 'discount_label' => ""
751 , 'discount_amount' => 0
752 , 'tax_label' => ""
753 , 'tax_rate' => ""
754 , 'tax_amount' => "0.00"
755 , 'subtotal' => $amount
756 , 'total' => $amount
757 , 'description' => $title
758 , 'extras' => array()
759
760 );
761
762 $invoice_data = array();
763 $invoice_data['items'] = $items;
764 $invoice_data['payment'] = array(
765 'total_cost' => $amount
766 , 'total_discounts' => ""
767 , 'total_taxes' => ""
768 , 'subtotal' => $amount
769 , 'total' => $amount
770 , 'bt_address' => get_user_meta($uid, $pp.'address', true)
771 , 'bt_address2' => get_user_meta($uid, $pp.'address2', true)
772 , 'bt_city' => get_user_meta($uid, $pp.'city', true)
773 , 'bt_province' => get_user_meta($uid, $pp.'province', true)
774 , 'bt_country' => get_user_meta($uid, $pp.'country', true)
775 , 'bt_postal' => get_user_meta($uid, $pp.'postal', true)
776 , 'bt_card_holder' => ""
777 , 'bt_card_number' => ""
778 , 'bt_card_type' => $paid_by
779 );
780
781
782
783 if ($invoice_type=="credit") {
784 $status = "credit";
785 } else {
786 $paid = (isset($_POST['paid']) && $_POST['paid']=="on") ? true : false;
787 if ($paid) {
788 $status = "paid";
789 } else {
790 $status = "unpaid";
791 }
792 }
793
794 $new_invoice_id = Invoice\create($invoice_data, 'generic', $title, $uid, $status, 'publish', $amount);
795 if ($invoice_type=="credit") {
796 update_post_meta($new_invoice_id, 'credit_amount', $amount);
797 }
798
799 // return json object
800 $return = array(
801 'success' => 'true'
802 );
803 die(json_encode($return));
804
805 }
806
807 public static function wp_ajax_course_registration() {
808 // Get given working classes
809 $user = new User\Account($_POST['user_id']);
810 $course = new Courses\Course($_POST['course_id']);
811 $enrolltype = $_POST['enrolltype'];
812 $tax_rate = $user->getLocTaxPct();
813
814 // Apply user to course, sets group, set enrollment, etc.
815 $user->registerForCourse($course->getID(), (boolean)isset($_POST['exam']), $enrolltype);
816 $user->approveToCourse($course->getID());
817
818 $order = new Invoice\Order();
819 $order->addItem(new OrderItem($course->$enrolltype, $tax_rate, $course->post_title, $course->getID()));
820
821 if (isset($_POST['studentfee']) && $_POST['studentfee'] == 1) {
822 $fee = number_format(CBVOptions\GetOption('student-fees', 'fees'), 2, '.', '');
823
824 $order->addItem(new OrderItem($fee, $tax_rate, 'Annual Registration Fee'));
825
826 $user->setMeta('fee_semester_paid', $course->getSemester());
827 }
828
829 if (isset($_POST['casebook']) && $_POST['casebook'] == 1) {
830 $book = UAM\getGroup('Casebook');
831 $book->addUser($user->ID);
832
833 $cost = substr($book->getDescription(), strpos($book->getDescription(), ':') + 1);
834 $order->addItem(new OrderItem($cost, CBV\get_tax_pct(), 'Casebook', CBV\CASEBOOK_POSTID));
835 }
836
837 if (isset($_POST['overseas']) && $_POST['overseas'] == 1) {
838 $os_cost = number_format(CBVOptions\GetOption('overseas-surcharge', 'fees'), 2, '.', '');
839 $order->addItem(new OrderItem($os_cost, $tax_rate, 'Overseas Surcharge'));
840 }
841
842 $cc = new CreditCard(null, $_POST['paid_by']);
843 $order->generateInvoice($user, 'course', 'Course Invoice', $cc);
844
845 die(json_encode(Array('success' => 'true', 'refresh' => 'true')));
846 }
847
848 public static function wp_ajax_update_registration() {
849
850 CBV\load('Events');
851
852 if (!isset($_POST['type'])) { die('Invalid Form Post'); }
853
854 $post = get_post($_POST['event_id']);
855
856 $uid = $_POST['uid'];
857 $event_id = $_POST['event_id'];
858 $type = $_POST['type'];
859
860 $status = $_POST['status'];
861
862 switch($status) {
863 case 'unpaid':
864 $status = 'unpaid';
865 $paid_by = '';
866 break;
867 case 'complementary':
868 $status = 'complementary';
869 $paid_by = '';
870 break;
871 default:
872 $status = 'paid';
873 $paid_by = $status;
874 break;
875 }
876
877 unset($_POST['action']);
878 unset($_POST['ajax']);
879 unset($_POST['event_id']);
880 unset($_POST['uid']);
881 unset($_POST['type']);
882 unset($_POST['status']);
883
884 $events = get_user_meta($uid, 'events',true);
885
886 // if $type = "edit"
887 if ($type=="edit") {
888
889 foreach($events as $index=>$event) {
890 if ($event['event_id']==$event_id) {
891 $events[$index]['status'] = $status;
892 unset($events[$index]['extras']);
893 $events[$index]['extras'] = $_POST;
894 break;
895 }
896 }
897 update_user_meta($uid, 'events', $events);
898 $return = array('success' => 'true', 'refresh' => 'false');
899
900 } else {
901
902 // KB
903
904 $user = new User\Account($uid);
905
906 $is_tax_exempt = false;
907 // loop through special status to see if exempt is there.
908 if ( isset( $user->special_statuses) ) {
909 foreach($user->special_statuses as $stat) {
910 if ($stat == "tax_exempt") {
911 $is_tax_exempt = true;
912 break;
913 }
914 }
915 }
916
917
918 $cost = get_post_meta($event_id, 'cost', true);
919
920 $role = $user->getRole();
921
922 $event = get_post($event_id);
923
924 $cehours = get_post_meta($event_id,'worth_cehours',true);
925 $early_bird_deadline = get_post_meta($event_id,'early_bird_deadline',true);
926 $early_bird_discount = get_post_meta($event_id,'early_bird_discount',true);
927 $member_discount = get_post_meta($event_id,'student_member_discount',true);
928 $reg_deadline = get_post_meta($event_id,'reg_deadline',true);
929 $event_date = get_post_meta($event_id,'event_date',true);
930
931 $give_earlybird_discount = isset($_POST['discount_earlybird']) ? true : false;
932 $give_member_discount = isset($_POST['discount_member']) ? true : false;
933
934 $event_term_slugs = array();
935 $terms = get_the_terms($event_id,'event_type');
936 if (!empty($terms)) {
937 foreach($terms as $types) {
938 $event_term_slugs[$types->slug] = $types->name;
939 }
940 }
941
942
943 $discounts = array();
944
945 $new_cost = $cost;
946 $total_discount = 0;
947
948 if ( $give_member_discount && !empty($member_discount) ) {
949 $show_member_discount = true;
950
951 $discounts[] = Array(
952 'discount_label' => "Student/Member Discount"
953 , 'discount' => $member_discount
954 );
955
956 $new_cost = ($new_cost - $member_discount);
957 $total_discount = ($total_discount + $member_discount);
958
959 }
960 if ( $give_earlybird_discount && !empty($early_bird_discount) ) {
961 $show_early_discount = true;
962
963 $discounts[] = Array(
964 'discount_label' => "Early Bird Discount"
965 , 'discount' => $early_bird_discount
966 );
967
968 $new_cost = ($new_cost - $early_bird_discount);
969 $total_discount = ($total_discount + $early_bird_discount);
970 }
971
972 $provstate = get_post_meta($event_id,'provstate',true);
973 if (empty($provstate) OR $provstate == "outside") {
974 $provstate = "ON";
975 }
976
977
978 if (isset($event_term_slugs['webinar'])) {
979 $tpp = get_user_meta($user->ID,'profile_preference',true);
980 $tpp = strtolower($tpp);
981 $province = get_user_meta($user->ID,$tpp."_province",true);
982
983 if ($is_tax_exempt) {
984 $tax_label = "Exempt";
985 $tax = 0;
986 $taxes = 0;
987 } else {
988 $tax_label = "Taxes-$province";
989 $tax = getTaxesByProvince($province);
990 $taxes = ($new_cost * ($tax/100));
991 }
992
993
994
995 } else {
996 if ($is_tax_exempt) {
997 $tax_label = "Exempt";
998 $tax = 0;
999 $taxes = 0;
1000 } else {
1001 $tax_label = "Taxes-$provstate";
1002 $tax = getTaxesByProvince($provstate); // tax percentage (whole number)
1003 $taxes = ($new_cost * ($tax/100));
1004 }
1005
1006 }
1007
1008
1009
1010
1011
1012
1013
1014 $invoice_post = $_POST;
1015
1016
1017 $details = Array('dietary','event_notes',
1018 'mealopt_one','mealopt_two','mealopt_three','mealopt_four','mealopt_five','mealopt_six','mealopt_seven','mealopt_eight','mealopt_nine','mealopt_ten',
1019 'session_one','session_two','session_three','session_four','session_five','session_six','session_seven','session_eight','session_nine','session_ten');
1020
1021 $extras = array();
1022 foreach($details as $index) {
1023 if ( isset($_POST[$index]) ) {
1024 $extras[$index] = $_POST[$index];
1025 }
1026 }
1027
1028
1029 $items = array();
1030
1031 $items[] = array(
1032 'post_id' => $event_id
1033 , 'cost' => get_post_meta($event_id,'cost',true)
1034 , 'discounts' => $discounts
1035 , 'tax_label' => $tax_label
1036 , 'tax_rate' => $tax
1037 , 'tax_amount' => $taxes
1038 , 'subtotal' => $new_cost
1039 , 'total' => number_format(($new_cost + $taxes),2)
1040 , 'description' => ""
1041 , 'extras' => $extras
1042
1043 );
1044
1045 $pp = get_user_meta($user->ID,'profile_preference',true);
1046 $pp = $pp . "_";
1047
1048 $invoice_data = array();
1049 $invoice_data['items'] = $items;
1050 $invoice_data['payment'] = array(
1051 'total_cost' => get_post_meta($event_id,'cost',true)
1052 , 'total_discounts' => $total_discount
1053 , 'total_taxes' => $taxes
1054 , 'subtotal' => $new_cost
1055 , 'total' => number_format(($new_cost + $taxes),2)
1056 , 'bt_address' => get_user_meta($user->ID, $pp.'address',true)
1057 , 'bt_address2' => get_user_meta($user->ID, $pp.'address2',true)
1058 , 'bt_city' => get_user_meta($user->ID, $pp.'city',true)
1059 , 'bt_province' => get_user_meta($user->ID, $pp.'province',true)
1060 , 'bt_country' => get_user_meta($user->ID, $pp.'country',true)
1061 , 'bt_postal' => get_user_meta($user->ID, $pp.'postal',true)
1062 , 'bt_card_holder' => ""
1063 , 'bt_card_number' => ""
1064 , 'bt_card_type' => ""
1065 );
1066
1067 $event_term_slugs = array();
1068 $terms = get_the_terms($event_id,'event_type');
1069
1070
1071 if (!empty($terms)) {
1072 foreach($terms as $types) {
1073 $event_term_slugs[$types->slug] = $types->name;
1074 }
1075 }
1076
1077
1078
1079 //create($items = array(), $invoice_type = 'event', $title = "Invoice", $user_id = 0, $status = 'pending', $reference = '', $publish = 'draft')
1080 $invoice_id = Invoice\create($invoice_data, 'event', 'Registration for Event via CBV Admin: '.$event->post_title, $user->ID, $status, 'publish',number_format(($new_cost + $taxes),2));
1081 $extras['invoice_id'] = $invoice_id;
1082 $extras['discounts'] = array(
1083 'member' => ($give_member_discount) ? "Y" : "N"
1084 , 'earlybird' => ($give_earlybird_discount) ? "Y" : "N"
1085 );
1086
1087 Events\set_attending($user->ID,$event_id,'paid',md5(rand()),$extras);
1088
1089
1090
1091
1092 }
1093 $return = array('success' => 'true', 'refresh' => 'true');
1094 die(json_encode($return));
1095
1096 }
1097
1098 public static function wp_ajax_admin_update_cehours() {
1099 CBV\load('CEHours');
1100 $cehours = CEHours\get_user_cehours($_POST['uid']);
1101 if ($_POST['action']=="edit") {
1102 unset($cehours[$_POST['indexed']]);
1103 }
1104
1105 $timestamp = CEHours\mysqldatetime_to_timestamp($_POST['date']);
1106
1107 if ($_POST['indexed']=="") {
1108 $_POST['indexed'] = Sequencer\generate('CEH');
1109 }
1110
1111
1112 $postarray = $_POST;
1113
1114 $cehours[$_POST['indexed']] = Array(
1115 'type' => $postarray['type']
1116 , 'subtype' => isset($postarray['subtype']) ? $postarray['subtype'] : ""
1117 , 'date' => CEHours\mysqldatetime_to_timestamp($postarray['date'])
1118 , 'activity' => isset($postarray['activity']) ? $postarray['activity'] : ""
1119 , 'institute' => isset($postarray['institution']) ? $postarray['institution'] : ""
1120 , 'hours' => $postarray['hours']
1121 , 'attended' => isset($postarray['attended']) ? "yes" : "no"
1122 , 'post_type' => "event"
1123 , 'post_id' => '0'
1124 , 'recorded' => time()
1125 );
1126
1127 /*
1128
1129 $cehours[$_POST['indexed']] = Array(
1130 'type' => $_POST['type']
1131 , 'date' => $timestamp
1132 , 'activity' => $_POST['activity']
1133 , 'hours' => $_POST['hours']
1134
1135 );
1136 */
1137
1138 update_user_meta($_POST['uid'], 'cehours', $cehours);
1139 // return json object
1140 $return = array(
1141 'success' => 'true'
1142 );
1143 die(json_encode($return));
1144
1145 }
1146
1147 public static function wp_ajax_admin_cancel_invoice() {
1148 $invoice_id = $_POST['invoice_id'];
1149 update_post_meta($invoice_id, 'trans_status', 'cancelled');
1150 $return = array(
1151 'success' => 'true'
1152 );
1153 die(json_encode($return));
1154 }
1155
1156 public static function wp_ajax_admin_update_invoice() {
1157 $invoice_id = $_POST['invoice_id'];
1158 $user_id = $_POST['uid'];
1159
1160 update_post_meta($invoice_id, 'trans_status', 'paid');
1161 $payment = get_post_meta($invoice_id, 'payment', true);
1162 $payment['bt_card_type'] = $_POST['paid_by'];
1163 update_post_meta($invoice_id, 'payment', $payment);
1164
1165 $invoice_for = get_post_meta($invoice_id, 'invoice_for', true);
1166 if ( !empty($invoice_for) && $invoice_for == "membership") {
1167 $next_year = (int) date("Y");
1168 $next_year = ($next_year + 1);
1169 update_user_meta($user_id, 'membership_valid_until', $next_year);
1170 }
1171
1172 $return = array(
1173 'success' => 'true'
1174 );
1175 die(json_encode($return));
1176 }
1177
1178 public static function wp_ajax_admin_refund_invoice() {
1179 $invoice_id = $_POST['invoice_id'];
1180 $amount = $_POST['amount'];
1181
1182 $invoice = get_post($invoice_id);
1183 $payment = get_post_meta($invoice_id, 'payment', true);
1184 $trans_amount = get_post_meta($invoice_id, 'trans_amount', true);
1185 $invoice_for = get_post_meta($invoice_id, 'invoice_for', true);
1186 $items = get_post_meta($invoice_id, 'items', true);
1187 update_post_meta($invoice->ID, 'refunded', date('Y-m-d H:i:s'));
1188
1189
1190 $invoice_data['items'] = $items;
1191 $invoice_data['payment'] = $payment;
1192 $new_invoice_id = Invoice\create($invoice_data, $invoice_for, $invoice->post_title, $invoice->post_author, 'credit', 'publish', $trans_amount);
1193 update_post_meta($new_invoice_id, 'original_invoice_id', $invoice_id);
1194 update_post_meta($new_invoice_id, 'credit_amount', $amount);
1195
1196 }
1197
1198 public static function wp_ajax_build_cehour_form() {
1199 $user = new User\Account($_GET['uid']);
1200 $uid = $user->ID;
1201
1202 $fname = get_user_meta($user->ID, 'first_name', true);
1203 $lname = get_user_meta($user->ID, 'last_name', true);
1204
1205 if (empty($fname) || empty($lname)) {
1206 $name = $user->user_login;
1207 } else {
1208 $name = $fname . " " . $lname;
1209 }
1210
1211 CBV\load('CEHours');
1212 ob_start();
1213 $action = isset($_GET['post_action']) ? $_GET['post_action'] : "edit";
1214 $cehours = CEHours\get_user_cehours($uid);
1215
1216 if ($action=="edit") {
1217 $record = $cehours[$_GET['indexed']];
1218 $indexed = $_GET['indexed'];
1219 $type = $record['type'];
1220 $date = date('Y-m-d',$record['date']);
1221 $activity = $record['activity'];
1222 $subtype = isset($record['subtype']) ? $record['subtype'] : "";
1223 $institute = isset($record['institute']) ? $record['institute'] : "";
1224 $attended = isset($record['attended']) ? $record['attended'] : "";
1225 $hours = $record['hours'];
1226 } else {
1227 $indexed = "";
1228 $type = "unstructured";
1229 $date = date('Y-m-d',time());
1230 $activity = "";
1231 $subtype = "";
1232 $institute = "";
1233 $attended = "";
1234 $hours = "0";
1235 }
1236
1237 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_cehour.php');
1238
1239 $content = ob_get_contents();
1240 ob_end_clean();
1241 die($content);
1242
1243 }
1244
1245 public static function wp_ajax_build_course_form() {
1246 $user = new User\Account($_GET['uid']);
1247 $course = new Courses\Course($_GET['course_id']);
1248
1249 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_course.php');
1250
1251 die;
1252 }
1253
1254 public static function wp_ajax_build_event_form() {
1255
1256 $user = new User\Account($_GET['uid']);
1257 $uid = $user->ID;
1258 $role = $user->getRole();
1259
1260 $fname = get_user_meta($user->ID, 'first_name', true);
1261 $lname = get_user_meta($user->ID, 'last_name', true);
1262
1263 if (empty($fname) || empty($lname)) {
1264 $name = $user->user_login;
1265 } else {
1266 $name = $fname . " " . $lname;
1267 }
1268
1269
1270 CBV\load('Events');
1271 ob_start();
1272
1273 $action = isset($_GET['post_action']) ? $_GET['post_action'] : "edit";
1274
1275 if ($action=="edit") {
1276 $user_event_meta = Events\get_event_registration($_GET['event_id'], $_GET['uid']);
1277 } else {
1278 $user_event_meta = Array();
1279 }
1280
1281 //CBV\trace($user_event_meta);
1282
1283 $post = Events\get_event($_GET['event_id']);
1284
1285 $show_dietary = get_post_meta($post->ID, 'show_dietary', true);
1286
1287 $session_description = get_post_meta($post->ID, 'session_description', true);
1288 $session_one = get_post_meta($post->ID, 'session_one', true);
1289 $session_two = get_post_meta($post->ID, 'session_two', true);
1290 $session_three = get_post_meta($post->ID, 'session_three', true);
1291 $session_four = get_post_meta($post->ID, 'session_four', true);
1292 $session_five = get_post_meta($post->ID, 'session_five', true);
1293 $session_six = get_post_meta($post->ID, 'session_six', true);
1294 $session_seven = get_post_meta($post->ID, 'session_seven', true);
1295 $session_eight = get_post_meta($post->ID, 'session_eight', true);
1296 $session_nine = get_post_meta($post->ID, 'session_nine', true);
1297 $session_ten = get_post_meta($post->ID, 'session_ten', true);
1298
1299 $mealopt_description = get_post_meta($post->ID, 'mealopt_description', true);
1300 $mealopt_one = get_post_meta($post->ID, 'mealopt_one', true);
1301 $mealopt_two = get_post_meta($post->ID, 'mealopt_two', true);
1302 $mealopt_three = get_post_meta($post->ID, 'mealopt_three', true);
1303 $mealopt_four = get_post_meta($post->ID, 'mealopt_four', true);
1304
1305 $mealopt_five = get_post_meta($post->ID, 'mealopt_five', true);
1306 $mealopt_six = get_post_meta($post->ID, 'mealopt_six', true);
1307 $mealopt_seven = get_post_meta($post->ID, 'mealopt_seven', true);
1308 $mealopt_eight = get_post_meta($post->ID, 'mealopt_eight', true);
1309 $mealopt_nine = get_post_meta($post->ID, 'mealopt_nine', true);
1310 $mealopt_ten = get_post_meta($post->ID, 'mealopt_ten', true);
1311
1312 $early_bird_deadline = get_post_meta($post->ID,'early_bird_deadline',true);
1313 $early_bird_discount = get_post_meta($post->ID,'early_bird_discount',true);
1314 $member_discount = get_post_meta($post->ID,'student_member_discount',true);
1315
1316 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_event.php');
1317
1318 $content = ob_get_contents();
1319 ob_end_clean();
1320 die($content);
1321
1322
1323 }
1324
1325 public static function wp_ajax_build_invoice_mark_paid_form() {
1326 $user = new User\Account($_GET['uid']);
1327 ob_start();
1328
1329 $invoice = get_post($_GET['invoice_id']);
1330
1331 $payment = get_post_meta($_GET['invoice_id'], 'payment', true);
1332 $trans_status = get_post_meta($_GET['invoice_id'], 'trans_status', true);
1333 $how_paid = strtolower($payment['bt_card_type']);
1334
1335 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_invoice.php');
1336
1337 $content = ob_get_contents();
1338 ob_end_clean();
1339 die($content);
1340 }
1341
1342 public static function wp_ajax_admin_refund_invoice_form() {
1343 $user = new User\Account($_GET['uid']);
1344 ob_start();
1345
1346 $invoice = new Invoice\Receipt($_GET['invoice_id']);
1347
1348 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'invoice-refund-view.php');
1349
1350 $content = ob_get_contents();
1351 ob_end_clean();
1352 die($content);
1353 }
1354
1355 public static function wp_ajax_issue_invoice_refund() {
1356 $invoice = new Invoice\Receipt($_POST['invoice_id']);
1357 $user = new User\Account($invoice->getOwner());
1358 $items = $_POST['keys'];
1359
1360 foreach ($items as $index => $yes) {
1361 if (1 /* checkbox on */) {
1362 $fee = 0;
1363 }
1364
1365 $invoice->seek($index)->cancel($fee);
1366 }
1367
1368 $invoice->runRefund();
1369 // Chris, do what you need to do with this....
1370
1371 // if there is an error, turn success to 'false' and set a msg.
1372 $return = array(
1373 'success' => 'true'
1374 , 'msg' => ''
1375 );
1376 die(json_encode($return));
1377 }
1378
1379 public static function wp_ajax_admin_search_merge_users() {
1380 global $wpdb;
1381
1382 $direction = $_POST['which_user_search'];
1383 $do_search = $_POST['do_search'];
1384 $do_merge = $_POST['do_merge'];
1385
1386 // Make sure we have sane 'defaults'
1387 if ($direction != 'from' && $direction != 'to') {
1388 $direction = 'from';
1389 }
1390 if ($do_search != 'yes' && $do_search != 'no') {
1391 $do_search = 'yes';
1392 }
1393 if ($do_merge != 'yes' && $do_merge != 'no') {
1394 $do_merge = 'yes';
1395 }
1396
1397 if ($do_search == 'yes') {
1398 $username = $wpdb->escape($_POST['search_user_' . $direction]);
1399
1400 // Don't search for an empty string as it will return all results
1401 if (empty($username)) {
1402 die(json_encode(array(
1403 'success' => 'false',
1404 'msg' => 'You must enter a value to search for.'
1405 )));
1406 }
1407
1408 // Initialize
1409 $html = '<table cellspacing="0" class="widefat post fixed merge-table" width="100%"><thead><tr><th>First Name</th><th>Last Name</th><th>Member ID</th><th>Email</th></tr></thead><tbody>';
1410 $i = 0;
1411
1412 // Check for search term in first_name, last_name, user_login, and user_email, but only if user status is not 'terminated'
1413 $query = "
1414 SELECT u.ID, u.user_email, umf.meta_value AS first_name, uml.meta_value AS last_name, umm.meta_value AS member_id
1415 FROM $wpdb->users AS u, $wpdb->usermeta AS uml, $wpdb->usermeta AS umf, $wpdb->usermeta AS umm, $wpdb->usermeta AS ums
1416 WHERE (uml.user_id = u.ID
1417 AND uml.meta_key = 'last_name'
1418 )
1419 AND (umf.user_id = u.ID
1420 AND umf.meta_key = 'first_name'
1421 )
1422 AND (ums.user_id = u.ID
1423 AND ums.meta_key = 'status'
1424 )
1425 AND (umm.user_id = u.ID
1426 AND umm.meta_key = 'member_id'
1427 )
1428 AND ((uml.meta_value LIKE '%$username%'
1429 OR umf.meta_value LIKE '%$username%'
1430 OR (umm.meta_value != '' AND umm.meta_value LIKE '%$username%'))
1431 AND ums.meta_value != 'terminated'
1432 )
1433 ORDER BY first_name, last_name";
1434 $result = $wpdb->get_results($query, ARRAY_A);
1435
1436 if (! empty($result)) {
1437 foreach ($result as $user) {
1438 $html .= <<<HTML
1439
1440 <tr>
1441 <td><input type="radio" name="merge_user_{$direction}" value="{$user['ID']}" />&nbsp;{$user['first_name']}</td>
1442 <td>{$user['last_name']}</td>
1443 <td>{$user['member_id']}</td>
1444 <td>{$user['user_email']}</td>
1445 </tr>
1446 HTML;
1447
1448 $i++;
1449 }
1450 } else {
1451 die(json_encode(array(
1452 'success' => 'false',
1453 'msg' => 'No users found matching that term.'
1454 )));
1455 }
1456 $html .= '</tbody></table>';
1457
1458 $return = array(
1459 'success' => 'true',
1460 'direction' => $direction,
1461 'html' => $html
1462 );
1463 } else if ($do_merge == 'yes') {
1464 if (empty($_POST['merge_user_from'])) {
1465 die(json_encode(array(
1466 'success' => 'false',
1467 'msg' => 'You must select a user to merge from.'
1468 )));
1469 }
1470 if (empty($_POST['merge_user_to'])) {
1471 die(json_encode(array(
1472 'success' => 'false',
1473 'msg' => 'You must select a user to merge to.'
1474 )));
1475 }
1476
1477 $from_user = new User\Account($_POST['merge_user_from']);
1478 $to_user = new User\Account($_POST['merge_user_to']);
1479 if ($from_user->ID == $to_user->ID) {
1480 die(json_encode(array(
1481 'success' => 'false',
1482 'msg' => 'You cannot merge the same user!'
1483 )));
1484 }
1485
1486 $html = '';
1487 $skipped_fields = array(
1488 'ID',
1489 'user_login',
1490 'user_pass',
1491 'user_nicename',
1492 'user_email',
1493 'user_url',
1494 'user_registered',
1495 'user_activation_key',
1496 'user_status',
1497 'display_name',
1498 'id',
1499 'caps',
1500 'cap_key',
1501 'roles',
1502 'allcaps',
1503 'filter',
1504 'status',
1505 'four_security_expiration',
1506 'course_4q_approvals',
1507 'user_level',
1508 'validated',
1509 'posts_per_page',
1510 'overload_ppp',
1511 'rich_editing',
1512 'comment_shortcuts',
1513 'admin_color',
1514 'use_ssl',
1515 'x_cicbv.person',
1516 'tz_profile_pub',
1517 'events',
1518 'four_security_questions',
1519 'special_statuses',
1520 'mainmenu',
1521 'cehours',
1522 'subscription',
1523 'notices',
1524 'invoices',
1525 'courses_registered',
1526 );
1527 // Get rid of the unnecessary data object in the current user object
1528 unset($from_user->data);
1529
1530 foreach ($from_user as $key => $val) {
1531 if (in_array($key, $skipped_fields)) {
1532 continue;
1533 }
1534
1535 // Special cases:
1536 // Only transfer member_id if it's not blank
1537 if ($key == 'member_id' && empty($val)) {
1538 continue;
1539 }
1540 // Don't transfer any wp_* fields
1541 if (substr($key, 0, 3) == 'wp_') {
1542 continue;
1543 }
1544
1545 // Make sure we're updating the right user ID and perform update
1546 update_user_meta($to_user->ID, $key, $val);
1547
1548 // Build a table of data
1549 $html .= "\n\t<tr><td width='150'>$key</td><td>$val</td></tr>";
1550 }
1551 if (! empty($from_user->user_email)) {
1552 // Transfer old user's profile preference email address (work, home, etc.) to new user's user_email field
1553 if (isset($from_user->profile_preference) && ! empty($from_user->profile_preference)) {
1554 $preference = strtolower($from_user->profile_preference) . '_email';
1555 if (isset($from_user->$preference) && ! empty($from_user->$preference)) {
1556 _update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->$preference));
1557 } else {
1558 _update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->user_email));
1559 }
1560 } else {
1561 _update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->user_email));
1562 }
1563 }
1564
1565 // Set a few meta values for the old user
1566 update_user_meta($from_user->ID, 'status', 'terminated');
1567 update_user_meta($from_user->ID, 'merged_to', $to_user->ID);
1568 update_user_meta($from_user->ID, 'datetime_merged', time());
1569
1570 $html = '<thead><tr><th colspan="2">Merge successful. Here are all the changes:</th></tr></thead><tbody>' .
1571 $html .
1572 '</tbody>';
1573
1574 $return = array(
1575 'success' => 'true',
1576 'fields' => $html
1577 );
1578 } else {
1579 $return = array(
1580 'success' => 'false',
1581 'msg' => 'Incorrect action. Please contact the webmaster.'
1582 );
1583 }
1584 die(json_encode($return));
1585 }
1586
1587 public static function admin_menu() {
1588 add_menu_page('CBV Users','CBV Users',CAPABILITY,'cbv_users',__NAMESPACE__ . '\display_users',null,3 );
1589 add_submenu_page('cbv_users','New User', 'New User',CAPABILITY,'cbv_users_create',__NAMESPACE__ . '\create_user');
1590 add_submenu_page('cbv_users','New User', 'Awaiting Validation',CAPABILITY,'cbv_users_signups',__NAMESPACE__ . '\signups');
1591 add_submenu_page('cbv_users', 'Merge Users', 'Merge Users', CAPABILITY, 'cbv_users_merge', __NAMESPACE__ . '\merge_users');
1592 //add_submenu_page('cbv_users', 'Fix Unpaid', 'Fix Unpaid', CAPABILITY, 'cbv_users_fix_unpaid', __NAMESPACE__ . '\fix_unpaid');
1593 }
1594
1595 public static function admin_init() {
1596 register_setting(OPTION_NAME, OPTION_NAME);
1597 }
1598
1599
1600 }
1601
1602 class Vars {
1603 public static $validation;
1604 }
...\ No newline at end of file ...\ No newline at end of file
1 /*
2 Masked Input plugin for jQuery
3 Copyright (c) 2007-2010 Josh Bush (digitalbush.com)
4 Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
5 Version: 1.2.3
6 */
7 (function($) {
8 var pasteEventName = ($.browser.msie ? 'paste' : 'input') + ".mask";
9 var iPhone = (window.orientation != undefined);
10
11 $.mask = {
12 //Predefined character definitions
13 definitions: {
14 '9': "[0-9]",
15 'a': "[A-Za-z]",
16 '*': "[A-Za-z0-9]"
17 }
18 };
19
20 $.fn.extend({
21 //Helper Function for Caret positioning
22 caret: function(begin, end) {
23 if (this.length == 0) return;
24 if (typeof begin == 'number') {
25 end = (typeof end == 'number') ? end : begin;
26 return this.each(function() {
27 if (this.setSelectionRange) {
28 this.focus();
29 this.setSelectionRange(begin, end);
30 } else if (this.createTextRange) {
31 var range = this.createTextRange();
32 range.collapse(true);
33 range.moveEnd('character', end);
34 range.moveStart('character', begin);
35 range.select();
36 }
37 });
38 } else {
39 if (this[0].setSelectionRange) {
40 begin = this[0].selectionStart;
41 end = this[0].selectionEnd;
42 } else if (document.selection && document.selection.createRange) {
43 var range = document.selection.createRange();
44 begin = 0 - range.duplicate().moveStart('character', -100000);
45 end = begin + range.text.length;
46 }
47 return { begin: begin, end: end };
48 }
49 },
50 unmask: function() { return this.trigger("unmask"); },
51 mask: function(mask, settings) {
52 if (!mask && this.length > 0) {
53 var input = $(this[0]);
54 var tests = input.data("tests");
55 return $.map(input.data("buffer"), function(c, i) {
56 return tests[i] ? c : null;
57 }).join('');
58 }
59 settings = $.extend({
60 placeholder: "_",
61 completed: null
62 }, settings);
63
64 var defs = $.mask.definitions;
65 var tests = [];
66 var partialPosition = mask.length;
67 var firstNonMaskPos = null;
68 var len = mask.length;
69
70 $.each(mask.split(""), function(i, c) {
71 if (c == '?') {
72 len--;
73 partialPosition = i;
74 } else if (defs[c]) {
75 tests.push(new RegExp(defs[c]));
76 if(firstNonMaskPos==null)
77 firstNonMaskPos = tests.length - 1;
78 } else {
79 tests.push(null);
80 }
81 });
82
83 return this.each(function() {
84 var input = $(this);
85 var buffer = $.map(mask.split(""), function(c, i) { if (c != '?') return defs[c] ? settings.placeholder : c });
86 var ignore = false; //Variable for ignoring control keys
87 var focusText = input.val();
88
89 input.data("buffer", buffer).data("tests", tests);
90
91 function seekNext(pos) {
92 while (++pos <= len && !tests[pos]);
93 return pos;
94 };
95
96 function shiftL(pos) {
97 while (!tests[pos] && --pos >= 0);
98 for (var i = pos; i < len; i++) {
99 if (tests[i]) {
100 buffer[i] = settings.placeholder;
101 var j = seekNext(i);
102 if (j < len && tests[i].test(buffer[j])) {
103 buffer[i] = buffer[j];
104 } else
105 break;
106 }
107 }
108 writeBuffer();
109 input.caret(Math.max(firstNonMaskPos, pos));
110 };
111
112 function shiftR(pos) {
113 for (var i = pos, c = settings.placeholder; i < len; i++) {
114 if (tests[i]) {
115 var j = seekNext(i);
116 var t = buffer[i];
117 buffer[i] = c;
118 if (j < len && tests[j].test(t))
119 c = t;
120 else
121 break;
122 }
123 }
124 };
125
126 function keydownEvent(e) {
127 var pos = $(this).caret();
128 var k = e.keyCode;
129 ignore = (k < 16 || (k > 16 && k < 32) || (k > 32 && k < 41));
130
131 //delete selection before proceeding
132 if ((pos.begin - pos.end) != 0 && (!ignore || k == 8 || k == 46))
133 clearBuffer(pos.begin, pos.end);
134
135 //backspace, delete, and escape get special treatment
136 if (k == 8 || k == 46 || (iPhone && k == 127)) {//backspace/delete
137 shiftL(pos.begin + (k == 46 ? (tests[pos.begin]?0:1) : -1));
138 return false;
139 } else if (k == 27) {//escape
140 input.val(focusText);
141 input.caret(0, checkVal());
142 return false;
143 }
144 };
145
146 function keypressEvent(e) {
147 if (ignore) {
148 ignore = false;
149 //Fixes Mac FF bug on backspace
150 return (e.keyCode == 8) ? false : null;
151 }
152 e = e || window.event;
153 var k = e.charCode || e.keyCode || e.which;
154 var pos = $(this).caret();
155
156 if (e.ctrlKey || e.altKey || e.metaKey) {//Ignore
157 return true;
158 } else if ((k >= 32 && k <= 125) || k > 186) {//typeable characters
159 var p = seekNext(pos.begin - 1);
160 if (p < len) {
161 var c = String.fromCharCode(k);
162 if (tests[p].test(c)) {
163 shiftR(p);
164 buffer[p] = c;
165 writeBuffer();
166 var next = seekNext(p);
167 $(this).caret(next);
168 if (settings.completed && next >= len)
169 settings.completed.call(input);
170 }
171 }
172 }
173 return false;
174 };
175
176 function clearBuffer(start, end) {
177 for (var i = start; i < end && i < len; i++) {
178 if (tests[i])
179 buffer[i] = settings.placeholder;
180 }
181 };
182
183 function writeBuffer() { return input.val(buffer.join('')).val(); };
184
185 function checkVal(allow) {
186 //try to place characters where they belong
187 var test = input.val();
188 var lastMatch = -1;
189 for (var i = 0, pos = 0; i < len; i++) {
190 if (tests[i]) {
191 buffer[i] = settings.placeholder;
192 while (pos++ < test.length) {
193 var c = test.charAt(pos - 1);
194 if (tests[i].test(c)) {
195 buffer[i] = c;
196 lastMatch = i;
197 break;
198 }
199 }
200 if (pos > test.length)
201 break;
202 } else if (buffer[i] == test.charAt(pos) && i!=partialPosition) {
203 pos++;
204 lastMatch = i;
205 }
206 }
207 if (!allow && lastMatch + 1 < partialPosition) {
208 input.val("");
209 clearBuffer(0, len);
210 } else if (allow || lastMatch + 1 >= partialPosition) {
211 writeBuffer();
212 if (!allow) input.val(input.val().substring(0, lastMatch + 1));
213 }
214 return (partialPosition ? i : firstNonMaskPos);
215 };
216
217 if (!input.attr("readonly"))
218 input
219 .one("unmask", function() {
220 input
221 .unbind(".mask")
222 .removeData("buffer")
223 .removeData("tests");
224 })
225 .bind("focus.mask", function() {
226 focusText = input.val();
227 var pos = checkVal();
228 writeBuffer();
229 setTimeout(function() {
230 if (pos == mask.length)
231 input.caret(0, pos);
232 else
233 input.caret(pos);
234 }, 0);
235 })
236 .bind("blur.mask", function() {
237 checkVal();
238 if (input.val() != focusText)
239 input.change();
240 })
241 .bind("keydown.mask", keydownEvent)
242 .bind("keypress.mask", keypressEvent)
243 .bind(pasteEventName, function() {
244 setTimeout(function() { input.caret(checkVal(true)); }, 0);
245 });
246
247 checkVal(); //Perform initial check for existing values
248 });
249 }
250 });
251 })(jQuery);
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\UserManager;
3
4 use Tz, Tz\Common;
5 use Tz\WordPress\CBV;
6 use Tz\WordPress\UAM;
7 use Tz\WordPress\Tools;
8 use Tz\WordPress\Tools\HTML;
9 use Exception, StdClass;
10 use WP_User, WP_Roles;
11
12 Tools\import('HTML');
13
14 $rc = new WP_Roles();
15 $roles = $rc->role_names;
16 ksort($roles);
17 unset($rc, $roles['administrator']);
18
19 ?>
20
21 <style>
22
23 #post-body {
24 -moz-border-radius-bottomleft:6px;
25 -moz-border-radius-bottomright:6px;
26 -moz-border-radius-topright:6px;
27 -moz-border-radius-topleft:6px;
28 background:none repeat scroll 0 0 #FFFFFF;
29 border-width:1px 1px 1px 1px;
30 padding:10px;
31 margin-top:20px;
32 }
33 #nav-menu-header, #post-body,#post-header {
34 border-color:#CCCCCC;
35 border-style:solid;
36 }
37
38 #menu-management .nav-tab {
39 background:none repeat scroll 0 0 #F4F4F4;
40 }
41
42 #menu-management .nav-tab-active {
43 background:none repeat scroll 0 0 #fff;
44 border-bottom-color:#fff;
45 }
46
47 </style>
48 <div id="" class="wrap">
49 <div id="icon-users" class="icon32"><br /></div>
50 <h2>Creating a new CBV User...</h2>
51
52 <div id="post-body">
53 <div style="padding:10px 10px 0px 10px; min-width:760px;">
54 <form method="post" id="admin-new-user-form">
55
56 <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table" style="float:left; width:350px;">
57 <tbody>
58 <tr>
59 <th width="120px;">Username:</th>
60 <td><input type="text" name="username" required /></td>
61 </tr>
62 <tr>
63 <th>First Name:</th>
64 <td><input type="text" name="first_name" required /></td>
65 </tr>
66 <tr>
67 <th>Last Name:</th>
68 <td><input type="text" name="last_name" id="create_last_name" required /></td>
69 </tr>
70 <tr><td colspan="2">&nbsp;</td></tr>
71 <tr>
72 <th>&nbsp;</th>
73 <td><select name="profile_preference" id="profile_preference"><option value="Home">Home&nbsp;</option><option value="Work">Work&nbsp;</option></select></td>
74 </tr>
75 <tr>
76 <th>Email:</th>
77 <td><input type="text" name="email" required /></td>
78 </tr>
79 <tr>
80 <th>Country:</th>
81 <td><?php echo HTML\form_dropdown('country', HTML\Vars::$countries, '', "id='country'"); ?></td>
82 </tr>
83 <tr>
84 <th>Province:</th>
85 <td><?php echo HTML\form_linked_dropdown('province', 'country', HTML\Vars::$provinces,'', ''); ?></td>
86 </tr>
87 </tbody>
88 </table>
89
90 <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table" style="float:left; width:350px;">
91 <tbody>
92 <tr>
93 <th>User Type:</th>
94 <td>
95 <select name="user_role" id="create_user_role">
96 <?php foreach($roles as $roled=>$name):?>
97 <option value="<?php echo $roled;?>" <?php echo ($roled=="guest") ? "selected" : "";?>><?php echo $name;?></option>
98 <?php endforeach;?>
99 </select>
100 </td>
101 </tr>
102 <tr id="create_member_id">
103 <th class="member_id_label">Member ID:</th>
104 <td><input type="text" name="member_id" id="member_id" readonly="readonly" /></td>
105 </tr>
106 <tr><td colspan="2">&nbsp;</td></tr>
107 <tr>
108 <th>Password (twice):</th>
109 <td><input type="password" name="password" required /></td>
110 </tr>
111 <tr>
112 <th>&nbsp;</th>
113 <td><input type="password" name="password2" required /></td>
114 </tr>
115 </tbody>
116 </table>
117
118 <div style="clear:both;"></div>
119
120 <div class="validation-errors" style="display:none;margin-top:10px;"><div class="error-wrap"><h6>OOPS...</h6><ul></ul></div></div>
121
122 <div style="margin-top:10px;padding-top:5px; border-top:1px solid #e8e8e8;">
123 <input type="submit" value="Create User" />
124 </div>
125
126 </form>
127 </div>
128
129 </div>
130
131 </div>
132
133 <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
134 <script type="text/javascript">
135 var $ = jQuery;
136
137 var $role_selector = $('#create_user_role');
138 var $member_id_container = $('#create_member_id');
139 var $member_id_label = $('.member_id_label');
140 var $member_id_field = $('#member_id');
141 var $form = $('#admin-new-user-form');
142 var $last_name_field = $('#create_last_name');
143
144 function changedUserRole() {
145 if ($role_selector.val() == "member" || $role_selector.val()=="student") {
146 if ($role_selector.val() == "member") {
147 $member_id_label.html('Member ID:');
148 } else {
149 $member_id_label.html('Student ID:');
150 }
151 updateMemberID();
152 $member_id_container.show();
153 } else {
154 $member_id_container.hide();
155 }
156 }
157
158 function updateMemberID() {
159 /*
160 var lname = $last_name_field.val();
161 if ($role_selector.val() == "member") {
162 $.ajax({
163 url: '/wp-admin/admin-ajax.php'
164 , data: ({ajax:"yes", action: 'admin_create_member_id', last_name: lname})
165 , dataType: 'json'
166 , type: 'post'
167 , success: function(data) {
168 $member_id_field.val(data.member_id);
169 }
170 });
171 }
172 */
173 $member_id_field.removeAttr('readonly');
174 }
175
176 $(function() {
177 changedUserRole();
178
179 $('#create_last_name').blur(function() {
180 updateMemberID();
181 });
182
183 $role_selector.change(function() {
184 changedUserRole();
185 });
186
187 var options = {
188 url: '/wp-admin/admin-ajax.php'
189 , dataType: 'json'
190 , type: 'post'
191 , data: ({ajax:"yes", action: 'admin_create_user', section: 'create'})
192 , beforeSubmit: function(formData, jqForm, options) {
193 var $error_container = jQuery('.validation-errors');
194 $error_container.hide();
195 }
196 , success: function(data) {
197 if (data.success == "true") {
198 document.location.href=data.edit_profile
199 } else {
200 var $error_container = jQuery('.validation-errors');
201 jQuery('h6',$error_container).html("OOPS...");
202 jQuery('ul',$error_container).html(data.msg);
203 $error_container.show();
204 }
205
206 }
207 };
208 $form.ajaxForm(options);
209
210 });
211
212
213 </script>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\UserManager;
3
4 use Tz, Tz\Common;
5 use Tz\WordPress\CBV;
6 use Tz\WordPress\CBV\CEHours;
7 use Tz\WordPress\CBV\Events;
8 use Tz\WordPress\UAM;
9
10 use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
11 use Tz\WordPress\Tools\Notifications;
12
13 use Exception, StdClass;
14 use WP_User;
15
16 ini_set('display_errors', 1);
17
18 $records_per_page = 20;
19
20 $filter_role = isset($_GET['role']) ? $_GET['role'] : null;
21 $pagenum = isset($_GET['pagenum']) ? $_GET['pagenum'] : 1;
22 $search = isset($_GET['search_criteria']) ? $_GET['search_criteria'] : null;
23
24 $site_users = get_users($filter_role, $pagenum, $records_per_page, false, $search);
25 $rows = $site_users->countTotal();
26
27 $last = ceil($rows/$records_per_page);
28 if ($last < 1) {
29 $last = 1;
30 }
31
32 if ($pagenum < 1) {
33 $pagenum = 1;
34 } elseif ($pagenum > $last) {
35 $pagenum = $last;
36 }
37
38 if ($filter_role) {
39 $url = $_SERVER['PHP_SELF']."?page=cbv_users&role=$filter_role&pagenum=";
40 } elseif ($search) {
41 $url = $_SERVER['PHP_SELF']."?page=cbv_users&search_criteria=$search&pagenum=";
42 } else {
43 $url = $_SERVER['PHP_SELF']."?page=cbv_users&pagenum=";
44 }
45
46 // Pager section
47 $loop_test = 0;
48 $loop_initial = 0;
49
50 $show_ellipsis_limit = 7;
51 $ellipsis_before = '';
52 $ellipsis_after = '';
53 $ellipsis_common = '...';
54
55 $tag = '[pagenum]';
56 $template = '<a href="' . $url . $tag . '">' . $tag . '</a>';
57 $template_with_class = '<a href="' . $url . $tag . '" class="active">' . $tag . '</a>';
58
59 $prev_link = ($pagenum == 1) ? '' : ' <a href="' . $url . ($pagenum - 1) . '">Prev</a> ';
60 $next_link = ($pagenum == $last) ? '' : ' <a href="' . $url . ($pagenum + 1) . '">Next</a> ';
61 $first_link = ' <a href="' . $url . '1">First</a> ';
62 $last_link = ' <a href="' . $url . $last . '">Last</a> ';
63
64 $pager = '';
65
66 // Style: 1...5 6 7...100
67 if ($last > 1) {
68 $pager = ' | Pages: ';
69
70 // Set options
71
72 // ...31 32 33...
73 if ($last > $show_ellipsis_limit) {
74 // 1 2 3 4...last
75 if ($pagenum > 0 && $pagenum < 4) {
76 $loop_initial = 2;
77 $loop_test = 5;
78 $ellipsis_after = $ellipsis_common;
79 // 4 5 6...last
80 } elseif ($pagenum > 3 && $pagenum < ($last - 1)) {
81 $loop_initial = $pagenum - 1;
82 $loop_test = $pagenum + 2;
83 $ellipsis_before = $ellipsis_common;
84
85 // This is to eliminate the $ellipsis when we're on the 3rd last page
86 if ($pagenum < ($last - 2)) {
87 $ellipsis_after = $ellipsis_common;
88 }
89 // 8 9 10(last)
90 } else {
91 $loop_initial = $pagenum - 2;
92 $loop_test = $last;
93 $ellipsis_before = $ellipsis_common;
94 }
95 // 1 2 3 4 5 6 7
96 } else {
97 $loop_initial = 2;
98 $loop_test = $last;
99 }
100
101 // Now start building html
102
103 // Start with 'First' link, then previous page link
104 if ($last > $show_ellipsis_limit && $pagenum != 1) {
105 $pager .= $first_link . $prev_link;
106 }
107
108 // Set active template to highlight page 1 if that's what we're on
109 if ($pagenum == 1) {
110 $pager .= str_ireplace($tag, 1, $template_with_class);
111 } else {
112 $pager .= str_ireplace($tag, 1, $template);
113 }
114
115 // Implement middle loops
116 $pager .= $ellipsis_before;
117 for ($i = $loop_initial; $i < $loop_test; $i++) {
118 if ($pagenum == $i) {
119 $pager .= str_ireplace($tag, $i, $template_with_class);
120 } else {
121 $pager .= str_ireplace($tag, $i, $template);
122 }
123 }
124 $pager .= $ellipsis_after;
125
126 // Set active template to highlight page 1 if that's what we're on
127 if ($pagenum == $last) {
128 $pager .= str_ireplace($tag, $last, $template_with_class);
129 } else {
130 $pager .= str_ireplace($tag, $last, $template);
131 }
132
133 // Finish with next page link, then 'Last' link
134 if ($last > $show_ellipsis_limit && $pagenum != $last) {
135 $pager .= $next_link;
136 $pager .= $last_link;
137 }
138 }
139
140 ?>
141 <div id="" class="wrap">
142 <div id="icon-users" class="icon32"><br /></div>
143 <h2>CBV User Manager <a href="/wp-admin/admin.php?page=cbv_users_create" class="button add-new-h2">Add New</a></h2>
144 <p style="display:none;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam iaculis convallis nisi eu dignissim. Quisque malesuada augue in mi blandit at blandit tortor sollicitudin. Cras at justo mi, vel mollis est. Donec orci erat, blandit varius vehicula vitae, volutpat at lorem. Etiam tincidunt bibendum ante, non tincidunt purus faucibus sed. Suspendisse eget facilisis tellus. Nulla imperdiet leo placerat diam sollicitudin nec mattis neque mattis. Cras id lacus tellus. Phasellus volutpat vehicula porttitor. Praesent erat felis, pharetra mollis egestas sit amet, rhoncus eget nisl. Morbi interdum sapien vitae nibh pharetra scelerisque. Mauris porta accumsan velit ac aliquam. Sed sit amet dictum felis. Fusce tempus vulputate nulla, quis tincidunt velit mattis eu.</p>
145
146 <div class="users-role-bar">
147 <?php if (isset($_GET['search_criteria'])):?>
148 <div style="margin-bottom:10px;display:block;"><strong>Searched for: </strong> <?php echo strip_tags($_GET['search_criteria']); ?> <a href="/wp-admin/admin.php?page=cbv_users" class="button">Clear Search</a></div>
149 <?php else: ?>
150 <strong>Filter</strong>:
151 <?php $users = count_users(); ?>
152 <a href="/wp-admin/admin.php?page=cbv_users" <?php echo (!isset($_GET['role']) ? "class='active'" : ""); ?>>All</a>
153 <?php
154 if (isset($users['avail_roles'])) {
155 foreach($users['avail_roles'] as $role=>$counted) {
156 print ' | <a href="/wp-admin/admin.php?page=cbv_users&role='.$role.'" '.( (isset($_GET['role']) && $_GET['role']==$role) ? "class='active'" : "").'>'.ucwords($role).'</a>';
157 }
158 }
159
160 ?>
161 <form method="GET" action="<?php echo $_SERVER['PHP_SELF']."?page=cbv_users"; ?>"><input type="hidden" name="page" value="cbv_users" /><div style="margin-top:3px;display:block;"><em>or</em> <strong>Search</strong>: <input type="text" name="search_criteria" value="" /><input type="submit" value="Go" /></div></form>
162 <?php endif;?>
163 </div>
164
165 <div class="TzPaginateResults">
166 <?php
167 echo "Users: $rows ";
168 echo $pager;
169 ?>
170 </div>
171 <div style="clear:both"></div>
172 <table cellspacing="0" class="widefat post fixed">
173 <thead>
174 <tr>
175 <th scope="col" class="manage-column">Name</th>
176 <th scope="col" width="180" class="manage-column">Member ID</th>
177 <th scope="col" width="250" class="manage-column">Email</th>
178 <th scope="col" width="200" class="manage-column">Role</th>
179 <th scope="col" width="100" class="manage-column">Status</th>
180
181 <th scope="col" width="100" class="manage-column">&nbsp;</th>
182
183 </tr>
184 </thead>
185 <tbody>
186 <?php
187 foreach ($site_users as $user):
188 $pref = strtolower($user->email_address_preference);
189 if (!in_array($pref, Array('home', 'work'))) {
190
191 $pref = strtolower($user->profile_preference);
192 if (!in_array($pref, Array('home', 'work'))) {
193 $email = $user->user_email;
194 } else {
195 $email = $user->{$pref . '_email'};
196 }
197
198 //$pref = (empty($user->home_email) ? 'work' : 'home');
199 } else {
200 $email = $user->{$pref . '_email'};
201 }
202 ?>
203 <tr>
204 <td><a href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $user->id; ?>"><?php echo $user->last_name . ', ' . $user->first_name; ?></a></td>
205 <td><a href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $user->id; ?>"><?php echo $user->member_id; ?></a></td>
206 <td><?php echo $email ?></td>
207 <td><?php echo current(array_keys($user->wp_capabilities)); ?></td>
208 <td><?php echo ucwords($user->status);?></td>
209
210 <td><a href="/wp-admin/admin-ajax.php?ajax=yes&action=build_user_remove&uid=<?php echo $user->user_id;?>" class="remove-user" rel="<?php echo $user->user_id;?>">Remove User</a></td>
211
212 </tr>
213 <?php endforeach; ?>
214 </body>
215 </table>
216
217 <div class="TzPaginateResults" style="margin-top:10px;">
218 <?php
219 echo "Users: $rows ";
220 echo $pager;
221 ?>
222 </div>
223 <div style="clear:both;"></div>
224
225 </div>
226 <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\UserManager;
3
4 use Tz, Tz\Common;
5 use Tz\WordPress\CBV;
6 use Tz\WordPress\CBV\CEHours;
7 use Tz\WordPress\CBV\Events;
8 use Tz\WordPress\CBV\User;
9
10 use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
11 use Tz\WordPress\Tools\Notifications;
12
13 use Exception, StdClass;
14
15 $user = new CBV\User\Account($_GET['uid']);
16 $suser = new CBV\User\CurrentAccount();
17
18 $role = $user->getRole();
19
20 $fname = $user->first_name;
21 $lname = $user->last_name;
22
23 if (empty($fname) || empty($lname)) {
24 $name = $user->user_login;
25 } else {
26 $name = $fname . " " . $lname;
27 }
28
29 $section = isset($_GET['section']) ? $_GET['section'] : "overview";
30
31 call_user_func(function() {
32 CBV\load('Events');
33 });
34 ?>
35 <style>
36
37 #post-body {
38 -moz-border-radius-bottomleft:6px;
39 -moz-border-radius-bottomright:6px;
40 -moz-border-radius-topright:6px;
41 background:none repeat scroll 0 0 #FFFFFF;
42 border-width:1px 1px 1px;
43 padding:10px;
44 }
45 #nav-menu-header, #post-body,#post-header {
46 border-color:#CCCCCC;
47 border-style:solid;
48 }
49
50 #menu-management .nav-tab {
51 background:none repeat scroll 0 0 #F4F4F4;
52 }
53
54 #menu-management .nav-tab-active {
55 background:none repeat scroll 0 0 #fff;
56 border-bottom-color:#fff;
57 }
58
59 </style>
60
61 <script type="text/javascript">var user_id = <?php echo $_GET['uid'];?>;</script>
62
63 <div id="" class="wrap">
64 <div id="icon-users" class="icon32"><br /></div>
65 <h2>Editing: <?php echo $name; ?>
66 <?php if (!empty($user->member_id)) { echo '<span class="admin-member-id"> (' . $user->member_id . ')</span>'; }?>
67 <?php if (in_array($suser->getRole(), Array('administrator', 'cbv_admin'))): ?>
68 (<a href="<?php echo get_author_posts_url($user->ID); ?>?sulogin=1">Login</a>)
69 <?php endif; ?>
70 </h2>
71
72 <p style="display:none;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam iaculis convallis nisi eu dignissim. Quisque malesuada augue in mi blandit at blandit tortor sollicitudin. Cras at justo mi, vel mollis est. Donec orci erat, blandit varius vehicula vitae, volutpat at lorem. Etiam tincidunt bibendum ante, non tincidunt purus faucibus sed. Suspendisse eget facilisis tellus. Nulla imperdiet leo placerat diam sollicitudin nec mattis neque mattis. Cras id lacus tellus. Phasellus volutpat vehicula porttitor. Praesent erat felis, pharetra mollis egestas sit amet, rhoncus eget nisl. Morbi interdum sapien vitae nibh pharetra scelerisque. Mauris porta accumsan velit ac aliquam. Sed sit amet dictum felis. Fusce tempus vulputate nulla, quis tincidunt velit mattis eu.</p>
73
74 <div id="menu-management" style="margin-top:25px;">
75 <div class="nav-tabs-nav">
76 <div class="nav-tabs-wrapper" class="section-<?php echo @$_GET['section'];?>">
77 <div class="nav-tabs" style="padding: 0px; margin-left: 0px;">
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']; ?>&section=overview">Overview</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']; ?>&section=profile">Profile</a>
80 <a id="events" class="nav-tab hide-if-no-js <?php echo ($section=="events") ? "nav-tab-active" : ""; ?>" href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $_GET['uid']; ?>&section=events">Events</a>
81 <a id="courses" class="nav-tab hide-if-no-js <?php echo ($section=="courses") ? "nav-tab-active" : ""; ?>" href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $_GET['uid']; ?>&section=courses">Courses</a>
82 <?php if ($role=="member"): ?>
83 <a id="cehours" class="nav-tab hide-if-no-js <?php echo ($section=="cehours") ? "nav-tab-active" : ""; ?>" href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $_GET['uid']; ?>&section=cehours">Continuing Ed.</a>
84 <?php endif; ?>
85 <a id="payhistory" class="nav-tab hide-if-no-js <?php echo ($section=="payhistory") ? "nav-tab-active" : ""; ?>" href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $_GET['uid']; ?>&section=payhistory">Invoice/Receipts</a>
86 <a id="notes" class="nav-tab hide-if-no-js <?php echo ($section=="notes") ? "nav-tab-active" : ""; ?>" href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $_GET['uid']; ?>&section=notes">Admin Notes</a>
87 </div>
88 </div>
89 </div>
90
91 <div id="post-body" style="padding:0px 10px 15px 10px;">
92 <?php require_once('edit_user_' . $section . '.php'); ?>
93 </div>
94
95 </div>
96
97 </div>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\UserManager;
3
4 use Tz, Tz\Common;
5 use Tz\WordPress\CBV;
6 use Tz\WordPress\CBV\CEHours;
7 use Tz\WordPress\UAM;
8
9 use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
10 use Tz\WordPress\Tools\Notifications;
11
12 use Exception, StdClass;
13 use WP_User;
14
15 $uid = $_GET['uid'];
16
17 CBV\load('CEHours');
18 $cehours = CEHours\get_user_cehours($uid);
19
20 ?>
21 <div style="padding:10px 10px 0px 10px; min-width:760px;">
22 <h2 style="margin-bottom:10px;padding-bottom:0px;">Continuing Education Hours... <a href="/wp-admin/admin-ajax.php?ajax=yes&post_action=create&action=build_cehour_form&uid=<?php echo $uid?>&indexed=0" id="admin_add_new_cehours" class="button add-new-h2">Add New</a></h2>
23
24 <?php
25 if (empty($cehours)) :
26 print "<p>No CE Hours recorded.</p>";
27 else:
28
29 ?>
30
31 <table cellspacing="0" class="widefat post fixed" style="margin-top:0px;">
32 <thead>
33 <tr>
34 <th scope="col" width="150">Date Recorded</th>
35 <th scope="col" width="150">Type</th>
36 <th scope="col">Activity</th>
37 <th scope="col" width="150">Structured</th>
38 <th scope="col" width="100">Unstructured</th>
39 <th scope="col" width="100">&nbsp;</th>
40 </tr>
41 </thead>
42 <tbody>
43 <?php foreach($cehours as $index=>$ce):
44 $ce_date = date('F j, Y',$ce['date']);
45 ?>
46 <tr>
47 <td><?php echo $ce_date; ?></td>
48 <td><?php echo ucwords($ce['subtype']); ?></td>
49 <td><?php echo $ce['activity']; ?></td>
50 <td><?php echo ($ce['type']=="structured") ? $ce['hours'] : 0;?></td>
51 <td><?php echo ($ce['type']=="unstructured") ? $ce['hours'] : 0;?></td>
52 <td class="cehours-remove-td"><a href="/wp-admin/admin-ajax.php?ajax=yes&action=build_cehour_form&uid=<?php echo $uid?>&indexed=<?php echo $index;?>" class="cehours-edit" rel="<?php echo $index;?>">edit</a> | <a href="#" class="cehours-remove" rel="<?php echo $index;?>">remove</a></td>
53 </tr>
54 <?php endforeach; ?>
55 </tbody>
56 </table>
57 <?php
58 endif;
59
60 ?>
61 </div>
62 <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\UserManager;
3 use Tz, Tz\Common;
4 use Tz\WordPress\Tools;
5 use Tz\WordPress\CBV;
6 use Tz\WordPress\CBV\Courses, Tz\WordPress\CBV\Courses\Registration;
7 use Tz\WordPress\CBV\User;
8 use Tz\WordPress\UAM;
9 use WP_Query;
10
11 // check to see if user is eligible for course (is member/student)
12
13 CBV\load('Courses');
14 $user = new User\Account($_GET['uid']);
15 $courses = Courses\getActiveCourses();
16 $lookup = Array();
17 foreach ($courses as $course) {
18 $lookup[$course->getTemplateID()] = $course;
19 }
20
21 $fn_cd = function($tid, $key) use ($courses, $lookup) {
22 if (!isset($lookup[$tid])) {
23 return 'Not Available';
24 }
25
26 return date('Y-m-d', $courses[$lookup[$tid]->getID()]->{$key});
27 };
28 ?>
29 <div style="padding:10px 10px 0px 10px; min-width:760px;">
30 <div id="Tz4QContainer">
31 <?php if ($user->course_4q_approvals == 'P'): ?>
32 <h2>Security Question Status</h2>
33 <ul>
34 <?php
35 CBV\load('Courses\Registration');
36 $four_questions = Registration\get_four_questions();
37 foreach ($user->four_security_questions as $key => $yesno) {
38 if ($yesno == 1) {
39 echo "<li>Q: {$four_questions[$key]} (yes)</li>";
40 }
41 }
42 ?>
43 </ul>
44
45 <p style="padding: 0 1em;"><em>&quot;<?php echo nl2br(htmlspecialchars($user->four_security_explanation)); ?>&quot;</em></p>
46
47 <p id="TzFQActions">
48 <input type="button" value=" Approve " />
49 <input type="button" value=" Decline " />
50 </p>
51 <?php endif; ?>
52 </div>
53
54 <h2 style="margin-bottom:10px;padding-bottom:0px;">Current Courses</h2>
55
56 <table class="clean-lines widefat post fixed">
57 <thead><tr>
58 <th>Course</th>
59 <th width="85">Type</th>
60 <th width="100">Latest Mark</th>
61 <th>Registration Deadline</th>
62 <th>Semester Runs</th>
63 <th>Register</th>
64 </tr></thead>
65 <tbody>
66 <?php
67 $templates = new WP_Query(Array(
68 'post_type' => CBV\PCT_COURSETEMPLATE
69 , 'posts_per_page' => 0
70 ));
71 while ($templates->have_posts()):
72 $templates->the_post();
73 ?>
74 <tr>
75 <td><?php echo get_the_title(); ?></td>
76 <td><?php echo get_post_meta(get_the_ID(), 'course_type', true); ?></td>
77 <td><?php echo $user->getMark(get_the_ID()); ?></td>
78 <td><?php echo $fn_cd(get_the_ID(), 'course_regi_close'); ?>
79 <td><?php echo $fn_cd(get_the_ID(), 'course_start') . '&nbsp;-&nbsp;' . $fn_cd(get_the_ID(), 'course_end'); ?></td>
80 <td>
81 <?php if (isset($lookup[get_the_ID()]) && $lookup[get_the_ID()]->registrationOpen()): ?>
82 <?php if ($user->courseApprovalStatus($lookup[get_the_ID()]->getID()) == $user::CAS_APPROVED): ?>
83 Registered
84 <?php else: ?>
85 <a href="/wp-admin/admin-ajax.php?ajax=yes&action=build_course_form&post_action=create&uid=<?php echo $user->ID; ?>&course_id=<?php echo $lookup[get_the_ID()]->getID();?>" class="course-edit" rel="<?php echo get_the_id();?>">Register</a>
86 <?php endif; ?>
87 <?php endif; ?>
88 </td>
89 </tr>
90 <?php
91 endwhile;
92 _reset_postdata();
93 ?>
94 </tbody>
95 </table>
96
97 <h2>Course History</h2>
98 <table class="clean-lines widefat post fixed" id="mark_history">
99 <thead><tr>
100 <th>Course</th>
101 <th>Type</th>
102 <th>Mark</th>
103 <th>Semester</th>
104 <th>Date Achieved</th>
105 </tr></thead>
106
107 <tbody>
108 <?php
109 foreach ($user->marks['history'] as $data):
110 $course = new Courses\Course($data['course_id']);
111 ?>
112 <tr>
113 <td><?php echo $course->post_title; ?></td>
114 <td><?php echo $course->course_type; ?></td>
115 <td><a href="#" id="edit_mark_<?php echo $course->ID; ?>" data-mark="editable" data-course-id="<?php echo $course->ID; ?>" data-mark-value="<?php echo $data['mark']; ?>"><?php echo $data['mark']; ?></a></td>
116 <td><?php echo $course->getSemester(); ?></td>
117 <td><?php echo date('Y-m-d', $data['added']); ?></td>
118 </tr>
119 <?php endforeach; ?>
120 </tbody>
121 </table>
122
123 </div>
124 <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\UserManager;
3
4 use Tz, Tz\Common;
5 use Tz\WordPress\CBV;
6 use Tz\WordPress\CBV\CEHours;
7 use Tz\WordPress\CBV\Events;
8 use Tz\WordPress\UAM;
9
10 use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
11 use Tz\WordPress\Tools\Notifications;
12
13 use Exception, StdClass;
14 use WP_User;
15
16 $uid = $_GET['uid'];
17
18 CBV\load('Events');
19 $events = get_user_meta($user->ID, 'events', true);
20 ?>
21 <div style="padding:10px 10px 0px 10px; min-width:760px;">
22 <?php
23 if (empty($events) || count($events) < 1):
24 echo '<h2 style="margin-bottom:10px;padding-bottom:0px;">'.$name.' is not registered for any events...</h2>';
25 else: ?>
26
27 <h2 style="margin-bottom:10px;padding-bottom:0px;">Registered for Events...</h2>
28
29 <table cellspacing="0" class="widefat post fixed">
30 <thead>
31 <tr>
32 <th scope="col">Event Name</th>
33 <th scope="col" width="150">Event Date</th>
34 <th scope="col" width="150">Registered</th>
35 <th scope="col" width="100">&nbsp;</th>
36 </tr>
37 </thead>
38 <tbody>
39 <?php foreach($user->events as $event):
40 $e = Events\get_event($event['event_id']);
41
42 if ( empty($e->ID) OR $e->ID < 1) { continue; }
43
44 $event_date = get_post_meta($e->ID, 'event_date', true);
45 ?>
46 <tr>
47 <td><?php echo $e->post_title;?></td>
48 <td><?php echo date('F j, Y',$event_date);?></td>
49 <td><?php echo date('F j, Y',$event['register_date']);?></td>
50 <td class="event-cancel-td"><a href="/wp-admin/admin-ajax.php?ajax=yes&action=build_event_form&uid=<?php echo $uid?>&event_id=<?php echo $e->ID;?>" class="event-edit" rel="<?php echo $e->ID;?>">edit</a> | <a href="#" class="event-cancel" rel="<?php echo $e->ID;?>">cancel</a></td>
51 </tr>
52 <?php endforeach; ?>
53 </tbody>
54 </table>
55
56 <h4 style="margin-bottom:5px;padding-bottom:0px; padding-left:10px;"><em>Events not registered for...</em></h4>
57 <?php endif; ?>
58 <?php
59 $posts = query_posts(Array(
60 'post_type' => 'events'
61 , 'posts_per_page' => -1
62 , 'paged' => (get_query_var('paged') ? get_query_var('paged') : 1)
63
64 , 'meta_key' => 'event_date'
65 /*
66 , 'meta_compare' => '>'
67 , 'meta_value' => (time() + (60*60*24)) // event date + 1 day, so that they can register the day of...
68 */
69 , 'orderby' => 'meta_value'
70
71 , 'order' => 'DESC'
72 ));
73 ?>
74
75 <table cellspacing="0" class="widefat post fixed">
76 <thead>
77 <tr>
78 <th scope="col">Event Name</th>
79 <th scope="col" width="150">Event Date</th>
80 <th scope="col" width="150">Register By</th>
81 <th scope="col" width="100">Cost</th>
82 <th scope="col" width="100">&nbsp;</th>
83 </tr>
84 </thead>
85 <tbody>
86 <?php foreach($posts as $post):
87 if (!Events\is_attending($post->ID, $uid) && UAM\can_user_access($post->ID, $uid)):
88
89
90 // get categories....
91 $event_term_slugs = array();
92 $terms = get_the_terms($post->ID,'event_type');
93
94 $external_only = false;
95 if (!empty($terms)) {
96 foreach($terms as $types) {
97 $event_term_slugs[$types->slug] = $types->name;
98 if ($types->slug == "externalevent") {
99 $external_only = true;
100 }
101 }
102 }
103
104 if ($external_only) {
105 continue;
106 }
107
108 $event_date = get_post_meta($post->ID, 'event_date', true);
109
110 if (isset($event_term_slugs['webinar'])) {
111 $is_archived = get_post_meta($post->ID, 'is_archived_webinar', true);
112 /*if (!$is_archived == "on") { continue; }*/
113 } else {
114
115 if ($event_date < (current_time('timestamp') - (60*60*24))) {
116 continue;
117 }
118
119 }
120
121
122
123
124 $event_date = get_post_meta($post->ID, 'event_date', true);
125 $register_date = get_post_meta($post->ID, 'reg_deadline', true);
126 $cost = get_post_meta($post->ID,'cost',true);
127 if (empty($cost) || $cost < 1 || strtolower($cost)=="free") { $cost = 0; }
128 ?>
129 <tr>
130 <td><?php echo $post->post_title;?><br />
131 <?php foreach($terms as $the_term) { echo $the_term->name; } ?>
132 </td>
133 <td><?php echo date('F j, Y',$event_date);?></td>
134 <td><?php echo date('F j, Y',$register_date);?></td>
135 <td>$<?php echo number_format($cost,2);?></td>
136 <td><a href="/wp-admin/admin-ajax.php?ajax=yes&action=build_event_form&post_action=create&uid=<?php echo $uid?>&event_id=<?php echo $post->ID;?>" class="event-edit" rel="<?php echo $post->ID;?>">Register</a></td>
137 </tr>
138 <?php endif; endforeach; ?>
139 </tbody>
140 </table>
141
142 </div>
143 <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\UserManager;
3
4 use Tz, Tz\Common;
5 use Tz\WordPress\CBV;
6 use Tz\WordPress\CBV\CEHours;
7 use Tz\WordPress\CBV\Invoice;
8 use Tz\WordPress\CBV\Events;
9 use Tz\WordPress\UAM;
10
11 use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
12 use Tz\WordPress\Tools\Notifications;
13
14 use Exception, StdClass;
15 use WP_User;
16 ?>
17 <div style="padding:10px 10px 0px 10px; min-width:760px;position:relative;">
18 <h2 style="margin-bottom:10px;padding-bottom:0px;">Admin notes...</h2>
19
20 <form id="edit_user_notes">
21 <input type="hidden" name="uid" value="<?php echo $_GET['uid']; ?>" />
22 <textarea style="width:99%" rows="10" id="note" name="note"><?php echo get_user_meta($_GET['uid'], 'admin_notes',true);?></textarea>
23 <div style="margin-top:15px;"><input type="submit" value="Update Notes" /><span class="update-placeholder"></span></div>
24 </form>
25
26
27 </div>
28 <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\UserManager;
3
4 use Tz, Tz\Common;
5 use Tz\WordPress\CBV;
6 use Tz\WordPress\CBV\CEHours;
7 use Tz\WordPress\CBV\Events;
8 use Tz\WordPress\CBV\User;
9 use Tz\WordPress\UAM;
10
11 use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
12 use Tz\WordPress\Tools\Notifications;
13
14 use Exception, StdClass;
15 use WP_User, WP_Roles;
16
17 $uid = $_GET['uid'];
18 $account = new User\Account($uid);
19
20 $pp = get_user_meta($uid, 'profile_preference', true).'_';
21
22 $first_name = get_user_meta($uid, 'first_name', true);
23 $last_name = get_user_meta($uid, 'last_name', true);
24
25 // contact info.
26 $country = get_user_meta($uid, $pp.'country', true);
27 $mobile = get_user_meta($uid, 'mobile', true);
28
29 $email_pref = get_user_meta($uid, 'email_address_preference', true);
30 if (!empty($email_pref) && $email_pref != "none") {
31 $pref = strtolower($email_pref)."_";
32 $email = get_user_meta($uid, $pref."email", true);
33 } else {
34 $email = "";
35 }
36
37
38 //$email = $user->user_email;//get_user_meta($uid, 'email', true);
39
40 // professional stuff
41 $title = get_user_meta($uid, 'title', true);
42 $company = get_user_meta($uid, 'company_name', true);
43
44 // status
45 $status = get_user_meta($uid, 'status', true);
46
47 // membership
48 $member_id = get_user_meta($uid, 'member_id', true);
49
50 $notify_me = get_user_meta($uid, 'notify_me', true);
51
52
53 $rc = new WP_Roles();
54 $roles = $rc->role_names;
55 ksort($roles);
56 unset($rc, $roles['administrator']);
57
58
59 ?>
60
61 <div style="padding:10px 10px 0px 10px; min-width:760px;">
62 <form method="post" id="overview_form">
63 <h2 style="margin-bottom:10px;padding-bottom:0px;">Overview of Users' Account...</h2>
64 <div style="float:left; width:300px;margin-right:50px;">
65
66 <table cellspacing="0" class="widefat post fixed" style="border:none;">
67 <tbody>
68 <tr>
69 <th>User Login:</th>
70 <td><?php echo $account->user_login; ?></td>
71 </tr>
72 <?php if (!empty($first_name)): ?>
73 <tr>
74 <th>First Name:</th>
75 <td><?php echo $first_name; ?></td>
76 </tr>
77 <?php endif; ?>
78
79 <?php if (!empty($last_name)): ?>
80 <tr>
81 <th>Last Name:</th>
82 <td><?php echo $last_name; ?></td>
83 </tr>
84 <?php endif; ?>
85
86 <?php if (!empty($company)): ?>
87 <tr>
88 <th>Company:</th>
89 <td><?php echo $company; ?></td>
90 </tr>
91 <?php endif; ?>
92
93 <?php if (!empty($title)): ?>
94 <tr>
95 <th>Title:</th>
96 <td><?php echo $title; ?></td>
97 </tr>
98 <?php endif; ?>
99
100
101
102 <?php if (!empty($email)): ?>
103 <tr>
104 <th>Email:</th>
105 <td><a href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a></td>
106 </tr>
107 <?php endif; ?>
108
109
110
111 </tbody>
112 </table>
113
114 <h3 style="margin-bottom:5px; padding-bottom:0px;">Change User Password:</h3>
115 <table cellpadding="0" cellspacing="0" border="0">
116 <tbody>
117 <tr>
118 <td width="150">New Password (twice)</td>
119 <td><input type="password" name="password1" value="" /></td>
120 </tr>
121 <tr>
122 <td>&nbsp;</td>
123 <td><input type="password" name="password2" value="" /></td>
124 </tr>
125 <tr><td colspan="2" style="font-size:11px;"><em>(leave them blank to not change their password)</em></td></tr>
126 </tbody>
127 </table>
128
129 <div style="clear:both;"></div>
130
131
132 <div id="show_special_status" style="display:block;">
133 <h3 style="margin-bottom:5px; padding-bottom:0px;">Special Status:</h3>
134 <input type="hidden" name="special_status_active" value="true" />
135 <table cellpadding="0" cellspacing="0" border="0">
136 <tbody>
137 <tr>
138 <td width="20"><input type="checkbox" id="status_retired" name="special_status[]" value="status_retired" <?php search_special_status('status_retired');?> /></td>
139 <td><label for="status_retired">Retired status</label></td>
140 </tr>
141 <tr>
142 <td width="20"><input type="checkbox" id="status_disabled" name="special_status[]" value="status_disabled" <?php search_special_status('status_disabled');?> /></td>
143 <td><label for="status_disabled">Disability status</label></td>
144 </tr>
145 <tr>
146 <td width="20"><input type="checkbox" id="status_parental" name="special_status[]" value="status_parental" <?php search_special_status('status_parental');?> /></td>
147 <td><label for="status_parental">Parental status</label></td>
148 </tr>
149 <tr>
150 <td width="20"><input type="checkbox" id="status_educational" name="special_status[]" value="status_educational" <?php search_special_status('status_educational');?> /></td>
151 <td><label for="status_educational">Educational status</label></td>
152 </tr>
153 <tr>
154 <td width="20"><input type="checkbox" id="tax_exempt" name="special_status[]" value="tax_exempt" <?php search_special_status('tax_exempt');?> /></td>
155 <td><label for="tax_exempt">Tax Exemption</label></td>
156 </tr>
157 <tr>
158 <td width="20"><input type="checkbox" id="status_life" name="special_status[]" value="status_life" <?php search_special_status('status_life');?> /></td>
159 <td><label for="status_life">Life Member</label></td>
160 </tr>
161 </tbody>
162 </table>
163
164 <div style="clear:both;"></div>
165 </div>
166
167
168
169 </div>
170 <div style="float:left; width:360px; border-left: 1px solid #ccc;">
171 <div style="margin-left:20px; margin-bottom:20px;">
172
173 <!-- coming soon...
174 <h3 style="margin-bottom:5px; padding-bottom:0px;">Account Balance:</h3>
175 <div style="color:red; font-size:18px;">-$130.00</div>
176 -->
177
178
179 <input type="hidden" name="uid" value="<?php echo $uid; ?>" />
180 <input type="hidden" name="section" value="account" />
181
182 <h3 style="margin-bottom:5px; padding-bottom:0px;">Account:</h3>
183
184 <table cellpadding="0" cellspacing="0" width="100%" border="0">
185 <tbody>
186 <tr>
187 <td width="100">Status:</td>
188 <td>
189 <select name="status" style="width:150px;">
190 <option value="active" <?php echo ($status=="active") ? "selected" : ""; ?>>Active</option>
191 <option value="suspended" <?php echo ($status=="suspended") ? "selected" : ""; ?>>Suspended</option>
192 <option value="terminated" <?php echo ($status=="terminated") ? "selected" : ""; ?>>Terminated</option>
193 </select>
194 </td>
195 </tr>
196
197 <?php if($role!="administrator"):?>
198 <tr>
199 <td>Type:</td>
200 <td>
201 <select name="user_role" id="user_role" style="width:150px;">
202 <?php foreach($roles as $roled=>$name):?>
203 <option value="<?php echo $roled;?>" <?php echo ($roled==$role) ? "selected" : "";?>><?php echo $name;?></option>
204 <?php endforeach;?>
205 </select>
206 </td>
207 </tr>
208 <?php endif; ?>
209
210
211 <?php
212 $mau = get_user_meta($_GET['uid'], 'membership_valid_until', true);
213 if ( !empty($mau) ) {
214 $current_mau = $mau;
215 } else {
216 $current_mau = "";
217 }
218 ?>
219 <tr>
220 <td>Active Until</td>
221 <td>
222 <select name="membership_valid_until" id="membership_valid_until" style="width:150px;">
223 <option value="" <?php echo ($current_mau=="") ? "selected" : ""; ?>>Select ...</option>
224
225 <?php if ( !empty($current_mau) ): ?>
226 <option value="<?php echo $current_mau;?>" selected><?php echo $current_mau;?></option>
227 <?php endif; ?>
228
229 <optgroup label="Change to:">
230 <?php
231 $max_avail_mau = ((int) date("Y") + 3);
232 for($mi = (int) date("Y"); $mi <= $max_avail_mau;$mi++) {
233 echo '<option value="'.$mi.'">'.$mi.'</option>';
234 }
235 ?>
236 </optgroup>
237 </select>
238 </td>
239 </tr>
240
241 </tbody>
242 </table>
243
244 <div style="clear:both;"></div>
245 <div>
246 <h3>Groups:</h3>
247 <ul>
248 <?php
249 $groups = UAM\getGroups();
250 foreach ($groups as $group):
251 $dom = "group[{$group->getID()}]";
252 $checked = ($account->isMemberOf($group->getName()) ? ' checked="checked"' : '');
253 $disabled = ($group->isRoleAffiliated($account->getRole()) ? ' disabled="disabled"' : '');
254 ?>
255 <li>
256 <input type="hidden" name="grpanch[<?php echo $group->getID(); ?>]" value="1" />
257 <input type="checkbox" name="<?php echo $dom; ?>" id="<?php echo $dom; ?>" value="1" <?php echo $checked . $disabled; ?> />
258 <label for="<?php echo $dom; ?>"><?php echo $group->getName(); ?></label>
259 </li>
260 <?php endforeach; ?>
261 </ul>
262 </div>
263
264
265 <div class="validation-errors" style="display:none;"><div class="error-wrap"><h6>OOPS...</h6><ul></ul></div></div>
266 <br />
267 <input type="submit" value="Update Account" /><span class="update-placeholder"></span>
268
269
270
271
272 </div>
273 <div style="clear:both;"></div>
274 </div>
275 <div style="clear:both;"></div>
276 </form>
277 </div>
278
279 <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
280 <script type="text/javascript">
281 jQuery(function() {
282 /* Dan asked me to keep special status open for all in the backend.
283 jQuery('#user_role').change(function() {
284 if (jQuery(this).val() == "member") {
285 jQuery('#show_special_status').show();
286 } else {
287 jQuery('#show_special_status').hide();
288 }
289 });
290 */
291 });
292 </script>
293
294
1 <?php
2 namespace Tz\WordPress\Tools\UserManager;
3
4 use Tz, Tz\Common;
5 use Tz\WordPress\CBV;
6 use Tz\WordPress\CBV\CEHours;
7 use Tz\WordPress\CBV\Invoice;
8 use Tz\WordPress\CBV\Events;
9 use Tz\WordPress\UAM;
10
11 use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
12 use Tz\WordPress\Tools\Notifications;
13
14 use Exception, StdClass;
15 use WP_User;
16 ?>
17 <div style="padding:10px 10px 0px 10px; min-width:760px;position:relative;">
18
19 <h2 style="margin-bottom:10px;padding-bottom:0px;">Users' Invoice/Receipts...
20 <?php if (!isset($_GET['view'])):?>
21 <a href="#" class="button add-new-h2" id="creditNotBtn">Create new Invoice/Credit Note</a>
22 <?php endif; ?>
23 </h2>
24
25 <div id="credit_note" style="display:none;">
26 <div style="border:1px solid #e8e8e8; background-color:#f5f5f5;padding:10px;">
27 <form id="creditForm" method="POST">
28 <input type="hidden" name="uid" value="<?php echo $_GET['uid']; ?>" />
29 <h3 style="margin:0;padding:0;">Invoice/Credit Note...</h3>
30 <table width="100%" style="margin-top:10px;">
31 <tbody>
32 <tr>
33 <td width="130">Type</td>
34 <td>
35 <select name="invoice_type" id="invoice_type">
36 <option value="invoice">Invoice</option>
37 <option value="membership">Membership Fees</option>
38 <option value="credit">Credit Note</option>
39 </select>
40 </td>
41 </tr>
42 <tr class="invoice_credit_only">
43 <td>Description</td>
44 <td><input type="text" name="title" style="width:400px" /></td>
45 </tr>
46 <tr class="invoice_credit_only">
47 <td>Amount ($)</td>
48 <td><input type="text" name="amount" /></td>
49 </tr>
50 <tr class="invoice_only">
51 <td>Paid?</td>
52 <td><input type="checkbox" name="paid" value="on" /></td>
53 </tr>
54 <tr class="invoice_only">
55 <td>Paid By</td>
56 <td>
57 <select name="paid_by">
58 <option value="">Select payment type...</option>
59 <option value="PPV">Pre-paid with Visa</option>
60 <option value="PPMC">Pre-paid with Mastercard</option>
61 <option value="PPAMEX">Pre-paid with American Express</option>
62 <option value="CHEQUE">Paid by Cheque</option>
63 </select>
64 </td>
65 </tr>
66 <tr>
67 <td colspan="4" style="padding-top:5px;"><input type="submit" value="Apply Invoice/Credit Note" /></td>
68 </tr>
69 </tbody>
70 </table>
71 </form>
72 </div>
73 </div>
74
75 <?php
76 if ( isset($_GET['view']) ) {
77 $invoice = get_post($_GET['view']);
78
79 $invoice->items = get_post_meta($invoice->ID, 'items',true);
80 $invoice->payment = get_post_meta($invoice->ID, 'payment',true);
81
82 $date = strtotime($invoice->post_date);
83 $date = date("F j, Y",$date);
84
85 if ( ($invoice->post_author !== Tools\getCurrentUser()->ID) AND !is_admin()) {
86 print "<div style='color:#DF1C24;font-weight:bold;'>YOU CAN ONLY VIEW YOUR OWN INVOICES.</div>";
87
88 } else {
89
90 $html = '<p><a href="/wp-admin/admin.php?page=cbv_users&action=edit&uid='.$_GET['uid'].'&section=payhistory">Show all invoices</a></p>';
91
92
93
94 $html .= '<div style="text-align:right;margin-bottom:5px;"><a href="/invoices/?view='.$invoice->ID.'&pagename=invoice-preview" class="glabel label-black-print print-invoice-handler" target="_blank"></a></div>';
95
96 $html .= Invoice\DrawInvoice($invoice,true);
97
98 $html .= '<div style="text-align:right;margin-top:5px;"><a href="/invoices/?view='.$_GET['view'].'&pagename=invoice-preview" class="glabel label-black-print print-invoice-handler" target="_blank"></a></div>';
99
100
101 print $html;
102 }
103
104 } else {
105 Invoice\showMyInvoices($_GET['uid'], "/wp-admin/admin.php?page=cbv_users&action=edit&uid=".$_GET['uid']."&section=payhistory&view=");
106 }
107 ?>
108
109 <?php if (!isset($_GET['view']) && !isset($_GET['pay'])): ?>
110 <div id="tax_receipts" style="margin-top:40px;">
111 <h3>T2202a Receipts</h3>
112 <table cellpadding="0" cellspacing="0" border="0">
113 <tbody>
114
115 <?php
116
117 $t2202a = get_user_meta($_GET['uid'], 't2202a', true);
118 if ( empty ($t2202a) ) {
119 echo '<tr><td colspan="2">No t2202a\'s available.</td></tr>';
120 } else {
121 foreach ($t2202a as $year => $file) {
122 ?>
123 <tr>
124 <td width="120"><strong><?php echo $year; ?></strong></td>
125 <td><a href="<?php echo "/wp-content/uploads/t2202a/".$file; ?>">Download 2010 <?php echo ucwords(strtolower('TUITION, EDUCATION, AND TEXTBOOK AMOUNTS CERTIFICATE'));?></a></td>
126 </tr>
127 <?php
128 }
129 }
130 ?>
131 </tbody>
132 </table>
133 </div>
134 <?php endif; ?>
135
136
137
138
139 </div>
140 <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
141 <script type="text/javascript">
142 jQuery(document).ready(function($) {
143
144
145
146 $('#invoice-table').dataTable({
147 "sPaginationType": "full_numbers"
148 , "bFilter": false
149 , "bLengthChange": false
150 , "aaSorting": [[ 0, "desc" ]]
151 , "iDisplayLength": 20
152 , "oLanguage": {
153 "sZeroRecords": "No matching records found"
154 , "sEmptyTable": "No invoices/receipts available"
155 , "sInfo": "Showing _START_ to _END_ of _TOTAL_ invoices/receipts"
156 , "sInfoEmpty": "Showing 0 to 0 of 0 invoices/receipts"
157 , "sInfoFiltered": "(filtered from _MAX_ total invoices/receipts)"
158 }
159 });
160
161
162 });
163 </script>
1 <?php
2 namespace Tz\WordPress\Tools\UserManager;
3
4 use Tz, Tz\Common;
5 use Tz\WordPress\CBV;
6 use Tz\WordPress\CBV\User;
7 use Tz\WordPress\CBV\CEHours;
8 use Tz\WordPress\CBV\Events;
9 use Tz\WordPress\UAM;
10 use Tz\WordPress\Tools\HTML;
11
12 use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
13 use Tz\WordPress\Tools\Notifications;
14
15 use Exception, StdClass;
16 use WP_User;
17
18 $user = new WP_User($_GET['uid']);
19
20 Tools\import('HTML');
21
22
23
24 $profile_preference = get_user_meta($user->ID, 'profile_preference', true);
25 $preference = get_user_meta($user->ID, 'email_address_preference', true);
26
27 ?>
28 <div style="padding:10px 10px 0px 10px; min-width:800px;" class="my-profile-edit">
29 <h2 style="margin-bottom:10px;padding-bottom:0px;">Users' Profile...</h2>
30 <form name="admin-edit-user-profile" id="admin-edit-user-profile" style="margin-top:0;padding-top:0;">
31 <input type="hidden" name="section" value="profile" />
32 <input type="hidden" name="uid" value="<?php echo $user->ID;?>" />
33 <div style="float:left; width:400px;margin-right:20px;">
34
35 <h4>Personal Information</h4>
36 <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
37 <tbody>
38 <tr>
39 <th width="150">Prefix:</th>
40 <td>
41 <select name="prefix">
42 <?php HTML\select_opts_prefixes(get_user_meta($_GET['uid'], 'prefix', true)); ?>
43 </select>
44 </td>
45 </tr>
46 <tr>
47 <th width="150">First Name:</th>
48 <td><input type="text" name="first_name" value="<?php echo get_user_meta($_GET['uid'], 'first_name', true);?>" /></td>
49 </tr>
50 <tr>
51 <th>Middle Name:</th>
52 <td><input type="text" name="initial" value="<?php echo get_user_meta($_GET['uid'], 'initial', true);?>" /></td>
53 </tr>
54 <tr>
55 <th>Last Name:</th>
56 <td><input type="text" name="last_name" value="<?php echo get_user_meta($_GET['uid'], 'last_name', true);?>" /></td>
57 </tr>
58 <tr>
59 <th>Degrees:</th>
60 <td><input type="text" name="degrees" value="<?php echo get_user_meta($_GET['uid'], 'degrees', true);?>" /></td>
61 </tr>
62 <tr>
63 <th>Designations:</th>
64 <td><input type="text" name="designations" value="<?php echo get_user_meta($_GET['uid'], 'designations', true);?>" /></td>
65 </tr>
66 <tr>
67 <th>Biography:</th>
68 <td><textarea name="description"><?php echo get_user_meta($_GET['uid'], 'description', true);?></textarea></td>
69 </tr>
70 <tr>
71 <th>Date of Birth:<br /><span style="font-size:10px;color:#999;font-weight:normal;">(Ex. YYYY-MM-DD)</span></th>
72 <td><input type="text" name="date_of_birth" class="datepicker" value="<?php echo get_user_meta($_GET['uid'], 'date_of_birth', true);?>" rel="mask-birthdate" /></td>
73 </tr>
74 </tbody>
75 </table>
76
77 <h4>Notification Settings</h4>
78 <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
79 <tbody>
80 <tr>
81 <th width="150">Email for Notifications:</th>
82 <td>
83 <select name="email_address_preference">
84 <?php
85 $preference = get_user_meta($_GET['uid'], 'email_address_preference',true);
86 $home_email = get_user_meta($_GET['uid'],'home_email',true);
87 $work_email = get_user_meta($_GET['uid'],'work_email',true);
88 ?>
89 <option value="none" <?php echo ($preference=="none") ? "selected" : "";?>>None</option>
90 <?php if(!empty($home_email)):?><option value="Home" <?php echo ($preference=="Home") ? "selected" : "";?>>Home > <?php echo $home_email;?></option><?php endif;?>
91 <?php if(!empty($work_email)):?><option value="Work"<?php echo ($preference=="Work") ? "selected" : "";?>>Work > <?php echo $work_email;?></option><?php endif;?>
92 </select>
93 </td>
94 </tr>
95 </tbody>
96 </table>
97
98 <?php if ($role=="member") :?>
99 <h4>Membership</h4>
100 <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
101 <tbody>
102 <tr>
103 <th width="150">Member Since:</th>
104 <td><input type="text" name="member_since" value="<?php echo get_user_meta($_GET['uid'], 'member_since', true);?>" /></td>
105 </tr>
106 </tbody>
107 </table>
108 <?php endif;?>
109
110
111
112
113 </div>
114
115
116 <div style="float:left; width:350px;"> <!-- RIGHT SIDE -->
117
118 <h4>Home Contact Information</h4>
119 <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
120 <tbody>
121 <tr>
122 <td colspan="2"><input type="radio" name="profile_preference" value="Home" <?php echo (get_user_meta($_GET['uid'], 'profile_preference', true) == "Home") ? "checked='checked'" : ""; ?> />&nbsp;<em>Preferred</em> contact method.</td>
123 </tr>
124 <tr><td colspan="2">&nbsp;</td></tr>
125 <tr>
126 <th>Address:</th>
127 <td><input type="text" name="home_address" value="<?php echo get_user_meta($_GET['uid'], 'home_address', true);?>" /></td>
128 </tr>
129 <tr>
130 <th>Suite:</th>
131 <td><input type="text" name="home_address2" value="<?php echo get_user_meta($_GET['uid'], 'home_address2', true);?>" /></td>
132 </tr>
133 <tr>
134 <th>City:</th>
135 <td><input type="text" name="home_city" value="<?php echo get_user_meta($_GET['uid'], 'home_city', true);?>" /></td>
136 </tr>
137 <tr>
138 <th>Country:</th>
139 <td><?php echo HTML\form_dropdown('home_country', HTML\Vars::$countries, get_user_meta($_GET['uid'], 'home_country', true), "id='home_country'"); ?></td>
140 </tr>
141 <tr>
142 <th>State/Province:</th>
143 <td><?php echo HTML\form_linked_dropdown('home_province', 'home_country', HTML\Vars::$provinces,get_user_meta($_GET['uid'], 'home_country', true), get_user_meta($_GET['uid'], 'home_province', true)); ?></td>
144 </tr>
145 <tr>
146 <th>Postal:</th>
147 <td><input type="text" name="home_postal" value="<?php echo get_user_meta($_GET['uid'], 'home_postal', true); ?>" /></td>
148 </tr>
149
150 <tr>
151 <th>Phone:</th>
152 <td><input type="text" name="home_phone" value="<?php echo get_user_meta($_GET['uid'], 'home_phone', true);?>" rel="mask-phone" /></td>
153 </tr>
154 <tr>
155 <th>Email:</th>
156 <td><input type="text" name="home_email" value="<?php echo get_user_meta($_GET['uid'], 'home_email', true);?>" /></td>
157 </tr>
158 <tr>
159 <th>Mobile:</th>
160 <td><input type="text" name="home_mobile" value="<?php echo get_user_meta($_GET['uid'], 'home_mobile', true);?>" rel="mask-phone" /></td>
161 </tr>
162 </tbody>
163 </table>
164
165 <h4>Work Contact Information</h4>
166 <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
167 <tbody>
168 <tr>
169 <td colspan="2"><input type="radio" name="profile_preference" value="Work" <?php echo (get_user_meta($_GET['uid'], 'profile_preference', true) == "Work") ? "checked='checked'" : ""; ?> />&nbsp;<em>Preferred</em> contact method.</td>
170 </tr>
171 <tr><td colspan="2">&nbsp;</td></tr>
172 <tr class="work-only">
173 <th>Company:</th>
174 <td><input type="text" name="company" value="<?php echo get_user_meta($_GET['uid'], 'company', true);?>" /></td>
175 </tr>
176 <tr class="work-only">
177 <th>Company Type:</th>
178 <td><?php echo HTML\form_dropdown('company_type', HTML\Vars::$company_types, get_user_meta($_GET['uid'], 'company_type', true), "id='company_type'"); ?></td>
179 </tr>
180 <tr class="work-only">
181 <th>Title:</th>
182 <td><input type="text" name="title" value="<?php echo get_user_meta($_GET['uid'], 'title', true);?>" /></td>
183 </tr>
184 <tr>
185 <th>Address:</th>
186 <td><input type="text" name="work_address" value="<?php echo get_user_meta($_GET['uid'], 'work_address', true);?>" /></td>
187 </tr>
188 <tr>
189 <th>Suite:</th>
190 <td><input type="text" name="work_address2" value="<?php echo get_user_meta($_GET['uid'], 'work_address2', true);?>" /></td>
191 </tr>
192 <tr>
193 <th>City:</th>
194 <td><input type="text" name="work_city" value="<?php echo get_user_meta($_GET['uid'], 'work_city', true);?>" /></td>
195 </tr>
196 <tr>
197 <th>Country:</th>
198 <td><?php echo HTML\form_dropdown('work_country', HTML\Vars::$countries, get_user_meta($_GET['uid'], 'work_country', true), "id='work_country'"); ?></td>
199 </tr>
200 <tr>
201 <th>State/Province:</th>
202 <td><?php echo HTML\form_linked_dropdown('work_province', 'work_country', HTML\Vars::$provinces,get_user_meta($_GET['uid'], 'work_country', true), get_user_meta($_GET['uid'], 'work_province', true)); ?></td>
203 </tr>
204
205 <tr>
206 <th>Postal:</th>
207 <td><input type="text" name="work_postal" value="<?php echo get_user_meta($_GET['uid'], 'work_postal', true); ?>" /></td>
208 </tr>
209
210 <tr>
211 <th>Phone:</th>
212 <td><input type="text" name="work_phone" value="<?php echo get_user_meta($_GET['uid'], 'work_phone', true);?>" rel="mask-phone" />
213 &nbsp;Ext. <input style="width:40px;" type="text" name="work_extension" value="<?php echo get_user_meta($_GET['uid'], 'work_extension', true);?>" rel="mask-phone" /></td>
214 </tr>
215 <tr>
216 <th>Fax:</th>
217 <td><input type="text" name="work_fax" value="<?php echo get_user_meta($_GET['uid'], 'work_fax', true);?>" rel="mask-phone" /></td>
218 </tr>
219 <tr>
220 <th>Email:</th>
221 <td><input type="text" name="work_email" value="<?php echo get_user_meta($_GET['uid'], 'work_email', true);?>" /></td>
222 </tr>
223 <tr>
224 <th>Mobile:</th>
225 <td><input type="text" name="work_mobile" value="<?php echo get_user_meta($_GET['uid'], 'work_mobile', true);?>" rel="mask-phone" /></td>
226 </tr>
227 <tr class="work-only">
228 <th>Website:</th>
229 <td><input type="text" name="website" value="<?php echo get_user_meta($_GET['uid'], 'website', true);?>" /></td>
230 </tr>
231 </tbody>
232 </table>
233
234 </div>
235
236
237
238 <div style="clear:both;"></div>
239 <div class="validation-errors" style="display:none;"><div class="error-wrap"><h6>OOPS...</h6><ul></ul></div></div>
240 <br />
241 <input type="submit" value="Update Profile" /><span class="update-placeholder"></span>
242
243
244 </form>
245 </div>
246 <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
247 <script src="<?php echo Tools\url('../');?>"></script>
248 <script>
249 jQuery(function($) {
250 //$('input[rel="mask-phone"]').mask("999-999-9999");
251 $('input[rel="mask-birthdate"]').mask("9999-99-99");
252 /*
253 update_listing_preference();
254
255
256 jQuery('#profile_preference').change(function() {
257 update_listing_preference();
258 });
259 */
260 });
261 </script>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\UserManager;
3
4 use Tz, Tz\Common;
5 use Tz\WordPress\CBV;
6 use Tz\WordPress\CBV\User;
7 use Tz\WordPress\UAM;
8 use Tz\WordPress\Tools;
9 use Tz\WordPress\Tools\Auth;
10 use Exception, StdClass;
11 use WP_User;
12
13 global $wpdb;
14
15 // Get the original timezone (so we can set it back) and figure out the
16 // timestamp for March 1 UTC
17 $original_timezone = date_default_timezone_get();
18 date_default_timezone_set('UTC');
19 $begin_date = strtotime('March 1');
20 // Set the timezone back to original setting
21 date_default_timezone_set($original_timezone);
22
23 if (! empty($_POST['do_fix']) && $_POST['do_fix'] == 'y') {
24 $count_result = mysql_query("SELECT COUNT(*) FROM `{$wpdb->users}`", $wpdb->dbh);
25 list($num) = mysql_fetch_row($count_result);
26 $max = 1000;
27
28 for ($ui = 0; $ui < $num; $ui += $max) {
29 $users = $wpdb->get_results("SELECT `ID` FROM `{$wpdb->users}` LIMIT {$ui}, {$max}");
30 foreach ($users as $user) {
31 $invoices = get_user_meta($user->ID, 'invoices', TRUE);
32 foreach ($invoices as $invoice_id) {
33 // Get the transaction status
34 $trans_status = get_post_meta($invoice_id, 'trans_status', TRUE);
35 // Don't do anything unless the status is 'unpaid'
36 if ($trans_status != 'unpaid') {
37 continue;
38 }
39 // Get the invoice and check if it's newer than March 1 UTC
40 $invoice = get_post($invoice_id);
41 if (strtotime($invoice->post_date) < $begin_date) {
42 continue;
43 }
44
45 // Here's the heavy work: get the payment data and add appropriate taxes
46 $payment = get_post_meta($invoice_id, 'payment', TRUE);
47 $trans_amount = get_post_meta($invoice_id, 'trans_amount', TRUE);
48
49 $pp = get_user_meta($user->ID, 'profile_preference', true);
50 // Get the user's profile preference and use it to get the tax percent
51 if (!empty($pp)) {
52 $preference = strtolower($pp) . '_province';
53 $tax_percent = getTaxesByProvince(get_user_meta($user->ID, $preference, true)) * .01;
54 } else {
55 $tax_percent = getTaxesByProvince($payment['bt_province']) * .01;
56 }
57
58 $payment['total_taxes'] = $payment['total_cost'] * $tax_percent;
59 $payment['total'] = number_format($payment['total_cost'] - $payment['total_discounts'] + $payment['total_taxes'], 2);
60 $trans_amount = $payment['total'];
61
62 // Now update the post
63 update_post_meta($invoice_id, 'payment', $payment);
64 update_post_meta($invoice_id, 'trans_amount', $trans_amount);
65 }
66 }
67 unset($users, $invoices);
68 }
69 }
70
71 ?>
72 <style>
73
74 h4 {
75 float: left;
76 padding-right: 1em;
77 }
78
79 .merge-users {
80 float: left;
81 padding-right: 2em;
82 }
83
84 .merge-users label {
85 float: left;
86 font-weight: bold;
87 padding-right: 1em;
88 }
89
90 .merge-users input {
91 float: left;
92 }
93
94 .clear {
95 float: left;
96 clear: both;
97 }
98
99 .user-list, .user-list li {
100 float: left;
101 clear: both;
102 }
103
104 .changed {
105 margin-top: 5px;
106 clear: both;
107 display: none;
108 }
109
110 .changed h6 {
111 padding: 0px;
112 margin: 0px 0px 10px 0px;
113 font-size: 11px;
114 text-transform: uppercase;
115 }
116
117 .changed ul {
118 margin: 0;
119 padding: 0;
120 }
121
122 .changed ul li {
123 margin: 0px 0px 3px 0px;
124 padding: 0px;
125 font-size: 11px;
126 background: none;
127 }
128 .merge-table td { padding:10px;}
129 </style>
130
131 <div class="wrap">
132
133 <div id="icon-users" class="icon32"><br /></div>
134 <h2>Fix Unpaid Invoices</h2>
135
136 <div class="validation-errors" style="display:none; margin: 10px 0px 10px;">
137 <div class="error-wrap">
138 <ul></ul>
139 </div>
140 </div>
141
142 <div id="post-body" style="padding:10px 0px 15px 0px;">
143 <form method="post" id="fix_unpaid_invoices">
144 <!--<table cellspacing="0" class="widefat post fixed merge-table">
145 <thead>
146 <tr>
147 <th width="50%"><label for="search_user_from">Merge <strong><em>FROM</em></strong> User:</label></th>
148 <th width="50%"><label for="search_user_to">Merge <strong><em>TO</em></strong> User:</label></th>
149 </tr>
150 </thead>
151 <tbody>
152 <tr>
153 <td>
154 <div class="merge-users">
155 <input class="clear" type="text" name="search_user_from" value="<?php echo $_POST['search_user_from'] ?>" />
156 <input type="button" name="btn_user_from" value="Search" />&nbsp;<img id="search_user_from_spinner" class="spinners" src="/wp-content/tz-tools/com/Branding/images/spinner.gif" style="display:none;" />
157
158 </div>
159 </td>
160 <td>
161 <div class="merge-users">
162 <input class="clear" type="text" name="search_user_to" value="<?php echo $_POST['search_user_to'] ?>" />
163 <input type="button" name="btn_user_to" value="Search" />&nbsp;<img id="search_user_to_spinner" class="spinners" src="/wp-content/tz-tools/com/Branding/images/spinner.gif" style="display:none;" />
164 </div>
165 </td>
166 </tr>
167 <tr>
168 <td><div id="user-list-from"></div></td>
169 <td><div id="user-list-to"></div></td>
170 </tr>
171 </tbody>
172 </table>-->
173
174 <div id="field-list" class="changed">
175 <table cellspacing="0" class="widefat post fixed merge-table"></table>
176 </div>
177
178 <div style="clear:both;"></div>
179
180 <div style="margin-top:10px;">
181 <input type="hidden" name="do_fix" value="y" />
182 <input type="submit" value="Do It" />
183 </div>
184
185 </form>
186
187 </div>
188
189 </div>
1 <?php
2 namespace Tz\WordPress\Tools\UserManager;
3
4 use Tz, Tz\Common;
5 use Tz\WordPress\CBV;
6 use Tz\WordPress\CBV\User;
7 use Tz\WordPress\UAM;
8 use Tz\WordPress\Tools;
9 use Tz\WordPress\Tools\Auth;
10 use Exception, StdClass;
11 use WP_User;
12
13 // Make sure some defaults are set because we use these values as is in the input boxes
14 if (! isset($_POST['search_user_from'])) {
15 $_POST['search_user_from'] = '';
16 }
17 if (! isset($_POST['search_user_to'])) {
18 $_POST['search_user_to'] = '';
19 }
20
21 ?>
22 <style>
23
24
25
26 h4 {
27 float: left;
28 padding-right: 1em;
29 }
30
31 .merge-users {
32 float: left;
33 padding-right: 2em;
34 }
35
36 .merge-users label {
37 float: left;
38 font-weight: bold;
39 padding-right: 1em;
40 }
41
42 .merge-users input {
43 float: left;
44 }
45
46 .clear {
47 float: left;
48 clear: both;
49 }
50
51 .user-list, .user-list li {
52 float: left;
53 clear: both;
54 }
55
56 .changed {
57 margin-top: 5px;
58 clear: both;
59 display: none;
60 }
61
62 .changed h6 {
63 padding: 0px;
64 margin: 0px 0px 10px 0px;
65 font-size: 11px;
66 text-transform: uppercase;
67 }
68
69 .changed ul {
70 margin: 0;
71 padding: 0;
72 }
73
74 .changed ul li {
75 margin: 0px 0px 3px 0px;
76 padding: 0px;
77 font-size: 11px;
78 background: none;
79 }
80 .merge-table td { padding:10px;}
81 </style>
82
83 <div class="wrap">
84
85 <div id="icon-users" class="icon32"><br /></div>
86 <h2>Merge CBV Users...</h2>
87
88 <div class="validation-errors" style="display:none; margin: 10px 0px 10px;">
89 <div class="error-wrap">
90 <ul></ul>
91 </div>
92 </div>
93
94 <div id="post-body" style="padding:10px 0px 15px 0px;">
95 <form method="post" id="admin-search-merge-form">
96 <table cellspacing="0" class="widefat post fixed merge-table">
97 <thead>
98 <tr>
99 <th width="50%"><label for="search_user_from">Merge <strong><em>FROM</em></strong> User:</label></th>
100 <th width="50%"><label for="search_user_to">Merge <strong><em>TO</em></strong> User:</label></th>
101 </tr>
102 </thead>
103 <tbody>
104 <tr>
105 <td>
106 <div class="merge-users">
107 <input class="clear" type="text" name="search_user_from" value="<?php echo $_POST['search_user_from'] ?>" />
108 <input type="button" name="btn_user_from" value="Search" />&nbsp;<img id="search_user_from_spinner" class="spinners" src="/wp-content/tz-tools/com/Branding/images/spinner.gif" style="display:none;" />
109
110 </div>
111 </td>
112 <td>
113 <div class="merge-users">
114 <input class="clear" type="text" name="search_user_to" value="<?php echo $_POST['search_user_to'] ?>" />
115 <input type="button" name="btn_user_to" value="Search" />&nbsp;<img id="search_user_to_spinner" class="spinners" src="/wp-content/tz-tools/com/Branding/images/spinner.gif" style="display:none;" />
116 </div>
117 </td>
118 </tr>
119 <tr>
120 <td><div id="user-list-from"></div></td>
121 <td><div id="user-list-to"></div></td>
122 </tr>
123 </tbody>
124 </table>
125
126 <div id="field-list" class="changed">
127 <table cellspacing="0" class="widefat post fixed merge-table"></table>
128 </div>
129
130 <div style="clear:both;"></div>
131
132 <div style="margin-top:10px;">
133 <input type="hidden" value="from" name="which_user_search" />
134 <input type="hidden" value="no" name="do_search" />
135 <input type="hidden" value="no" name="do_merge" />
136 <input type="button" value="Merge Users" name="btn_merge" />
137 </div>
138
139 </form>
140
141 </div>
142
143 </div>
144
145 <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
146 <script type="text/javascript">
147 var $ = jQuery;
148 var $which_user_search = $('[name=which_user_search]');
149 var $do_search = $('[name=do_search]');
150 var $do_merge = $('[name=do_merge]');
151 var $form = $('#admin-search-merge-form');
152 var $field_list = $('#field-list');
153 var $error_container = $('.validation-errors');
154
155 var $from_spinner = $('#search_user_from_spinner');
156 var $to_spinner = $('#search_user_to_spinner');
157
158 $('[name=btn_user_from]').click(function() {
159 $from_spinner.show();
160 $which_user_search.val("from");
161 $do_search.val("yes");
162 $form.submit();
163 });
164
165 $('[name=btn_user_to]').click(function() {
166 $to_spinner.show();
167 $which_user_search.val("to");
168 $do_search.val("yes");
169 $form.submit();
170 });
171
172 $('[name=btn_merge]').click(function() {
173 $do_search.val("no");
174 $do_merge.val("yes");
175
176 if (confirm('Are you sure you want to merge users? This action is NOT reversible!')) {
177 $form.submit();
178 }
179 });
180
181 $(function() {
182
183 var options = {
184 url: ajaxurl,
185 dataType: 'json',
186 type: 'post',
187 data: ({ajax:"yes", action: 'admin_search_merge_users'}),
188 success: function(data) {
189 $('.spinners').hide();
190 if (data.success == "false") {
191 $('h6', $error_container).html("OOPS...");
192 $('ul', $error_container).html(data.msg);
193 $field_list.hide();
194 $error_container.show();
195 } else {
196 $error_container.hide();
197 if (data.fields === undefined) {
198 $('#user-list-' + data.direction).html(data.html);
199 $field_list.hide();
200 } else {
201 $('#user-list-from').html("");
202 $('#user-list-to').html("");
203 $('table', $field_list).html(data.fields);
204 $field_list.show();
205 }
206 }
207 }
208 };
209 $form.ajaxForm(options);
210
211 });
212
213 </script>
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
8 <title>Edit CE Hours</title>
9 <style type="text/css">
10
11 html, body { margin:0px; padding:0;}
12 .title-link {
13 color:#f7bd55;
14 font-size: 12px;
15 font-weight: bold;
16 text-align: left;
17 line-height: 1.75em;
18 background: #3b0d32;
19 border: solid 1px #FFF;
20 border-bottom: solid 1px #999;
21 cursor: default;
22 padding: 0em; padding:3px 10px 3px 10px;
23 margin: 0em;
24
25 }
26
27
28 form {
29 display: block;
30 margin-right:20px;
31 }
32
33 .dashboard-section-title { font-weight:bold; color:#3b0d32; }
34 </style>
35 </head>
36
37 <body>
38
39 <div style="display:block; width:750px; margin-bottom:10px;">
40
41 <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;">Edit <?php echo $name; ?>'s CE Hours:</div>
42
43 <form method="post" action="" id="edit-cehours-form">
44 <input type="hidden" name="uid" value="<?php echo $uid; ?>" />
45 <input type="hidden" name="indexed" value="<?php echo $indexed; ?>" />
46 <input type="hidden" name="action" value="<?php echo $action; ?>" />
47
48
49 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
50 <div class="dashboard-section-links"></div>
51 <div class="dashboard-section-content small">
52 <table class="clean no-left-padding">
53 <tbody>
54 <tr class="top-td">
55 <td width="140"><select style="width:120px;" name="type"><option value="structured" <?php echo ($type=="structured") ? "selected" : ""; ?>>Structured</option><option value="unstructured" <?php echo ($type=="unstructured") ? "selected" : ""; ?>>Unstructured</option></select></td>
56 <th>Date:</th>
57 <td width="150"><input type="text" name="date" readonly class="datepicker" style="width:120px;" value="<?php echo $date;?>" /></td>
58 <th>Activity Type:</th>
59 <td><select style="width:120px;" name="subtype" class="subtype" id="subtype"><option value="none" <?php echo ($subtype=="") ? "selected" : ""?>>Non Specific</option><option value="event" <?php echo ($subtype=="event") ? "selected" : ""?>>External Event</option><option value="lump" <?php echo ($subtype=="lump") ? "selected" : ""?>>Lump Sum</option><option value="compliance" <?php echo ($subtype=="compliance") ? "selected" : ""?>>Compliance</option></select></td>
60 <th>Hours:</th>
61 <td style="width:50px;"><input type="text" name="hours" style="width:45px;" maxlength="4" value="<?php echo $hours;?>" /></td>
62 </tr>
63 <tr class="activity_row bottom-border-td">
64 <th colspan="7" style="text-align:left;"><label style="padding-right:10px;">Activity:</label><input type="text" name="activity" style="width:450px;" value="<?php echo $activity;?>" /></th>
65 </tr>
66 <tr>
67 <td colspan="7"><div><input type="submit" value="Apply" /></div></td>
68 </tr>
69 </tbody>
70 </table>
71
72 </div>
73 </div>
74
75
76 </form>
77 </div>
78
79 <script type="text/javascript">
80 var $ = jQuery;
81
82 function updateCEType(obj) {
83 var $selectbox = $(obj);
84 var $table = $(obj).parent().parent().parent();
85 var $activity_row = $('tr.activity_row', $table);
86
87 switch($selectbox.val()) {
88 case 'event':
89 var r = '<th colspan="7" style="text-align:left;"><label style="padding-right:10px;">Activity:</label><input type="text" name="activity" style="width:200px;" value="<?php echo $activity;?>" />&nbsp;&nbsp;<label style="padding-right:10px;">Institution:</label><input type="text" name="institution" style="width:200px;" value="<?php echo $institute;?>" />&nbsp;&nbsp;<input type="checkbox" name="attended" value="on" <?php echo ($attended=="yes") ? 'checked="checked"' : ''; ?> />&nbsp;They Attended</th>';
90 break;
91 case 'lump':
92 var r = '<th colspan="7" style="text-align:left;"><input type="hidden" name="activity" style="width:450px;" value="Lump Sum Entry" />For the date, choose any date within the year for which you are reporting.</th>';
93 break;
94 default:
95 var r = '<th colspan="7" style="text-align:left;"><label style="padding-right:10px;">Activity:</label><input type="text" name="activity" style="width:450px;" value="<?php echo $activity;?>" /></th>';
96 }
97
98 $activity_row.html(r);
99 }
100
101
102 jQuery(function($) {
103 $('.subtype').live('change', function() {
104 updateCEType(this);
105 });
106
107 updateCEType($('.subtype'));
108
109 });
110
111 </script>
112
113 </body>
114 </html>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 $enrolments = $course->getEnrolments($user->ID);
3 ?>
4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
7 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
8 <head>
9 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
10
11 <title>Edit Course</title>
12 <style type="text/css">
13
14 html, body { margin:0px; padding:0;}
15 .title-link {
16 color:#f7bd55;
17 font-size: 12px;
18 font-weight: bold;
19 text-align: left;
20 line-height: 1.75em;
21 background: #3b0d32;
22 border: solid 1px #FFF;
23 border-bottom: solid 1px #999;
24 cursor: default;
25 padding: 0em; padding:3px 10px 3px 10px;
26 margin: 0em;
27 }
28
29 form {
30 display: block;
31 margin-right:20px;
32 }
33
34 .dashboard-section-title { font-weight:bold; color:#3b0d32; }
35 </style>
36 </head>
37
38 <body>
39 <form method="post" id="edit-course-form">
40 <input type="hidden" name="course_id" value="<?php echo $course->getID(); ?>" />
41 <input type="hidden" name="user_id" value="<?php echo $user->ID; ?>" />
42
43 <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 $course->post_title;?></div>
44
45 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
46 <div class="dashboard-section-title">HOW TO PROCESS THE REGISTRATION:</div>
47 <div class="dashboard-section-links"></div>
48 <div class="dashboard-section-content small">
49 <select name="paid_by">
50 <?php /*
51 <option value="unpaid">Invoice User</option>
52 <option value="complementary">Complementary</option>
53 */ ?>
54 <option value="visa">Paid by Prepaid Visa</option>
55 <option value="mc">Paid by Prepaid Mastercard</option>
56 <option value="amex">Paid by Prepaid American Express</option>
57 <option value="cheque">Paid by Cheque</option>
58 </select>
59 </div>
60 </div>
61
62 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
63 <div class="dashboard-section-title">ENROLMENT TYPE</div>
64 <div class="dashboard-section-links"></div>
65 <div class="dashboard-section-content small">
66 <select name="enrolltype">
67 <?php foreach ($enrolments as $key => $display): ?>
68 <option value="<?php echo $key; ?>"><?php echo $display; ?></option>
69 <?php endforeach; ?>
70 </select>
71 </div>
72 </div>
73
74 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
75 <div class="dashboard-section-title">
76 <input type="checkbox" name="exam" id="exam" value="1" checked />
77 <label for="exam">WRITING EXAM?</label>
78 </div>
79 </div>
80
81 <?php if ($user->isStudentFeeDue()): ?>
82 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
83 <div class="dashboard-section-title">
84 <input type="checkbox" name="studentfee" id="studentfee" value="1" checked />
85 <label for="studentfee">PAID ANNUAL REGISTRATION FEE?</label>
86 </div>
87 </div>
88 <?php endif; ?>
89
90 <?php if (!$user->isMemberOf('Casebook')): ?>
91 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
92 <div class="dashboard-section-title">
93 <input type="checkbox" name="casebook" id="casebook" value="1" checked />
94 <label for="casebook">PURCHASED CASEBOOK?</label>
95 </div>
96 </div>
97 <?php endif; ?>
98
99 <?php if ($user->isOverseas()): ?>
100 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
101 <div class="dashboard-section-title">
102 <input type="checkbox" name="overseas" id="overseas" value="1" checked />
103 <label for="overseas">PAID OVERSEAS SURCHARGE?</label>
104 </div>
105 </div>
106 <?php endif; ?>
107
108 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
109 <div class="dashboard-section-title"></div>
110 <div class="dashboard-section-links"></div>
111 <div class="dashboard-section-content small">
112 <div><input type="submit" value="Register" /></div>
113 </div>
114 </div>
115
116 </body>
117 </html>
...\ No newline at end of file ...\ No newline at end of file
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
8 <title>Edit Event</title>
9 <style type="text/css">
10
11 html, body { margin:0px; padding:0;}
12 .title-link {
13 color:#f7bd55;
14 font-size: 12px;
15 font-weight: bold;
16 text-align: left;
17 line-height: 1.75em;
18 background: #3b0d32;
19 border: solid 1px #FFF;
20 border-bottom: solid 1px #999;
21 cursor: default;
22 padding: 0em; padding:3px 10px 3px 10px;
23 margin: 0em;
24 }
25
26 form {
27 display: block;
28 margin-right:20px;
29 }
30
31 .dashboard-section-title { font-weight:bold; color:#3b0d32; }
32 </style>
33 </head>
34
35 <body>
36
37 <div style="width: 760px;">
38
39 <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;">Admin Event Registration: <?php echo $post->post_title;?></div>
40
41 <div style="padding: 10px 0px 10px 10px; width:350px; float:left;">
42 <table class="small-table">
43
44 <?php
45 // get categories....
46 $event_term_slugs = array();
47 $terms = get_the_terms($post->ID,'event_type');
48
49 $external_only = false;
50 if (!empty($terms)) {
51 foreach($terms as $types) {
52 $event_term_slugs[$types->slug] = $types->name;
53 }
54 }
55
56 $location = get_post_meta($post->ID, 'location', true);
57
58 $cost = get_post_meta($post->ID,'cost',true);
59
60 if ( ($cost == "0" || $cost == "0.00" || strtolower($cost) == "free") && !$external_only ) {
61 $purchasable = false;
62 $cost = "FREE";
63 } elseif ( (!empty($cost) && (int) $cost < 1) && !$external_only ) {
64 $purchasable = false;
65 $cost = $cost;
66 } elseif ( (empty($cost) && (int) $cost < 1) && !$external_only ) {
67 $purchasable = false;
68 $cost = $cost;
69 } elseif ($external_only) {
70
71 $purchasable = false;
72
73 } else {
74 $cost = (int) $cost;
75 $cost = str_replace(",","",$cost);
76 $purchasable = true;
77 }
78
79 ?>
80
81 <tr>
82 <td width="140"><strong>Event Type</strong></td>
83 <td>
84 <?php
85 foreach($terms as $term) {
86 echo $term->name.'<br />';
87 }
88 ?>
89 </td>
90 </tr>
91 <?php if (!empty($location)):?>
92 <tr>
93 <td><strong>Location</strong></td>
94 <td><?php echo $location; ?></td>
95 </tr>
96 <?php endif; ?>
97 <tr>
98 <td><strong>When</strong></td>
99 <td>
100 <?php
101
102 $event_date = get_post_meta($post->ID, 'event_date', true);
103 $event_date_end = get_post_meta($post->ID, 'event_date_end', true);
104
105 if ( empty($event_date_end) ) {
106 echo date("M j, Y",$event_date);
107 } else {
108 $start_month = date("M", $event_date);
109 $start_day = date("d", $event_date);
110 $start_year = date("Y", $event_date);
111
112 $end_month = date("M", $event_date_end);
113 $end_day = date("d", $event_date_end);
114 $end_year = date("Y", $event_date_end);
115
116 // format: April 3-7, 2011
117 if ($start_month == $end_month && $start_year == $end_year) {
118 echo $start_month." ".$start_day."-".$end_day.", ".$start_year;
119 } elseif ($start_month != $end_month && $start_year == $end_year) {
120 echo $start_month." ".$start_day." - ".$end_month." ".$end_day.", ".$start_year;
121 } else {
122 // format: April 3 - May 2, 2011
123 echo $start_month." ".$start_day.", ".$start_year." - ".$end_month." ".$end_day.", ".$start_year;
124 }
125
126
127 }
128
129 ?>
130 </td>
131 </tr>
132 <tr>
133 <td><strong>Cost</strong></td>
134 <td><?php echo ($purchasable) ? "$".number_format($cost,2) : $cost; ?></td>
135 </tr>
136 <tr>
137 <td><strong>Stud./Mem. Discount</strong></td>
138 <td><?php echo (!empty($member_discount)) ? "$".number_format($member_discount,2) : "<em>None</em>";?></td>
139 </tr>
140 <tr>
141 <td><strong>Earlybird Discount</strong></td>
142 <td><?php echo (!empty($early_bird_discount)) ? "$".number_format($early_bird_discount,2) : "<em>None</em>";?></td>
143 </tr>
144 <?php if (!empty($early_bird_deadline) && !empty($early_bird_discount)): ?>
145 <tr>
146 <td><strong>Earlybird Deadline</strong></td>
147 <td><?php echo date("M d, Y",$early_bird_deadline); ?></td>
148 </tr>
149 <?php endif; ?>
150
151 </table>
152 </div>
153
154 <div style="padding: 0px 0px 10px 0px; width:380px; float:right;">
155 <?php
156 $extras = $user_event_meta['extras'];
157 ?>
158
159 <form method="post" action="" id="edit-event-form">
160
161 <input type="hidden" name="uid" value="<?php echo $uid; ?>" />
162 <input type="hidden" name="event_id" value="<?php echo $post->ID; ?>" />
163 <input type="hidden" name="type" value="<?php echo $action; ?>" />
164
165 <?php if ($action != "edit"): ?>
166 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
167 <div class="dashboard-section-title">HOW TO PROCESS THE REGISTRATION:</div>
168 <div class="dashboard-section-links"></div>
169 <div class="dashboard-section-content small">
170 <select name="status">
171 <option value="unpaid" <?php echo ($user_event_meta['status']=="unpaid") ? "selected" : ""; ?>>Invoice User</option>
172 <option value="complementary" <?php echo ($user_event_meta['status']=="complementary") ? "selected" : ""; ?>>Complementary</option>
173 <option value="visa" <?php echo ($user_event_meta['status']=="paid" && $user_event_meta['extras']['paid_by']=="visa") ? "selected" : ""; ?>>Paid by Prepaid Visa</option>
174 <option value="mc" <?php echo ($user_event_meta['status']=="paid" && $user_event_meta['extras']['paid_by']=="mc") ? "selected" : ""; ?>>Paid by Prepaid Mastercard</option>
175 <option value="amex" <?php echo ($user_event_meta['status']=="paid" && $user_event_meta['extras']['paid_by']=="amex") ? "selected" : ""; ?>>Paid by Prepaid American Express</option>
176 <option value="cheque" <?php echo ($user_event_meta['status']=="paid" && $user_event_meta['extras']['paid_by']=="cheque") ? "selected" : ""; ?>>Paid by Cheque</option>
177 </select>
178 </div>
179 </div>
180
181 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
182 <div class="dashboard-section-title">ASSIGN DISCOUNTS:</div>
183 <div class="dashboard-section-links"></div>
184 <div class="dashboard-section-content small">
185
186 <?php if ( empty($member_discount) && empty($early_bird_discount) ): ?>
187 <p style="color:#999;padding-top:0; margin-top:0;">In order to assign a discount, the discount must have a numeric value in the Event Admin.</p>
188 <?php else: ?>
189
190
191 <table>
192 <?php if (!empty($member_discount)):
193
194 $is_member = ($role=="member" OR $role=="student") ? true : false;
195
196 ?>
197 <tr>
198 <td width="20"><input type="checkbox" id="discount_member" name="discount_member" value="on" <?php echo ($is_member) ? "checked='checked'" : "";?> /></td>
199 <td><label for="discount_member">Student/Member Discount</label></td>
200 </tr>
201 <?php endif; ?>
202
203 <?php if (!empty($early_bird_discount)):
204
205 $is_eb_avail = (!empty($early_bird_deadline) && $early_bird_deadline > time()) ? true : false;
206
207 ?>
208 <tr>
209 <td width="20"><input type="checkbox" id="discount_earlybird" name="discount_earlybird" value="on" <?php echo ($is_eb_avail) ? "checked='checked'" : ""; ?> /></td>
210 <td><label for="discount_earlybird">Earlybird Discount</label></td>
211 </tr>
212 <?php endif; ?>
213 </table>
214 <?php endif; ?>
215 </div>
216 </div>
217 <?php endif; ?>
218
219 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
220 <div class="dashboard-section-title">ADDITIONAL NOTES</div>
221 <div class="dashboard-section-links"></div>
222 <div class="dashboard-section-content small">
223 <textarea name="event_notes" class="input-field-css input-large" rows="3" style="width:350px;"><?php echo isset($extras['event_notes']) ? $extras['event_notes'] : ""; ?></textarea>
224 </div>
225 </div>
226
227 <?php
228 if (!empty($show_dietary)): ?>
229 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
230 <div class="dashboard-section-title">SPECIAL DIETARY REQUIREMENTS</div>
231 <div class="dashboard-section-links"></div>
232 <div class="dashboard-section-content small">
233 <textarea name="dietary" class="input-field-css input-large" rows="5" style="width:350px;"><?php echo isset($extras['dietary']) ? $extras['dietary'] : ""; ?></textarea>
234 </div>
235 </div>
236 <?php endif; ?>
237
238 <?php if (!empty($mealopt_description) || !empty($mealopt_one) || !empty($mealopt_two) || !empty($mealopt_three) || !empty($mealopt_four)):?>
239
240 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
241 <div class="dashboard-section-title">MEAL OPTIONS</div>
242 <div class="dashboard-section-links"></div>
243 <div class="dashboard-section-content small">
244 <?php if (!empty($mealopt_description)) { echo "<div><strong>".$mealopt_description."</strong></div>"; } ?>
245 <table class="clean no-left-padding">
246 <tbody>
247 <?php if (!empty($mealopt_one) && $mealopt_one != ""):?>
248 <tr>
249 <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_one" value="on" <?php echo (isset($extras['mealopt_one'])) ? "checked" : ""; ?> /></th>
250 <td><?php echo $mealopt_one; ?></td>
251 </tr>
252 <?php endif; ?>
253
254 <?php if (!empty($mealopt_two) && $mealopt_two != ""):?>
255 <tr>
256 <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_two" value="on" <?php echo (isset($extras['mealopt_two'])) ? "checked" : ""; ?> /></th>
257 <td><?php echo $mealopt_two; ?></td>
258 </tr>
259 <?php endif; ?>
260
261 <?php if (!empty($mealopt_three) && $mealopt_three != ""):?>
262 <tr>
263 <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_three" value="on" <?php echo (isset($extras['mealopt_three'])) ? "checked" : ""; ?> /></th>
264 <td><?php echo $mealopt_three; ?></td>
265 </tr>
266 <?php endif; ?>
267
268 <?php if (!empty($mealopt_four) && $mealopt_four != ""):?>
269 <tr>
270 <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_four" value="on" <?php echo (isset($extras['mealopt_four'])) ? "checked" : ""; ?> /></th>
271 <td><?php echo $mealopt_four; ?></td>
272 </tr>
273 <?php endif; ?>
274
275 <?php if (!empty($mealopt_five) && $mealopt_five != ""):?>
276 <tr>
277 <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_five" value="on" <?php echo (isset($extras['mealopt_five'])) ? "checked" : ""; ?> /></th>
278 <td><?php echo $mealopt_five; ?></td>
279 </tr>
280 <?php endif; ?>
281
282 <?php if (!empty($mealopt_six) && $mealopt_six != ""):?>
283 <tr>
284 <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_six" value="on" <?php echo (isset($extras['mealopt_six'])) ? "checked" : ""; ?> /></th>
285 <td><?php echo $mealopt_six; ?></td>
286 </tr>
287 <?php endif; ?>
288
289 <?php if (!empty($mealopt_seven) && $mealopt_seven != ""):?>
290 <tr>
291 <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_seven" value="on" <?php echo (isset($extras['mealopt_seven'])) ? "checked" : ""; ?> /></th>
292 <td><?php echo $mealopt_seven; ?></td>
293 </tr>
294 <?php endif; ?>
295
296 <?php if (!empty($mealopt_eight) && $mealopt_eight != ""):?>
297 <tr>
298 <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_eight" value="on" <?php echo (isset($extras['mealopt_eight'])) ? "checked" : ""; ?> /></th>
299 <td><?php echo $mealopt_eight; ?></td>
300 </tr>
301 <?php endif; ?>
302
303 <?php if (!empty($mealopt_nine) && $mealopt_nine != ""):?>
304 <tr>
305 <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_nine" value="on" <?php echo (isset($extras['mealopt_nine'])) ? "checked" : ""; ?> /></th>
306 <td><?php echo $mealopt_nine; ?></td>
307 </tr>
308 <?php endif; ?>
309
310 <?php if (!empty($mealopt_ten) && $mealopt_ten != ""):?>
311 <tr>
312 <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_ten" value="on" <?php echo (isset($extras['mealopt_ten'])) ? "checked" : ""; ?> /></th>
313 <td><?php echo $mealopt_ten; ?></td>
314 </tr>
315 <?php endif; ?>
316
317
318 </tbody>
319 </table>
320 </div>
321 </div>
322 <?php endif; ?>
323
324 <?php if (!empty($session_description) || !empty($session_one) || !empty($session_two) || !empty($session_three) || !empty($session_four) || !empty($session_five) || !empty($session_six)):?>
325 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
326 <div class="dashboard-section-title">SESSION OPTIONS</div>
327 <div class="dashboard-section-links"></div>
328 <div class="dashboard-section-content small">
329 <?php if (!empty($session_description)) { echo "<div><strong>".$session_description."</strong></div>"; } ?>
330 <table class="clean no-left-padding">
331 <tbody>
332
333 <?php if (!empty($session_one)):?>
334 <tr>
335 <th width="40" style="text-align:right;"><input type="checkbox" name="session_one" value="on" <?php echo (isset($extras['session_one'])) ? "checked" : ""; ?> /></th>
336 <td><?php echo $session_one; ?></td>
337 </tr>
338 <?php endif; ?>
339
340 <?php if (!empty($session_two)):?>
341 <tr>
342 <th width="40" style="text-align:right;"><input type="checkbox" name="session_two" value="on" <?php echo (isset($extras['session_two'])) ? "checked" : ""; ?> /></th>
343 <td><?php echo $session_two; ?></td>
344 </tr>
345 <?php endif; ?>
346
347 <?php if (!empty($session_three)):?>
348 <tr>
349 <th width="40" style="text-align:right;"><input type="checkbox" name="session_three" value="on" <?php echo (isset($extras['session_three'])) ? "checked" : ""; ?> /></th>
350 <td><?php echo $session_three; ?></td>
351 </tr>
352 <?php endif; ?>
353
354 <?php if (!empty($session_four)):?>
355 <tr>
356 <th width="40" style="text-align:right;"><input type="checkbox" name="session_four" value="on" <?php echo (isset($extras['session_four'])) ? "checked" : ""; ?> /></th>
357 <td><?php echo $session_four; ?></td>
358 </tr>
359 <?php endif; ?>
360
361 <?php if (!empty($session_five)):?>
362 <tr>
363 <th width="40" style="text-align:right;"><input type="checkbox" name="session_five" value="on" <?php echo (isset($extras['session_five'])) ? "checked" : ""; ?> /></th>
364 <td><?php echo $session_five; ?></td>
365 </tr>
366 <?php endif; ?>
367
368 <?php if (!empty($session_six)):?>
369 <tr>
370 <th width="40" style="text-align:right;"><input type="checkbox" name="session_six" value="on" <?php echo (isset($extras['session_six'])) ? "checked" : ""; ?> /></th>
371 <td><?php echo $session_six; ?></td>
372 </tr>
373 <?php endif; ?>
374
375 <?php if (!empty($session_seven)):?>
376 <tr>
377 <th width="40" style="text-align:right;"><input type="checkbox" name="session_seven" value="on" <?php echo (isset($extras['session_seven'])) ? "checked" : ""; ?> /></th>
378 <td><?php echo $session_seven; ?></td>
379 </tr>
380 <?php endif; ?>
381
382 <?php if (!empty($session_eight)):?>
383 <tr>
384 <th width="40" style="text-align:right;"><input type="checkbox" name="session_eight" value="on" <?php echo (isset($extras['session_eight'])) ? "checked" : ""; ?> /></th>
385 <td><?php echo $session_eight; ?></td>
386 </tr>
387 <?php endif; ?>
388
389 <?php if (!empty($session_nine)):?>
390 <tr>
391 <th width="40" style="text-align:right;"><input type="checkbox" name="session_nine" value="on" <?php echo (isset($extras['session_nine'])) ? "checked" : ""; ?> /></th>
392 <td><?php echo $session_nine; ?></td>
393 </tr>
394 <?php endif; ?>
395
396 <?php if (!empty($session_ten)):?>
397 <tr>
398 <th width="40" style="text-align:right;"><input type="checkbox" name="session_ten" value="on" <?php echo (isset($extras['session_ten'])) ? "checked" : ""; ?> /></th>
399 <td><?php echo $session_ten; ?></td>
400 </tr>
401 <?php endif; ?>
402
403 </tbody>
404 </table>
405 </div>
406 </div>
407 <?php endif; ?>
408
409
410 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
411 <div class="dashboard-section-title"></div>
412 <div class="dashboard-section-links"></div>
413 <div class="dashboard-section-content small">
414 <div><input type="submit" value="<?php echo ($action=="edit") ? "Update" : "Register"; ?>" /></div>
415 </div>
416 </div>
417
418 </form>
419 </div>
420 <div style="clear:both;"></div>
421
422 </div>
423 </body>
424 </html>
...\ No newline at end of file ...\ No newline at end of file
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
8 <title>Edit Event</title>
9 <style type="text/css">
10
11 html, body { margin:0px; padding:0;}
12 .title-link {
13 color:#f7bd55;
14 font-size: 12px;
15 font-weight: bold;
16 text-align: left;
17 line-height: 1.75em;
18 background: #3b0d32;
19 border: solid 1px #FFF;
20 border-bottom: solid 1px #999;
21 cursor: default;
22 padding: 0em; padding:3px 10px 3px 10px;
23 margin: 0em;
24 }
25
26 form {
27 display: block;
28 margin-right:20px;
29 }
30
31 .dashboard-section-title { font-weight:bold; color:#3b0d32; }
32 </style>
33 </head>
34
35 <body>
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;">Mark Invoice Paid:</div>
38
39
40 <div style="padding: 0px 0px 10px 0px;">
41 <form method="post" action="" id="edit-invoice-form">
42
43 <input type="hidden" name="uid" value="<?php echo $_GET['uid']; ?>" />
44 <input type="hidden" name="invoice_id" value="<?php echo $_GET['invoice_id']; ?>" />
45
46 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
47 <div class="dashboard-section-content small">
48 <select name="paid_by">
49 <option value="">Select payment type...</option>
50 <option value="PPV">Pre-paid with Visa</option>
51 <option value="PPMC">Pre-paid with Mastercard</option>
52 <option value="PPAMEX">Pre-paid with American Express</option>
53 <option value="CHEQUE">Paid by Cheque</option>
54 </select>
55 </div>
56 </div>
57
58
59 <div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
60 <div class="dashboard-section-title"></div>
61 <div class="dashboard-section-links"></div>
62 <div class="dashboard-section-content small">
63 <div><input type="submit" value="Update" /></div>
64 </div>
65 </div>
66
67 </form>
68 </div>
69 </body>
70 </html>
...\ No newline at end of file ...\ No newline at end of file
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
6 <title>Refund: <?php echo $invoice->getTitle(); ?></title>
7
8 </head>
9
10 <body class="invoice-refund">
11 <style type="text/css">
12 html, body { margin:0px; padding:0;}
13 .title-link {
14 color: #F7BD55;
15 font-size: 12px;
16 font-weight: bold;
17 text-align: left;
18 line-height: 1.75em;
19 background: #3B0D32;
20 border: 1px solid #FFF;
21 border-bottom: 1px solid #999;
22 cursor: default;
23 padding: 3px 10px 3px 10px;
24 margin: 0em;
25 }
26
27 form {
28 display: block;
29 margin-right: 20px;
30 }
31
32 table.item-listings tr th { text-align: left; border-bottom: 1px solid #CCC; }
33 table.item-listings tr td { text-aling: left; border-bottom: 1px solid #CCC; }
34
35 table.item-listings tbody tr.odd td { background-color: #F5F5F5; }
36
37 table.item-listings tr th,
38 table.item-listings tr td { padding: 4px 5px; }
39 table.item-listings thead tr th { padding-bottom: 10px; }
40
41 table { border-collapse:collapse; }
42
43 .dashboard-section-title { font-weight:bold; color:#3b0d32; }
44
45 label.amount {
46 color: #999;
47 font-size: 11px;
48 }
49
50 .part-wrapper {
51 display: block;
52 width: 750px;
53 margin-bottom: 0;
54 }
55 </style>
56
57 <div class="part-wrapper">
58 <div class="title-link">Refund: <?php echo $invoice->getTitle(); ?></div>
59 <div style="padding:10px;">
60
61 <form id="invoice_refund_form">
62
63 <table cellpadding="0" cellspacing="0" width="100%" border="0" class="item-listings">
64 <thead><tr>
65 <th>Item Description</th>
66 <th width="140">Refund?</th>
67 <th width="140">Cancel Fee?</th>
68 </tr></thead>
69
70 <tbody>
71 <?php
72 $i = 0;
73 foreach ($invoice as $key => $item):
74 $unq = "keys[{$key}]";
75 ?>
76 <tr class="<?php echo (++$i & 1 ? 'odd' : 'even'); ?>">
77 <td><label for="<?php echo $unq; ?>"><?php echo $item->getDescription(); ?></label></td>
78 <td>
79 <input type="checkbox" checked="checked" value="1" id="<?php echo $unq; ?>" name="<?php echo $unq; ?>" />
80 <label for="<?php echo $unq; ?>" class="amount">(-$<?php echo $item->getTotal(true); ?>)</label>
81 </td>
82 <td>
83 <input type="checkbox" checked="checked" value="1" id="force_cancellation_fee" name="force_cancellation_fee" />
84 <label for="<?php echo $unq; ?>" class="amount">(+<?php echo '$150.00'; ?>)</label>
85 </td>
86 </tr>
87 <?php endforeach; ?>
88 </tbody></table>
89
90 <div style="padding-top:8px; margin-top:25px;">
91 <table cellpadding="0" cellspacing="0" width="100%" border="0">
92 <tr>
93 <td width="400" style="text-align:right;">
94 <input type="submit" value="Apply Changes" /> <input type="button" value="Cancel Changes" id="refund_cancel_btn" />
95 </td>
96 </tr>
97 </table>
98 </div>
99 </form>
100 </div>
101 </div>
102 </body>
103 </html>
...\ No newline at end of file ...\ No newline at end of file
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
8 <title>Remove User</title>
9 <style type="text/css">
10
11 html, body { margin:0px; padding:0;}
12 .title-link {
13 display:block;
14 color:#f7bd55;
15 font-size: 12px;
16 font-weight: bold;
17 text-align: left;
18 line-height: 1.75em;
19 background-color: #3b0d32;
20 border: solid 1px #FFF;
21 border-bottom: solid 1px #999;
22 cursor: default;
23 padding: 0em; padding:3px 10px 3px 10px;
24 margin: 0em;
25 }
26
27 form {
28 display: block;
29 margin-right:20px;
30 }
31
32 .dashboard-section-title { font-weight:bold; color:#3b0d32; }
33 </style>
34 </head>
35
36 <body>
37
38 <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;">Are you sure you want to remove this user?</div>
39
40 <form method="post" action="" id="remove-user-form">
41 <input type="hidden" name="uid" value="<?php echo $uid; ?>" />
42
43 <div class="dashboard-section" style="margin-left:5px;margin-top:10px;">
44 <div class="dashboard-section-links"></div>
45 <div class="dashboard-section-content small" style="padding:10px;">
46 <table width="300" cellpadding="0" cellspacing="0" border="0">
47 <tbody>
48 <tr>
49 <td width="20" valign="top"><input type="radio" name="remove_action" value="remove_all" id="remove_all" /></td>
50 <td><label for="remove_all">Yes, remove user and all related registrations, posts and comments.<br /><span style="font-size:11px; color:#999;"><em>(not recommended)</em></span></label></td>
51 </tr>
52 <tr><td colspan="2">&nbsp;</td></tr>
53 <tr>
54 <td width="20" valign="top"><input type="radio" name="remove_action" value="terminate" id="terminate" checked="checked" /></td>
55 <td><label for="terminate">Yes, but I just want to terminate them, and remove their access to the site.</label></td>
56 </tr>
57 <tr><td valign="middle" colspan="2" class="confirm-delete" style="color:red; font-size:10px;height:25px;">&nbsp;</td></tr>
58 <tr>
59 <td colspan="2"><input type="submit" value="&nbsp;I'm sure; Proceed!&nbsp;" /></td>
60 </tr>
61 </tbody>
62 </table>
63 </div>
64 </div>
65
66
67 </form>
68 <script type="text/javascript">
69 var $ = jQuery;
70 $('#remove_all').click(function() {
71 $('.confirm-delete').html('This action cannot be undone. Proceed with caution.');
72 });
73 $('#terminate').click(function() {
74 $('.confirm-delete').empty();
75 });
76 </script>
77 </body>
78 </html>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\UserManager;
3
4 use Tz, Tz\Common;
5 use Tz\WordPress\CBV;
6 use Exception, StdClass;
7
8 $users = _get_signups();
9
10
11
12
13 ?>
14 <div id="" class="wrap">
15 <div id="icon-users" class="icon32"><br /></div>
16 <h2>Users awaiting validation</h2>
17 <p style="display:none;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam iaculis convallis nisi eu dignissim. Quisque malesuada augue in mi blandit at blandit tortor sollicitudin. Cras at justo mi, vel mollis est. Donec orci erat, blandit varius vehicula vitae, volutpat at lorem. Etiam tincidunt bibendum ante, non tincidunt purus faucibus sed. Suspendisse eget facilisis tellus. Nulla imperdiet leo placerat diam sollicitudin nec mattis neque mattis. Cras id lacus tellus. Phasellus volutpat vehicula porttitor. Praesent erat felis, pharetra mollis egestas sit amet, rhoncus eget nisl. Morbi interdum sapien vitae nibh pharetra scelerisque. Mauris porta accumsan velit ac aliquam. Sed sit amet dictum felis. Fusce tempus vulputate nulla, quis tincidunt velit mattis eu.</p>
18
19 <table cellspacing="0" class="widefat post fixed" style="margin-top:20px;">
20 <thead>
21 <tr>
22 <th width="200">Login</th>
23 <th>Email</th>
24 <th width="200">Date Registered</th>
25 <th width="200">&nbsp;</th>
26 </tr>
27 </thead>
28 <tbody>
29 <?php foreach($users as $user): ?>
30 <tr>
31 <td><?php echo $user->user_login; ?></td>
32 <td><a href="mailto:<?php echo $user->user_email; ?>"><?php echo $user->user_email; ?></a></td>
33 <td><?php echo date("M j, Y @ h:ia",strtotime($user->registered)); ?></td>
34 <td style="text-align:right;"><a href="#" class="activate" rel="<?php echo $user->activation_key;?>">Activate</a> | <a href="#" class="remove" rel="<?php echo $user->activation_key;?>">Remove</a></td>
35 </tr>
36 <?php endforeach;?>
37 </tbody>
38 </table>
39 </div>
40
41 <script type="text/javascript">
42 jQuery(document).ready(function($) {
43
44 $('.activate').click(function(e) {
45 var activation_key = $(this).attr('rel');
46
47 $.ajax({
48 url: '/wp-admin/admin-ajax.php'
49 , dataType: 'json'
50 , type: 'POST'
51 , data: ({ajax:"yes", action: 'override_activate', akey: activation_key})
52 , success: function(date) {
53 document.location.href = document.location.href;
54 }
55 });
56 e.preventDefault();
57 return false;
58 });
59
60 $('.remove').click(function(e) {
61 var activation_key = $(this).attr('rel');
62
63 $.ajax({
64 url: '/wp-admin/admin-ajax.php'
65 , dataType: 'json'
66 , type: 'POST'
67 , data: ({ajax:"yes", action: 'override_remove', akey: activation_key})
68 , success: function(date) {
69 document.location.href = document.location.href;
70 }
71 });
72 e.preventDefault();
73 return false;
74 });
75
76 });
77 </script>
...\ No newline at end of file ...\ No newline at end of file