c25bc9b6 by Kevin Burton

User Manager CE Hours

1 parent 16b32285
......@@ -7,7 +7,7 @@ function update_listing_preference() {
}
}
jQuery(function() {
jQuery(function($) {
Date.firstDayOfWeek = 0;
Date.format = 'yyyy-mm-dd';
......
......@@ -187,11 +187,6 @@ class ProfileValidation extends Common\Validation {
}
public function date_of_birth($val) {
if (!empty($val)) {
if (!HTML\validateDate($val)) {
throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' must be in YYYY-MM-DD format.');
}
}
update_user_meta($_POST['uid'], __FUNCTION__, $val);
}
......@@ -240,6 +235,11 @@ class ProfileValidation extends Common\Validation {
throw new Exception('An invalid email address was entered in Email');
}
}
if ($_POST['profile_preference']=="Home") {
wp_update_user( Array ('ID'=>$_POST['uid'] , 'user_email'=>$val) );
}
update_user_meta($_POST['uid'], 'home_email', $val);
}
......@@ -288,6 +288,11 @@ class ProfileValidation extends Common\Validation {
throw new Exception('An invalid email address was entered in Email');
}
}
if ($_POST['profile_preference']=="Work") {
wp_update_user( Array ('ID'=>$_POST['uid'] , 'user_email'=>$val) );
}
update_user_meta($_POST['uid'], 'work_email', $val);
}
......@@ -673,12 +678,30 @@ class Actions {
}
$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"
, 'event_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
......@@ -713,12 +736,18 @@ class Actions {
$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";
}
......
......@@ -70,14 +70,10 @@ $preference = get_user_meta($user->ID, 'email_address_preference', true);
</tbody>
</table>
<h4>Notification & Settings</h4>
<h4>Notification Settings</h4>
<table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
<tbody>
<tr>
<th width="150">Profile Preference</th>
<td><select name="profile_preference" id="profile_preference"><option value="Home" <?php echo ($profile_preference=="Home") ? "selected" : ""; ?>>Home&nbsp;</option><option value="Work" <?php echo ($profile_preference=="Work") ? "selected" : ""; ?>>Work&nbsp;</option></select></td>
</tr>
<tr>
<th width="150">Email for Notifications:</th>
<td>
<select name="email_address_preference">
......@@ -119,6 +115,10 @@ $preference = get_user_meta($user->ID, 'email_address_preference', true);
<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>
......@@ -175,7 +175,10 @@ $preference = get_user_meta($user->ID, 'email_address_preference', true);
<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="Home" <?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>
......
......@@ -36,7 +36,7 @@
<body>
<div style="display:block; width:500px;">
<div style="display:block; width:750px;">
<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>
......@@ -51,32 +51,20 @@
<div class="dashboard-section-content small">
<table class="clean no-left-padding">
<tbody>
<tr>
<th width="100">Type:</th>
<td>
<select name="type">
<option value="structured" <?php echo ($type=="structured") ? "selected" : ""; ?>>Structured</option>
<option value="unstructured" <?php echo ($type=="unstructured") ? "selected" : ""; ?>>Unstructured</option>
</select>
</td>
</tr>
<tr>
<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><input type="text" class="datepicker" name="date" value="<?php echo $date;?>" /></td>
</tr>
<tr>
<th>Activity</th>
<td><input type="text" name="activity" value="<?php echo $activity;?>" /></td>
</tr>
<tr>
<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></select></td>
<th>Hours:</th>
<td><input type="text" name="hours" value="<?php echo $hours;?>" /></td>
<td style="width:50px;"><input type="text" name="hours" style="width:30px;" maxlength="2" 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>
<th>&nbsp;</th>
<td><div><input type="submit" value="<?php echo ($action=="edit") ? "Update" : "Apply"; ?>" /></div> </td>
<td colspan="7"><div><input type="submit" value="Apply" /></div></td>
</tr>
</tbody>
</table>
......@@ -87,5 +75,37 @@
</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;
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
......