Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
dev:location_handler [2007/02/10 11:55]
fran
— (current)
Line 1: Line 1:
-Main Author: [[http://www.r4vi.org | Ravindra de Silva ]] Contributors: ... 
  
-====== Location Library ====== 
- 
-===== Generate Location Boxes ===== 
- 
-This allows you to create a set of select boxes with AJAX capability. 
-all you need to do is include the libray and call the API function. For AJAX to function 
-javascript needs to be enabled at the client side. 
- 
-The function to use is 
- 
-<code php> 
-shn_location($range,$value=null,$parent=null,$extra_opts=null) 
-</code> 
- 
-  * $range is the range of location levels you want to display 
-i.e Though levels from Country to City exists ,you might want to display only 
-Country to State  
-  * if you want to pre-select a location ,then pass a value. If you pass a city then 
-the State and Country will also be populated. 
-  * If you want to show only the locations of the Country "USA" then you can pass the  
-location id of USA as $parent. 
-  * In $extra_opts you can specify whether you want to display location unknown check box 
-and whether you want to display camps ,organizations alongside the locations. 
-for example if you want to show camps ,then pass $extra_opts["camps"]=true; 
- 
- 
- 
-e.g: 
-<code php> 
-require_once $global['approot']."/inc/lib_location.inc"; 
-$extra_opts["camps"]=true; 
-$range=array("start"=>1,"end"=>4); 
-shn_location($range,$_SESSION['org']['loc'],null,$extra_opts); 
-</code> 
- 
-this will create 4 select boxes from level 1 to level 4 
-remember in the database in field_options ,we define the levels. 
-In addition this will generate a select box to select camps. 
- 
-if you need only the first 3 levels 
-<code php> 
-$range=array("start"=>1,"end"=>3); 
-</code> 
- 
-Then once the form is submitted ,there will a POST variable per each level 
-name of the variable will be the level no. 
- 
-Note: You can display both camps and organizations at the same time with locations. 
-it will be extended to display Inventories as well. 
- 
-<code php> 
-        $extra_opts["camps"]=true; 
-        $extra_opts["org"]=true; 
-</code> 
- 
-above code will produce two radio buttons and a set of location select 
-boxes. 
-when you select the "camp" radio button , a select box will appear with 
-the camps. 
-when you select a camp ,through AJAX, location details of the 
-camp(country,city,state,ect) will be retrieved and the location boxes 
-will get populated with those. 
-similar functionality can be seen when you select the "organization"  
-radio button. 
- 
-===== Obtain the location selected by user from POST variables ===== 
- 
-the function to use is  
- 
-<code php> 
-shn_location_get_form_submit_loc(); 
-</code> 
- 
-This function will start from the lowest level of the select boxes (say city) and goes up  
-the select boxes till it finds a location selected and return it. 
- 
-e.g 
-<code php> 
- 
-    $loc=shn_location_get_form_submit_loc(); 
-    if($loc==-1){ 
-    add_error(SHN_ERR_OR_LOCATION_INCOMPLETE); 
-        $error=true; 
-    } 
-</code> 
- 
- 
-====== Other API functions ====== 
-<code php> 
-shn_location_is_leaf($loc) 
-</code> 
- 
-Returns true if the location does not have any children 
- 
-<code php> 
-shn_location_get_descendants($loc,&$loc_arr)) 
-</code> 
- 
-Returns an array of descendants of a location 
- 
-<code php> 
-shn_location_level_range_form($name,$label,$sel) 
-</code> 
- 
-Displays the full range of location levels for the user 
- 
-<code php> 
-shn_get_parents($child,&$loc_arr) 
-</code> 
- 
- Returns the list of parents of the location. Starting from the location to 
- the parent,grand parent,ect. For each level the name and location id is returned. 
- 
-<code php> 
- shn_get_level($loc) 
-</code> 
- 
-Returns the level of the location  
- 
-<code php> 
- shn_is_last_level($loc) 
-</code> 
- 
-Returns whether the location is in the last level or not 
- 
-<code php> 
- shn_get_last_level() 
-</code> 
- 
-Returns the last location level avaliable  
- 
-<code php> 
- shn_get_range() 
-</code> 
- 
-Returns the range of levels avaliable  

QR Code
QR Code dev:location_handler (generated for current page)