phpLens
 home  products examples manual  faq support forum  contact news  login store

More Examples:   View Source:   searchInEditNew

Free Download

This demo allows you to enter complaint records for products you are supporting. You can perform a search in the both the EDIT/NEW record forms for the product the customer is complaining about.

  PHPLens
E New Srch
(E) (e)id (e)custname (e)telephone (e)address1 (e)address2  
1
71436
Ryan78170864477WTdCyiPxyjbhlEiBvnZawom
[Del]
2
71453
nogood8715348683661MJneNEkCWohZKSzwHGqjIMigPLHCnev
[Del]
3
71452
Adam23147557165ifpOGcSmChNvwBfKpkSdHETAhNPvy
[Del]
4
71411
fifa5527518709709nfIMivfdudOSthFSvXjxurhVgUMrfm
[Del]
5
71444
Rebecca82200003254ovusOyrmufkUtVJbnFmYSycOiFqzo
[Del]
6
71442
Sydney54779527304OfiPrZWydtkIfkEgzygsrddnwAiYrZkt
[Del]
7
71455
Eli65769023004iJBjImLxFJlbsikERnguHMyJKEWeBbQJXx
[Del]
8
71402
Samuel52571050975cRLvYvTbvXNLWZjJhbJRQtDsDVhDp
[Del]
9
71439
Kevin88495103813njWzzwxHnxIdtuqLJPZuxghaMmnxccjL
[Del]
10
71432
Jose23341443337IgVrDAccYVmoInXehbkQyWNGjyDP
[Del]
(E) Edit Record     
(e)id 71436 
(e)Product*
(e)custname
(e)telephone
(e)address1
(e)address2
(e)Complaint
 
  PHPLens (Page 1)  
E New Srch

Notes

This feature is available since 3.1.

This demo show to create complaint records, retrieving the product id using a search form built into the NEW/EDIT record form. This is particularly useful when we have a 100,000 product table and we don't want to pull every product record in a normal lookup, but allow the user to enter the first few characters of the product name, then we perform a search.

The two key properties are:

$lens->lookupLens = 
	'PRODUCTID^#select productid,productname from products where productid={productid} ';

The lookupLens is used to perform the mapping between product and productid. We use a hot-update, instead of a regular lookup because we only want to retrieve the required records based on some search criteria, and not pull down 100,000 product records. Hot-updates begin with a #, and matched with the complaint record's {productid}.

$lens->searchInEditNew =
	"PRODUCTID^select concat('Product: ',productname),productname,productid 
		from products where productname like '{#}%'^>1";

There are two modes for searchInEditNew. The simpler first one is discussed in ex919. This example is when the search field is also a lookup, so we need to define a hot update lookupLens. This is because we don't want to display the productid in the search field, but the product name.

Now the searchInEditNew uses a SELECT SQL that retrieves 3 fields, the first being the text to display in the popup, the 2nd is the text to display after the popup item is selected, and the 3rd is what we actually store into the database record. The {#} is substituted with what the user entered in the input field.

And the ^>1 at the end of the searchInEditNew means the user must enter at least 1 character to perform a search. Also note that for this type of searchInEditNew, the field must be a mustFill field.

Lastly, this example has the details being displayed below the grid, using $lens->showRecNo = 5;

email: contact#phplens.com (change # to @)     telephone (malaysia): 60-3-7947 2888     fax (malaysia): 60-3-7947 2800