function editUserForm() { if ($_POST['isPostback']) { // now we process the form $defaults = $_POST; // validation and trimming $_POST['tbPass'] = trim($_POST['tbPass']); $_POST['tbFirst'] = trim($_POST['tbFirst']); $_POST['tbLast'] = trim($_POST['tbLast']); $_POST['tbEmail'] = trim($_POST['tbEmail']); if (strlen($_POST['tbPass']) > 0 && strlen($_POST['tbPass']) < 4) { $errors[] = "Your password must be more than 4 characters long"; } if (strlen($_POST['tbFirst']) == 0) { $errors[] = "You must enter a first name"; } if (strlen($_POST['tbLast']) == 0) { $errors[] = "You must enter a last name"; } if (!preg_match('/^[^@\\s]+@([-a-z0-9]+\\.)+[a-z]{2,}$/i', $_POST['tbEmail'])) { $errors[] = "You must enter a valid email address"; } if (strlen(strval(intval($_POST['tbPhone1A'] . $_POST['tbPhone1B'] . $_POST['tbPhone1C']))) < 10) { $errors[] = "Please enter a valid primary phone number"; } if (strlen($_POST['tbPhone2A'] . $_POST['tbPhone2B'] . $_POST['tbPhone2C'])) { if (strlen(strval(intval($_POST['tbPhone2A'] . $_POST['tbPhone2B'] . $_POST['tbPhone2C']))) < 10) { $errors[] = "Please enter a valid secondary phone number"; } } if ($_POST['tbPay'] != strval(floatval($_POST['tbPay']))) { $errors[] = "You must enter a valid hourly rate"; } if (!$errors) { // our input is clean, go ahead and submit $sInsertError = updateUser($_POST); redirect("myEmps.php"); } } else { // get current details for user $aUserVals = getUserVals($_REQUEST['u_id']); $aPhone1 = formatPhoneNum($aUserVals->user_phone1); $aPhone2 = formatPhoneNum($aUserVals->user_phone2); $defaults['tbPass'] = $aUserVals->user_pass; $defaults['tbFirst'] = $aUserVals->user_first; $defaults['tbLast'] = $aUserVals->user_last; $defaults['tbEmail'] = $aUserVals->user_email; $defaults['tbPhone1A'] = $aPhone1[0]; $defaults['tbPhone1B'] = $aPhone1[1]; $defaults['tbPhone1C'] = $aPhone1[2]; $defaults['tbPhone2A'] = $aPhone2[0]; $defaults['tbPhone2B'] = $aPhone2[1]; $defaults['tbPhone2C'] = $aPhone2[2]; $defaults['tbPay'] = $aUserVals->user_pay_rate; $defaults['hdID'] = $aUserVals->user_id; $defaults['cbActive'] = $aUserVals->user_inactive; } // get the list of supervisors $aSupers = getSupervisors(); // get employees supervisors $aEmpSupers = getEmpSupervisors($aUserVals->user_id); foreach ($aEmpSupers as $EmpSuper) { $aSelectedSupers[] = $EmpSuper->super_super; } // get the user types < the current user $aTypes = getUserTypes($_SESSION['USERTYPE']); ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?> " method="post" name="frmAddUser"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <input name="hdID" type="hidden" value="<?php echo $defaults['hdID']; ?> "> <tr> <td colspan="2"><strong>Edit User</strong></td> </tr> <?php if (isset($sInsertError)) { print "<tr><td colspan=2><span class=errorMsg>{$sInsertError}</span></td></tr>"; } if ($errors) { print "<tr><td colspan=2 class=errorMsg><strong>Please correct the following errors:</strong><br><ul><li>"; print implode('</li><li>', $errors); print "</li></td></tr>"; } ?> <tr class="evenRow"> <td width="26%">Username </td> <td width="74%"><?php echo $aUserVals->user_name; ?> </td> </tr> <tr> <td>User Password </td> <td><input name="tbPass" type="password" id="tbPass" size="10" maxlength="20"></td> </tr> <tr class="evenRow"> <td>First Name </td> <td><input name="tbFirst" type="text" id="tbFirst" size="10" maxlength="20" value="<?php echo $defaults['tbFirst']; ?> "></td> </tr> <tr> <td>Last Name </td> <td><input name="tbLast" type="text" id="tbLast" size="10" maxlength="20" value="<?php echo $defaults['tbLast']; ?> "></td> </tr> <tr class="evenRow"> <td>Email Address</td> <td><input name="tbEmail" type="text" id="tbEmail" size="20" maxlength="50" value="<?php echo $defaults['tbEmail']; ?> "></td> </tr> <tr> <td>Phone 1 </td> <td> (<input name="tbPhone1A" type="text" id="tbPhone1A" size="3" maxlength="3" value="<?php echo $defaults['tbPhone1A']; ?> ">) <input name="tbPhone1B" type="text" id="tbPhone1B" size="3" maxlength="3" value="<?php echo $defaults['tbPhone1B']; ?> "> - <input name="tbPhone1C" type="text" id="tbPhone1C" size="4" maxlength="4" value="<?php echo $defaults['tbPhone1C']; ?> "></td> </tr> <tr class="evenRow"> <td>Phone 2 </td> <td> (<input name="tbPhone2A" type="text" id="tbPhone2A" size="3" maxlength="3" value="<?php echo $defaults['tbPhone2A']; ?> ">) <input name="tbPhone2B" type="text" id="tbPhone2B" size="3" maxlength="3" value="<?php echo $defaults['tbPhone2B']; ?> "> - <input name="tbPhone2C" type="text" id="tbPhone2C" size="4" maxlength="4" value="<?php echo $defaults['tbPhone2C']; ?> "></td> </tr> <tr> <td>Supervisors</td> <td><select name="msSupers[]" size="4" multiple id="msSupers"> <option value="0">None</option> <?php foreach ($aSupers as $Super) { if (in_array($Super->user_id, $aSelectedSupers)) { print "<option value=\"{$Super->user_id}\" selected>{$Super->user_first} {$Super->user_last}</option>"; } else { print "<option value=\"{$Super->user_id}\">{$Super->user_first} {$Super->user_last}</option>"; } } ?> </select></td> </tr> <tr class="evenRow"> <td>Account Type </td> <td><select name="ddType" id="ddType"> <?php foreach ($aTypes as $Type) { if ($Type->type_id == $aUserVals->user_type) { print "<option value=\"{$Type->type_id}\" selected>{$Type->type_name}</option>"; } else { print "<option value=\"{$Type->type_id}\">{$Type->type_name}</option>"; } } ?> </select></td> </tr> <tr> <td>Hourly Rate </td> <td>$<input name="tbPay" type="text" id="tbPay" size="6" maxlength="6" value="<?php echo $defaults['tbPay']; ?> "></td> </tr> <tr class="evenRow"> <td>User Inactive?</td> <td>Yes: <input type="radio" name="cbActive" value="1"<?php if ($defaults['cbActive']) { print " checked=checked"; } ?> /> No: <input type="radio" name="cbActive" value="0"<?php if (!$defaults['cbActive']) { print " checked=checked"; } ?> /> </td> </tr> <tr> <td colspan=2 align="center"><input name="isPostback" type="hidden" id="isPostback" value="1"> <input name="btSubmit" type="submit" id="btSubmit" value="Save Edits?"></td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table></form> <?php }
function schedEvent($postData, $iEventID = '') { global $mail; global $host; global $docroot; // take the input vals, call addEvent, and call addAssign // if we have an event_id, we do an update, else, we just add if ($iEventID) { $iEID = $iEventID; // we update the event, delete the currently assigned emps, and re-add the sub'd ones updateEvent($iEventID, sanitizeInput($postData['dDate']), sanitizeInput($postData['dStartTime']), sanitizeInput($postData['dEndTime']), sanitizeInput($postData['area']), sanitizeInput($postData['tbName'])); // now do the delete delAssign($iEventID); } else { // first add the event and get back the eventID $iEID = addEvent(sanitizeInput($postData['dDate']), sanitizeInput($postData['dStartTime']), sanitizeInput($postData['dEndTime']), sanitizeInput($postData['area']), sanitizeInput($postData['tbName'])); } // now we grab the positions for the area // and iterate through the emp lists, adding the assignments $oPositions = getAreaPos($postData['area']); $oEmps = getMyEmployees($_SESSION['USERID']); // grab data for email // get sender details $oSender = getUserVals($_SESSION['USERID']); // get event details $oEventDetails = getEventDetails($iEID); // set up email basics $mail->From = $oSender->user_email; $mail->FromName = $oSender->user_first . ' ' . $oSender->user_last; // if updated event, change subj line if ($iEventID) { $sSubj = "UPDATED: "; } else { $sSubj = ""; } $sSubj .= 'You have been scheduled for ' . $oEventDetails->event_name; $mail->Subject = $sSubj; // the message // handle updated event if ($iEventID) { $sBody = "The following event has been UPDATED!\n"; } else { $sBody = ""; } $sBody .= "You have been scheduled for the following:\n"; $sBody .= "Event Name: " . $oEventDetails->event_name . "\n"; $sBody .= "Event Date: " . date("l, F jS, Y", strtotime($oEventDetails->event_date)) . "\n"; $sBody .= "From: " . date("g:i a", strtotime($oEventDetails->event_start)) . " To: " . date("g:i a", strtotime($oEventDetails->event_end)) . "\n"; $sBody .= "\nPlease see http://" . $host . $docroot . " for more details.\n"; $sBody .= "Thanks, \n" . $oSender->user_first . " " . $oSender->user_last; // append to mail $mail->Body = $sBody; // iterate list $bAssigned = false; // this flag flips once an assignment is made foreach ($oEmps as $Emp) { if ($_POST['rad' . $Emp->user_id]) { $bAssigned = true; // flip the flag addAssign($Emp->user_id, $_POST['rad' . $Emp->user_id], $iEID); $mail->AddAddress($Emp->user_email, $Emp->user_first . " " . $Emp->user_last); } } // now check for curUser assign if ($_POST['rad' . $_SESSION['USERID']]) { addAssign($_SESSION['USERID'], $_POST['rad' . $_SESSION['USERID']], $iEID); } // send mail if checkbox checked and if >= 1 emp assigned if ($postData['chkMail'] && $bAssigned) { // send the mail if (!$mail->Send()) { accessDenied("There has been an error sending mail!"); } $mail->ClearAddresses(); $mail->ClearAttachments(); } return $iEID; }
* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // $Id: viewSched.php,v 1.7 2005/10/30 22:37:19 atrommer Exp $ checkUser($_SESSION['USERTYPE'], 2); if (empty($_REQUEST['user'])) { // keep people from navigating here directly accessDenied("Please choose a user first."); } $oEmp = getUserVals($_REQUEST['user']); if (empty($oEmp)) { // this would happen if they arbitrarily typed in a num in the url accessDenied("You selected an invalid user!"); } if (!$_REQUEST['doPop']) { doHeader("Viewing {$oEmp->user_first} {$oEmp->user_last}'s schedule"); } else { ?> <html> <head> <title>Viewing <?php echo $oEmp->user_first . ' ' . $oEmp->user_last; ?> 's schedule</title> <link href="global.css" rel="stylesheet" type="text/css">
$errors[] = "Please enter a valid primary phone number"; } if (strlen($_POST['tbPhone2A'] . $_POST['tbPhone2B'] . $_POST['tbPhone2C'])) { if (strlen(strval(intval($_POST['tbPhone2A'] . $_POST['tbPhone2B'] . $_POST['tbPhone2C']))) < 10) { $errors[] = "Please enter a valid secondary phone number"; } } //if ($_POST['tbPay'] != strval(floatval($_POST['tbPay']))) { // $errors[] = "You must enter a valid hourly rate"; } if (!$errors) { // our input is clean, go ahead and submit $sInsertError = updateCurrentUser($_POST, $_SESSION['USERID'], $_SESSION['USERTYPE'], $_SESSION['USERNAME']); } } else { // get current details for user $aUserVals = getUserVals($_SESSION['USERID']); $aPhone1 = formatPhoneNum($aUserVals->user_phone1); $aPhone2 = formatPhoneNum($aUserVals->user_phone2); $defaults['tbPass'] = $aUserVals->user_pass; $defaults['tbFirst'] = $aUserVals->user_first; $defaults['tbLast'] = $aUserVals->user_last; $defaults['tbEmail'] = $aUserVals->user_email; $defaults['tbPhone1A'] = $aPhone1[0]; $defaults['tbPhone1B'] = $aPhone1[1]; $defaults['tbPhone1C'] = $aPhone1[2]; $defaults['tbPhone2A'] = $aPhone2[0]; $defaults['tbPhone2B'] = $aPhone2[1]; $defaults['tbPhone2C'] = $aPhone2[2]; $defaults['tbPay'] = $aUserVals->user_pay_rate; $defaults['hdID'] = $aUserVals->user_id; }