Skip to content
Snippets Groups Projects
Commit dca09e4d authored by Jared Hancock's avatar Jared Hancock
Browse files

Ensure consistent name format for agent dropdown

parent ad9276e9
Branches
Tags
No related merge requests found
...@@ -124,6 +124,7 @@ class Dept { ...@@ -124,6 +124,7 @@ class Dept {
} }
function getMembers($criteria=null) { function getMembers($criteria=null) {
global $cfg;
if(!$this->members || $criteria) { if(!$this->members || $criteria) {
$members = array(); $members = array();
...@@ -144,7 +145,16 @@ class Dept { ...@@ -144,7 +145,16 @@ class Dept {
AND s.isactive=1 AND s.isactive=1
AND s.onvacation=0 ) '; AND s.onvacation=0 ) ';
$sql.=' ORDER BY s.lastname, s.firstname'; switch ($cfg->getDefaultNameFormat()) {
case 'last':
case 'lastfirst':
case 'legal':
$sql .= ' ORDER BY s.lastname, s.firstname';
break;
default:
$sql .= ' ORDER BY s.firstname, s.lastname';
}
if(($res=db_query($sql)) && db_num_rows($res)) { if(($res=db_query($sql)) && db_num_rows($res)) {
while(list($id)=db_fetch_row($res)) while(list($id)=db_fetch_row($res))
......
...@@ -193,7 +193,7 @@ implements EmailContact { ...@@ -193,7 +193,7 @@ implements EmailContact {
} }
function getName() { function getName() {
return new PersonsName($this->ht['firstname'].' '.$this->ht['lastname']); return new PersonsName(array('first' => $this->ht['firstname'], 'last' => $this->ht['lastname']));
} }
function getFirstName() { function getFirstName() {
...@@ -602,20 +602,32 @@ implements EmailContact { ...@@ -602,20 +602,32 @@ implements EmailContact {
/**** Static functions ********/ /**** Static functions ********/
function getStaffMembers($availableonly=false) { function getStaffMembers($availableonly=false) {
global $cfg;
$sql='SELECT s.staff_id, CONCAT_WS(" ", s.firstname, s.lastname) as name ' $sql = 'SELECT s.staff_id, s.firstname, s.lastname FROM '
.' FROM '.STAFF_TABLE.' s '; .STAFF_TABLE.' s ';
if($availableonly) { if($availableonly) {
$sql.=' INNER JOIN '.GROUP_TABLE.' g ON(g.group_id=s.group_id AND g.group_enabled=1) ' $sql.=' INNER JOIN '.GROUP_TABLE.' g ON(g.group_id=s.group_id AND g.group_enabled=1) '
.' WHERE s.isactive=1 AND s.onvacation=0'; .' WHERE s.isactive=1 AND s.onvacation=0';
} }
$sql.=' ORDER BY s.lastname, s.firstname'; switch ($cfg->getDefaultNameFormat()) {
case 'last':
case 'lastfirst':
case 'legal':
$sql .= ' ORDER BY s.lastname, s.firstname';
break;
default:
$sql .= ' ORDER BY s.firstname, s.lastname';
}
$users=array(); $users=array();
if(($res=db_query($sql)) && db_num_rows($res)) { if(($res=db_query($sql)) && db_num_rows($res)) {
while(list($id, $name) = db_fetch_row($res)) while(list($id, $fname, $lname) = db_fetch_row($res))
$users[$id] = $name; $users[$id] = new PersonsName(
array('first' => $fname, 'last' => $lname));
} }
return $users; return $users;
......
...@@ -623,8 +623,14 @@ class PersonsName { ...@@ -623,8 +623,14 @@ class PersonsName {
elseif($cfg) elseif($cfg)
$this->format = $cfg->getDefaultNameFormat(); $this->format = $cfg->getDefaultNameFormat();
$this->parts = static::splitName($name); if (!is_array($name)) {
$this->name = $name; $this->parts = static::splitName($name);
$this->name = $name;
}
else {
$this->parts = $name;
$this->name = implode(' ', $name);
}
} }
function getFirst() { function getFirst() {
......
<?php <?php
if(!defined('OSTSTAFFINC') || !$thisstaff || !$thisstaff->isStaff()) die('Access Denied'); if(!defined('OSTSTAFFINC') || !$thisstaff || !$thisstaff->isStaff()) die('Access Denied');
$qs = array(); $qs = array();
$select='SELECT staff.*,CONCAT_WS(" ",firstname,lastname) as name,dept.dept_name as dept '; $select='SELECT staff.*,dept.dept_name as dept ';
$from='FROM '.STAFF_TABLE.' staff '. $from='FROM '.STAFF_TABLE.' staff '.
'LEFT JOIN '.DEPT_TABLE.' dept ON(staff.dept_id=dept.dept_id) '; 'LEFT JOIN '.DEPT_TABLE.' dept ON(staff.dept_id=dept.dept_id) ';
$where='WHERE staff.isvisible=1 '; $where='WHERE staff.isvisible=1 ';
...@@ -31,6 +31,16 @@ if($_REQUEST['did'] && is_numeric($_REQUEST['did'])) { ...@@ -31,6 +31,16 @@ if($_REQUEST['did'] && is_numeric($_REQUEST['did'])) {
$sortOptions=array('name'=>'staff.firstname,staff.lastname','email'=>'staff.email','dept'=>'dept.dept_name', $sortOptions=array('name'=>'staff.firstname,staff.lastname','email'=>'staff.email','dept'=>'dept.dept_name',
'phone'=>'staff.phone','mobile'=>'staff.mobile','ext'=>'phone_ext', 'phone'=>'staff.phone','mobile'=>'staff.mobile','ext'=>'phone_ext',
'created'=>'staff.created','login'=>'staff.lastlogin'); 'created'=>'staff.created','login'=>'staff.lastlogin');
switch ($cfg->getDefaultNameFormat()) {
case 'last':
case 'lastfirst':
case 'legal':
$sortOptions['name'] = 'staff.lastname, staff.firstname';
break;
// Otherwise leave unchanged
}
$orderWays=array('DESC'=>'DESC','ASC'=>'ASC'); $orderWays=array('DESC'=>'DESC','ASC'=>'ASC');
$sort=($_REQUEST['sort'] && $sortOptions[strtolower($_REQUEST['sort'])])?strtolower($_REQUEST['sort']):'name'; $sort=($_REQUEST['sort'] && $sortOptions[strtolower($_REQUEST['sort'])])?strtolower($_REQUEST['sort']):'name';
//Sorting options... //Sorting options...
...@@ -111,9 +121,11 @@ else ...@@ -111,9 +121,11 @@ else
<?php <?php
if($res && db_num_rows($res)): if($res && db_num_rows($res)):
$ids=($errors && is_array($_POST['ids']))?$_POST['ids']:null; $ids=($errors && is_array($_POST['ids']))?$_POST['ids']:null;
while ($row = db_fetch_array($res)) { ?> while ($row = db_fetch_array($res)) {
$name = new PersonsName(array('first' => $row['firstname'], 'last' => $row['lastname']));
?>
<tr id="<?php echo $row['staff_id']; ?>"> <tr id="<?php echo $row['staff_id']; ?>">
<td>&nbsp;<?php echo Format::htmlchars($row['name']); ?></td> <td>&nbsp;<?php echo Format::htmlchars($name); ?></td>
<td>&nbsp;<?php echo Format::htmlchars($row['dept']); ?></td> <td>&nbsp;<?php echo Format::htmlchars($row['dept']); ?></td>
<td>&nbsp;<?php echo Format::htmlchars($row['email']); ?></td> <td>&nbsp;<?php echo Format::htmlchars($row['email']); ?></td>
<td>&nbsp;<?php echo Format::phone($row['phone']); ?></td> <td>&nbsp;<?php echo Format::phone($row['phone']); ?></td>
......
<?php <?php
if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied'); if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
$qs = array(); $qs = array();
$select='SELECT staff.*,CONCAT_WS(" ",firstname,lastname) as name, grp.group_name, dept.dept_name as dept,count(m.team_id) as teams '; $select='SELECT staff.*, grp.group_name, dept.dept_name as dept,count(m.team_id) as teams ';
$from='FROM '.STAFF_TABLE.' staff '. $from='FROM '.STAFF_TABLE.' staff '.
'LEFT JOIN '.GROUP_TABLE.' grp ON(staff.group_id=grp.group_id) '. 'LEFT JOIN '.GROUP_TABLE.' grp ON(staff.group_id=grp.group_id) '.
'LEFT JOIN '.DEPT_TABLE.' dept ON(staff.dept_id=dept.dept_id) '. 'LEFT JOIN '.DEPT_TABLE.' dept ON(staff.dept_id=dept.dept_id) '.
...@@ -25,6 +25,16 @@ if($_REQUEST['tid'] && is_numeric($_REQUEST['tid'])) { ...@@ -25,6 +25,16 @@ if($_REQUEST['tid'] && is_numeric($_REQUEST['tid'])) {
$sortOptions=array('name'=>'staff.firstname,staff.lastname','username'=>'staff.username','status'=>'isactive', $sortOptions=array('name'=>'staff.firstname,staff.lastname','username'=>'staff.username','status'=>'isactive',
'group'=>'grp.group_name','dept'=>'dept.dept_name','created'=>'staff.created','login'=>'staff.lastlogin'); 'group'=>'grp.group_name','dept'=>'dept.dept_name','created'=>'staff.created','login'=>'staff.lastlogin');
switch ($cfg->getDefaultNameFormat()) {
case 'last':
case 'lastfirst':
case 'legal':
$sortOptions['name'] = 'staff.lastname, staff.firstname';
break;
// Otherwise leave unchanged
}
$orderWays=array('DESC'=>'DESC','ASC'=>'ASC'); $orderWays=array('DESC'=>'DESC','ASC'=>'ASC');
$sort=($_REQUEST['sort'] && $sortOptions[strtolower($_REQUEST['sort'])])?strtolower($_REQUEST['sort']):'name'; $sort=($_REQUEST['sort'] && $sortOptions[strtolower($_REQUEST['sort'])])?strtolower($_REQUEST['sort']):'name';
//Sorting options... //Sorting options...
...@@ -143,11 +153,12 @@ else ...@@ -143,11 +153,12 @@ else
$sel=false; $sel=false;
if($ids && in_array($row['staff_id'],$ids)) if($ids && in_array($row['staff_id'],$ids))
$sel=true; $sel=true;
$name = new PersonsName(array('first' => $row['firstname'], 'last' => $row['lastname']));
?> ?>
<tr id="<?php echo $row['staff_id']; ?>"> <tr id="<?php echo $row['staff_id']; ?>">
<td width=7px> <td width=7px>
<input type="checkbox" class="ckb" name="ids[]" value="<?php echo $row['staff_id']; ?>" <?php echo $sel?'checked="checked"':''; ?> > <input type="checkbox" class="ckb" name="ids[]" value="<?php echo $row['staff_id']; ?>" <?php echo $sel?'checked="checked"':''; ?> >
<td><a href="staff.php?id=<?php echo $row['staff_id']; ?>"><?php echo Format::htmlchars($row['name']); ?></a>&nbsp;</td> <td><a href="staff.php?id=<?php echo $row['staff_id']; ?>"><?php echo Format::htmlchars($name); ?></a>&nbsp;</td>
<td><?php echo $row['username']; ?></td> <td><?php echo $row['username']; ?></td>
<td><?php echo $row['isactive']?__('Active'):'<b>'.__('Locked').'</b>'; ?>&nbsp;<?php echo $row['onvacation']?'<small>(<i>'.__('vacation').'</i>)</small>':''; ?></td> <td><?php echo $row['isactive']?__('Active'):'<b>'.__('Locked').'</b>'; ?>&nbsp;<?php echo $row['onvacation']?'<small>(<i>'.__('vacation').'</i>)</small>':''; ?></td>
<td><a href="groups.php?id=<?php echo $row['group_id']; ?>"><?php echo Format::htmlchars($row['group_name']); ?></a></td> <td><a href="groups.php?id=<?php echo $row['group_id']; ?>"><?php echo Format::htmlchars($row['group_name']); ?></a></td>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment