diff --git a/include/ajax.admin.php b/include/ajax.admin.php index c9f82a5c40e1dd8ed6dd19df1f052144952e3cf2..39743c1b6a33f8888e9a42ba00a5fc287d2d212d 100644 --- a/include/ajax.admin.php +++ b/include/ajax.admin.php @@ -156,4 +156,34 @@ class AdminAjaxAPI extends AjaxController { return $this->encode($role->getPermissionInfo()); } + + function addStaff() { + global $ost, $thisstaff; + + if (!$thisstaff) + Http::response(403, 'Agent login required'); + if (!$thisstaff->isAdmin()) + Http::response(403, 'Access denied'); + + $form = new StaffQuickAddForm($_POST); + + if ($_POST && $form->isValid()) { + $staff = Staff::create(); + $errors = array(); + if ($staff->update($form->getClean(), $errors)) { + Http::response(201, $this->encode(array( + 'id' => $staff->getId(), + 'name' => (string) $staff->getName(), + ), 'application/json')); + } + foreach ($errors as $name=>$desc) + if ($F = $form->getField($name)) + $F->addError($desc); + } + + $title = __("Add New Agent"); + $path = ltrim($ost->get_path_info(), '/'); + + include STAFFINC_DIR . 'templates/quick-add.tmpl.php'; + } } diff --git a/include/ajax.staff.php b/include/ajax.staff.php index 37c71462caa02ec72b20528ec8b71df8f8c0056e..e0292420f5a8754143f5a09b3e93fcb287b35968 100644 --- a/include/ajax.staff.php +++ b/include/ajax.staff.php @@ -54,11 +54,45 @@ class StaffAjaxAPI extends AjaxController { } $title = __("Set Agent Password"); + $verb = __('Update'); $path = ltrim($ost->get_path_info(), '/'); - include STAFFINC_DIR . 'templates/set-password.tmpl.php'; + include STAFFINC_DIR . 'templates/quick-add.tmpl.php'; } + function changePassword($id) { + global $ost, $thisstaff; + + if (!$thisstaff) + Http::response(403, 'Agent login required'); + if (!$id || $thisstaff->getId() != $id) + Http::response(404, 'No such agent'); + + $form = new PasswordChangeForm($_POST); + + if ($_POST && $form->isValid()) { + $clean = $form->getClean(); + try { + $thisstaff->setPassword($clean['passwd1'], $clean['current']); + if ($thisstaff->save()) + Http::response(201, 'Successfully updated'); + } + catch (BadPassword $ex) { + $passwd1 = $form->getField('passwd1'); + $passwd1->addError($ex->getMessage()); + } + catch (PasswordUpdateFailed $ex) { + // TODO: Add a warning banner or crash the update + } + } + + $title = __("Change Password"); + $verb = __('Update'); + $path = ltrim($ost->get_path_info(), '/'); + + include STAFFINC_DIR . 'templates/quick-add.tmpl.php'; + } + function getAgentPerms($id) { global $thisstaff; diff --git a/include/class.staff.php b/include/class.staff.php index 4b194946f1ff0d8b2aba8888cdd822bc4ec32e1e..20cdfcfffc930fd32c8f1e6e8d4b13e9452d6be9 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -637,9 +637,6 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { } } - if ($errors) - return false; - $this->firstname = $vars['firstname']; $this->lastname = $vars['lastname']; $this->email = $vars['email']; @@ -656,6 +653,9 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { $this->default_paper_size = $vars['default_paper_size']; $this->lang = $vars['lang']; + if ($errors) + return false; + $_SESSION['::lang'] = null; TextDomain::configureForUser($this); @@ -1158,9 +1158,36 @@ extends AbstractForm { if ($clean['passwd1'] != $clean['passwd2']) $this->getField('passwd1')->addError(__('Passwords do not match')); } +} - function render($staff=true) { - return parent::render($staff, false, array('template' => 'dynamic-form-simple.tmpl.php')); +class PasswordChangeForm +extends AbstractForm { + function buildFields() { + return array( + 'current' => new PasswordField(array( + 'placeholder' => __('Current Password'), + 'required' => true, + 'autofocus' => true, + )), + 'passwd1' => new PasswordField(array( + 'placeholder' => __('New Password'), + 'required' => true, + 'layout' => new GridFluidCell(12, array('style' => 'padding-top: 30px')), + )), + 'passwd2' => new PasswordField(array( + 'placeholder' => __('Confirm Password'), + 'required' => true, + )), + ); + } + + function getInstructions() { + return __('Confirm your current password and enter a new password to continue'); + } + + function validate($clean) { + if ($clean['passwd1'] != $clean['passwd2']) + $this->getField('passwd1')->addError(__('Passwords do not match')); } } @@ -1179,7 +1206,7 @@ extends AbstractForm { 'clone' => new ChoiceField(array( 'default' => 0, 'choices' => - array(0 => '— '.__('Clone an existing agent').' —'), + array(0 => '— '.__('Clone an existing agent').' —') + Staff::getStaffMembers(), 'configuration' => array( 'classes' => 'span12', @@ -1260,3 +1287,94 @@ extends AbstractForm { return parent::render($staff, false, array('template' => 'dynamic-form-simple.tmpl.php')); } } + +class StaffQuickAddForm +extends AbstractForm { + static $layout = 'GridFormLayout'; + + function buildFields() { + global $cfg; + + return array( + 'firstname' => new TextboxField(array( + 'required' => true, + 'configuration' => array( + 'placeholder' => __("First Name"), + 'autofocus' => true, + ), + 'layout' => new GridFluidCell(6), + )), + 'lastname' => new TextboxField(array( + 'required' => true, + 'configuration' => array( + 'placeholder' => __("Last Name"), + ), + 'layout' => new GridFluidCell(6), + )), + 'email' => new TextboxField(array( + 'required' => true, + 'configuration' => array( + 'validator' => 'email', + 'placeholder' => __('Email Address — e.g. me@mycompany.com'), + ), + )), + 'dept_id' => new ChoiceField(array( + 'label' => __('Department'), + 'required' => true, + 'choices' => Dept::getDepartments(), + 'default' => $cfg->getDefaultDeptId(), + 'layout' => new GridFluidCell(6), + )), + 'role_id' => new ChoiceField(array( + 'label' => __('Primary Role'), + 'required' => true, + 'choices' => + array(0 => __('Select Role')) + + Role::getRoles(), + 'layout' => new GridFluidCell(6), + )), + 'isadmin' => new BooleanField(array( + 'label' => __('Account Type'), + 'configuration' => array( + 'desc' => __('Agent has access to the admin panel'), + ), + 'layout' => new GridFluidCell(6), + )), + 'welcome_email' => new BooleanField(array( + 'configuration' => array( + 'desc' => __('Send a welcome email with login information'), + ), + 'default' => true, + 'layout' => new GridFluidCell(12, array('style' => 'padding-top: 50px')), + )), + 'passwd1' => new PasswordField(array( + 'required' => true, + 'configuration' => array( + 'placeholder' => __("Temporary Password"), + ), + 'visibility' => new VisibilityConstraint( + new Q(array('welcome_email' => false)) + ), + 'layout' => new GridFluidCell(6), + )), + 'passwd2' => new PasswordField(array( + 'required' => true, + 'configuration' => array( + 'placeholder' => __("Confirm Password"), + ), + 'visibility' => new VisibilityConstraint( + new Q(array('welcome_email' => false)) + ), + 'layout' => new GridFluidCell(6), + )), + // TODO: Add role_id drop-down + ); + } + + function getClean() { + $clean = parent::getClean(); + list($clean['username'],) = preg_split('/[^\w-]/', $clean['email'], 2); + $clean['role_id'] = 1; + return $clean; + } +} diff --git a/include/class.team.php b/include/class.team.php index c7a66058dd0d5b5ce31196fd09e7b49a025ea4bd..d059eba518a7af990b6d65442a1c8ca98ff26119 100644 --- a/include/class.team.php +++ b/include/class.team.php @@ -366,7 +366,7 @@ extends AbstractForm { 'label' => __('Optionally select a leader for the team'), 'default' => 0, 'choices' => - array(0 => '— '.__('None').' —'), + array(0 => '— '.__('None').' —') + Staff::getStaffMembers(), 'configuration' => array( 'classes' => 'span12', diff --git a/include/staff/header.inc.php b/include/staff/header.inc.php index 8ceef837a5488e15199e1d04402ae495ffb94b5f..0b595def74aa9406e6b6f09d2a75e4a1ea06920c 100644 --- a/include/staff/header.inc.php +++ b/include/staff/header.inc.php @@ -65,7 +65,7 @@ if ($lang) { <?php }else{ ?> | <a href="index.php" class="no-pjax"><?php echo __('Agent Panel'); ?></a> <?php } ?> - | <a href="profile.php"><?php echo __('My Preferences'); ?></a> + | <a href="profile.php"><?php echo __('Profile'); ?></a> | <a href="logout.php?auth=<?php echo $ost->getLinkToken(); ?>" class="no-pjax"><?php echo __('Log Out'); ?></a> </p> <a href="index.php" class="no-pjax" id="logo"> diff --git a/include/staff/profile.inc.php b/include/staff/profile.inc.php index c942f984160efc0e6e12acc0bc87a27f5ee00d9b..d1ff943b39ca2fec80018f7be0ebd0e1978c4793 100644 --- a/include/staff/profile.inc.php +++ b/include/staff/profile.inc.php @@ -1,132 +1,137 @@ <?php if(!defined('OSTSTAFFINC') || !$staff || !$thisstaff) die('Access Denied'); - -$info=$staff->getInfo(); -$info['signature'] = Format::viewableImages($info['signature']); -$info=Format::htmlchars(($errors && $_POST)?$_POST:$info); -$info['id']=$staff->getId(); ?> + <form action="profile.php" method="post" id="save" autocomplete="off"> <?php csrf_token(); ?> <input type="hidden" name="do" value="update"> - <input type="hidden" name="id" value="<?php echo $info['id']; ?>"> + <input type="hidden" name="id" value="<?php echo $staff->getId(); ?>"> <h2><?php echo __('My Account Profile');?></h2> - <table class="form_table" width="940" border="0" cellspacing="0" cellpadding="2"> - <thead> - <tr> - <th colspan="2"> - <h4><?php echo __('Account Information');?></h4> - <em><?php echo __('Contact information');?></em> - </th> - </tr> - </thead> - <tbody> - <tr> - <td width="180" class="required"> - <?php echo __('Username');?>: - </td> - <td><b><?php echo $staff->getUserName(); ?></b> <i class="help-tip icon-question-sign" href="#username"></i></td> - </tr> + <ul class="clean tabs"> + <li class="active"><a href="#account"><i class="icon-user"></i> <?php echo __('Account'); ?></a></li> + <li><a href="#preferences"><?php echo __('Preferences'); ?></a></li> + <li><a href="#signature"><?php echo __('Signature'); ?></a></li> + </ul> + + <div class="tab_content" id="account"> + <table class="table two-column" width="940" border="0" cellspacing="0" cellpadding="2"> + <tbody> <tr> - <td width="180" class="required"> - <?php echo __('First Name');?>: - </td> - <td> - <input type="text" size="34" name="firstname" value="<?php echo $info['firstname']; ?>"> - <span class="error">* <?php echo $errors['firstname']; ?></span> - </td> + <td class="required"><?php echo __('Name'); ?>:</td> + <td> + <input type="text" size="20" maxlength="64" style="width: 145px" name="firstname" + autofocus value="<?php echo Format::htmlchars($staff->firstname); ?>" + placeholder="<?php echo __("First Name"); ?>" /> + <input type="text" size="20" maxlength="64" style="width: 145px" name="lastname" + value="<?php echo Format::htmlchars($staff->lastname); ?>" + placeholder="<?php echo __("Last Name"); ?>" /> + <div class="error"><?php echo $errors['firstname']; ?></div> + <div class="error"><?php echo $errors['lastname']; ?></div> + </td> </tr> <tr> - <td width="180" class="required"> - <?php echo __('Last Name');?>: - </td> - <td> - <input type="text" size="34" name="lastname" value="<?php echo $info['lastname']; ?>"> - <span class="error">* <?php echo $errors['lastname']; ?></span> - </td> + <td class="required"><?php echo __('Email Address'); ?>:</td> + <td> + <input type="email" size="40" maxlength="64" style="width: 300px" name="email" + value="<?php echo Format::htmlchars($staff->email); ?>" + placeholder="<?php echo __('e.g. me@mycompany.com'); ?>" /> + <div class="error"><?php echo $errors['email']; ?></div> + </td> </tr> <tr> - <td width="180" class="required"> - <?php echo __('Email Address');?>: - </td> - <td> - <input type="text" size="34" name="email" value="<?php echo $info['email']; ?>"> - <span class="error">* <?php echo $errors['email']; ?></span> - </td> + <td><?php echo __('Phone Number');?>:</td> + <td> + <input type="tel" size="18" name="phone" class="auto phone" + value="<?php echo Format::htmlchars($staff->phone); ?>" /> + <?php echo __('Ext');?> + <input type="text" size="5" name="phone_ext" + value="<?php echo Format::htmlchars($staff->phone_ext); ?>"> + <div class="error"><?php echo $errors['phone']; ?></div> + <div class="error"><?php echo $errors['phone_ext']; ?></div> + </td> </tr> <tr> - <td width="180"> - <?php echo __('Phone Number');?>: - </td> - <td> - <input type="text" size="22" name="phone" value="<?php echo $info['phone']; ?>"> - <span class="error"> <?php echo $errors['phone']; ?></span> - Ext <input type="text" size="5" name="phone_ext" value="<?php echo $info['phone_ext']; ?>"> - <span class="error"> <?php echo $errors['phone_ext']; ?></span> - </td> + <td><?php echo __('Mobile Number');?>:</td> + <td> + <input type="tel" size="18" name="mobile" class="auto phone" + value="<?php echo Format::htmlchars($staff->mobile); ?>" /> + <div class="error"><?php echo $errors['mobile']; ?></div> + </td> </tr> - <tr> - <td width="180"> - <?php echo __('Mobile Number');?>: - </td> - <td> - <input type="text" size="22" name="mobile" value="<?php echo $info['mobile']; ?>"> - <span class="error"> <?php echo $errors['mobile']; ?></span> - </td> + </tbody> + <!-- ================================================ --> + <tbody> + <tr class="header"> + <th colspan="2"> + <?php echo __('Authentication'); ?> + </th> </tr> + <?php if ($bk = $staff->getAuthBackend()) { ?> <tr> - <th colspan="2"> - <em><strong><?php echo __('Preferences');?></strong>: <?php echo __('Profile preferences and settings.');?></em> - </th> + <td><?php echo __("Backend"); ?></td> + <td><?php echo $bk->getName(); ?></td> </tr> + <?php } ?> <tr> - <td width="180"> - <?php echo __('Time Zone');?>: - </td> - <td> - <?php - $TZ_NAME = 'timezone'; - $TZ_TIMEZONE = $info['timezone']; - include STAFFINC_DIR.'templates/timezone.tmpl.php'; ?> - <div class="error"><?php echo $errors['timezone']; ?></div> - </td> + <td class="required"><?php echo __('Username'); ?>: + <span class="error">*</span></td> + <td> + <input type="text" size="40" style="width:300px" + class="staff-username typeahead" + name="username" disabled value="<?php echo Format::htmlchars($staff->username); ?>" /> +<?php if (!$bk || $bk->supportsPasswordChange()) { ?> + <button type="button" class="action-button" onclick="javascript: + $.dialog('ajax.php/staff/'+<?php echo $staff->getId(); ?>+'/change-password', 201);"> + <i class="icon-refresh"></i> <?php echo __('Change Password'); ?> + </button> +<?php } ?> + <i class="offset help-tip icon-question-sign" href="#username"></i> + <div class="error"><?php echo $errors['username']; ?></div> + </td> + </tr> + </tbody> + <!-- ================================================ --> + <tbody> + <tr class="header"> + <th colspan="2"> + <?php echo __('Status and Settings'); ?> + </th> </tr> -<?php if ($cfg->getSecondaryLanguages()) { ?> <tr> - <td width="180"> - <?php echo __('Preferred Language'); ?>: - </td> - <td> - <?php - $langs = Internationalization::getConfiguredSystemLanguages(); ?> - <select name="lang"> - <option value="">— <?php echo __('Use Browser Preference'); ?> —</option> -<?php foreach($langs as $l) { - $selected = ($info['lang'] == $l['code']) ? 'selected="selected"' : ''; ?> - <option value="<?php echo $l['code']; ?>" <?php echo $selected; - ?>><?php echo Internationalization::getLanguageDescription($l['code']); ?></option> -<?php } ?> - </select> - <span class="error"> <?php echo $errors['lang']; ?></span> - </td> + <td colspan="2"> + <label> + <input type="checkbox" name="show_assigned_tickets" + <?php echo ($staff->show_assigned_tickets) ? 'checked="checked"' : ''; ?> /> + <?php echo __('Show assigned tickets on open queue.'); ?> + </label> + <i class="help-tip icon-question-sign" href="#show_assigned_tickets"></i> + <br/> + <label> + <input type="checkbox" name="onvacation" + <?php echo ($staff->onvacation) ? 'checked="checked"' : ''; ?> /> + <?php echo __('Vacation Mode'); ?> + </label> + <br/> </tr> -<?php } ?> -<?php if (extension_loaded('intl')) { ?> - <tr><td width="220"><?php echo __('Preferred Locale');?>:</td> - <td> - <select name="locale"> - <option value=""><?php echo __('Use Language Preference'); ?></option> -<?php foreach (Internationalization::allLocales() as $code=>$name) { ?> - <option value="<?php echo $code; ?>" <?php - if ($code == $info['locale']) - echo 'selected="selected"'; - ?>><?php echo $name; ?></option> -<?php } ?> - </select> - </td> + </tbody> + </table> + </div> + + <!-- =================== PREFERENCES ======================== --> + + <div class="hidden tab_content" id="preferences"> + <table class="table two-column" width="100%"> + <tbody> + <tr class="header"> + <th colspan="2"> + <?php echo __('Preferences'); ?> + <div><small><?php echo __( + "Profile preferences and settings" + ); ?> + </small></div> + </th> </tr> -<?php } ?> <tr> <td width="180"><?php echo __('Maximum Page size');?>:</td> <td> @@ -142,7 +147,9 @@ $info['id']=$staff->getId(); </td> </tr> <tr> - <td width="180"><?php echo __('Auto Refresh Rate');?>:</td> + <td width="180"><?php echo __('Auto Refresh Rate');?>: + <div class="faded"><?php echo __('Tickets page refresh rate in minutes.'); ?></div> + </td> <td> <select name="auto_refresh_rate"> <option value="0">— <?php echo __('disable');?> —</option> @@ -158,11 +165,12 @@ $info['id']=$staff->getId(); $y=2; } ?> </select> - <em><?php echo __('(Tickets page refresh rate in minutes.)');?></em> </td> </tr> <tr> - <td width="180"><?php echo __('Default Signature');?>:</td> + <td><?php echo __('Default Signature');?>: + <div class="faded"><?php echo __('This can be selected when replying to a ticket');?></div> + </td> <td> <select name="default_signature_type"> <option value="none" selected="selected">— <?php echo __('None');?> —</option> @@ -175,12 +183,13 @@ $info['id']=$staff->getId(); } ?> </select> - <em><?php echo __('(This can be selected when replying to a ticket)');?></em> - <span class="error"> <?php echo $errors['default_signature_type']; ?></span> + <div class="error"><?php echo $errors['default_signature_type']; ?></div> </td> </tr> <tr> - <td width="180"><?php echo __('Default Paper Size');?>:</td> + <td width="180"><?php echo __('Default Paper Size');?>: + <div class="faded"><?php echo __('Paper size used when printing tickets to PDF');?></div> + </td> <td> <select name="default_paper_size"> <option value="none" selected="selected">— <?php echo __('None');?> —</option> @@ -192,70 +201,91 @@ $info['id']=$staff->getId(); } ?> </select> - <em><?php echo __('Paper size used when printing tickets to PDF');?></em> - <span class="error"> <?php echo $errors['default_paper_size']; ?></span> - </td> - </tr> - <tr> - <td><?php echo __('Show Assigned Tickets');?>:</td> - <td> - <input type="checkbox" name="show_assigned_tickets" <?php echo $info['show_assigned_tickets']?'checked="checked"':''; ?>> - <em><?php echo __('Show assigned tickets on open queue.');?></em> - <i class="help-tip icon-question-sign" href="#show_assigned_tickets"></i></em> + <div class="error"><?php echo $errors['default_paper_size']; ?></div> </td> </tr> - <tr> - <th colspan="2"> - <em><strong><?php echo __('Password');?></strong>: <?php echo __('To reset your password, provide your current password and a new password below.');?> <span class="error"> <?php echo $errors['passwd']; ?></span></em> - </th> + </tbody> + <tbody> + <tr class="header"> + <th colspan="2"> + <?php echo __('Localization'); ?> + </th> </tr> - <?php if (!isset($_SESSION['_staff']['reset-token'])) { ?> <tr> - <td width="180"> - <?php echo __('Current Password');?>: - </td> + <td><?php echo __('Time Zone');?>:</td> <td> - <input type="password" size="18" name="cpasswd" value="<?php echo $info['cpasswd']; ?>"> - <span class="error"> <?php echo $errors['cpasswd']; ?></span> + <?php + $TZ_NAME = 'timezone'; + $TZ_TIMEZONE = $info['timezone']; + include STAFFINC_DIR.'templates/timezone.tmpl.php'; ?> + <div class="error"><?php echo $errors['timezone']; ?></div> </td> </tr> - <?php } ?> +<?php if ($cfg->getSecondaryLanguages()) { ?> <tr> - <td width="180"> - <?php echo __('New Password');?>: - </td> + <td><?php echo __('Preferred Language'); ?>:</td> <td> - <input type="password" size="18" name="passwd1" value="<?php echo $info['passwd1']; ?>"> - <span class="error"> <?php echo $errors['passwd1']; ?></span> + <?php + $langs = Internationalization::getConfiguredSystemLanguages(); ?> + <select name="lang"> + <option value="">— <?php echo __('Use Browser Preference'); ?> —</option> +<?php foreach($langs as $l) { + $selected = ($info['lang'] == $l['code']) ? 'selected="selected"' : ''; ?> + <option value="<?php echo $l['code']; ?>" <?php echo $selected; + ?>><?php echo Internationalization::getLanguageDescription($l['code']); ?></option> +<?php } ?> + </select> + <span class="error"> <?php echo $errors['lang']; ?></span> </td> </tr> +<?php } ?> +<?php if (extension_loaded('intl')) { ?> <tr> - <td width="180"> - <?php echo __('Confirm New Password');?>: - </td> + <td><?php echo __('Preferred Locale');?>:</td> <td> - <input type="password" size="18" name="passwd2" value="<?php echo $info['passwd2']; ?>"> - <span class="error"> <?php echo $errors['passwd2']; ?></span> + <select name="locale"> + <option value=""><?php echo __('Use Language Preference'); ?></option> +<?php foreach (Internationalization::allLocales() as $code=>$name) { ?> + <option value="<?php echo $code; ?>" <?php + if ($code == $info['locale']) + echo 'selected="selected"'; + ?>><?php echo $name; ?></option> +<?php } ?> + </select> </td> </tr> - <tr> - <th colspan="2"> - <em><strong><?php echo __('Signature');?></strong>: <?php echo __('Optional signature used on outgoing emails.');?> - <span class="error"> <?php echo $errors['signature']; ?></span> <i class="help-tip icon-question-sign" href="#signature"></i></em> - </th> +<?php } ?> + </table> + </div> + + <!-- ==================== SIGNATURES ======================== --> + + <div id="signature" class="hidden"> + <table class="table two-column" width="100%"> + <tbody> + <tr class="header"> + <th colspan="2"> + <?php echo __('Signature'); ?> + <div><small><?php echo __( + "Optional signature used on outgoing emails.") + .' '. + __('Signature is made available as a choice, on ticket reply.'); ?> + </small></div> + </th> </tr> <tr> - <td colspan=2> + <td colspan="2"> <textarea class="richtext no-bar" name="signature" cols="21" rows="5" style="width: 60%;"><?php echo $info['signature']; ?></textarea> - <br><em><?php echo __('Signature is made available as a choice, on ticket reply.');?></em> </td> </tr> - </tbody> -</table> -<p style="text-align:center;"> - <input type="submit" name="submit" value="<?php echo __('Save Changes');?>"> - <input type="reset" name="reset" value="<?php echo __('Reset Changes');?>"> - <input type="button" name="cancel" value="<?php echo __('Cancel Changes');?>" onclick='window.location.href="index.php"'> -</p> + </tbody> + </table> + </div> + + <p style="text-align:center;"> + <input type="submit" name="submit" value="<?php echo __('Save Changes'); ?>"> + <input type="reset" name="reset" value="<?php echo __('Reset');?>"> + <input type="button" name="cancel" value="<?php echo __('Cancel');?>" onclick="window.history.go(-1);"> + </p> </form> diff --git a/include/staff/staff.inc.php b/include/staff/staff.inc.php index 96cb584877af45512c66174258821ec98bee806c..3478dcefd3d97c5a69dd62a77a19e05c08c3e712 100644 --- a/include/staff/staff.inc.php +++ b/include/staff/staff.inc.php @@ -35,7 +35,7 @@ else { </h2> <ul class="clean tabs"> - <li class="active"><a href="#account"><?php echo __('Account'); ?></a></li> + <li class="active"><a href="#account"><i class="icon-user"></i> <?php echo __('Account'); ?></a></li> <li><a href="#access"><?php echo __('Access'); ?></a></li> <li><a href="#permissions"><?php echo __('Permisions'); ?></a></li> <li><a href="#teams"><?php echo __('Teams'); ?></a></li> @@ -286,7 +286,7 @@ foreach ($staff->dept_access as $dept_access) { ?> <option value="0" data-quick-add>— <?php echo __('Add New');?> —</option> </select> - <button type="button" class="action-button"> + <button type="button" class="green button"> <?php echo __('Add'); ?> </button> </td> @@ -378,7 +378,7 @@ foreach ($staff->teams as $TM) { ?> <option value="0" data-quick-add>— <?php echo __('Add New');?> —</option> </select> - <button type="button" class="action-button"> + <button type="button" class="green button"> <?php echo __('Add'); ?> </button> </td> @@ -405,7 +405,7 @@ foreach ($staff->teams as $TM) { <p style="text-align:center;"> <input type="submit" name="submit" value="<?php echo $submit_text; ?>"> <input type="reset" name="reset" value="<?php echo __('Reset');?>"> - <input type="button" name="cancel" value="<?php echo __('Cancel');?>" onclick='window.location.href="helptopics.php"'> + <input type="button" name="cancel" value="<?php echo __('Cancel');?>" onclick="window.history.go(-1);"> </p> </form> diff --git a/include/staff/staffmembers.inc.php b/include/staff/staffmembers.inc.php index c1f12f9ce409a5560dd29c96803eaafad09b4241..4df36165646be7b0e5bb059544fd31bf2b88fbf1 100644 --- a/include/staff/staffmembers.inc.php +++ b/include/staff/staffmembers.inc.php @@ -107,14 +107,14 @@ $agents->limit($pageNav->getLimit())->offset($pageNav->getStart()); } ?> </select> - <input type="submit" name="submit" class="small" value="<?php echo __('Apply');?>"/> + <input type="submit" name="submit" class="small button" value="<?php echo __('Apply');?>"/> </form> </div> <form id="mass-actions" action="staff.php" method="POST" name="staff" > <div class="pull-right"> - <a class="action-button" href="staff.php?a=add"> + <a class="green button action-button" href="staff.php?a=add"> <i class="icon-plus-sign"></i> <?php echo __('Add New Agent'); ?> </a> @@ -125,23 +125,25 @@ $agents->limit($pageNav->getLimit())->offset($pageNav->getStart()); <div id="action-dropdown-more" class="action-dropdown anchor-right"> <ul id="actions"> <li><a class="confirm" data-name="enable" href="staff.php?a=enable"> - <i class="icon-trash icon-fixed-width"></i> + <i class="icon-ok-sign icon-fixed-width"></i> <?php echo __('Enable'); ?></a></li> <li><a class="confirm" data-name="disable" href="staff.php?a=disable"> - <i class="icon-trash icon-fixed-width"></i> + <i class="icon-ban-circle icon-fixed-width"></i> <?php echo __('Disable'); ?></a></li> - <li><a class="confirm" data-name="delete" href="staff.php?a=delete"> - <i class="icon-trash icon-fixed-width"></i> - <?php echo __('Delete'); ?></a></li> <li><a class="dialog-first" data-action="permissions" href="#staff/reset-permissions"> - <i class="icon-trash icon-fixed-width"></i> + <i class="icon-sitemap icon-fixed-width"></i> <?php echo __('Reset Permissions'); ?></a></li> <li><a class="dialog-first" data-action="department" href="#staff/change-department"> - <i class="icon-trash icon-fixed-width"></i> + <i class="icon-truck icon-fixed-width"></i> <?php echo __('Change Department'); ?></a></li> + <!-- TODO: Implement "Reset Access" mass action <li><a class="dialog-first" href="#staff/reset-access"> - <i class="icon-trash icon-fixed-width"></i> + <i class="icon-puzzle-piece icon-fixed-width"></i> <?php echo __('Reset Access'); ?></a></li> + --> + <li class="danger"><a class="confirm" data-name="delete" href="staff.php?a=delete"> + <i class="icon-trash icon-fixed-width"></i> + <?php echo __('Delete'); ?></a></li> </ul> </div> </div> diff --git a/scp/ajax.php b/scp/ajax.php index bc5207be392f96fbb062204e98c52b8bdf40639d..be0e7c33db7ca4dfabef4b5f1d5087f164551e00 100644 --- a/scp/ajax.php +++ b/scp/ajax.php @@ -229,12 +229,14 @@ $dispatcher = patterns('', url('^/quick-add', patterns('ajax.admin.php:AdminAjaxAPI', url('^/department$', 'addDepartment'), url('^/team$', 'addTeam'), - url('^/role$', 'addRole') + url('^/role$', 'addRole'), + url('^/staff$', 'addStaff') )), url_get('^/role/(?P<id>\d+)/perms', 'getRolePerms') )), url('^/staff', patterns('ajax.staff.php:StaffAjaxAPI', url('^/(?P<id>\d+)/set-password$', 'setPassword'), + url('^/(?P<id>\d+)/change-password$', 'changePassword'), url_get('^/(?P<id>\d+)/perms', 'getAgentPerms'), url('^/reset-permissions', 'resetPermissions'), url('^/change-department', 'changeDepartment') diff --git a/scp/js/scp.js b/scp/js/scp.js index 608555ef86998caf916d3d1c5282247cb8207921..2dac3978ae6e8060724840a56f0169a848307db2 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -659,6 +659,16 @@ $.dialog = function (url, codes, cb, options) { }); if (options.onload) { options.onload(); } }; +$(document).on('click', 'a[data-dialog]', function(event) { + event.preventDefault(); + event.stopImmediatePropagation(); + var link = $(this); + $.dialog($(this).data('dialog'), 201, function() { + if (link.attr('href').length > 1) $.pjax.click(event, '#pjax-container'); + else $.pjax.reload('#pjax-container'); + }); + return false; +}); $.sysAlert = function (title, msg, cb) { var $dialog = $('.dialog#alert'); diff --git a/scp/profile.php b/scp/profile.php index 0ceaf50651e6dc18d2693cc8e7149bd7c337f2d7..f787324a4b2f7a34a59eccaa3cba728db780a6d0 100644 --- a/scp/profile.php +++ b/scp/profile.php @@ -25,7 +25,7 @@ if($_POST && $_POST['id']!=$thisstaff->getId()) { //Check dummy ID used on the f if(!$staff) $errors['err']=sprintf(__('%s: Unknown or invalid'), __('agent')); - elseif($thisstaff->updateProfile($_POST,$errors)){ + elseif($staff->updateProfile($_POST,$errors)){ $msg=__('Profile updated successfully'); }elseif(!$errors['err']) $errors['err']=__('Profile update error. Try correcting the errors below and try again!'); @@ -33,7 +33,14 @@ if($_POST && $_POST['id']!=$thisstaff->getId()) { //Check dummy ID used on the f //Forced password Change. if($thisstaff->forcePasswdChange() && !$errors['err']) - $errors['err']=sprintf(__('<b>Hi %s</b> - You must change your password to continue!'),$thisstaff->getFirstName()); + $errors['err'] = str_replace( + '<a>', + sprintf('<a data-dialog="ajax.php/staff/%d/change-password" href="#">', $thisstaff->getId()), + sprintf( + __('<b>Hi %s</b> - You must <a>change your password to continue</a>!'), + $thisstaff->getFirstName() + ) + ); elseif($thisstaff->onVacation() && !$warn) $warn=sprintf(__("<b>Welcome back %s</b>! You are listed as 'on vacation' Please let your manager know that you are back."),$thisstaff->getFirstName());