bd69a0c6 by Chris Boden

Removed UserManager from repository

1 parent 7eb0331b
function submitMark(e) {
if (e.keyCode == 27) {
document.getElementById(e.target.getAttribute('data-ref')).style.display = 'inline';
e.target.parentNode.removeChild(e.target);
return;
}
if (e.keyCode == 13) {
jQuery.ajax({
url: '/wp-admin/admin-ajax.php'
, data: {ajax: 'yes', action: 'update_mark', uid: user_id, course_id: e.target.getAttribute('data-course-id'), value: e.target.value}
, type: 'POST'
, dataType: 'json'
, success: function() {
var oLink = document.getElementById(e.target.getAttribute('data-ref'));
oLink.setAttribute('data-mark-value', e.target.value);
oLink.firstChild.nodeValue = e.target.value;
oLink.style.display = 'inline';
e.target.parentNode.removeChild(e.target);
}
});
}
}
function update_listing_preference() {
var pref = jQuery('#profile_preference').val();
if (pref == "Work") {
jQuery('.work-only').show();
} else {
jQuery('.work-only').hide();
}
}
jQuery(function($) {
Date.firstDayOfWeek = 0;
Date.format = 'yyyy-mm-dd';
if (jQuery('.datepicker').length > 0) {
jQuery('.datepicker').datePicker(
{
startDate: '1920-01-01',
endDate: (new Date()).asString()
}
);
}
$('#invoice_type').change(function() {
var invoice_type = $(this).val();
switch(invoice_type) {
case 'invoice':
$('tr.invoice_credit_only').show();
$('tr.invoice_only').show();
break;
case 'membership':
$('tr.invoice_credit_only').hide();
$('tr.invoice_only').show();
break;
default:
$('tr.invoice_credit_only').show();
$('tr.invoice_only').hide();
}
});
jQuery('#creditNotBtn').click(function(e) {
jQuery('#credit_note').slideToggle('fast');
var InvoiceType = $('#invoice_type');
if (InvoiceType.val() == "invoice") {
$('.invoice_only').show();
} else {
$('.invoice_only').hide();
}
jQuery('#creditForm').ajaxForm({
url: '/wp-admin/admin-ajax.php'
, data: ({ajax:"yes", action: 'create_invoice_note'})
, dateType: 'json'
, type: 'POST'
, success: function(data) {
// reload, cannot use reload() because then the form values get re-applied.
document.location.href = document.location.href;
}
});
e.preventDefault();
return false;
});
jQuery('.remove-user').colorbox({onComplete: function() {
var cb = this;
var options = {
beforeSubmit: function() {}
, success: function(data) {
document.location.href = document.location.href;
}
, error: function(XMLHttpRequest, textStatus, errorThrown) {
document.location.href = document.location.href;
}
, data: ({ajax:"yes", action: 'remove_user'})
, dataType: 'json'
, url: '/wp-admin/admin-ajax.php'
};
jQuery('#remove-user-form').ajaxForm(options);
}});
jQuery('#edit_user_notes').ajaxForm({
url: '/wp-admin/admin-ajax.php'
, data: ({ajax:"yes", action: 'update_edit_notes'})
, type: 'POST'
, dataType: 'json'
, success: function(data) {
jQuery('.update-placeholder').html('Update Successful.');
}
});
jQuery('#admin-edit-user-profile').ajaxForm({
url: '/wp-admin/admin-ajax.php'
, data: ({ajax:"yes", action: 'update_edit_profile'})
, dataType: 'json'
, type: 'post'
, beforeSubmit: function(formData, jqForm, options) {
var $error_container = jQuery('.validation-errors');
$error_container.hide();
}
, success: function(data) {
if (data.success == "true") {
jQuery('.update-placeholder').html('Update Successful.');
} else {
//$('.register-form :input').removeAttr('disabled');
var $error_container = jQuery('.validation-errors');
jQuery('h6',$error_container).html("OOPS...");
jQuery('ul',$error_container).html(data.msg);
$error_container.show();
}
}
, error: function(XMLHttpRequest, textStatus, errorThrown) {
var $error_container = jQuery('.validation-errors');
jQuery('h6',$error_container).html("OOPS...");
jQuery('ul',$error_container).html("<li>Please check all required fields and be sure they are the right format.</li>");
$error_container.show();
}
});
// overview ajaxForm...
jQuery('#overview_form').ajaxForm({
url: '/wp-admin/admin-ajax.php'
, data: ({ajax:"yes", action: 'update_account'})
, dataType: 'json'
, type: 'post'
, beforeSubmit: function(formData, jqForm, options) {
var $error_container = jQuery('.validation-errors');
$error_container.hide();
}
, success: function(data) {
if (data.success == "true") {
jQuery('.update-placeholder').html('Update Successful.');
} else {
//$('.register-form :input').removeAttr('disabled');
var $error_container = jQuery('.validation-errors');
jQuery('h6',$error_container).html("OOPS...");
jQuery('ul',$error_container).html(data.msg);
$error_container.show();
}
}
, error: function(XMLHttpRequest, textStatus, errorThrown) {
var $error_container = jQuery('.validation-errors');
jQuery('h6',$error_container).html("A server error has occurred.");
jQuery('ul',$error_container).html("<li>"+errorThrown+"</li>");
$error_container.show();
}
});
jQuery('.event-edit').colorbox({onComplete: function() {
var cb = this;
var options = {
beforeSubmit: function() {}
, success: function(data) {
if (data.refresh == "true") {
document.location.href = document.location.href;
} else {
jQuery.colorbox.close();
}
}
, data: ({ajax:"yes", action: 'update_registration'})
, dataType: 'json'
, url: '/wp-admin/admin-ajax.php'
};
jQuery('#edit-event-form').ajaxForm(options);
}});
jQuery('.invoice-refund-btn').live('click', function(e) {
var iid = $(this).attr('rel');
var current_amount = $(this).attr('amount');
// now we are going to pop up with invoice items.
$.colorbox({
href: '/wp-admin/admin-ajax.php?ajax=yes&action=admin_refund_invoice_form&invoice_id='+iid+'&uid='+user_id
, onComplete: function() {
jQuery('#invoice_refund_form').ajaxForm({
url: '/wp-admin/admin-ajax.php'
, data: ({ajax:"yes", action: 'issue_invoice_refund', invoice_id: iid})
, dataType: 'json'
, type: 'POST'
, success: function(data) {
if (data.success == 'true') {
document.location.href = document.location.href;
} else {
jAlert(data.msg, 'Server Error Encountered');
}
}
, error: function(XMLHttpRequest, textStatus, errorThrown) {
jAlert(textStatus, 'Server Error Encountered');
}
});
$('#refund_cancel_btn').click(function(e) {
e.preventDefault();
$.colorbox.close();
});
}
});
e.preventDefault();
return false;
});
jQuery('.invoice-cancel-btn').live('click', function(e) {
var iid = $(this).attr('rel');
jConfirm('<strong>Are you sure</strong> you want to <em>cancel</em> the invoice?', 'Cancel Invoice', function(c) {
if (c) {
jQuery.ajax({
url: '/wp-admin/admin-ajax.php'
, data: ({ajax:"yes", action: 'admin_cancel_invoice',invoice_id:iid})
, dataType: 'json'
, type: 'POST'
, success: function(data) {
document.location.reload();
}
});
}
});
e.preventDefault();
return false;
});
jQuery('.admin-mark-invoice-paid').colorbox({onComplete: function() {
var cb = this;
var options = {
success: function(data) {
document.location.reload();
}
, data: ({ajax:"yes", action: 'admin_update_invoice'})
, dataType: 'json'
, url: '/wp-admin/admin-ajax.php'
};
jQuery('#edit-invoice-form').ajaxForm(options);
}});
jQuery('.course-edit').colorbox({onComplete: function() {
var cb = this;
var options = {
beforeSubmit: function() {}
, success: function(data) {
if (data.refresh == "true") {
document.location.href = document.location.href;
} else {
jQuery.colorbox.close();
}
}
, data: ({ajax:"yes", action: 'course_registration'})
, dataType: 'json'
, url: '/wp-admin/admin-ajax.php'
};
jQuery('#edit-course-form').ajaxForm(options);
}});
jQuery('#admin_add_new_cehours').colorbox({onComplete: function() {
jQuery('.datepicker').datePicker(
{
startDate: '1920-01-01',
endDate: (new Date()).asString()
}
);
var options = {
success: function(data) {
document.location.href = document.location.href;
}
, data: ({ajax:"yes", action: 'admin_update_cehours'})
, dataType: 'json'
, url: '/wp-admin/admin-ajax.php'
};
jQuery('#edit-cehours-form').ajaxForm(options);
}});
jQuery('.cehours-edit').colorbox({onComplete: function() {
jQuery('.datepicker').datePicker(
{
startDate: '1920-01-01',
endDate: (new Date()).asString()
}
);
var options = {
success: function(data) {
document.location.href = document.location.href;
}
, data: ({ajax:"yes", action: 'admin_update_cehours'})
, dataType: 'json'
, url: '/wp-admin/admin-ajax.php'
};
jQuery('#edit-cehours-form').ajaxForm(options);
}});
jQuery('.cehours-remove').click(function(e) {
var ds = jQuery(this).attr('rel');
jConfirm('Are you sure?', 'Remove CE Hours?', function(c) {
if (c) {
jQuery.ajax({
url: '/wp-admin/admin-ajax.php'
, data: ({ajax:"yes", action: 'admin_remove_cehours', uid:user_id, indexed: ds})
, type: 'post'
, dataType: 'json'
, success: function(data) {
document.location.href = document.location.href;
}
});
}
});
e.preventDefault();
return false;
});
jQuery('.event-cancel').click(function(e) {
var eventcontainer = jQuery(this).parent();
var link = jQuery(this);
jConfirm('Are you sure?', 'Cancel Registration', function(c) {
if (c) {
eventcontainer.empty().addClass('spinner');
jQuery.ajax({
url: '/wp-admin/admin-ajax.php'
, data: ({ajax:"yes", action: 'cancel_registration', uid: user_id, eid: link.attr('rel')})
, type: 'post'
, success: function(data) {
document.location.href = document.location.href;
/*
if (data.ask_credit=="true") {
// ask if they want to credit....
jPrompt('How much (if any) would you like to credit their account?', '0.00', 'Registration has been cancelled', function(r) {
if( r ) {
jQuery.ajax({
url: '/wp-admin/admin-ajax.php'
, data: ({ajax:"yes", action: 'post_credit', uid:user_id, post_id: link.attr('rel'), amount:r})
, type: 'POST'
, dataType: 'json'
});
}
document.location.href = document.location.href;
});
} else {
document.location.href = document.location.href;
}
*/
}
, dataType: 'json'
});
}
});
e.preventDefault();
return false;
});
jQuery('#TzFQActions input').click(function(e) {
jQuery.ajax({
url: '/wp-admin/admin-ajax.php'
, data: {ajax: 'yes', action: 'update_fq_status', uid: user_id, status: e.target.value}
, type: 'POST'
, dataType: 'json'
, success: function() {
jQuery("#Tz4QContainer").remove();
}
});
});
jQuery('#mark_history a[data-mark="editable"]').click(function(e) {
var oEdit = document.createElement('input');
oEdit.type = 'text';
oEdit.size = 3;
oEdit.value = e.target.getAttribute('data-mark-value');
e.target.parentNode.appendChild(oEdit);
oEdit.setAttribute('data-ref', e.target.id);
oEdit.setAttribute('data-course-id', e.target.getAttribute('data-course-id'));
oEdit.focus();
jQuery(oEdit).keydown(submitMark);
e.target.style.display = 'none';
}).each(function(i, o) {
o.onclick = function() { return false; };
});
});
\ No newline at end of file
<?php
/*
Plugin Name: CBV User Manager
Description: All-In-One User Management for CBV
Version: 1.0
Author: Tenzing Communications Inc.
Author URI: http://www.gotenzing.com
*/
namespace Tz\WordPress\Tools\UserManager;
use Tz\Common;
use Tz\WordPress\Tools;
use Tz\WordPress\Tools\Auth;
use Tz\WordPress\Tools\Sequencer;
use Tz\WordPress\UAM;
use Tz\WordPress\Tools\HTML;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\User;
use Tz\WordPress\CBV\Events;
use Tz\WordPress\CBV\CEHours;
use Tz\WordPress\CBV\Invoice, Tz\WordPress\CBV\Invoice\Order\Item as OrderItem;
use Tz\WordPress\CBV\Beanstream\Card as CreditCard;
use Tz\WordPress\CBV\Courses;
use Tz\WordPress\CBV\CBVOptions;
use Exception, StdClass, ArrayAccess, Iterator, Countable;
const OPTION_NAME = "user_options";
const CAPABILITY = "manage_cbv_users";
CBV\load('Invoice');
CBV\load('User');
Tools\import('HTML');
call_user_func(function() {
$role = get_role('administrator');
$role->add_cap(CAPABILITY);
Tools\add_actions(__NAMESPACE__ . '\Actions');
Vars::$validation = new StdClass;
Vars::$validation->errors = Array();
});
function fix_unpaid() {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'fix_unpaid.php');
}
function display_users() {
/*
global $wpdb;
// temporary - remove when done...
$query = $wpdb->get_results("SELECT ID FROM {$wpdb->users}");
foreach($query as $user) {
$status = get_user_meta($user->ID, 'status', true);
if (empty($status)) {
update_user_meta($user->ID, 'status', 'active');
}
}
*/
// end temporary.
if ( isset($_GET['action']) && ($_GET['action']=="edit") && isset($_GET['uid']) && ($_GET['uid'] > 0) ) {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'edit_user.php');
} elseif (isset($_GET['action']) && $_GET['action']=="edit-partial") {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_'.$_GET['section'].'.php');
} else {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'display_users.php');
}
}
function getTaxesByProvince($provstate = "ON") {
return CBV\get_tax_pct($provstate);
}
function search_special_status($key) {
$special_statuses = get_user_meta($_GET['uid'], 'special_statuses',true);
if (!empty($special_statuses)) {
foreach($special_statuses as $stat) {
if ($stat == $key) {
echo 'checked';
break;
}
}
}
}
function create_instant_invoice($id = 0) {
Actions::wp_ajax_create_invoice_note($id);
}
function get_users($role = null, $pagenum=1, $records_per_page=0, $return_count_only = false, $search = null) {
$fs = Array();
if (!is_null($role)) {
$len = strlen($role);
$fs = Array('wp_capabilities' => "a:1:{s:{$len}:\\\\\\\\\"{$role}\\\\\\\\\"");
}
$users = new Tools\UserSearch(
Array('member_id', 'first_name', 'last_name', 'home_email', 'work_email', 'email_address_preference', 'status', 'wp_capabilities')
, $records_per_page
, $pagenum
, 'last_name'
, 'ASC'
, $fs
, $search
);
$users->setUserClass('Tz\WordPress\CBV\User\Account');
return $users;
}
function create_user() {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create_user.php');
}
function signups() {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'signups.php');
}
function _get_signups() {
global $wpdb;
$users = $wpdb->get_results("SELECT * FROM wp_signups WHERE active = 0 ORDER BY registered ASC");
return $users;
}
function merge_users() {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'merge_users.php');
}
class ProfileValidation extends Common\Validation {
public function prefix($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function member_since($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function first_name($val) {
if(empty($val)) {
throw new Exception('First name cannot be blank');
} else {
update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
}
}
public function initial($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function last_name($val) {
if(empty($val)) {
throw new Exception('Last name cannot be blank');
} else {
update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
}
}
public function degrees($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function designations($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function company_type($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function description($val) {
update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
}
public function date_of_birth($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function home_address($val) {
update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
}
public function home_address2($val) {
update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
}
public function home_city($val) {
update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
}
public function home_province($val) {
if ( $_POST['profile_preference']=="Home" ) {
if (empty($val)) {
throw new Exception('Home Province field can not be empty');
}
}
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function home_postal($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function home_country($val) {
if ( $_POST['profile_preference']=="Home" ) {
if (empty($val)) {
throw new Exception('Home Country field can not be empty');
}
}
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function home_phone($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function home_mobile($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function home_email($val) {
if (!empty($val)) {
if (!(boolean)preg_match(CBV\VALID_EMAIL, (string)$val)) {
throw new Exception('An invalid email address was entered in Email');
}
}
if ($_POST['profile_preference']=="Home") {
_update_user( Array ('ID'=>$_POST['uid'] , 'user_email'=>$val) );
}
update_user_meta($_POST['uid'], 'home_email', $val);
}
public function work_address($val) {
update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
}
public function work_address2($val) {
update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
}
public function work_city($val) {
update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val));
}
public function work_province($val) {
if ($_POST['profile_preference']=="Work") {
if (empty($val)) {
throw new Exception('Work Province field can not be empty');
}
}
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function work_postal($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function work_country($val) {
if ($_POST['profile_preference']=="Work") {
if (empty($val)) {
throw new Exception('Work Country field can not be empty');
}
}
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function work_phone($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function work_extension($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function work_mobile($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function work_email($val) {
if (!empty($val)) {
if (!(boolean)preg_match(CBV\VALID_EMAIL, (string)$val)) {
throw new Exception('An invalid email address was entered in Email');
}
}
if ($_POST['profile_preference']=="Work") {
_update_user( Array ('ID'=>$_POST['uid'] , 'user_email'=>$val) );
}
update_user_meta($_POST['uid'], 'work_email', $val);
}
public function company($val) {
update_user_meta($_POST['uid'],'company', User\clean_string($val));
}
public function title($val) {
update_user_meta($_POST['uid'], 'title', User\clean_string($val));
}
public function fax($val) {
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
public function website($val) {
if (!empty($val)) {
if (substr($val, 0, 7) != 'http://' && substr($val, 0, 8) != 'https://') {
$val = 'http://' . $val;
}
if (!(boolean)filter_var($val, FILTER_VALIDATE_URL)) {
throw new Exception('An invalid url was entered in website');
}
}
update_user_meta($_POST['uid'], 'website', User\clean_string($val));
}
public function profile_preference($val) {
update_user_meta($_POST['uid'], 'profile_preference', $val);
}
public function email_address_preference($val) {
update_user_meta($_POST['uid'], 'email_address_preference', $val);
}
}
class AccountValidation extends Common\Validation {
protected $on_groups = false;
protected $all_groups = false;
protected function setGroups() {
if (false === $this->on_groups || false === $this->all_groups) {
return false;
}
foreach ($this->all_groups as $id => $one) {
if (isset($this->on_groups[$id])) {
UAM\getGroupByID($id)->addUser($_POST['uid']);
} else {
UAM\getGroupByID($id)->removeUser($_POST['uid']);
}
}
}
public function group($val) {
return;
}
public function grpanch($val) {
$this->on_groups = (isset($_POST['group']) ? $_POST['group'] : Array());
$this->all_groups = $val;
$this->setGroups();
}
public function status($val) {
/*
$account = new User\Account($_POST['uid']);
$account->setStatus($val);
*/
update_user_meta($_POST['uid'], 'status',$val);
}
public function special_status_active($vals) {
delete_usermeta($_POST['uid'], 'special_statuses');
if (isset($_POST['special_status'])) {
$s = $_POST['special_status'];
if (count($s) > 0) {
update_user_meta($_POST['uid'], 'special_statuses', $s);
}
}
}
public function user_role($val) {
/*
$user = new User\Account($_POST['uid']);
try {
$user->set_role($val);
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
*/
CBV\user_change_role($val, $_POST['uid']);
}
public function password1($val) {
if (!empty($_POST['password1']) || !empty($_POST['password2'])) {
if ($_POST['password1']==$_POST['password2']) {
// update the user's password...
_update_user(Array('ID' => $_POST['uid'], 'user_pass' => $_POST['password1']));
} else {
throw new Exception('Passwords must match.');
}
}
}
public function membership_valid_until($val) {
update_user_meta($_POST['uid'], 'membership_valid_until',$val);
}
}
class CreateValidation extends Common\Validation {
public function first_name($val) {
if(empty($val)) {
throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
}
}
public function last_name($val) {
if(empty($val)) {
throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
}
}
public function username($val) {
if(empty($val)) {
throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
}
}
public function email($val) {
if (!empty($val)) {
if (!(boolean)preg_match(CBV\VALID_EMAIL, (string)$val)) {
throw new Exception('An invalid email address was entered in ' . User\Vars::$field_lookup[__FUNCTION__]);
}
} else {
throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' field can not be empty');
}
}
public function country($val) {
if(empty($val)) {
throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
}
}
public function province($val) {
if(empty($val)) {
throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
}
}
public function user_role($val) {
if(empty($val)) {
throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
}
}
public function password($val) {
if(!empty($val)) {
if ($_POST['password'] != $_POST['password2']) {
throw new Exception('Passwords do not match');
}
} else {
throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank');
}
}
}
function run_validation() {
$section = $_POST['section'];
$class = __NAMESPACE__ . '\\' . ucwords(array_shift(explode('-', $section))) . 'Validation';
Vars::$validation = new $class($_POST);
return (count(Vars::$validation->errors) > 0 ? false : true);
}
class Actions {
public static function wp_ajax_update_mark() {
$account = new User\Account($_POST['uid']);
$marks = $account->marks;
$marks['history'][$_POST['course_id']]['mark'] = $_POST['value'];
update_user_meta($account->ID, 'marks', $marks);
}
public static function wp_ajax_update_fq_status() {
$return = Array('success' => 'false');
$status = trim(strtolower($_POST['status']));
$lookup = Array(
'approve' => 'A'
, 'decline' => 'D'
);
if (isset($lookup[$status])) {
update_user_meta($_POST['uid'], 'course_4q_approvals', $lookup[$status]);
$return['success'] = 'true';
}
die(json_encode($return));
}
public static function wp_ajax_update_edit_notes() {
global $wpdb;
$uid = $_POST['uid'];
$note = $_POST['note'];
update_user_meta($uid, 'admin_notes', $note);
}
public static function wp_ajax_override_activate() {
global $wpdb;
$activation_key = $_POST['akey'];
Auth\activate($_POST['akey']);
$return = array(
'success' => 'true'
);
die(json_encode($return));
}
public static function wp_ajax_override_remove() {
global $wpdb;
$activation_key = $_POST['akey'];
$wpdb->query("DELETE FROM wp_signups WHERE activation_key='$activation_key' LIMIT 1");
$return = array(
'success' => 'true'
);
die(json_encode($return));
}
public static function wp_ajax_remove_user() {
$remove_action = $_POST['remove_action'];
if ($remove_action=="remove_all") {
// oh boy....
@wp_delete_user( $_POST['uid'] );
} else {
update_user_meta($_POST['uid'], 'status', 'terminated');
}
$return = array(
'success' => 'true'
);
die(json_encode($return));
}
public static function wp_ajax_build_user_remove() {
$uid = $_GET['uid'];
ob_start();
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'remove_user.php');
$content = ob_get_contents();
ob_end_clean();
die($content);
}
public static function wp_ajax_admin_create_user() {
run_validation();
Tools\import('Auth');
$valid = (count(Vars::$validation->errors) > 0) ? false : true;
if ($valid) {
$user_role = $_POST['user_role']; unset($_POST['user_role']);
$username = $_POST['username']; unset($_POST['username']);
$email = $_POST['email']; unset($_POST['email']);
if ($user_role != "member") { unset($_POST['member_id']); }
$password = $_POST['password']; unset($_POST['password']); unset($_POST['password2']);
$fp = strtolower($_POST['profile_preference'])."_";
// register the user.
$user_details = Array(
'first_name' => User\clean_string($_POST['first_name'])
, 'last_name' => User\clean_string($_POST['last_name'])
, $fp.'province' => $_POST['province']
, $fp.'country' => $_POST['country']
, $fp.'email' => $email
);
unset($user_details['email']);
if (isset($_POST['member_id'])) { $user_details['member_id'] = $_POST['member_id']; }
$user_details = array_merge(User\Vars::$meta_defaults, $user_details);
try {
$user_key = Auth\register($username, $email, $password, $user_details);
$uid = Auth\activate($user_key, $password);
$u = new User\Account($uid);
$u->set_role($user_role);
update_user_meta($uid, 'validated', time());
} catch (Exception $e) {
$return = array(
'success' => false
, 'msg' => $e->getMessage()
);
die(json_encode($return));
}
$return = array(
'success' => 'true'
, 'edit_profile' => '/wp-admin/admin.php?page=cbv_users&action=edit&uid='.$uid.'&section=profile'
, 'msg' => '<li>' . implode('</li><li>', Vars::$validation->errors) . '</li>'
);
} else {
$return = array(
'success' => 'false'
, 'msg' => '<li>' . implode('</li><li>', Vars::$validation->errors) . '</li>'
);
}
die(json_encode($return));
}
public static function wp_ajax_admin_create_member_id() {
// do logic here to create the user's member id.
$member_id = $_POST['last_name'] . time();
$return = array(
'member_id' => $member_id
);
die(json_encode($return));
}
public static function wp_ajax_admin_remove_cehours() {
CBV\load('CEHours');
$cehours = CEHours\get_user_cehours($_POST['uid']);
$compare = $_POST['indexed'];
if (isset($cehours[$compare])) {
unset($cehours[$compare]);
}
update_user_meta($_POST['uid'], 'cehours',$cehours);
$return = array(
'success' => 'true'
);
die(json_encode($return));
}
public static function wp_ajax_update_edit_profile() {
run_validation();
$return = array(
'success' => (count(Vars::$validation->errors) > 0 ? 'false' : 'true')
, 'msg' => '<li>' . implode('</li><li>', Vars::$validation->errors) . '</li>'
);
die(json_encode($return));
}
public static function wp_ajax_cancel_registration() {
CBV\load('Events');
Events\cancel_registration($_POST['uid'], $_POST['eid']);
$event = get_post($_POST['eid']);
$cost = get_post_meta($_POST['eid'], 'cost', true);
if (empty($cost) || $cost < 1 || strtolower($cost)=="free") {
$cost = 0;
}
$return = array(
'success' => 'true',
'ask_credit' => (($cost > 0) ? 'true' : 'false')
);
die(json_encode($return));
}
public static function wp_ajax_update_account() {
run_validation();
$return = array(
'success' => (count(Vars::$validation->errors) > 0 ? 'false' : 'true')
, 'msg' => '<li>' . implode('</li><li>', Vars::$validation->errors) . '</li>'
);
die(json_encode($return));
}
public static function wp_ajax_create_invoice_note($uid = 0) {
global $wpdb;
if ($uid == 0) {
$uid = $_POST['uid'];
}
// All this for tax purposes....
$pp = strtolower(get_user_meta($uid, 'profile_preference', true));
if (empty($pp)) {
$pp = "home";
}
$pp = $pp . "_";
$amount = $_POST['amount'];
$invoice_type = $_POST['invoice_type'];
$paid_by = $_POST['paid_by'];
$title = $_POST['title'];
$paid = (isset($_POST['paid']) && $_POST['paid']=="on") ? true : false;
if ($invoice_type=="invoice") {
if (!$paid) {
$paid_by = "";
}
} else {
$paid_by = "";
}
// if membership....
if ($invoice_type=="membership") {
$paid = (isset($_POST['paid']) && $_POST['paid']=="on") ? true : false;
if ($paid) {
$status = "paid";
} else {
$status = "unpaid";
}
Invoice\GenerateMembershipInvoice($uid, $status, $paid_by, true);
// return json object
$return = array(
'success' => 'true'
);
die(json_encode($return));
}
// if not membership.....
$items = array();
$items[] = array(
'post_id' => 0
, 'cost' => $amount
, 'discount_label' => ""
, 'discount_amount' => 0
, 'tax_label' => ""
, 'tax_rate' => ""
, 'tax_amount' => "0.00"
, 'subtotal' => $amount
, 'total' => $amount
, 'description' => $title
, 'extras' => array()
);
$invoice_data = array();
$invoice_data['items'] = $items;
$invoice_data['payment'] = array(
'total_cost' => $amount
, 'total_discounts' => ""
, 'total_taxes' => ""
, 'subtotal' => $amount
, 'total' => $amount
, 'bt_address' => get_user_meta($uid, $pp.'address', true)
, 'bt_address2' => get_user_meta($uid, $pp.'address2', true)
, 'bt_city' => get_user_meta($uid, $pp.'city', true)
, 'bt_province' => get_user_meta($uid, $pp.'province', true)
, 'bt_country' => get_user_meta($uid, $pp.'country', true)
, 'bt_postal' => get_user_meta($uid, $pp.'postal', true)
, 'bt_card_holder' => ""
, 'bt_card_number' => ""
, 'bt_card_type' => $paid_by
);
if ($invoice_type=="credit") {
$status = "credit";
} else {
$paid = (isset($_POST['paid']) && $_POST['paid']=="on") ? true : false;
if ($paid) {
$status = "paid";
} else {
$status = "unpaid";
}
}
$new_invoice_id = Invoice\create($invoice_data, 'generic', $title, $uid, $status, 'publish', $amount);
if ($invoice_type=="credit") {
update_post_meta($new_invoice_id, 'credit_amount', $amount);
}
// return json object
$return = array(
'success' => 'true'
);
die(json_encode($return));
}
public static function wp_ajax_course_registration() {
// Get given working classes
$user = new User\Account($_POST['user_id']);
$course = new Courses\Course($_POST['course_id']);
$enrolltype = $_POST['enrolltype'];
$tax_rate = $user->getLocTaxPct();
// Apply user to course, sets group, set enrollment, etc.
$user->registerForCourse($course->getID(), (boolean)isset($_POST['exam']), $enrolltype);
$user->approveToCourse($course->getID());
$order = new Invoice\Order();
$order->addItem(new OrderItem($course->$enrolltype, $tax_rate, $course->post_title, $course->getID()));
if (isset($_POST['studentfee']) && $_POST['studentfee'] == 1) {
$fee = number_format(CBVOptions\GetOption('student-fees', 'fees'), 2, '.', '');
$order->addItem(new OrderItem($fee, $tax_rate, 'Annual Registration Fee'));
$user->setMeta('fee_semester_paid', $course->getSemester());
}
if (isset($_POST['casebook']) && $_POST['casebook'] == 1) {
$book = UAM\getGroup('Casebook');
$book->addUser($user->ID);
$cost = substr($book->getDescription(), strpos($book->getDescription(), ':') + 1);
$order->addItem(new OrderItem($cost, CBV\get_tax_pct(), 'Casebook', CBV\CASEBOOK_POSTID));
}
if (isset($_POST['overseas']) && $_POST['overseas'] == 1) {
$os_cost = number_format(CBVOptions\GetOption('overseas-surcharge', 'fees'), 2, '.', '');
$order->addItem(new OrderItem($os_cost, $tax_rate, 'Overseas Surcharge'));
}
$cc = new CreditCard(null, $_POST['paid_by']);
$order->generateInvoice($user, 'course', 'Course Invoice', $cc);
die(json_encode(Array('success' => 'true', 'refresh' => 'true')));
}
public static function wp_ajax_update_registration() {
CBV\load('Events');
if (!isset($_POST['type'])) { die('Invalid Form Post'); }
$post = get_post($_POST['event_id']);
$uid = $_POST['uid'];
$event_id = $_POST['event_id'];
$type = $_POST['type'];
$status = $_POST['status'];
switch($status) {
case 'unpaid':
$status = 'unpaid';
$paid_by = '';
break;
case 'complementary':
$status = 'complementary';
$paid_by = '';
break;
default:
$status = 'paid';
$paid_by = $status;
break;
}
unset($_POST['action']);
unset($_POST['ajax']);
unset($_POST['event_id']);
unset($_POST['uid']);
unset($_POST['type']);
unset($_POST['status']);
$events = get_user_meta($uid, 'events',true);
// if $type = "edit"
if ($type=="edit") {
foreach($events as $index=>$event) {
if ($event['event_id']==$event_id) {
$events[$index]['status'] = $status;
unset($events[$index]['extras']);
$events[$index]['extras'] = $_POST;
break;
}
}
update_user_meta($uid, 'events', $events);
$return = array('success' => 'true', 'refresh' => 'false');
} else {
// KB
$user = new User\Account($uid);
$is_tax_exempt = false;
// loop through special status to see if exempt is there.
if ( isset( $user->special_statuses) ) {
foreach($user->special_statuses as $stat) {
if ($stat == "tax_exempt") {
$is_tax_exempt = true;
break;
}
}
}
$cost = get_post_meta($event_id, 'cost', true);
$role = $user->getRole();
$event = get_post($event_id);
$cehours = get_post_meta($event_id,'worth_cehours',true);
$early_bird_deadline = get_post_meta($event_id,'early_bird_deadline',true);
$early_bird_discount = get_post_meta($event_id,'early_bird_discount',true);
$member_discount = get_post_meta($event_id,'student_member_discount',true);
$reg_deadline = get_post_meta($event_id,'reg_deadline',true);
$event_date = get_post_meta($event_id,'event_date',true);
$give_earlybird_discount = isset($_POST['discount_earlybird']) ? true : false;
$give_member_discount = isset($_POST['discount_member']) ? true : false;
$event_term_slugs = array();
$terms = get_the_terms($event_id,'event_type');
if (!empty($terms)) {
foreach($terms as $types) {
$event_term_slugs[$types->slug] = $types->name;
}
}
$discounts = array();
$new_cost = $cost;
$total_discount = 0;
if ( $give_member_discount && !empty($member_discount) ) {
$show_member_discount = true;
$discounts[] = Array(
'discount_label' => "Student/Member Discount"
, 'discount' => $member_discount
);
$new_cost = ($new_cost - $member_discount);
$total_discount = ($total_discount + $member_discount);
}
if ( $give_earlybird_discount && !empty($early_bird_discount) ) {
$show_early_discount = true;
$discounts[] = Array(
'discount_label' => "Early Bird Discount"
, 'discount' => $early_bird_discount
);
$new_cost = ($new_cost - $early_bird_discount);
$total_discount = ($total_discount + $early_bird_discount);
}
$provstate = get_post_meta($event_id,'provstate',true);
if (empty($provstate) OR $provstate == "outside") {
$provstate = "ON";
}
if (isset($event_term_slugs['webinar'])) {
$tpp = get_user_meta($user->ID,'profile_preference',true);
$tpp = strtolower($tpp);
$province = get_user_meta($user->ID,$tpp."_province",true);
if ($is_tax_exempt) {
$tax_label = "Exempt";
$tax = 0;
$taxes = 0;
} else {
$tax_label = "Taxes-$province";
$tax = getTaxesByProvince($province);
$taxes = ($new_cost * ($tax/100));
}
} else {
if ($is_tax_exempt) {
$tax_label = "Exempt";
$tax = 0;
$taxes = 0;
} else {
$tax_label = "Taxes-$provstate";
$tax = getTaxesByProvince($provstate); // tax percentage (whole number)
$taxes = ($new_cost * ($tax/100));
}
}
$invoice_post = $_POST;
$details = Array('dietary','event_notes',
'mealopt_one','mealopt_two','mealopt_three','mealopt_four','mealopt_five','mealopt_six','mealopt_seven','mealopt_eight','mealopt_nine','mealopt_ten',
'session_one','session_two','session_three','session_four','session_five','session_six','session_seven','session_eight','session_nine','session_ten');
$extras = array();
foreach($details as $index) {
if ( isset($_POST[$index]) ) {
$extras[$index] = $_POST[$index];
}
}
$items = array();
$items[] = array(
'post_id' => $event_id
, 'cost' => get_post_meta($event_id,'cost',true)
, 'discounts' => $discounts
, 'tax_label' => $tax_label
, 'tax_rate' => $tax
, 'tax_amount' => $taxes
, 'subtotal' => $new_cost
, 'total' => number_format(($new_cost + $taxes),2)
, 'description' => ""
, 'extras' => $extras
);
$pp = get_user_meta($user->ID,'profile_preference',true);
$pp = $pp . "_";
$invoice_data = array();
$invoice_data['items'] = $items;
$invoice_data['payment'] = array(
'total_cost' => get_post_meta($event_id,'cost',true)
, 'total_discounts' => $total_discount
, 'total_taxes' => $taxes
, 'subtotal' => $new_cost
, 'total' => number_format(($new_cost + $taxes),2)
, 'bt_address' => get_user_meta($user->ID, $pp.'address',true)
, 'bt_address2' => get_user_meta($user->ID, $pp.'address2',true)
, 'bt_city' => get_user_meta($user->ID, $pp.'city',true)
, 'bt_province' => get_user_meta($user->ID, $pp.'province',true)
, 'bt_country' => get_user_meta($user->ID, $pp.'country',true)
, 'bt_postal' => get_user_meta($user->ID, $pp.'postal',true)
, 'bt_card_holder' => ""
, 'bt_card_number' => ""
, 'bt_card_type' => ""
);
$event_term_slugs = array();
$terms = get_the_terms($event_id,'event_type');
if (!empty($terms)) {
foreach($terms as $types) {
$event_term_slugs[$types->slug] = $types->name;
}
}
//create($items = array(), $invoice_type = 'event', $title = "Invoice", $user_id = 0, $status = 'pending', $reference = '', $publish = 'draft')
$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));
$extras['invoice_id'] = $invoice_id;
$extras['discounts'] = array(
'member' => ($give_member_discount) ? "Y" : "N"
, 'earlybird' => ($give_earlybird_discount) ? "Y" : "N"
);
Events\set_attending($user->ID,$event_id,'paid',md5(rand()),$extras);
}
$return = array('success' => 'true', 'refresh' => 'true');
die(json_encode($return));
}
public static function wp_ajax_admin_update_cehours() {
CBV\load('CEHours');
$cehours = CEHours\get_user_cehours($_POST['uid']);
if ($_POST['action']=="edit") {
unset($cehours[$_POST['indexed']]);
}
$timestamp = CEHours\mysqldatetime_to_timestamp($_POST['date']);
if ($_POST['indexed']=="") {
$_POST['indexed'] = Sequencer\generate('CEH');
}
$postarray = $_POST;
$cehours[$_POST['indexed']] = Array(
'type' => $postarray['type']
, 'subtype' => isset($postarray['subtype']) ? $postarray['subtype'] : ""
, 'date' => CEHours\mysqldatetime_to_timestamp($postarray['date'])
, 'activity' => isset($postarray['activity']) ? $postarray['activity'] : ""
, 'institute' => isset($postarray['institution']) ? $postarray['institution'] : ""
, 'hours' => $postarray['hours']
, 'attended' => isset($postarray['attended']) ? "yes" : "no"
, 'post_type' => "event"
, 'post_id' => '0'
, 'recorded' => time()
);
/*
$cehours[$_POST['indexed']] = Array(
'type' => $_POST['type']
, 'date' => $timestamp
, 'activity' => $_POST['activity']
, 'hours' => $_POST['hours']
);
*/
update_user_meta($_POST['uid'], 'cehours', $cehours);
// return json object
$return = array(
'success' => 'true'
);
die(json_encode($return));
}
public static function wp_ajax_admin_cancel_invoice() {
$invoice_id = $_POST['invoice_id'];
update_post_meta($invoice_id, 'trans_status', 'cancelled');
$return = array(
'success' => 'true'
);
die(json_encode($return));
}
public static function wp_ajax_admin_update_invoice() {
$invoice_id = $_POST['invoice_id'];
$user_id = $_POST['uid'];
update_post_meta($invoice_id, 'trans_status', 'paid');
$payment = get_post_meta($invoice_id, 'payment', true);
$payment['bt_card_type'] = $_POST['paid_by'];
update_post_meta($invoice_id, 'payment', $payment);
$invoice_for = get_post_meta($invoice_id, 'invoice_for', true);
if ( !empty($invoice_for) && $invoice_for == "membership") {
$next_year = (int) date("Y");
$next_year = ($next_year + 1);
update_user_meta($user_id, 'membership_valid_until', $next_year);
}
$return = array(
'success' => 'true'
);
die(json_encode($return));
}
public static function wp_ajax_admin_refund_invoice() {
$invoice_id = $_POST['invoice_id'];
$amount = $_POST['amount'];
$invoice = get_post($invoice_id);
$payment = get_post_meta($invoice_id, 'payment', true);
$trans_amount = get_post_meta($invoice_id, 'trans_amount', true);
$invoice_for = get_post_meta($invoice_id, 'invoice_for', true);
$items = get_post_meta($invoice_id, 'items', true);
update_post_meta($invoice->ID, 'refunded', date('Y-m-d H:i:s'));
$invoice_data['items'] = $items;
$invoice_data['payment'] = $payment;
$new_invoice_id = Invoice\create($invoice_data, $invoice_for, $invoice->post_title, $invoice->post_author, 'credit', 'publish', $trans_amount);
update_post_meta($new_invoice_id, 'original_invoice_id', $invoice_id);
update_post_meta($new_invoice_id, 'credit_amount', $amount);
}
public static function wp_ajax_build_cehour_form() {
$user = new User\Account($_GET['uid']);
$uid = $user->ID;
$fname = get_user_meta($user->ID, 'first_name', true);
$lname = get_user_meta($user->ID, 'last_name', true);
if (empty($fname) || empty($lname)) {
$name = $user->user_login;
} else {
$name = $fname . " " . $lname;
}
CBV\load('CEHours');
ob_start();
$action = isset($_GET['post_action']) ? $_GET['post_action'] : "edit";
$cehours = CEHours\get_user_cehours($uid);
if ($action=="edit") {
$record = $cehours[$_GET['indexed']];
$indexed = $_GET['indexed'];
$type = $record['type'];
$date = date('Y-m-d',$record['date']);
$activity = $record['activity'];
$subtype = isset($record['subtype']) ? $record['subtype'] : "";
$institute = isset($record['institute']) ? $record['institute'] : "";
$attended = isset($record['attended']) ? $record['attended'] : "";
$hours = $record['hours'];
} else {
$indexed = "";
$type = "unstructured";
$date = date('Y-m-d',time());
$activity = "";
$subtype = "";
$institute = "";
$attended = "";
$hours = "0";
}
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_cehour.php');
$content = ob_get_contents();
ob_end_clean();
die($content);
}
public static function wp_ajax_build_course_form() {
$user = new User\Account($_GET['uid']);
$course = new Courses\Course($_GET['course_id']);
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_course.php');
die;
}
public static function wp_ajax_build_event_form() {
$user = new User\Account($_GET['uid']);
$uid = $user->ID;
$role = $user->getRole();
$fname = get_user_meta($user->ID, 'first_name', true);
$lname = get_user_meta($user->ID, 'last_name', true);
if (empty($fname) || empty($lname)) {
$name = $user->user_login;
} else {
$name = $fname . " " . $lname;
}
CBV\load('Events');
ob_start();
$action = isset($_GET['post_action']) ? $_GET['post_action'] : "edit";
if ($action=="edit") {
$user_event_meta = Events\get_event_registration($_GET['event_id'], $_GET['uid']);
} else {
$user_event_meta = Array();
}
//CBV\trace($user_event_meta);
$post = Events\get_event($_GET['event_id']);
$show_dietary = get_post_meta($post->ID, 'show_dietary', true);
$session_description = get_post_meta($post->ID, 'session_description', true);
$session_one = get_post_meta($post->ID, 'session_one', true);
$session_two = get_post_meta($post->ID, 'session_two', true);
$session_three = get_post_meta($post->ID, 'session_three', true);
$session_four = get_post_meta($post->ID, 'session_four', true);
$session_five = get_post_meta($post->ID, 'session_five', true);
$session_six = get_post_meta($post->ID, 'session_six', true);
$session_seven = get_post_meta($post->ID, 'session_seven', true);
$session_eight = get_post_meta($post->ID, 'session_eight', true);
$session_nine = get_post_meta($post->ID, 'session_nine', true);
$session_ten = get_post_meta($post->ID, 'session_ten', true);
$mealopt_description = get_post_meta($post->ID, 'mealopt_description', true);
$mealopt_one = get_post_meta($post->ID, 'mealopt_one', true);
$mealopt_two = get_post_meta($post->ID, 'mealopt_two', true);
$mealopt_three = get_post_meta($post->ID, 'mealopt_three', true);
$mealopt_four = get_post_meta($post->ID, 'mealopt_four', true);
$mealopt_five = get_post_meta($post->ID, 'mealopt_five', true);
$mealopt_six = get_post_meta($post->ID, 'mealopt_six', true);
$mealopt_seven = get_post_meta($post->ID, 'mealopt_seven', true);
$mealopt_eight = get_post_meta($post->ID, 'mealopt_eight', true);
$mealopt_nine = get_post_meta($post->ID, 'mealopt_nine', true);
$mealopt_ten = get_post_meta($post->ID, 'mealopt_ten', true);
$early_bird_deadline = get_post_meta($post->ID,'early_bird_deadline',true);
$early_bird_discount = get_post_meta($post->ID,'early_bird_discount',true);
$member_discount = get_post_meta($post->ID,'student_member_discount',true);
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_event.php');
$content = ob_get_contents();
ob_end_clean();
die($content);
}
public static function wp_ajax_build_invoice_mark_paid_form() {
$user = new User\Account($_GET['uid']);
ob_start();
$invoice = get_post($_GET['invoice_id']);
$payment = get_post_meta($_GET['invoice_id'], 'payment', true);
$trans_status = get_post_meta($_GET['invoice_id'], 'trans_status', true);
$how_paid = strtolower($payment['bt_card_type']);
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_invoice.php');
$content = ob_get_contents();
ob_end_clean();
die($content);
}
public static function wp_ajax_admin_refund_invoice_form() {
$user = new User\Account($_GET['uid']);
ob_start();
$invoice = new Invoice\Receipt($_GET['invoice_id']);
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'invoice-refund-view.php');
$content = ob_get_contents();
ob_end_clean();
die($content);
}
public static function wp_ajax_issue_invoice_refund() {
$invoice = new Invoice\Receipt($_POST['invoice_id']);
$user = new User\Account($invoice->getOwner());
$items = $_POST['keys'];
foreach ($items as $index => $yes) {
if (1 /* checkbox on */) {
$fee = 0;
}
$invoice->seek($index)->cancel($fee);
}
$invoice->runRefund();
// Chris, do what you need to do with this....
// if there is an error, turn success to 'false' and set a msg.
$return = array(
'success' => 'true'
, 'msg' => ''
);
die(json_encode($return));
}
public static function wp_ajax_admin_search_merge_users() {
global $wpdb;
$direction = $_POST['which_user_search'];
$do_search = $_POST['do_search'];
$do_merge = $_POST['do_merge'];
// Make sure we have sane 'defaults'
if ($direction != 'from' && $direction != 'to') {
$direction = 'from';
}
if ($do_search != 'yes' && $do_search != 'no') {
$do_search = 'yes';
}
if ($do_merge != 'yes' && $do_merge != 'no') {
$do_merge = 'yes';
}
if ($do_search == 'yes') {
$username = $wpdb->escape($_POST['search_user_' . $direction]);
// Don't search for an empty string as it will return all results
if (empty($username)) {
die(json_encode(array(
'success' => 'false',
'msg' => 'You must enter a value to search for.'
)));
}
// Initialize
$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>';
$i = 0;
// Check for search term in first_name, last_name, user_login, and user_email, but only if user status is not 'terminated'
$query = "
SELECT u.ID, u.user_email, umf.meta_value AS first_name, uml.meta_value AS last_name, umm.meta_value AS member_id
FROM $wpdb->users AS u, $wpdb->usermeta AS uml, $wpdb->usermeta AS umf, $wpdb->usermeta AS umm, $wpdb->usermeta AS ums
WHERE (uml.user_id = u.ID
AND uml.meta_key = 'last_name'
)
AND (umf.user_id = u.ID
AND umf.meta_key = 'first_name'
)
AND (ums.user_id = u.ID
AND ums.meta_key = 'status'
)
AND (umm.user_id = u.ID
AND umm.meta_key = 'member_id'
)
AND ((uml.meta_value LIKE '%$username%'
OR umf.meta_value LIKE '%$username%'
OR (umm.meta_value != '' AND umm.meta_value LIKE '%$username%'))
AND ums.meta_value != 'terminated'
)
ORDER BY first_name, last_name";
$result = $wpdb->get_results($query, ARRAY_A);
if (! empty($result)) {
foreach ($result as $user) {
$html .= <<<HTML
<tr>
<td><input type="radio" name="merge_user_{$direction}" value="{$user['ID']}" />&nbsp;{$user['first_name']}</td>
<td>{$user['last_name']}</td>
<td>{$user['member_id']}</td>
<td>{$user['user_email']}</td>
</tr>
HTML;
$i++;
}
} else {
die(json_encode(array(
'success' => 'false',
'msg' => 'No users found matching that term.'
)));
}
$html .= '</tbody></table>';
$return = array(
'success' => 'true',
'direction' => $direction,
'html' => $html
);
} else if ($do_merge == 'yes') {
if (empty($_POST['merge_user_from'])) {
die(json_encode(array(
'success' => 'false',
'msg' => 'You must select a user to merge from.'
)));
}
if (empty($_POST['merge_user_to'])) {
die(json_encode(array(
'success' => 'false',
'msg' => 'You must select a user to merge to.'
)));
}
$from_user = new User\Account($_POST['merge_user_from']);
$to_user = new User\Account($_POST['merge_user_to']);
if ($from_user->ID == $to_user->ID) {
die(json_encode(array(
'success' => 'false',
'msg' => 'You cannot merge the same user!'
)));
}
$html = '';
$skipped_fields = array(
'ID',
'user_login',
'user_pass',
'user_nicename',
'user_email',
'user_url',
'user_registered',
'user_activation_key',
'user_status',
'display_name',
'id',
'caps',
'cap_key',
'roles',
'allcaps',
'filter',
'status',
'four_security_expiration',
'course_4q_approvals',
'user_level',
'validated',
'posts_per_page',
'overload_ppp',
'rich_editing',
'comment_shortcuts',
'admin_color',
'use_ssl',
'x_cicbv.person',
'tz_profile_pub',
'events',
'four_security_questions',
'special_statuses',
'mainmenu',
'cehours',
'subscription',
'notices',
'invoices',
'courses_registered',
);
// Get rid of the unnecessary data object in the current user object
unset($from_user->data);
foreach ($from_user as $key => $val) {
if (in_array($key, $skipped_fields)) {
continue;
}
// Special cases:
// Only transfer member_id if it's not blank
if ($key == 'member_id' && empty($val)) {
continue;
}
// Don't transfer any wp_* fields
if (substr($key, 0, 3) == 'wp_') {
continue;
}
// Make sure we're updating the right user ID and perform update
update_user_meta($to_user->ID, $key, $val);
// Build a table of data
$html .= "\n\t<tr><td width='150'>$key</td><td>$val</td></tr>";
}
if (! empty($from_user->user_email)) {
// Transfer old user's profile preference email address (work, home, etc.) to new user's user_email field
if (isset($from_user->profile_preference) && ! empty($from_user->profile_preference)) {
$preference = strtolower($from_user->profile_preference) . '_email';
if (isset($from_user->$preference) && ! empty($from_user->$preference)) {
_update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->$preference));
} else {
_update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->user_email));
}
} else {
_update_user(array('ID' => $to_user->ID, 'user_email' => $from_user->user_email));
}
}
// Set a few meta values for the old user
update_user_meta($from_user->ID, 'status', 'terminated');
update_user_meta($from_user->ID, 'merged_to', $to_user->ID);
update_user_meta($from_user->ID, 'datetime_merged', time());
$html = '<thead><tr><th colspan="2">Merge successful. Here are all the changes:</th></tr></thead><tbody>' .
$html .
'</tbody>';
$return = array(
'success' => 'true',
'fields' => $html
);
} else {
$return = array(
'success' => 'false',
'msg' => 'Incorrect action. Please contact the webmaster.'
);
}
die(json_encode($return));
}
public static function admin_menu() {
add_menu_page('CBV Users','CBV Users',CAPABILITY,'cbv_users',__NAMESPACE__ . '\display_users',null,3 );
add_submenu_page('cbv_users','New User', 'New User',CAPABILITY,'cbv_users_create',__NAMESPACE__ . '\create_user');
add_submenu_page('cbv_users','New User', 'Awaiting Validation',CAPABILITY,'cbv_users_signups',__NAMESPACE__ . '\signups');
add_submenu_page('cbv_users', 'Merge Users', 'Merge Users', CAPABILITY, 'cbv_users_merge', __NAMESPACE__ . '\merge_users');
//add_submenu_page('cbv_users', 'Fix Unpaid', 'Fix Unpaid', CAPABILITY, 'cbv_users_fix_unpaid', __NAMESPACE__ . '\fix_unpaid');
}
public static function admin_init() {
register_setting(OPTION_NAME, OPTION_NAME);
}
}
class Vars {
public static $validation;
}
\ No newline at end of file
/*
Masked Input plugin for jQuery
Copyright (c) 2007-2010 Josh Bush (digitalbush.com)
Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
Version: 1.2.3
*/
(function($) {
var pasteEventName = ($.browser.msie ? 'paste' : 'input') + ".mask";
var iPhone = (window.orientation != undefined);
$.mask = {
//Predefined character definitions
definitions: {
'9': "[0-9]",
'a': "[A-Za-z]",
'*': "[A-Za-z0-9]"
}
};
$.fn.extend({
//Helper Function for Caret positioning
caret: function(begin, end) {
if (this.length == 0) return;
if (typeof begin == 'number') {
end = (typeof end == 'number') ? end : begin;
return this.each(function() {
if (this.setSelectionRange) {
this.focus();
this.setSelectionRange(begin, end);
} else if (this.createTextRange) {
var range = this.createTextRange();
range.collapse(true);
range.moveEnd('character', end);
range.moveStart('character', begin);
range.select();
}
});
} else {
if (this[0].setSelectionRange) {
begin = this[0].selectionStart;
end = this[0].selectionEnd;
} else if (document.selection && document.selection.createRange) {
var range = document.selection.createRange();
begin = 0 - range.duplicate().moveStart('character', -100000);
end = begin + range.text.length;
}
return { begin: begin, end: end };
}
},
unmask: function() { return this.trigger("unmask"); },
mask: function(mask, settings) {
if (!mask && this.length > 0) {
var input = $(this[0]);
var tests = input.data("tests");
return $.map(input.data("buffer"), function(c, i) {
return tests[i] ? c : null;
}).join('');
}
settings = $.extend({
placeholder: "_",
completed: null
}, settings);
var defs = $.mask.definitions;
var tests = [];
var partialPosition = mask.length;
var firstNonMaskPos = null;
var len = mask.length;
$.each(mask.split(""), function(i, c) {
if (c == '?') {
len--;
partialPosition = i;
} else if (defs[c]) {
tests.push(new RegExp(defs[c]));
if(firstNonMaskPos==null)
firstNonMaskPos = tests.length - 1;
} else {
tests.push(null);
}
});
return this.each(function() {
var input = $(this);
var buffer = $.map(mask.split(""), function(c, i) { if (c != '?') return defs[c] ? settings.placeholder : c });
var ignore = false; //Variable for ignoring control keys
var focusText = input.val();
input.data("buffer", buffer).data("tests", tests);
function seekNext(pos) {
while (++pos <= len && !tests[pos]);
return pos;
};
function shiftL(pos) {
while (!tests[pos] && --pos >= 0);
for (var i = pos; i < len; i++) {
if (tests[i]) {
buffer[i] = settings.placeholder;
var j = seekNext(i);
if (j < len && tests[i].test(buffer[j])) {
buffer[i] = buffer[j];
} else
break;
}
}
writeBuffer();
input.caret(Math.max(firstNonMaskPos, pos));
};
function shiftR(pos) {
for (var i = pos, c = settings.placeholder; i < len; i++) {
if (tests[i]) {
var j = seekNext(i);
var t = buffer[i];
buffer[i] = c;
if (j < len && tests[j].test(t))
c = t;
else
break;
}
}
};
function keydownEvent(e) {
var pos = $(this).caret();
var k = e.keyCode;
ignore = (k < 16 || (k > 16 && k < 32) || (k > 32 && k < 41));
//delete selection before proceeding
if ((pos.begin - pos.end) != 0 && (!ignore || k == 8 || k == 46))
clearBuffer(pos.begin, pos.end);
//backspace, delete, and escape get special treatment
if (k == 8 || k == 46 || (iPhone && k == 127)) {//backspace/delete
shiftL(pos.begin + (k == 46 ? (tests[pos.begin]?0:1) : -1));
return false;
} else if (k == 27) {//escape
input.val(focusText);
input.caret(0, checkVal());
return false;
}
};
function keypressEvent(e) {
if (ignore) {
ignore = false;
//Fixes Mac FF bug on backspace
return (e.keyCode == 8) ? false : null;
}
e = e || window.event;
var k = e.charCode || e.keyCode || e.which;
var pos = $(this).caret();
if (e.ctrlKey || e.altKey || e.metaKey) {//Ignore
return true;
} else if ((k >= 32 && k <= 125) || k > 186) {//typeable characters
var p = seekNext(pos.begin - 1);
if (p < len) {
var c = String.fromCharCode(k);
if (tests[p].test(c)) {
shiftR(p);
buffer[p] = c;
writeBuffer();
var next = seekNext(p);
$(this).caret(next);
if (settings.completed && next >= len)
settings.completed.call(input);
}
}
}
return false;
};
function clearBuffer(start, end) {
for (var i = start; i < end && i < len; i++) {
if (tests[i])
buffer[i] = settings.placeholder;
}
};
function writeBuffer() { return input.val(buffer.join('')).val(); };
function checkVal(allow) {
//try to place characters where they belong
var test = input.val();
var lastMatch = -1;
for (var i = 0, pos = 0; i < len; i++) {
if (tests[i]) {
buffer[i] = settings.placeholder;
while (pos++ < test.length) {
var c = test.charAt(pos - 1);
if (tests[i].test(c)) {
buffer[i] = c;
lastMatch = i;
break;
}
}
if (pos > test.length)
break;
} else if (buffer[i] == test.charAt(pos) && i!=partialPosition) {
pos++;
lastMatch = i;
}
}
if (!allow && lastMatch + 1 < partialPosition) {
input.val("");
clearBuffer(0, len);
} else if (allow || lastMatch + 1 >= partialPosition) {
writeBuffer();
if (!allow) input.val(input.val().substring(0, lastMatch + 1));
}
return (partialPosition ? i : firstNonMaskPos);
};
if (!input.attr("readonly"))
input
.one("unmask", function() {
input
.unbind(".mask")
.removeData("buffer")
.removeData("tests");
})
.bind("focus.mask", function() {
focusText = input.val();
var pos = checkVal();
writeBuffer();
setTimeout(function() {
if (pos == mask.length)
input.caret(0, pos);
else
input.caret(pos);
}, 0);
})
.bind("blur.mask", function() {
checkVal();
if (input.val() != focusText)
input.change();
})
.bind("keydown.mask", keydownEvent)
.bind("keypress.mask", keypressEvent)
.bind(pasteEventName, function() {
setTimeout(function() { input.caret(checkVal(true)); }, 0);
});
checkVal(); //Perform initial check for existing values
});
}
});
})(jQuery);
\ No newline at end of file
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\CBV;
use Tz\WordPress\UAM;
use Tz\WordPress\Tools;
use Tz\WordPress\Tools\HTML;
use Exception, StdClass;
use WP_User, WP_Roles;
Tools\import('HTML');
$rc = new WP_Roles();
$roles = $rc->role_names;
ksort($roles);
unset($rc, $roles['administrator']);
?>
<style>
#post-body {
-moz-border-radius-bottomleft:6px;
-moz-border-radius-bottomright:6px;
-moz-border-radius-topright:6px;
-moz-border-radius-topleft:6px;
background:none repeat scroll 0 0 #FFFFFF;
border-width:1px 1px 1px 1px;
padding:10px;
margin-top:20px;
}
#nav-menu-header, #post-body,#post-header {
border-color:#CCCCCC;
border-style:solid;
}
#menu-management .nav-tab {
background:none repeat scroll 0 0 #F4F4F4;
}
#menu-management .nav-tab-active {
background:none repeat scroll 0 0 #fff;
border-bottom-color:#fff;
}
</style>
<div id="" class="wrap">
<div id="icon-users" class="icon32"><br /></div>
<h2>Creating a new CBV User...</h2>
<div id="post-body">
<div style="padding:10px 10px 0px 10px; min-width:760px;">
<form method="post" id="admin-new-user-form">
<table cellpadding="0" cellspacing="0" border="0" class="my-profile-table" style="float:left; width:350px;">
<tbody>
<tr>
<th width="120px;">Username:</th>
<td><input type="text" name="username" required /></td>
</tr>
<tr>
<th>First Name:</th>
<td><input type="text" name="first_name" required /></td>
</tr>
<tr>
<th>Last Name:</th>
<td><input type="text" name="last_name" id="create_last_name" required /></td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<th>&nbsp;</th>
<td><select name="profile_preference" id="profile_preference"><option value="Home">Home&nbsp;</option><option value="Work">Work&nbsp;</option></select></td>
</tr>
<tr>
<th>Email:</th>
<td><input type="text" name="email" required /></td>
</tr>
<tr>
<th>Country:</th>
<td><?php echo HTML\form_dropdown('country', HTML\Vars::$countries, '', "id='country'"); ?></td>
</tr>
<tr>
<th>Province:</th>
<td><?php echo HTML\form_linked_dropdown('province', 'country', HTML\Vars::$provinces,'', ''); ?></td>
</tr>
</tbody>
</table>
<table cellpadding="0" cellspacing="0" border="0" class="my-profile-table" style="float:left; width:350px;">
<tbody>
<tr>
<th>User Type:</th>
<td>
<select name="user_role" id="create_user_role">
<?php foreach($roles as $roled=>$name):?>
<option value="<?php echo $roled;?>" <?php echo ($roled=="guest") ? "selected" : "";?>><?php echo $name;?></option>
<?php endforeach;?>
</select>
</td>
</tr>
<tr id="create_member_id">
<th class="member_id_label">Member ID:</th>
<td><input type="text" name="member_id" id="member_id" readonly="readonly" /></td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<th>Password (twice):</th>
<td><input type="password" name="password" required /></td>
</tr>
<tr>
<th>&nbsp;</th>
<td><input type="password" name="password2" required /></td>
</tr>
</tbody>
</table>
<div style="clear:both;"></div>
<div class="validation-errors" style="display:none;margin-top:10px;"><div class="error-wrap"><h6>OOPS...</h6><ul></ul></div></div>
<div style="margin-top:10px;padding-top:5px; border-top:1px solid #e8e8e8;">
<input type="submit" value="Create User" />
</div>
</form>
</div>
</div>
</div>
<script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
<script type="text/javascript">
var $ = jQuery;
var $role_selector = $('#create_user_role');
var $member_id_container = $('#create_member_id');
var $member_id_label = $('.member_id_label');
var $member_id_field = $('#member_id');
var $form = $('#admin-new-user-form');
var $last_name_field = $('#create_last_name');
function changedUserRole() {
if ($role_selector.val() == "member" || $role_selector.val()=="student") {
if ($role_selector.val() == "member") {
$member_id_label.html('Member ID:');
} else {
$member_id_label.html('Student ID:');
}
updateMemberID();
$member_id_container.show();
} else {
$member_id_container.hide();
}
}
function updateMemberID() {
/*
var lname = $last_name_field.val();
if ($role_selector.val() == "member") {
$.ajax({
url: '/wp-admin/admin-ajax.php'
, data: ({ajax:"yes", action: 'admin_create_member_id', last_name: lname})
, dataType: 'json'
, type: 'post'
, success: function(data) {
$member_id_field.val(data.member_id);
}
});
}
*/
$member_id_field.removeAttr('readonly');
}
$(function() {
changedUserRole();
$('#create_last_name').blur(function() {
updateMemberID();
});
$role_selector.change(function() {
changedUserRole();
});
var options = {
url: '/wp-admin/admin-ajax.php'
, dataType: 'json'
, type: 'post'
, data: ({ajax:"yes", action: 'admin_create_user', section: 'create'})
, beforeSubmit: function(formData, jqForm, options) {
var $error_container = jQuery('.validation-errors');
$error_container.hide();
}
, success: function(data) {
if (data.success == "true") {
document.location.href=data.edit_profile
} else {
var $error_container = jQuery('.validation-errors');
jQuery('h6',$error_container).html("OOPS...");
jQuery('ul',$error_container).html(data.msg);
$error_container.show();
}
}
};
$form.ajaxForm(options);
});
</script>
\ No newline at end of file
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\CEHours;
use Tz\WordPress\CBV\Events;
use Tz\WordPress\UAM;
use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
use Tz\WordPress\Tools\Notifications;
use Exception, StdClass;
use WP_User;
ini_set('display_errors', 1);
$records_per_page = 20;
$filter_role = isset($_GET['role']) ? $_GET['role'] : null;
$pagenum = isset($_GET['pagenum']) ? $_GET['pagenum'] : 1;
$search = isset($_GET['search_criteria']) ? $_GET['search_criteria'] : null;
$site_users = get_users($filter_role, $pagenum, $records_per_page, false, $search);
$rows = $site_users->countTotal();
$last = ceil($rows/$records_per_page);
if ($last < 1) {
$last = 1;
}
if ($pagenum < 1) {
$pagenum = 1;
} elseif ($pagenum > $last) {
$pagenum = $last;
}
if ($filter_role) {
$url = $_SERVER['PHP_SELF']."?page=cbv_users&role=$filter_role&pagenum=";
} elseif ($search) {
$url = $_SERVER['PHP_SELF']."?page=cbv_users&search_criteria=$search&pagenum=";
} else {
$url = $_SERVER['PHP_SELF']."?page=cbv_users&pagenum=";
}
// Pager section
$loop_test = 0;
$loop_initial = 0;
$show_ellipsis_limit = 7;
$ellipsis_before = '';
$ellipsis_after = '';
$ellipsis_common = '...';
$tag = '[pagenum]';
$template = '<a href="' . $url . $tag . '">' . $tag . '</a>';
$template_with_class = '<a href="' . $url . $tag . '" class="active">' . $tag . '</a>';
$prev_link = ($pagenum == 1) ? '' : ' <a href="' . $url . ($pagenum - 1) . '">Prev</a> ';
$next_link = ($pagenum == $last) ? '' : ' <a href="' . $url . ($pagenum + 1) . '">Next</a> ';
$first_link = ' <a href="' . $url . '1">First</a> ';
$last_link = ' <a href="' . $url . $last . '">Last</a> ';
$pager = '';
// Style: 1...5 6 7...100
if ($last > 1) {
$pager = ' | Pages: ';
// Set options
// ...31 32 33...
if ($last > $show_ellipsis_limit) {
// 1 2 3 4...last
if ($pagenum > 0 && $pagenum < 4) {
$loop_initial = 2;
$loop_test = 5;
$ellipsis_after = $ellipsis_common;
// 4 5 6...last
} elseif ($pagenum > 3 && $pagenum < ($last - 1)) {
$loop_initial = $pagenum - 1;
$loop_test = $pagenum + 2;
$ellipsis_before = $ellipsis_common;
// This is to eliminate the $ellipsis when we're on the 3rd last page
if ($pagenum < ($last - 2)) {
$ellipsis_after = $ellipsis_common;
}
// 8 9 10(last)
} else {
$loop_initial = $pagenum - 2;
$loop_test = $last;
$ellipsis_before = $ellipsis_common;
}
// 1 2 3 4 5 6 7
} else {
$loop_initial = 2;
$loop_test = $last;
}
// Now start building html
// Start with 'First' link, then previous page link
if ($last > $show_ellipsis_limit && $pagenum != 1) {
$pager .= $first_link . $prev_link;
}
// Set active template to highlight page 1 if that's what we're on
if ($pagenum == 1) {
$pager .= str_ireplace($tag, 1, $template_with_class);
} else {
$pager .= str_ireplace($tag, 1, $template);
}
// Implement middle loops
$pager .= $ellipsis_before;
for ($i = $loop_initial; $i < $loop_test; $i++) {
if ($pagenum == $i) {
$pager .= str_ireplace($tag, $i, $template_with_class);
} else {
$pager .= str_ireplace($tag, $i, $template);
}
}
$pager .= $ellipsis_after;
// Set active template to highlight page 1 if that's what we're on
if ($pagenum == $last) {
$pager .= str_ireplace($tag, $last, $template_with_class);
} else {
$pager .= str_ireplace($tag, $last, $template);
}
// Finish with next page link, then 'Last' link
if ($last > $show_ellipsis_limit && $pagenum != $last) {
$pager .= $next_link;
$pager .= $last_link;
}
}
?>
<div id="" class="wrap">
<div id="icon-users" class="icon32"><br /></div>
<h2>CBV User Manager <a href="/wp-admin/admin.php?page=cbv_users_create" class="button add-new-h2">Add New</a></h2>
<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>
<div class="users-role-bar">
<?php if (isset($_GET['search_criteria'])):?>
<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>
<?php else: ?>
<strong>Filter</strong>:
<?php $users = count_users(); ?>
<a href="/wp-admin/admin.php?page=cbv_users" <?php echo (!isset($_GET['role']) ? "class='active'" : ""); ?>>All</a>
<?php
if (isset($users['avail_roles'])) {
foreach($users['avail_roles'] as $role=>$counted) {
print ' | <a href="/wp-admin/admin.php?page=cbv_users&role='.$role.'" '.( (isset($_GET['role']) && $_GET['role']==$role) ? "class='active'" : "").'>'.ucwords($role).'</a>';
}
}
?>
<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>
<?php endif;?>
</div>
<div class="TzPaginateResults">
<?php
echo "Users: $rows ";
echo $pager;
?>
</div>
<div style="clear:both"></div>
<table cellspacing="0" class="widefat post fixed">
<thead>
<tr>
<th scope="col" class="manage-column">Name</th>
<th scope="col" width="180" class="manage-column">Member ID</th>
<th scope="col" width="250" class="manage-column">Email</th>
<th scope="col" width="200" class="manage-column">Role</th>
<th scope="col" width="100" class="manage-column">Status</th>
<th scope="col" width="100" class="manage-column">&nbsp;</th>
</tr>
</thead>
<tbody>
<?php
foreach ($site_users as $user):
$pref = strtolower($user->email_address_preference);
if (!in_array($pref, Array('home', 'work'))) {
$pref = strtolower($user->profile_preference);
if (!in_array($pref, Array('home', 'work'))) {
$email = $user->user_email;
} else {
$email = $user->{$pref . '_email'};
}
//$pref = (empty($user->home_email) ? 'work' : 'home');
} else {
$email = $user->{$pref . '_email'};
}
?>
<tr>
<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>
<td><a href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $user->id; ?>"><?php echo $user->member_id; ?></a></td>
<td><?php echo $email ?></td>
<td><?php echo current(array_keys($user->wp_capabilities)); ?></td>
<td><?php echo ucwords($user->status);?></td>
<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>
</tr>
<?php endforeach; ?>
</body>
</table>
<div class="TzPaginateResults" style="margin-top:10px;">
<?php
echo "Users: $rows ";
echo $pager;
?>
</div>
<div style="clear:both;"></div>
</div>
<script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
\ No newline at end of file
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\CEHours;
use Tz\WordPress\CBV\Events;
use Tz\WordPress\CBV\User;
use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
use Tz\WordPress\Tools\Notifications;
use Exception, StdClass;
$user = new CBV\User\Account($_GET['uid']);
$suser = new CBV\User\CurrentAccount();
$role = $user->getRole();
$fname = $user->first_name;
$lname = $user->last_name;
if (empty($fname) || empty($lname)) {
$name = $user->user_login;
} else {
$name = $fname . " " . $lname;
}
$section = isset($_GET['section']) ? $_GET['section'] : "overview";
call_user_func(function() {
CBV\load('Events');
});
?>
<style>
#post-body {
-moz-border-radius-bottomleft:6px;
-moz-border-radius-bottomright:6px;
-moz-border-radius-topright:6px;
background:none repeat scroll 0 0 #FFFFFF;
border-width:1px 1px 1px;
padding:10px;
}
#nav-menu-header, #post-body,#post-header {
border-color:#CCCCCC;
border-style:solid;
}
#menu-management .nav-tab {
background:none repeat scroll 0 0 #F4F4F4;
}
#menu-management .nav-tab-active {
background:none repeat scroll 0 0 #fff;
border-bottom-color:#fff;
}
</style>
<script type="text/javascript">var user_id = <?php echo $_GET['uid'];?>;</script>
<div id="" class="wrap">
<div id="icon-users" class="icon32"><br /></div>
<h2>Editing: <?php echo $name; ?>
<?php if (!empty($user->member_id)) { echo '<span class="admin-member-id"> (' . $user->member_id . ')</span>'; }?>
<?php if (in_array($suser->getRole(), Array('administrator', 'cbv_admin'))): ?>
(<a href="<?php echo get_author_posts_url($user->ID); ?>?sulogin=1">Login</a>)
<?php endif; ?>
</h2>
<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>
<div id="menu-management" style="margin-top:25px;">
<div class="nav-tabs-nav">
<div class="nav-tabs-wrapper" class="section-<?php echo @$_GET['section'];?>">
<div class="nav-tabs" style="padding: 0px; margin-left: 0px;">
<a id="overview" class="nav-tab hide-if-no-js <?php echo ($section=="overview") ? "nav-tab-active" : ""; ?>" href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $_GET['uid']; ?>&section=overview">Overview</a>
<a id="profile" class="nav-tab hide-if-no-js <?php echo ($section=="profile") ? "nav-tab-active" : ""; ?>" href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $_GET['uid']; ?>&section=profile">Profile</a>
<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>
<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>
<?php if ($role=="member"): ?>
<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>
<?php endif; ?>
<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>
<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>
</div>
</div>
</div>
<div id="post-body" style="padding:0px 10px 15px 10px;">
<?php require_once('edit_user_' . $section . '.php'); ?>
</div>
</div>
</div>
\ No newline at end of file
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\CEHours;
use Tz\WordPress\UAM;
use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
use Tz\WordPress\Tools\Notifications;
use Exception, StdClass;
use WP_User;
$uid = $_GET['uid'];
CBV\load('CEHours');
$cehours = CEHours\get_user_cehours($uid);
?>
<div style="padding:10px 10px 0px 10px; min-width:760px;">
<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>
<?php
if (empty($cehours)) :
print "<p>No CE Hours recorded.</p>";
else:
?>
<table cellspacing="0" class="widefat post fixed" style="margin-top:0px;">
<thead>
<tr>
<th scope="col" width="150">Date Recorded</th>
<th scope="col" width="150">Type</th>
<th scope="col">Activity</th>
<th scope="col" width="150">Structured</th>
<th scope="col" width="100">Unstructured</th>
<th scope="col" width="100">&nbsp;</th>
</tr>
</thead>
<tbody>
<?php foreach($cehours as $index=>$ce):
$ce_date = date('F j, Y',$ce['date']);
?>
<tr>
<td><?php echo $ce_date; ?></td>
<td><?php echo ucwords($ce['subtype']); ?></td>
<td><?php echo $ce['activity']; ?></td>
<td><?php echo ($ce['type']=="structured") ? $ce['hours'] : 0;?></td>
<td><?php echo ($ce['type']=="unstructured") ? $ce['hours'] : 0;?></td>
<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>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
endif;
?>
</div>
<script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
\ No newline at end of file
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\Tools;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\Courses, Tz\WordPress\CBV\Courses\Registration;
use Tz\WordPress\CBV\User;
use Tz\WordPress\UAM;
use WP_Query;
// check to see if user is eligible for course (is member/student)
CBV\load('Courses');
$user = new User\Account($_GET['uid']);
$courses = Courses\getActiveCourses();
$lookup = Array();
foreach ($courses as $course) {
$lookup[$course->getTemplateID()] = $course;
}
$fn_cd = function($tid, $key) use ($courses, $lookup) {
if (!isset($lookup[$tid])) {
return 'Not Available';
}
return date('Y-m-d', $courses[$lookup[$tid]->getID()]->{$key});
};
?>
<div style="padding:10px 10px 0px 10px; min-width:760px;">
<div id="Tz4QContainer">
<?php if ($user->course_4q_approvals == 'P'): ?>
<h2>Security Question Status</h2>
<ul>
<?php
CBV\load('Courses\Registration');
$four_questions = Registration\get_four_questions();
foreach ($user->four_security_questions as $key => $yesno) {
if ($yesno == 1) {
echo "<li>Q: {$four_questions[$key]} (yes)</li>";
}
}
?>
</ul>
<p style="padding: 0 1em;"><em>&quot;<?php echo nl2br(htmlspecialchars($user->four_security_explanation)); ?>&quot;</em></p>
<p id="TzFQActions">
<input type="button" value=" Approve " />
<input type="button" value=" Decline " />
</p>
<?php endif; ?>
</div>
<h2 style="margin-bottom:10px;padding-bottom:0px;">Current Courses</h2>
<table class="clean-lines widefat post fixed">
<thead><tr>
<th>Course</th>
<th width="85">Type</th>
<th width="100">Latest Mark</th>
<th>Registration Deadline</th>
<th>Semester Runs</th>
<th>Register</th>
</tr></thead>
<tbody>
<?php
$templates = new WP_Query(Array(
'post_type' => CBV\PCT_COURSETEMPLATE
, 'posts_per_page' => 0
));
while ($templates->have_posts()):
$templates->the_post();
?>
<tr>
<td><?php echo get_the_title(); ?></td>
<td><?php echo get_post_meta(get_the_ID(), 'course_type', true); ?></td>
<td><?php echo $user->getMark(get_the_ID()); ?></td>
<td><?php echo $fn_cd(get_the_ID(), 'course_regi_close'); ?>
<td><?php echo $fn_cd(get_the_ID(), 'course_start') . '&nbsp;-&nbsp;' . $fn_cd(get_the_ID(), 'course_end'); ?></td>
<td>
<?php if (isset($lookup[get_the_ID()]) && $lookup[get_the_ID()]->registrationOpen()): ?>
<?php if ($user->courseApprovalStatus($lookup[get_the_ID()]->getID()) == $user::CAS_APPROVED): ?>
Registered
<?php else: ?>
<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>
<?php endif; ?>
<?php endif; ?>
</td>
</tr>
<?php
endwhile;
_reset_postdata();
?>
</tbody>
</table>
<h2>Course History</h2>
<table class="clean-lines widefat post fixed" id="mark_history">
<thead><tr>
<th>Course</th>
<th>Type</th>
<th>Mark</th>
<th>Semester</th>
<th>Date Achieved</th>
</tr></thead>
<tbody>
<?php
foreach ($user->marks['history'] as $data):
$course = new Courses\Course($data['course_id']);
?>
<tr>
<td><?php echo $course->post_title; ?></td>
<td><?php echo $course->course_type; ?></td>
<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>
<td><?php echo $course->getSemester(); ?></td>
<td><?php echo date('Y-m-d', $data['added']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
\ No newline at end of file
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\CEHours;
use Tz\WordPress\CBV\Events;
use Tz\WordPress\UAM;
use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
use Tz\WordPress\Tools\Notifications;
use Exception, StdClass;
use WP_User;
$uid = $_GET['uid'];
CBV\load('Events');
$events = get_user_meta($user->ID, 'events', true);
?>
<div style="padding:10px 10px 0px 10px; min-width:760px;">
<?php
if (empty($events) || count($events) < 1):
echo '<h2 style="margin-bottom:10px;padding-bottom:0px;">'.$name.' is not registered for any events...</h2>';
else: ?>
<h2 style="margin-bottom:10px;padding-bottom:0px;">Registered for Events...</h2>
<table cellspacing="0" class="widefat post fixed">
<thead>
<tr>
<th scope="col">Event Name</th>
<th scope="col" width="150">Event Date</th>
<th scope="col" width="150">Registered</th>
<th scope="col" width="100">&nbsp;</th>
</tr>
</thead>
<tbody>
<?php foreach($user->events as $event):
$e = Events\get_event($event['event_id']);
if ( empty($e->ID) OR $e->ID < 1) { continue; }
$event_date = get_post_meta($e->ID, 'event_date', true);
?>
<tr>
<td><?php echo $e->post_title;?></td>
<td><?php echo date('F j, Y',$event_date);?></td>
<td><?php echo date('F j, Y',$event['register_date']);?></td>
<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>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<h4 style="margin-bottom:5px;padding-bottom:0px; padding-left:10px;"><em>Events not registered for...</em></h4>
<?php endif; ?>
<?php
$posts = query_posts(Array(
'post_type' => 'events'
, 'posts_per_page' => -1
, 'paged' => (get_query_var('paged') ? get_query_var('paged') : 1)
, 'meta_key' => 'event_date'
/*
, 'meta_compare' => '>'
, 'meta_value' => (time() + (60*60*24)) // event date + 1 day, so that they can register the day of...
*/
, 'orderby' => 'meta_value'
, 'order' => 'DESC'
));
?>
<table cellspacing="0" class="widefat post fixed">
<thead>
<tr>
<th scope="col">Event Name</th>
<th scope="col" width="150">Event Date</th>
<th scope="col" width="150">Register By</th>
<th scope="col" width="100">Cost</th>
<th scope="col" width="100">&nbsp;</th>
</tr>
</thead>
<tbody>
<?php foreach($posts as $post):
if (!Events\is_attending($post->ID, $uid) && UAM\can_user_access($post->ID, $uid)):
// get categories....
$event_term_slugs = array();
$terms = get_the_terms($post->ID,'event_type');
$external_only = false;
if (!empty($terms)) {
foreach($terms as $types) {
$event_term_slugs[$types->slug] = $types->name;
if ($types->slug == "externalevent") {
$external_only = true;
}
}
}
if ($external_only) {
continue;
}
$event_date = get_post_meta($post->ID, 'event_date', true);
if (isset($event_term_slugs['webinar'])) {
$is_archived = get_post_meta($post->ID, 'is_archived_webinar', true);
/*if (!$is_archived == "on") { continue; }*/
} else {
if ($event_date < (current_time('timestamp') - (60*60*24))) {
continue;
}
}
$event_date = get_post_meta($post->ID, 'event_date', true);
$register_date = get_post_meta($post->ID, 'reg_deadline', true);
$cost = get_post_meta($post->ID,'cost',true);
if (empty($cost) || $cost < 1 || strtolower($cost)=="free") { $cost = 0; }
?>
<tr>
<td><?php echo $post->post_title;?><br />
<?php foreach($terms as $the_term) { echo $the_term->name; } ?>
</td>
<td><?php echo date('F j, Y',$event_date);?></td>
<td><?php echo date('F j, Y',$register_date);?></td>
<td>$<?php echo number_format($cost,2);?></td>
<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>
</tr>
<?php endif; endforeach; ?>
</tbody>
</table>
</div>
<script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
\ No newline at end of file
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\CEHours;
use Tz\WordPress\CBV\Invoice;
use Tz\WordPress\CBV\Events;
use Tz\WordPress\UAM;
use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
use Tz\WordPress\Tools\Notifications;
use Exception, StdClass;
use WP_User;
?>
<div style="padding:10px 10px 0px 10px; min-width:760px;position:relative;">
<h2 style="margin-bottom:10px;padding-bottom:0px;">Admin notes...</h2>
<form id="edit_user_notes">
<input type="hidden" name="uid" value="<?php echo $_GET['uid']; ?>" />
<textarea style="width:99%" rows="10" id="note" name="note"><?php echo get_user_meta($_GET['uid'], 'admin_notes',true);?></textarea>
<div style="margin-top:15px;"><input type="submit" value="Update Notes" /><span class="update-placeholder"></span></div>
</form>
</div>
<script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
\ No newline at end of file
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\CEHours;
use Tz\WordPress\CBV\Events;
use Tz\WordPress\CBV\User;
use Tz\WordPress\UAM;
use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
use Tz\WordPress\Tools\Notifications;
use Exception, StdClass;
use WP_User, WP_Roles;
$uid = $_GET['uid'];
$account = new User\Account($uid);
$pp = get_user_meta($uid, 'profile_preference', true).'_';
$first_name = get_user_meta($uid, 'first_name', true);
$last_name = get_user_meta($uid, 'last_name', true);
// contact info.
$country = get_user_meta($uid, $pp.'country', true);
$mobile = get_user_meta($uid, 'mobile', true);
$email_pref = get_user_meta($uid, 'email_address_preference', true);
if (!empty($email_pref) && $email_pref != "none") {
$pref = strtolower($email_pref)."_";
$email = get_user_meta($uid, $pref."email", true);
} else {
$email = "";
}
//$email = $user->user_email;//get_user_meta($uid, 'email', true);
// professional stuff
$title = get_user_meta($uid, 'title', true);
$company = get_user_meta($uid, 'company_name', true);
// status
$status = get_user_meta($uid, 'status', true);
// membership
$member_id = get_user_meta($uid, 'member_id', true);
$notify_me = get_user_meta($uid, 'notify_me', true);
$rc = new WP_Roles();
$roles = $rc->role_names;
ksort($roles);
unset($rc, $roles['administrator']);
?>
<div style="padding:10px 10px 0px 10px; min-width:760px;">
<form method="post" id="overview_form">
<h2 style="margin-bottom:10px;padding-bottom:0px;">Overview of Users' Account...</h2>
<div style="float:left; width:300px;margin-right:50px;">
<table cellspacing="0" class="widefat post fixed" style="border:none;">
<tbody>
<tr>
<th>User Login:</th>
<td><?php echo $account->user_login; ?></td>
</tr>
<?php if (!empty($first_name)): ?>
<tr>
<th>First Name:</th>
<td><?php echo $first_name; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($last_name)): ?>
<tr>
<th>Last Name:</th>
<td><?php echo $last_name; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($company)): ?>
<tr>
<th>Company:</th>
<td><?php echo $company; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($title)): ?>
<tr>
<th>Title:</th>
<td><?php echo $title; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($email)): ?>
<tr>
<th>Email:</th>
<td><a href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a></td>
</tr>
<?php endif; ?>
</tbody>
</table>
<h3 style="margin-bottom:5px; padding-bottom:0px;">Change User Password:</h3>
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td width="150">New Password (twice)</td>
<td><input type="password" name="password1" value="" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="password" name="password2" value="" /></td>
</tr>
<tr><td colspan="2" style="font-size:11px;"><em>(leave them blank to not change their password)</em></td></tr>
</tbody>
</table>
<div style="clear:both;"></div>
<div id="show_special_status" style="display:block;">
<h3 style="margin-bottom:5px; padding-bottom:0px;">Special Status:</h3>
<input type="hidden" name="special_status_active" value="true" />
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td width="20"><input type="checkbox" id="status_retired" name="special_status[]" value="status_retired" <?php search_special_status('status_retired');?> /></td>
<td><label for="status_retired">Retired status</label></td>
</tr>
<tr>
<td width="20"><input type="checkbox" id="status_disabled" name="special_status[]" value="status_disabled" <?php search_special_status('status_disabled');?> /></td>
<td><label for="status_disabled">Disability status</label></td>
</tr>
<tr>
<td width="20"><input type="checkbox" id="status_parental" name="special_status[]" value="status_parental" <?php search_special_status('status_parental');?> /></td>
<td><label for="status_parental">Parental status</label></td>
</tr>
<tr>
<td width="20"><input type="checkbox" id="status_educational" name="special_status[]" value="status_educational" <?php search_special_status('status_educational');?> /></td>
<td><label for="status_educational">Educational status</label></td>
</tr>
<tr>
<td width="20"><input type="checkbox" id="tax_exempt" name="special_status[]" value="tax_exempt" <?php search_special_status('tax_exempt');?> /></td>
<td><label for="tax_exempt">Tax Exemption</label></td>
</tr>
<tr>
<td width="20"><input type="checkbox" id="status_life" name="special_status[]" value="status_life" <?php search_special_status('status_life');?> /></td>
<td><label for="status_life">Life Member</label></td>
</tr>
</tbody>
</table>
<div style="clear:both;"></div>
</div>
</div>
<div style="float:left; width:360px; border-left: 1px solid #ccc;">
<div style="margin-left:20px; margin-bottom:20px;">
<!-- coming soon...
<h3 style="margin-bottom:5px; padding-bottom:0px;">Account Balance:</h3>
<div style="color:red; font-size:18px;">-$130.00</div>
-->
<input type="hidden" name="uid" value="<?php echo $uid; ?>" />
<input type="hidden" name="section" value="account" />
<h3 style="margin-bottom:5px; padding-bottom:0px;">Account:</h3>
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td width="100">Status:</td>
<td>
<select name="status" style="width:150px;">
<option value="active" <?php echo ($status=="active") ? "selected" : ""; ?>>Active</option>
<option value="suspended" <?php echo ($status=="suspended") ? "selected" : ""; ?>>Suspended</option>
<option value="terminated" <?php echo ($status=="terminated") ? "selected" : ""; ?>>Terminated</option>
</select>
</td>
</tr>
<?php if($role!="administrator"):?>
<tr>
<td>Type:</td>
<td>
<select name="user_role" id="user_role" style="width:150px;">
<?php foreach($roles as $roled=>$name):?>
<option value="<?php echo $roled;?>" <?php echo ($roled==$role) ? "selected" : "";?>><?php echo $name;?></option>
<?php endforeach;?>
</select>
</td>
</tr>
<?php endif; ?>
<?php
$mau = get_user_meta($_GET['uid'], 'membership_valid_until', true);
if ( !empty($mau) ) {
$current_mau = $mau;
} else {
$current_mau = "";
}
?>
<tr>
<td>Active Until</td>
<td>
<select name="membership_valid_until" id="membership_valid_until" style="width:150px;">
<option value="" <?php echo ($current_mau=="") ? "selected" : ""; ?>>Select ...</option>
<?php if ( !empty($current_mau) ): ?>
<option value="<?php echo $current_mau;?>" selected><?php echo $current_mau;?></option>
<?php endif; ?>
<optgroup label="Change to:">
<?php
$max_avail_mau = ((int) date("Y") + 3);
for($mi = (int) date("Y"); $mi <= $max_avail_mau;$mi++) {
echo '<option value="'.$mi.'">'.$mi.'</option>';
}
?>
</optgroup>
</select>
</td>
</tr>
</tbody>
</table>
<div style="clear:both;"></div>
<div>
<h3>Groups:</h3>
<ul>
<?php
$groups = UAM\getGroups();
foreach ($groups as $group):
$dom = "group[{$group->getID()}]";
$checked = ($account->isMemberOf($group->getName()) ? ' checked="checked"' : '');
$disabled = ($group->isRoleAffiliated($account->getRole()) ? ' disabled="disabled"' : '');
?>
<li>
<input type="hidden" name="grpanch[<?php echo $group->getID(); ?>]" value="1" />
<input type="checkbox" name="<?php echo $dom; ?>" id="<?php echo $dom; ?>" value="1" <?php echo $checked . $disabled; ?> />
<label for="<?php echo $dom; ?>"><?php echo $group->getName(); ?></label>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class="validation-errors" style="display:none;"><div class="error-wrap"><h6>OOPS...</h6><ul></ul></div></div>
<br />
<input type="submit" value="Update Account" /><span class="update-placeholder"></span>
</div>
<div style="clear:both;"></div>
</div>
<div style="clear:both;"></div>
</form>
</div>
<script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
<script type="text/javascript">
jQuery(function() {
/* Dan asked me to keep special status open for all in the backend.
jQuery('#user_role').change(function() {
if (jQuery(this).val() == "member") {
jQuery('#show_special_status').show();
} else {
jQuery('#show_special_status').hide();
}
});
*/
});
</script>
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\CEHours;
use Tz\WordPress\CBV\Invoice;
use Tz\WordPress\CBV\Events;
use Tz\WordPress\UAM;
use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
use Tz\WordPress\Tools\Notifications;
use Exception, StdClass;
use WP_User;
?>
<div style="padding:10px 10px 0px 10px; min-width:760px;position:relative;">
<h2 style="margin-bottom:10px;padding-bottom:0px;">Users' Invoice/Receipts...
<?php if (!isset($_GET['view'])):?>
<a href="#" class="button add-new-h2" id="creditNotBtn">Create new Invoice/Credit Note</a>
<?php endif; ?>
</h2>
<div id="credit_note" style="display:none;">
<div style="border:1px solid #e8e8e8; background-color:#f5f5f5;padding:10px;">
<form id="creditForm" method="POST">
<input type="hidden" name="uid" value="<?php echo $_GET['uid']; ?>" />
<h3 style="margin:0;padding:0;">Invoice/Credit Note...</h3>
<table width="100%" style="margin-top:10px;">
<tbody>
<tr>
<td width="130">Type</td>
<td>
<select name="invoice_type" id="invoice_type">
<option value="invoice">Invoice</option>
<option value="membership">Membership Fees</option>
<option value="credit">Credit Note</option>
</select>
</td>
</tr>
<tr class="invoice_credit_only">
<td>Description</td>
<td><input type="text" name="title" style="width:400px" /></td>
</tr>
<tr class="invoice_credit_only">
<td>Amount ($)</td>
<td><input type="text" name="amount" /></td>
</tr>
<tr class="invoice_only">
<td>Paid?</td>
<td><input type="checkbox" name="paid" value="on" /></td>
</tr>
<tr class="invoice_only">
<td>Paid By</td>
<td>
<select name="paid_by">
<option value="">Select payment type...</option>
<option value="PPV">Pre-paid with Visa</option>
<option value="PPMC">Pre-paid with Mastercard</option>
<option value="PPAMEX">Pre-paid with American Express</option>
<option value="CHEQUE">Paid by Cheque</option>
</select>
</td>
</tr>
<tr>
<td colspan="4" style="padding-top:5px;"><input type="submit" value="Apply Invoice/Credit Note" /></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
<?php
if ( isset($_GET['view']) ) {
$invoice = get_post($_GET['view']);
$invoice->items = get_post_meta($invoice->ID, 'items',true);
$invoice->payment = get_post_meta($invoice->ID, 'payment',true);
$date = strtotime($invoice->post_date);
$date = date("F j, Y",$date);
if ( ($invoice->post_author !== Tools\getCurrentUser()->ID) AND !is_admin()) {
print "<div style='color:#DF1C24;font-weight:bold;'>YOU CAN ONLY VIEW YOUR OWN INVOICES.</div>";
} else {
$html = '<p><a href="/wp-admin/admin.php?page=cbv_users&action=edit&uid='.$_GET['uid'].'&section=payhistory">Show all invoices</a></p>';
$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>';
$html .= Invoice\DrawInvoice($invoice,true);
$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>';
print $html;
}
} else {
Invoice\showMyInvoices($_GET['uid'], "/wp-admin/admin.php?page=cbv_users&action=edit&uid=".$_GET['uid']."&section=payhistory&view=");
}
?>
<?php if (!isset($_GET['view']) && !isset($_GET['pay'])): ?>
<div id="tax_receipts" style="margin-top:40px;">
<h3>T2202a Receipts</h3>
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<?php
$t2202a = get_user_meta($_GET['uid'], 't2202a', true);
if ( empty ($t2202a) ) {
echo '<tr><td colspan="2">No t2202a\'s available.</td></tr>';
} else {
foreach ($t2202a as $year => $file) {
?>
<tr>
<td width="120"><strong><?php echo $year; ?></strong></td>
<td><a href="<?php echo "/wp-content/uploads/t2202a/".$file; ?>">Download 2010 <?php echo ucwords(strtolower('TUITION, EDUCATION, AND TEXTBOOK AMOUNTS CERTIFICATE'));?></a></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
<script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#invoice-table').dataTable({
"sPaginationType": "full_numbers"
, "bFilter": false
, "bLengthChange": false
, "aaSorting": [[ 0, "desc" ]]
, "iDisplayLength": 20
, "oLanguage": {
"sZeroRecords": "No matching records found"
, "sEmptyTable": "No invoices/receipts available"
, "sInfo": "Showing _START_ to _END_ of _TOTAL_ invoices/receipts"
, "sInfoEmpty": "Showing 0 to 0 of 0 invoices/receipts"
, "sInfoFiltered": "(filtered from _MAX_ total invoices/receipts)"
}
});
});
</script>
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\User;
use Tz\WordPress\CBV\CEHours;
use Tz\WordPress\CBV\Events;
use Tz\WordPress\UAM;
use Tz\WordPress\Tools\HTML;
use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD;
use Tz\WordPress\Tools\Notifications;
use Exception, StdClass;
use WP_User;
$user = new WP_User($_GET['uid']);
Tools\import('HTML');
$profile_preference = get_user_meta($user->ID, 'profile_preference', true);
$preference = get_user_meta($user->ID, 'email_address_preference', true);
?>
<div style="padding:10px 10px 0px 10px; min-width:800px;" class="my-profile-edit">
<h2 style="margin-bottom:10px;padding-bottom:0px;">Users' Profile...</h2>
<form name="admin-edit-user-profile" id="admin-edit-user-profile" style="margin-top:0;padding-top:0;">
<input type="hidden" name="section" value="profile" />
<input type="hidden" name="uid" value="<?php echo $user->ID;?>" />
<div style="float:left; width:400px;margin-right:20px;">
<h4>Personal Information</h4>
<table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
<tbody>
<tr>
<th width="150">Prefix:</th>
<td>
<select name="prefix">
<?php HTML\select_opts_prefixes(get_user_meta($_GET['uid'], 'prefix', true)); ?>
</select>
</td>
</tr>
<tr>
<th width="150">First Name:</th>
<td><input type="text" name="first_name" value="<?php echo get_user_meta($_GET['uid'], 'first_name', true);?>" /></td>
</tr>
<tr>
<th>Middle Name:</th>
<td><input type="text" name="initial" value="<?php echo get_user_meta($_GET['uid'], 'initial', true);?>" /></td>
</tr>
<tr>
<th>Last Name:</th>
<td><input type="text" name="last_name" value="<?php echo get_user_meta($_GET['uid'], 'last_name', true);?>" /></td>
</tr>
<tr>
<th>Degrees:</th>
<td><input type="text" name="degrees" value="<?php echo get_user_meta($_GET['uid'], 'degrees', true);?>" /></td>
</tr>
<tr>
<th>Designations:</th>
<td><input type="text" name="designations" value="<?php echo get_user_meta($_GET['uid'], 'designations', true);?>" /></td>
</tr>
<tr>
<th>Biography:</th>
<td><textarea name="description"><?php echo get_user_meta($_GET['uid'], 'description', true);?></textarea></td>
</tr>
<tr>
<th>Date of Birth:<br /><span style="font-size:10px;color:#999;font-weight:normal;">(Ex. YYYY-MM-DD)</span></th>
<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>
</tr>
</tbody>
</table>
<h4>Notification Settings</h4>
<table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
<tbody>
<tr>
<th width="150">Email for Notifications:</th>
<td>
<select name="email_address_preference">
<?php
$preference = get_user_meta($_GET['uid'], 'email_address_preference',true);
$home_email = get_user_meta($_GET['uid'],'home_email',true);
$work_email = get_user_meta($_GET['uid'],'work_email',true);
?>
<option value="none" <?php echo ($preference=="none") ? "selected" : "";?>>None</option>
<?php if(!empty($home_email)):?><option value="Home" <?php echo ($preference=="Home") ? "selected" : "";?>>Home > <?php echo $home_email;?></option><?php endif;?>
<?php if(!empty($work_email)):?><option value="Work"<?php echo ($preference=="Work") ? "selected" : "";?>>Work > <?php echo $work_email;?></option><?php endif;?>
</select>
</td>
</tr>
</tbody>
</table>
<?php if ($role=="member") :?>
<h4>Membership</h4>
<table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
<tbody>
<tr>
<th width="150">Member Since:</th>
<td><input type="text" name="member_since" value="<?php echo get_user_meta($_GET['uid'], 'member_since', true);?>" /></td>
</tr>
</tbody>
</table>
<?php endif;?>
</div>
<div style="float:left; width:350px;"> <!-- RIGHT SIDE -->
<h4>Home Contact Information</h4>
<table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
<tbody>
<tr>
<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>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<th>Address:</th>
<td><input type="text" name="home_address" value="<?php echo get_user_meta($_GET['uid'], 'home_address', true);?>" /></td>
</tr>
<tr>
<th>Suite:</th>
<td><input type="text" name="home_address2" value="<?php echo get_user_meta($_GET['uid'], 'home_address2', true);?>" /></td>
</tr>
<tr>
<th>City:</th>
<td><input type="text" name="home_city" value="<?php echo get_user_meta($_GET['uid'], 'home_city', true);?>" /></td>
</tr>
<tr>
<th>Country:</th>
<td><?php echo HTML\form_dropdown('home_country', HTML\Vars::$countries, get_user_meta($_GET['uid'], 'home_country', true), "id='home_country'"); ?></td>
</tr>
<tr>
<th>State/Province:</th>
<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>
</tr>
<tr>
<th>Postal:</th>
<td><input type="text" name="home_postal" value="<?php echo get_user_meta($_GET['uid'], 'home_postal', true); ?>" /></td>
</tr>
<tr>
<th>Phone:</th>
<td><input type="text" name="home_phone" value="<?php echo get_user_meta($_GET['uid'], 'home_phone', true);?>" rel="mask-phone" /></td>
</tr>
<tr>
<th>Email:</th>
<td><input type="text" name="home_email" value="<?php echo get_user_meta($_GET['uid'], 'home_email', true);?>" /></td>
</tr>
<tr>
<th>Mobile:</th>
<td><input type="text" name="home_mobile" value="<?php echo get_user_meta($_GET['uid'], 'home_mobile', true);?>" rel="mask-phone" /></td>
</tr>
</tbody>
</table>
<h4>Work Contact Information</h4>
<table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
<tbody>
<tr>
<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>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr class="work-only">
<th>Company:</th>
<td><input type="text" name="company" value="<?php echo get_user_meta($_GET['uid'], 'company', true);?>" /></td>
</tr>
<tr class="work-only">
<th>Company Type:</th>
<td><?php echo HTML\form_dropdown('company_type', HTML\Vars::$company_types, get_user_meta($_GET['uid'], 'company_type', true), "id='company_type'"); ?></td>
</tr>
<tr class="work-only">
<th>Title:</th>
<td><input type="text" name="title" value="<?php echo get_user_meta($_GET['uid'], 'title', true);?>" /></td>
</tr>
<tr>
<th>Address:</th>
<td><input type="text" name="work_address" value="<?php echo get_user_meta($_GET['uid'], 'work_address', true);?>" /></td>
</tr>
<tr>
<th>Suite:</th>
<td><input type="text" name="work_address2" value="<?php echo get_user_meta($_GET['uid'], 'work_address2', true);?>" /></td>
</tr>
<tr>
<th>City:</th>
<td><input type="text" name="work_city" value="<?php echo get_user_meta($_GET['uid'], 'work_city', true);?>" /></td>
</tr>
<tr>
<th>Country:</th>
<td><?php echo HTML\form_dropdown('work_country', HTML\Vars::$countries, get_user_meta($_GET['uid'], 'work_country', true), "id='work_country'"); ?></td>
</tr>
<tr>
<th>State/Province:</th>
<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>
</tr>
<tr>
<th>Postal:</th>
<td><input type="text" name="work_postal" value="<?php echo get_user_meta($_GET['uid'], 'work_postal', true); ?>" /></td>
</tr>
<tr>
<th>Phone:</th>
<td><input type="text" name="work_phone" value="<?php echo get_user_meta($_GET['uid'], 'work_phone', true);?>" rel="mask-phone" />
&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>
</tr>
<tr>
<th>Fax:</th>
<td><input type="text" name="work_fax" value="<?php echo get_user_meta($_GET['uid'], 'work_fax', true);?>" rel="mask-phone" /></td>
</tr>
<tr>
<th>Email:</th>
<td><input type="text" name="work_email" value="<?php echo get_user_meta($_GET['uid'], 'work_email', true);?>" /></td>
</tr>
<tr>
<th>Mobile:</th>
<td><input type="text" name="work_mobile" value="<?php echo get_user_meta($_GET['uid'], 'work_mobile', true);?>" rel="mask-phone" /></td>
</tr>
<tr class="work-only">
<th>Website:</th>
<td><input type="text" name="website" value="<?php echo get_user_meta($_GET['uid'], 'website', true);?>" /></td>
</tr>
</tbody>
</table>
</div>
<div style="clear:both;"></div>
<div class="validation-errors" style="display:none;"><div class="error-wrap"><h6>OOPS...</h6><ul></ul></div></div>
<br />
<input type="submit" value="Update Profile" /><span class="update-placeholder"></span>
</form>
</div>
<script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
<script src="<?php echo Tools\url('../');?>"></script>
<script>
jQuery(function($) {
//$('input[rel="mask-phone"]').mask("999-999-9999");
$('input[rel="mask-birthdate"]').mask("9999-99-99");
/*
update_listing_preference();
jQuery('#profile_preference').change(function() {
update_listing_preference();
});
*/
});
</script>
\ No newline at end of file
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\User;
use Tz\WordPress\UAM;
use Tz\WordPress\Tools;
use Tz\WordPress\Tools\Auth;
use Exception, StdClass;
use WP_User;
global $wpdb;
// Get the original timezone (so we can set it back) and figure out the
// timestamp for March 1 UTC
$original_timezone = date_default_timezone_get();
date_default_timezone_set('UTC');
$begin_date = strtotime('March 1');
// Set the timezone back to original setting
date_default_timezone_set($original_timezone);
if (! empty($_POST['do_fix']) && $_POST['do_fix'] == 'y') {
$count_result = mysql_query("SELECT COUNT(*) FROM `{$wpdb->users}`", $wpdb->dbh);
list($num) = mysql_fetch_row($count_result);
$max = 1000;
for ($ui = 0; $ui < $num; $ui += $max) {
$users = $wpdb->get_results("SELECT `ID` FROM `{$wpdb->users}` LIMIT {$ui}, {$max}");
foreach ($users as $user) {
$invoices = get_user_meta($user->ID, 'invoices', TRUE);
foreach ($invoices as $invoice_id) {
// Get the transaction status
$trans_status = get_post_meta($invoice_id, 'trans_status', TRUE);
// Don't do anything unless the status is 'unpaid'
if ($trans_status != 'unpaid') {
continue;
}
// Get the invoice and check if it's newer than March 1 UTC
$invoice = get_post($invoice_id);
if (strtotime($invoice->post_date) < $begin_date) {
continue;
}
// Here's the heavy work: get the payment data and add appropriate taxes
$payment = get_post_meta($invoice_id, 'payment', TRUE);
$trans_amount = get_post_meta($invoice_id, 'trans_amount', TRUE);
$pp = get_user_meta($user->ID, 'profile_preference', true);
// Get the user's profile preference and use it to get the tax percent
if (!empty($pp)) {
$preference = strtolower($pp) . '_province';
$tax_percent = getTaxesByProvince(get_user_meta($user->ID, $preference, true)) * .01;
} else {
$tax_percent = getTaxesByProvince($payment['bt_province']) * .01;
}
$payment['total_taxes'] = $payment['total_cost'] * $tax_percent;
$payment['total'] = number_format($payment['total_cost'] - $payment['total_discounts'] + $payment['total_taxes'], 2);
$trans_amount = $payment['total'];
// Now update the post
update_post_meta($invoice_id, 'payment', $payment);
update_post_meta($invoice_id, 'trans_amount', $trans_amount);
}
}
unset($users, $invoices);
}
}
?>
<style>
h4 {
float: left;
padding-right: 1em;
}
.merge-users {
float: left;
padding-right: 2em;
}
.merge-users label {
float: left;
font-weight: bold;
padding-right: 1em;
}
.merge-users input {
float: left;
}
.clear {
float: left;
clear: both;
}
.user-list, .user-list li {
float: left;
clear: both;
}
.changed {
margin-top: 5px;
clear: both;
display: none;
}
.changed h6 {
padding: 0px;
margin: 0px 0px 10px 0px;
font-size: 11px;
text-transform: uppercase;
}
.changed ul {
margin: 0;
padding: 0;
}
.changed ul li {
margin: 0px 0px 3px 0px;
padding: 0px;
font-size: 11px;
background: none;
}
.merge-table td { padding:10px;}
</style>
<div class="wrap">
<div id="icon-users" class="icon32"><br /></div>
<h2>Fix Unpaid Invoices</h2>
<div class="validation-errors" style="display:none; margin: 10px 0px 10px;">
<div class="error-wrap">
<ul></ul>
</div>
</div>
<div id="post-body" style="padding:10px 0px 15px 0px;">
<form method="post" id="fix_unpaid_invoices">
<!--<table cellspacing="0" class="widefat post fixed merge-table">
<thead>
<tr>
<th width="50%"><label for="search_user_from">Merge <strong><em>FROM</em></strong> User:</label></th>
<th width="50%"><label for="search_user_to">Merge <strong><em>TO</em></strong> User:</label></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="merge-users">
<input class="clear" type="text" name="search_user_from" value="<?php echo $_POST['search_user_from'] ?>" />
<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;" />
</div>
</td>
<td>
<div class="merge-users">
<input class="clear" type="text" name="search_user_to" value="<?php echo $_POST['search_user_to'] ?>" />
<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;" />
</div>
</td>
</tr>
<tr>
<td><div id="user-list-from"></div></td>
<td><div id="user-list-to"></div></td>
</tr>
</tbody>
</table>-->
<div id="field-list" class="changed">
<table cellspacing="0" class="widefat post fixed merge-table"></table>
</div>
<div style="clear:both;"></div>
<div style="margin-top:10px;">
<input type="hidden" name="do_fix" value="y" />
<input type="submit" value="Do It" />
</div>
</form>
</div>
</div>
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\CBV;
use Tz\WordPress\CBV\User;
use Tz\WordPress\UAM;
use Tz\WordPress\Tools;
use Tz\WordPress\Tools\Auth;
use Exception, StdClass;
use WP_User;
// Make sure some defaults are set because we use these values as is in the input boxes
if (! isset($_POST['search_user_from'])) {
$_POST['search_user_from'] = '';
}
if (! isset($_POST['search_user_to'])) {
$_POST['search_user_to'] = '';
}
?>
<style>
h4 {
float: left;
padding-right: 1em;
}
.merge-users {
float: left;
padding-right: 2em;
}
.merge-users label {
float: left;
font-weight: bold;
padding-right: 1em;
}
.merge-users input {
float: left;
}
.clear {
float: left;
clear: both;
}
.user-list, .user-list li {
float: left;
clear: both;
}
.changed {
margin-top: 5px;
clear: both;
display: none;
}
.changed h6 {
padding: 0px;
margin: 0px 0px 10px 0px;
font-size: 11px;
text-transform: uppercase;
}
.changed ul {
margin: 0;
padding: 0;
}
.changed ul li {
margin: 0px 0px 3px 0px;
padding: 0px;
font-size: 11px;
background: none;
}
.merge-table td { padding:10px;}
</style>
<div class="wrap">
<div id="icon-users" class="icon32"><br /></div>
<h2>Merge CBV Users...</h2>
<div class="validation-errors" style="display:none; margin: 10px 0px 10px;">
<div class="error-wrap">
<ul></ul>
</div>
</div>
<div id="post-body" style="padding:10px 0px 15px 0px;">
<form method="post" id="admin-search-merge-form">
<table cellspacing="0" class="widefat post fixed merge-table">
<thead>
<tr>
<th width="50%"><label for="search_user_from">Merge <strong><em>FROM</em></strong> User:</label></th>
<th width="50%"><label for="search_user_to">Merge <strong><em>TO</em></strong> User:</label></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="merge-users">
<input class="clear" type="text" name="search_user_from" value="<?php echo $_POST['search_user_from'] ?>" />
<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;" />
</div>
</td>
<td>
<div class="merge-users">
<input class="clear" type="text" name="search_user_to" value="<?php echo $_POST['search_user_to'] ?>" />
<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;" />
</div>
</td>
</tr>
<tr>
<td><div id="user-list-from"></div></td>
<td><div id="user-list-to"></div></td>
</tr>
</tbody>
</table>
<div id="field-list" class="changed">
<table cellspacing="0" class="widefat post fixed merge-table"></table>
</div>
<div style="clear:both;"></div>
<div style="margin-top:10px;">
<input type="hidden" value="from" name="which_user_search" />
<input type="hidden" value="no" name="do_search" />
<input type="hidden" value="no" name="do_merge" />
<input type="button" value="Merge Users" name="btn_merge" />
</div>
</form>
</div>
</div>
<script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script>
<script type="text/javascript">
var $ = jQuery;
var $which_user_search = $('[name=which_user_search]');
var $do_search = $('[name=do_search]');
var $do_merge = $('[name=do_merge]');
var $form = $('#admin-search-merge-form');
var $field_list = $('#field-list');
var $error_container = $('.validation-errors');
var $from_spinner = $('#search_user_from_spinner');
var $to_spinner = $('#search_user_to_spinner');
$('[name=btn_user_from]').click(function() {
$from_spinner.show();
$which_user_search.val("from");
$do_search.val("yes");
$form.submit();
});
$('[name=btn_user_to]').click(function() {
$to_spinner.show();
$which_user_search.val("to");
$do_search.val("yes");
$form.submit();
});
$('[name=btn_merge]').click(function() {
$do_search.val("no");
$do_merge.val("yes");
if (confirm('Are you sure you want to merge users? This action is NOT reversible!')) {
$form.submit();
}
});
$(function() {
var options = {
url: ajaxurl,
dataType: 'json',
type: 'post',
data: ({ajax:"yes", action: 'admin_search_merge_users'}),
success: function(data) {
$('.spinners').hide();
if (data.success == "false") {
$('h6', $error_container).html("OOPS...");
$('ul', $error_container).html(data.msg);
$field_list.hide();
$error_container.show();
} else {
$error_container.hide();
if (data.fields === undefined) {
$('#user-list-' + data.direction).html(data.html);
$field_list.hide();
} else {
$('#user-list-from').html("");
$('#user-list-to').html("");
$('table', $field_list).html(data.fields);
$field_list.show();
}
}
}
};
$form.ajaxForm(options);
});
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Edit CE Hours</title>
<style type="text/css">
html, body { margin:0px; padding:0;}
.title-link {
color:#f7bd55;
font-size: 12px;
font-weight: bold;
text-align: left;
line-height: 1.75em;
background: #3b0d32;
border: solid 1px #FFF;
border-bottom: solid 1px #999;
cursor: default;
padding: 0em; padding:3px 10px 3px 10px;
margin: 0em;
}
form {
display: block;
margin-right:20px;
}
.dashboard-section-title { font-weight:bold; color:#3b0d32; }
</style>
</head>
<body>
<div style="display:block; width:750px; margin-bottom:10px;">
<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>
<form method="post" action="" id="edit-cehours-form">
<input type="hidden" name="uid" value="<?php echo $uid; ?>" />
<input type="hidden" name="indexed" value="<?php echo $indexed; ?>" />
<input type="hidden" name="action" value="<?php echo $action; ?>" />
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
<table class="clean no-left-padding">
<tbody>
<tr class="top-td">
<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>
<th>Date:</th>
<td width="150"><input type="text" name="date" readonly class="datepicker" style="width:120px;" value="<?php echo $date;?>" /></td>
<th>Activity Type:</th>
<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>
<th>Hours:</th>
<td style="width:50px;"><input type="text" name="hours" style="width:45px;" maxlength="4" value="<?php echo $hours;?>" /></td>
</tr>
<tr class="activity_row bottom-border-td">
<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>
</tr>
<tr>
<td colspan="7"><div><input type="submit" value="Apply" /></div></td>
</tr>
</tbody>
</table>
</div>
</div>
</form>
</div>
<script type="text/javascript">
var $ = jQuery;
function updateCEType(obj) {
var $selectbox = $(obj);
var $table = $(obj).parent().parent().parent();
var $activity_row = $('tr.activity_row', $table);
switch($selectbox.val()) {
case 'event':
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>';
break;
case 'lump':
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>';
break;
default:
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>';
}
$activity_row.html(r);
}
jQuery(function($) {
$('.subtype').live('change', function() {
updateCEType(this);
});
updateCEType($('.subtype'));
});
</script>
</body>
</html>
\ No newline at end of file
<?php
$enrolments = $course->getEnrolments($user->ID);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Edit Course</title>
<style type="text/css">
html, body { margin:0px; padding:0;}
.title-link {
color:#f7bd55;
font-size: 12px;
font-weight: bold;
text-align: left;
line-height: 1.75em;
background: #3b0d32;
border: solid 1px #FFF;
border-bottom: solid 1px #999;
cursor: default;
padding: 0em; padding:3px 10px 3px 10px;
margin: 0em;
}
form {
display: block;
margin-right:20px;
}
.dashboard-section-title { font-weight:bold; color:#3b0d32; }
</style>
</head>
<body>
<form method="post" id="edit-course-form">
<input type="hidden" name="course_id" value="<?php echo $course->getID(); ?>" />
<input type="hidden" name="user_id" value="<?php echo $user->ID; ?>" />
<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>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">HOW TO PROCESS THE REGISTRATION:</div>
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
<select name="paid_by">
<?php /*
<option value="unpaid">Invoice User</option>
<option value="complementary">Complementary</option>
*/ ?>
<option value="visa">Paid by Prepaid Visa</option>
<option value="mc">Paid by Prepaid Mastercard</option>
<option value="amex">Paid by Prepaid American Express</option>
<option value="cheque">Paid by Cheque</option>
</select>
</div>
</div>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">ENROLMENT TYPE</div>
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
<select name="enrolltype">
<?php foreach ($enrolments as $key => $display): ?>
<option value="<?php echo $key; ?>"><?php echo $display; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">
<input type="checkbox" name="exam" id="exam" value="1" checked />
<label for="exam">WRITING EXAM?</label>
</div>
</div>
<?php if ($user->isStudentFeeDue()): ?>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">
<input type="checkbox" name="studentfee" id="studentfee" value="1" checked />
<label for="studentfee">PAID ANNUAL REGISTRATION FEE?</label>
</div>
</div>
<?php endif; ?>
<?php if (!$user->isMemberOf('Casebook')): ?>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">
<input type="checkbox" name="casebook" id="casebook" value="1" checked />
<label for="casebook">PURCHASED CASEBOOK?</label>
</div>
</div>
<?php endif; ?>
<?php if ($user->isOverseas()): ?>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">
<input type="checkbox" name="overseas" id="overseas" value="1" checked />
<label for="overseas">PAID OVERSEAS SURCHARGE?</label>
</div>
</div>
<?php endif; ?>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title"></div>
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
<div><input type="submit" value="Register" /></div>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Edit Event</title>
<style type="text/css">
html, body { margin:0px; padding:0;}
.title-link {
color:#f7bd55;
font-size: 12px;
font-weight: bold;
text-align: left;
line-height: 1.75em;
background: #3b0d32;
border: solid 1px #FFF;
border-bottom: solid 1px #999;
cursor: default;
padding: 0em; padding:3px 10px 3px 10px;
margin: 0em;
}
form {
display: block;
margin-right:20px;
}
.dashboard-section-title { font-weight:bold; color:#3b0d32; }
</style>
</head>
<body>
<div style="width: 760px;">
<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>
<div style="padding: 10px 0px 10px 10px; width:350px; float:left;">
<table class="small-table">
<?php
// get categories....
$event_term_slugs = array();
$terms = get_the_terms($post->ID,'event_type');
$external_only = false;
if (!empty($terms)) {
foreach($terms as $types) {
$event_term_slugs[$types->slug] = $types->name;
}
}
$location = get_post_meta($post->ID, 'location', true);
$cost = get_post_meta($post->ID,'cost',true);
if ( ($cost == "0" || $cost == "0.00" || strtolower($cost) == "free") && !$external_only ) {
$purchasable = false;
$cost = "FREE";
} elseif ( (!empty($cost) && (int) $cost < 1) && !$external_only ) {
$purchasable = false;
$cost = $cost;
} elseif ( (empty($cost) && (int) $cost < 1) && !$external_only ) {
$purchasable = false;
$cost = $cost;
} elseif ($external_only) {
$purchasable = false;
} else {
$cost = (int) $cost;
$cost = str_replace(",","",$cost);
$purchasable = true;
}
?>
<tr>
<td width="140"><strong>Event Type</strong></td>
<td>
<?php
foreach($terms as $term) {
echo $term->name.'<br />';
}
?>
</td>
</tr>
<?php if (!empty($location)):?>
<tr>
<td><strong>Location</strong></td>
<td><?php echo $location; ?></td>
</tr>
<?php endif; ?>
<tr>
<td><strong>When</strong></td>
<td>
<?php
$event_date = get_post_meta($post->ID, 'event_date', true);
$event_date_end = get_post_meta($post->ID, 'event_date_end', true);
if ( empty($event_date_end) ) {
echo date("M j, Y",$event_date);
} else {
$start_month = date("M", $event_date);
$start_day = date("d", $event_date);
$start_year = date("Y", $event_date);
$end_month = date("M", $event_date_end);
$end_day = date("d", $event_date_end);
$end_year = date("Y", $event_date_end);
// format: April 3-7, 2011
if ($start_month == $end_month && $start_year == $end_year) {
echo $start_month." ".$start_day."-".$end_day.", ".$start_year;
} elseif ($start_month != $end_month && $start_year == $end_year) {
echo $start_month." ".$start_day." - ".$end_month." ".$end_day.", ".$start_year;
} else {
// format: April 3 - May 2, 2011
echo $start_month." ".$start_day.", ".$start_year." - ".$end_month." ".$end_day.", ".$start_year;
}
}
?>
</td>
</tr>
<tr>
<td><strong>Cost</strong></td>
<td><?php echo ($purchasable) ? "$".number_format($cost,2) : $cost; ?></td>
</tr>
<tr>
<td><strong>Stud./Mem. Discount</strong></td>
<td><?php echo (!empty($member_discount)) ? "$".number_format($member_discount,2) : "<em>None</em>";?></td>
</tr>
<tr>
<td><strong>Earlybird Discount</strong></td>
<td><?php echo (!empty($early_bird_discount)) ? "$".number_format($early_bird_discount,2) : "<em>None</em>";?></td>
</tr>
<?php if (!empty($early_bird_deadline) && !empty($early_bird_discount)): ?>
<tr>
<td><strong>Earlybird Deadline</strong></td>
<td><?php echo date("M d, Y",$early_bird_deadline); ?></td>
</tr>
<?php endif; ?>
</table>
</div>
<div style="padding: 0px 0px 10px 0px; width:380px; float:right;">
<?php
$extras = $user_event_meta['extras'];
?>
<form method="post" action="" id="edit-event-form">
<input type="hidden" name="uid" value="<?php echo $uid; ?>" />
<input type="hidden" name="event_id" value="<?php echo $post->ID; ?>" />
<input type="hidden" name="type" value="<?php echo $action; ?>" />
<?php if ($action != "edit"): ?>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">HOW TO PROCESS THE REGISTRATION:</div>
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
<select name="status">
<option value="unpaid" <?php echo ($user_event_meta['status']=="unpaid") ? "selected" : ""; ?>>Invoice User</option>
<option value="complementary" <?php echo ($user_event_meta['status']=="complementary") ? "selected" : ""; ?>>Complementary</option>
<option value="visa" <?php echo ($user_event_meta['status']=="paid" && $user_event_meta['extras']['paid_by']=="visa") ? "selected" : ""; ?>>Paid by Prepaid Visa</option>
<option value="mc" <?php echo ($user_event_meta['status']=="paid" && $user_event_meta['extras']['paid_by']=="mc") ? "selected" : ""; ?>>Paid by Prepaid Mastercard</option>
<option value="amex" <?php echo ($user_event_meta['status']=="paid" && $user_event_meta['extras']['paid_by']=="amex") ? "selected" : ""; ?>>Paid by Prepaid American Express</option>
<option value="cheque" <?php echo ($user_event_meta['status']=="paid" && $user_event_meta['extras']['paid_by']=="cheque") ? "selected" : ""; ?>>Paid by Cheque</option>
</select>
</div>
</div>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">ASSIGN DISCOUNTS:</div>
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
<?php if ( empty($member_discount) && empty($early_bird_discount) ): ?>
<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>
<?php else: ?>
<table>
<?php if (!empty($member_discount)):
$is_member = ($role=="member" OR $role=="student") ? true : false;
?>
<tr>
<td width="20"><input type="checkbox" id="discount_member" name="discount_member" value="on" <?php echo ($is_member) ? "checked='checked'" : "";?> /></td>
<td><label for="discount_member">Student/Member Discount</label></td>
</tr>
<?php endif; ?>
<?php if (!empty($early_bird_discount)):
$is_eb_avail = (!empty($early_bird_deadline) && $early_bird_deadline > time()) ? true : false;
?>
<tr>
<td width="20"><input type="checkbox" id="discount_earlybird" name="discount_earlybird" value="on" <?php echo ($is_eb_avail) ? "checked='checked'" : ""; ?> /></td>
<td><label for="discount_earlybird">Earlybird Discount</label></td>
</tr>
<?php endif; ?>
</table>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">ADDITIONAL NOTES</div>
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
<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>
</div>
</div>
<?php
if (!empty($show_dietary)): ?>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">SPECIAL DIETARY REQUIREMENTS</div>
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
<textarea name="dietary" class="input-field-css input-large" rows="5" style="width:350px;"><?php echo isset($extras['dietary']) ? $extras['dietary'] : ""; ?></textarea>
</div>
</div>
<?php endif; ?>
<?php if (!empty($mealopt_description) || !empty($mealopt_one) || !empty($mealopt_two) || !empty($mealopt_three) || !empty($mealopt_four)):?>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">MEAL OPTIONS</div>
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
<?php if (!empty($mealopt_description)) { echo "<div><strong>".$mealopt_description."</strong></div>"; } ?>
<table class="clean no-left-padding">
<tbody>
<?php if (!empty($mealopt_one) && $mealopt_one != ""):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_one" value="on" <?php echo (isset($extras['mealopt_one'])) ? "checked" : ""; ?> /></th>
<td><?php echo $mealopt_one; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($mealopt_two) && $mealopt_two != ""):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_two" value="on" <?php echo (isset($extras['mealopt_two'])) ? "checked" : ""; ?> /></th>
<td><?php echo $mealopt_two; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($mealopt_three) && $mealopt_three != ""):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_three" value="on" <?php echo (isset($extras['mealopt_three'])) ? "checked" : ""; ?> /></th>
<td><?php echo $mealopt_three; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($mealopt_four) && $mealopt_four != ""):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_four" value="on" <?php echo (isset($extras['mealopt_four'])) ? "checked" : ""; ?> /></th>
<td><?php echo $mealopt_four; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($mealopt_five) && $mealopt_five != ""):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_five" value="on" <?php echo (isset($extras['mealopt_five'])) ? "checked" : ""; ?> /></th>
<td><?php echo $mealopt_five; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($mealopt_six) && $mealopt_six != ""):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_six" value="on" <?php echo (isset($extras['mealopt_six'])) ? "checked" : ""; ?> /></th>
<td><?php echo $mealopt_six; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($mealopt_seven) && $mealopt_seven != ""):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_seven" value="on" <?php echo (isset($extras['mealopt_seven'])) ? "checked" : ""; ?> /></th>
<td><?php echo $mealopt_seven; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($mealopt_eight) && $mealopt_eight != ""):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_eight" value="on" <?php echo (isset($extras['mealopt_eight'])) ? "checked" : ""; ?> /></th>
<td><?php echo $mealopt_eight; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($mealopt_nine) && $mealopt_nine != ""):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_nine" value="on" <?php echo (isset($extras['mealopt_nine'])) ? "checked" : ""; ?> /></th>
<td><?php echo $mealopt_nine; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($mealopt_ten) && $mealopt_ten != ""):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_ten" value="on" <?php echo (isset($extras['mealopt_ten'])) ? "checked" : ""; ?> /></th>
<td><?php echo $mealopt_ten; ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<?php endif; ?>
<?php if (!empty($session_description) || !empty($session_one) || !empty($session_two) || !empty($session_three) || !empty($session_four) || !empty($session_five) || !empty($session_six)):?>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">SESSION OPTIONS</div>
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
<?php if (!empty($session_description)) { echo "<div><strong>".$session_description."</strong></div>"; } ?>
<table class="clean no-left-padding">
<tbody>
<?php if (!empty($session_one)):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="session_one" value="on" <?php echo (isset($extras['session_one'])) ? "checked" : ""; ?> /></th>
<td><?php echo $session_one; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($session_two)):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="session_two" value="on" <?php echo (isset($extras['session_two'])) ? "checked" : ""; ?> /></th>
<td><?php echo $session_two; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($session_three)):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="session_three" value="on" <?php echo (isset($extras['session_three'])) ? "checked" : ""; ?> /></th>
<td><?php echo $session_three; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($session_four)):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="session_four" value="on" <?php echo (isset($extras['session_four'])) ? "checked" : ""; ?> /></th>
<td><?php echo $session_four; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($session_five)):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="session_five" value="on" <?php echo (isset($extras['session_five'])) ? "checked" : ""; ?> /></th>
<td><?php echo $session_five; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($session_six)):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="session_six" value="on" <?php echo (isset($extras['session_six'])) ? "checked" : ""; ?> /></th>
<td><?php echo $session_six; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($session_seven)):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="session_seven" value="on" <?php echo (isset($extras['session_seven'])) ? "checked" : ""; ?> /></th>
<td><?php echo $session_seven; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($session_eight)):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="session_eight" value="on" <?php echo (isset($extras['session_eight'])) ? "checked" : ""; ?> /></th>
<td><?php echo $session_eight; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($session_nine)):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="session_nine" value="on" <?php echo (isset($extras['session_nine'])) ? "checked" : ""; ?> /></th>
<td><?php echo $session_nine; ?></td>
</tr>
<?php endif; ?>
<?php if (!empty($session_ten)):?>
<tr>
<th width="40" style="text-align:right;"><input type="checkbox" name="session_ten" value="on" <?php echo (isset($extras['session_ten'])) ? "checked" : ""; ?> /></th>
<td><?php echo $session_ten; ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<?php endif; ?>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title"></div>
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
<div><input type="submit" value="<?php echo ($action=="edit") ? "Update" : "Register"; ?>" /></div>
</div>
</div>
</form>
</div>
<div style="clear:both;"></div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Edit Event</title>
<style type="text/css">
html, body { margin:0px; padding:0;}
.title-link {
color:#f7bd55;
font-size: 12px;
font-weight: bold;
text-align: left;
line-height: 1.75em;
background: #3b0d32;
border: solid 1px #FFF;
border-bottom: solid 1px #999;
cursor: default;
padding: 0em; padding:3px 10px 3px 10px;
margin: 0em;
}
form {
display: block;
margin-right:20px;
}
.dashboard-section-title { font-weight:bold; color:#3b0d32; }
</style>
</head>
<body>
<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>
<div style="padding: 0px 0px 10px 0px;">
<form method="post" action="" id="edit-invoice-form">
<input type="hidden" name="uid" value="<?php echo $_GET['uid']; ?>" />
<input type="hidden" name="invoice_id" value="<?php echo $_GET['invoice_id']; ?>" />
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-content small">
<select name="paid_by">
<option value="">Select payment type...</option>
<option value="PPV">Pre-paid with Visa</option>
<option value="PPMC">Pre-paid with Mastercard</option>
<option value="PPAMEX">Pre-paid with American Express</option>
<option value="CHEQUE">Paid by Cheque</option>
</select>
</div>
</div>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title"></div>
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
<div><input type="submit" value="Update" /></div>
</div>
</div>
</form>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Refund: <?php echo $invoice->getTitle(); ?></title>
</head>
<body class="invoice-refund">
<style type="text/css">
html, body { margin:0px; padding:0;}
.title-link {
color: #F7BD55;
font-size: 12px;
font-weight: bold;
text-align: left;
line-height: 1.75em;
background: #3B0D32;
border: 1px solid #FFF;
border-bottom: 1px solid #999;
cursor: default;
padding: 3px 10px 3px 10px;
margin: 0em;
}
form {
display: block;
margin-right: 20px;
}
table.item-listings tr th { text-align: left; border-bottom: 1px solid #CCC; }
table.item-listings tr td { text-aling: left; border-bottom: 1px solid #CCC; }
table.item-listings tbody tr.odd td { background-color: #F5F5F5; }
table.item-listings tr th,
table.item-listings tr td { padding: 4px 5px; }
table.item-listings thead tr th { padding-bottom: 10px; }
table { border-collapse:collapse; }
.dashboard-section-title { font-weight:bold; color:#3b0d32; }
label.amount {
color: #999;
font-size: 11px;
}
.part-wrapper {
display: block;
width: 750px;
margin-bottom: 0;
}
</style>
<div class="part-wrapper">
<div class="title-link">Refund: <?php echo $invoice->getTitle(); ?></div>
<div style="padding:10px;">
<form id="invoice_refund_form">
<table cellpadding="0" cellspacing="0" width="100%" border="0" class="item-listings">
<thead><tr>
<th>Item Description</th>
<th width="140">Refund?</th>
<th width="140">Cancel Fee?</th>
</tr></thead>
<tbody>
<?php
$i = 0;
foreach ($invoice as $key => $item):
$unq = "keys[{$key}]";
?>
<tr class="<?php echo (++$i & 1 ? 'odd' : 'even'); ?>">
<td><label for="<?php echo $unq; ?>"><?php echo $item->getDescription(); ?></label></td>
<td>
<input type="checkbox" checked="checked" value="1" id="<?php echo $unq; ?>" name="<?php echo $unq; ?>" />
<label for="<?php echo $unq; ?>" class="amount">(-$<?php echo $item->getTotal(true); ?>)</label>
</td>
<td>
<input type="checkbox" checked="checked" value="1" id="force_cancellation_fee" name="force_cancellation_fee" />
<label for="<?php echo $unq; ?>" class="amount">(+<?php echo '$150.00'; ?>)</label>
</td>
</tr>
<?php endforeach; ?>
</tbody></table>
<div style="padding-top:8px; margin-top:25px;">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td width="400" style="text-align:right;">
<input type="submit" value="Apply Changes" /> <input type="button" value="Cancel Changes" id="refund_cancel_btn" />
</td>
</tr>
</table>
</div>
</form>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Remove User</title>
<style type="text/css">
html, body { margin:0px; padding:0;}
.title-link {
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;
}
form {
display: block;
margin-right:20px;
}
.dashboard-section-title { font-weight:bold; color:#3b0d32; }
</style>
</head>
<body>
<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>
<form method="post" action="" id="remove-user-form">
<input type="hidden" name="uid" value="<?php echo $uid; ?>" />
<div class="dashboard-section" style="margin-left:5px;margin-top:10px;">
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small" style="padding:10px;">
<table width="300" cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td width="20" valign="top"><input type="radio" name="remove_action" value="remove_all" id="remove_all" /></td>
<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>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<td width="20" valign="top"><input type="radio" name="remove_action" value="terminate" id="terminate" checked="checked" /></td>
<td><label for="terminate">Yes, but I just want to terminate them, and remove their access to the site.</label></td>
</tr>
<tr><td valign="middle" colspan="2" class="confirm-delete" style="color:red; font-size:10px;height:25px;">&nbsp;</td></tr>
<tr>
<td colspan="2"><input type="submit" value="&nbsp;I'm sure; Proceed!&nbsp;" /></td>
</tr>
</tbody>
</table>
</div>
</div>
</form>
<script type="text/javascript">
var $ = jQuery;
$('#remove_all').click(function() {
$('.confirm-delete').html('This action cannot be undone. Proceed with caution.');
});
$('#terminate').click(function() {
$('.confirm-delete').empty();
});
</script>
</body>
</html>
\ No newline at end of file
<?php
namespace Tz\WordPress\Tools\UserManager;
use Tz, Tz\Common;
use Tz\WordPress\CBV;
use Exception, StdClass;
$users = _get_signups();
?>
<div id="" class="wrap">
<div id="icon-users" class="icon32"><br /></div>
<h2>Users awaiting validation</h2>
<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>
<table cellspacing="0" class="widefat post fixed" style="margin-top:20px;">
<thead>
<tr>
<th width="200">Login</th>
<th>Email</th>
<th width="200">Date Registered</th>
<th width="200">&nbsp;</th>
</tr>
</thead>
<tbody>
<?php foreach($users as $user): ?>
<tr>
<td><?php echo $user->user_login; ?></td>
<td><a href="mailto:<?php echo $user->user_email; ?>"><?php echo $user->user_email; ?></a></td>
<td><?php echo date("M j, Y @ h:ia",strtotime($user->registered)); ?></td>
<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>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('.activate').click(function(e) {
var activation_key = $(this).attr('rel');
$.ajax({
url: '/wp-admin/admin-ajax.php'
, dataType: 'json'
, type: 'POST'
, data: ({ajax:"yes", action: 'override_activate', akey: activation_key})
, success: function(date) {
document.location.href = document.location.href;
}
});
e.preventDefault();
return false;
});
$('.remove').click(function(e) {
var activation_key = $(this).attr('rel');
$.ajax({
url: '/wp-admin/admin-ajax.php'
, dataType: 'json'
, type: 'POST'
, data: ({ajax:"yes", action: 'override_remove', akey: activation_key})
, success: function(date) {
document.location.href = document.location.href;
}
});
e.preventDefault();
return false;
});
});
</script>
\ No newline at end of file