c25bc9b6 by Kevin Burton

User Manager CE Hours

1 parent 16b32285
...@@ -7,7 +7,7 @@ function update_listing_preference() { ...@@ -7,7 +7,7 @@ function update_listing_preference() {
7 } 7 }
8 } 8 }
9 9
10 jQuery(function() { 10 jQuery(function($) {
11 11
12 Date.firstDayOfWeek = 0; 12 Date.firstDayOfWeek = 0;
13 Date.format = 'yyyy-mm-dd'; 13 Date.format = 'yyyy-mm-dd';
......
...@@ -187,11 +187,6 @@ class ProfileValidation extends Common\Validation { ...@@ -187,11 +187,6 @@ class ProfileValidation extends Common\Validation {
187 } 187 }
188 188
189 public function date_of_birth($val) { 189 public function date_of_birth($val) {
190 if (!empty($val)) {
191 if (!HTML\validateDate($val)) {
192 throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' must be in YYYY-MM-DD format.');
193 }
194 }
195 update_user_meta($_POST['uid'], __FUNCTION__, $val); 190 update_user_meta($_POST['uid'], __FUNCTION__, $val);
196 } 191 }
197 192
...@@ -239,7 +234,12 @@ class ProfileValidation extends Common\Validation { ...@@ -239,7 +234,12 @@ class ProfileValidation extends Common\Validation {
239 if (!(boolean)preg_match(CBV\VALID_EMAIL, (string)$val)) { 234 if (!(boolean)preg_match(CBV\VALID_EMAIL, (string)$val)) {
240 throw new Exception('An invalid email address was entered in Email'); 235 throw new Exception('An invalid email address was entered in Email');
241 } 236 }
242 } 237 }
238
239 if ($_POST['profile_preference']=="Home") {
240 wp_update_user( Array ('ID'=>$_POST['uid'] , 'user_email'=>$val) );
241 }
242
243 update_user_meta($_POST['uid'], 'home_email', $val); 243 update_user_meta($_POST['uid'], 'home_email', $val);
244 } 244 }
245 245
...@@ -287,7 +287,12 @@ class ProfileValidation extends Common\Validation { ...@@ -287,7 +287,12 @@ class ProfileValidation extends Common\Validation {
287 if (!(boolean)preg_match(CBV\VALID_EMAIL, (string)$val)) { 287 if (!(boolean)preg_match(CBV\VALID_EMAIL, (string)$val)) {
288 throw new Exception('An invalid email address was entered in Email'); 288 throw new Exception('An invalid email address was entered in Email');
289 } 289 }
290 } 290 }
291
292 if ($_POST['profile_preference']=="Work") {
293 wp_update_user( Array ('ID'=>$_POST['uid'] , 'user_email'=>$val) );
294 }
295
291 update_user_meta($_POST['uid'], 'work_email', $val); 296 update_user_meta($_POST['uid'], 'work_email', $val);
292 } 297 }
293 298
...@@ -673,12 +678,30 @@ class Actions { ...@@ -673,12 +678,30 @@ class Actions {
673 } 678 }
674 679
675 680
681 $postarray = $_POST;
682
683 $cehours[$_POST['indexed']] = Array(
684 'type' => $postarray['type']
685 , 'subtype' => isset($postarray['subtype']) ? $postarray['subtype'] : ""
686 , 'date' => CEHours\mysqldatetime_to_timestamp($postarray['date'])
687 , 'activity' => isset($postarray['activity']) ? $postarray['activity'] : ""
688 , 'institute' => isset($postarray['institution']) ? $postarray['institution'] : ""
689 , 'hours' => $postarray['hours']
690 , 'attended' => isset($postarray['attended']) ? "yes" : "no"
691 , 'event_id' => "0"
692 , 'recorded' => time()
693 );
694
695 /*
696
676 $cehours[$_POST['indexed']] = Array( 697 $cehours[$_POST['indexed']] = Array(
677 'type' => $_POST['type'] 698 'type' => $_POST['type']
678 , 'date' => $timestamp 699 , 'date' => $timestamp
679 , 'activity' => $_POST['activity'] 700 , 'activity' => $_POST['activity']
680 , 'hours' => $_POST['hours'] 701 , 'hours' => $_POST['hours']
702
681 ); 703 );
704 */
682 705
683 update_user_meta($_POST['uid'], 'cehours', $cehours); 706 update_user_meta($_POST['uid'], 'cehours', $cehours);
684 // return json object 707 // return json object
...@@ -713,12 +736,18 @@ class Actions { ...@@ -713,12 +736,18 @@ class Actions {
713 $type = $record['type']; 736 $type = $record['type'];
714 $date = date('Y-m-d',$record['date']); 737 $date = date('Y-m-d',$record['date']);
715 $activity = $record['activity']; 738 $activity = $record['activity'];
739 $subtype = isset($record['subtype']) ? $record['subtype'] : "";
740 $institute = isset($record['institute']) ? $record['institute'] : "";
741 $attended = isset($record['attended']) ? $record['attended'] : "";
716 $hours = $record['hours']; 742 $hours = $record['hours'];
717 } else { 743 } else {
718 $indexed = ""; 744 $indexed = "";
719 $type = "unstructured"; 745 $type = "unstructured";
720 $date = date('Y-m-d',time()); 746 $date = date('Y-m-d',time());
721 $activity = ""; 747 $activity = "";
748 $subtype = "";
749 $institute = "";
750 $attended = "";
722 $hours = "0"; 751 $hours = "0";
723 } 752 }
724 753
......
...@@ -70,14 +70,10 @@ $preference = get_user_meta($user->ID, 'email_address_preference', true); ...@@ -70,14 +70,10 @@ $preference = get_user_meta($user->ID, 'email_address_preference', true);
70 </tbody> 70 </tbody>
71 </table> 71 </table>
72 72
73 <h4>Notification & Settings</h4> 73 <h4>Notification Settings</h4>
74 <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table"> 74 <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
75 <tbody> 75 <tbody>
76 <tr> 76 <tr>
77 <th width="150">Profile Preference</th>
78 <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>
79 </tr>
80 <tr>
81 <th width="150">Email for Notifications:</th> 77 <th width="150">Email for Notifications:</th>
82 <td> 78 <td>
83 <select name="email_address_preference"> 79 <select name="email_address_preference">
...@@ -117,7 +113,11 @@ $preference = get_user_meta($user->ID, 'email_address_preference', true); ...@@ -117,7 +113,11 @@ $preference = get_user_meta($user->ID, 'email_address_preference', true);
117 113
118 <h4>Home Contact Information</h4> 114 <h4>Home Contact Information</h4>
119 <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table"> 115 <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
120 <tbody> 116 <tbody>
117 <tr>
118 <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>
119 </tr>
120 <tr><td colspan="2">&nbsp;</td></tr>
121 <tr> 121 <tr>
122 <th>Address:</th> 122 <th>Address:</th>
123 <td><input type="text" name="home_address" value="<?php echo get_user_meta($_GET['uid'], 'home_address', true);?>" /></td> 123 <td><input type="text" name="home_address" value="<?php echo get_user_meta($_GET['uid'], 'home_address', true);?>" /></td>
...@@ -175,7 +175,10 @@ $preference = get_user_meta($user->ID, 'email_address_preference', true); ...@@ -175,7 +175,10 @@ $preference = get_user_meta($user->ID, 'email_address_preference', true);
175 <h4>Work Contact Information</h4> 175 <h4>Work Contact Information</h4>
176 <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table"> 176 <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table">
177 <tbody> 177 <tbody>
178 178 <tr>
179 <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>
180 </tr>
181 <tr><td colspan="2">&nbsp;</td></tr>
179 <tr class="work-only"> 182 <tr class="work-only">
180 <th>Company:</th> 183 <th>Company:</th>
181 <td><input type="text" name="company" value="<?php echo get_user_meta($_GET['uid'], 'company', true);?>" /></td> 184 <td><input type="text" name="company" value="<?php echo get_user_meta($_GET['uid'], 'company', true);?>" /></td>
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
36 36
37 <body> 37 <body>
38 38
39 <div style="display:block; width:500px;"> 39 <div style="display:block; width:750px;">
40 40
41 <div class="title-link" style="display:block;color:#f7bd55; font-size: 12px;font-weight: bold;text-align: left;line-height: 1.75em; background-color: #3b0d32; border: solid 1px #FFF; border-bottom: solid 1px #999; cursor: default; padding: 0em; padding:3px 10px 3px 10px; margin: 0em;">Edit <?php echo $name; ?>'s CE Hours:</div> 41 <div class="title-link" style="display:block;color:#f7bd55; font-size: 12px;font-weight: bold;text-align: left;line-height: 1.75em; background-color: #3b0d32; border: solid 1px #FFF; border-bottom: solid 1px #999; cursor: default; padding: 0em; padding:3px 10px 3px 10px; margin: 0em;">Edit <?php echo $name; ?>'s CE Hours:</div>
42 42
...@@ -51,32 +51,20 @@ ...@@ -51,32 +51,20 @@
51 <div class="dashboard-section-content small"> 51 <div class="dashboard-section-content small">
52 <table class="clean no-left-padding"> 52 <table class="clean no-left-padding">
53 <tbody> 53 <tbody>
54 <tr> 54 <tr class="top-td">
55 <th width="100">Type:</th> 55 <td width="140"><select style="width:120px;" name="type"><option value="structured" <?php echo ($type=="structured") ? "selected" : ""; ?>>Structured</option><option value="unstructured" <?php echo ($type=="unstructured") ? "selected" : ""; ?>>Unstructured</option></select></td>
56 <td>
57 <select name="type">
58 <option value="structured" <?php echo ($type=="structured") ? "selected" : ""; ?>>Structured</option>
59 <option value="unstructured" <?php echo ($type=="unstructured") ? "selected" : ""; ?>>Unstructured</option>
60 </select>
61 </td>
62 </tr>
63 <tr>
64 <th>Date:</th> 56 <th>Date:</th>
65 <td><input type="text" class="datepicker" name="date" value="<?php echo $date;?>" /></td> 57 <td width="150"><input type="text" name="date" readonly class="datepicker" style="width:120px;" value="<?php echo $date;?>" /></td>
66 </tr> 58 <th>Activity Type:</th>
67 <tr> 59 <td><select style="width:120px;" name="subtype" class="subtype" id="subtype"><option value="none" <?php echo ($subtype=="") ? "selected" : ""?>>Non Specific</option><option value="event" <?php echo ($subtype=="event") ? "selected" : ""?>>External Event</option></select></td>
68 <th>Activity</th>
69 <td><input type="text" name="activity" value="<?php echo $activity;?>" /></td>
70 </tr>
71
72 <tr>
73 <th>Hours:</th> 60 <th>Hours:</th>
74 <td><input type="text" name="hours" value="<?php echo $hours;?>" /></td> 61 <td style="width:50px;"><input type="text" name="hours" style="width:30px;" maxlength="2" value="<?php echo $hours;?>" /></td>
75 </tr> 62 </tr>
76 63 <tr class="activity_row bottom-border-td">
64 <th colspan="7" style="text-align:left;"><label style="padding-right:10px;">Activity:</label><input type="text" name="activity" style="width:450px;" value="<?php echo $activity;?>" /></th>
65 </tr>
77 <tr> 66 <tr>
78 <th>&nbsp;</th> 67 <td colspan="7"><div><input type="submit" value="Apply" /></div></td>
79 <td><div><input type="submit" value="<?php echo ($action=="edit") ? "Update" : "Apply"; ?>" /></div> </td>
80 </tr> 68 </tr>
81 </tbody> 69 </tbody>
82 </table> 70 </table>
...@@ -87,5 +75,37 @@ ...@@ -87,5 +75,37 @@
87 75
88 </form> 76 </form>
89 </div> 77 </div>
78
79 <script type="text/javascript">
80 var $ = jQuery;
81
82 function updateCEType(obj) {
83 var $selectbox = $(obj);
84 var $table = $(obj).parent().parent().parent();
85 var $activity_row = $('tr.activity_row', $table);
86
87 switch($selectbox.val()) {
88 case 'event':
89 var r = '<th colspan="7" style="text-align:left;"><label style="padding-right:10px;">Activity:</label><input type="text" name="activity" style="width:200px;" value="<?php echo $activity;?>" />&nbsp;&nbsp;<label style="padding-right:10px;">Institution:</label><input type="text" name="institution" style="width:200px;" value="<?php echo $institute;?>" />&nbsp;&nbsp;<input type="checkbox" name="attended" value="on" <?php echo ($attended=="yes") ? 'checked="checked"' : ''; ?> />&nbsp;They Attended</th>';
90 break;
91 default:
92 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>';
93 }
94
95 $activity_row.html(r);
96 }
97
98
99 jQuery(function($) {
100 $('.subtype').live('change', function() {
101 updateCEType(this);
102 });
103
104 updateCEType($('.subtype'));
105
106 });
107
108 </script>
109
90 </body> 110 </body>
91 </html> 111 </html>
...\ No newline at end of file ...\ No newline at end of file
......