dgrant
Joined: 22 Sep 2005
Posts: 60
|
| Posted: Thu Jan 05, 2006 4:12 pm Post subject: PATCH: Two new functions for utils.php |
|
|
I added these two functions to utils.php. I use them in my Quotes/CreatePDF.php, and figure they may be useful:
Code:
// DG Jan 5 2006
// getObjectOwnerFullName
// given an object ID, return the text name of the user assigned to it
function getObjectOwnerFullName($crmid)
{
global $vtlog;
$vtlog->logthis("in getObjectOwnerFullName ".$crmid,'info');
global $adb;
if($crmid != '')
{
$sql = "select smownerid from crmentity where crmid=".$crmid;
$result = $adb->query($sql);
$userid = $adb->query_result($result,0,"smownerid");
$sql = "select first_name, last_name from users where id='".$userid."'";
$result = $adb->query($sql);
$num_rows = $adb->num_rows($result);
if($num_rows > 0) {
$first_name = $adb->query_result($result,0,"first_name");
$last_name = $adb->query_result($result,0,"last_name");
$user_name = $first_name." ".$last_name;
}
else {
$user_name = "No Name";
}
}
return $user_name;
}
// DG Jan 5 2006
// getUserFullName
// given an user ID, return the full name of the user
function getUserFullName($userid)
{
global $vtlog;
$vtlog->logthis("in getUserFullName ".$userid,'info');
global $adb;
if($userid != '')
{
$sql = "select first_name, last_name from users where id=".$userid;
$result = $adb->query($sql);
$num_rows = $adb->num_rows($result);
if($num_rows > 0) {
$first_name = $adb->query_result($result,0,"first_name");
$last_name = $adb->query_result($result,0,"last_name");
$user_name = $first_name." ".$last_name;
}
else {
$user_name = "No Name";
}
}
return $user_name;
}
Nothing groundbreaking, but useful to me.
DG |
|