labtech
Database
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_ContactSimpleSearch
Parameters
Name
Type
Mode
search
varchar(75)
IN
page
int
IN
pagesize
int
IN
userid
int
IN
Definition
BEGIN DECLARE _perm TINYINT(1); SET _perm = (SELECT BIT_OR(0 < (userclasses.permissions & (1 << 15) OR userclasses.permissions & 1)) FROM userclasses JOIN users WHERE FIND_IN_SET(userclasses.classid, users.clientid) AND users.userid=userid); PREPARE STMT FROM "SELECT a.ContactID, IFNULL(b.Name, 'Global') AS `Name`, a.FirstName, a.LastName, a.Address1, a.Address2, a.City, a.State, a.Zip, a.Phone, a.Cell, a.Fax, a.Pager, a.Email, a.MSN, a.AIM, a.ICQ, a.Last_User, a.ClientID, a.LocationID, c.Name as LocationName, a.Password FROM contacts a LEFT JOIN clients b ON a.clientid = b.clientid LEFT JOIN locations c ON a.locationid = c.locationid Where (a.clientid = 0 OR a.clientid = b.clientid) AND ( a.ClientID like CONCAT('%', ?, '%') or a.FirstName like CONCAT('%', ?, '%') or a.LastName like CONCAT('%', ?, '%') or a.Address1 like CONCAT('%', ?, '%') or a.Address2 like CONCAT('%', ?, '%') or a.City like CONCAT('%', ?, '%') or a.State like CONCAT('%', ?, '%') or a.Zip like CONCAT('%', ?, '%') or a.Phone like CONCAT('%', ?, '%') or a.Fax like CONCAT('%', ?, '%') or a.Cell like CONCAT('%', ?, '%') or a.Pager like CONCAT('%', ?, '%') or a.Email like CONCAT('%', ?, '%') or a.MSN like CONCAT('%', ?, '%') or a.AIM like CONCAT('%', ?, '%') or a.ICQ like CONCAT('%', ?, '%') ) AND (a.clientid = 0 OR a.clientid IN (Select usersec.clientid FROM UserSec WHERE UserID=?)) AND (?) order by b.Name, a.LastName, a.Firstname ASC LIMIT ?,?"; SET @LIMIT = (page * pagesize) - pagesize; SET @size = pagesize; SET @s = search; SET @U = userid; SET @P = _perm; EXECUTE STMT USING @s,@s,@s,@s,@s,@s,@s,@s,@s,@s,@s,@s,@s,@s,@s,@s,@U,@P,@LIMIT,@size; END