Revision [1095]
Last edited on 2008-02-07 15:59:21 by EmDeeAdditions:
A script is run (you probably only need to run it once per day via cron), and this updates all customers with their geocoded address data.
Another script is run which generates an XML file, which contains all the data google maps needs... since google maps references the XML file and not the database, this saves database processing time.
geocode.php
geocode_genxml.php
You can run the script (geocode_genxml.php) to see if your XML file is being created properly.
Now you can add a display map page to webERP.
displaymap.php
Another script is run which generates an XML file, which contains all the data google maps needs... since google maps references the XML file and not the database, this saves database processing time.
geocode.php
geocode_genxml.php
You can run the script (geocode_genxml.php) to see if your XML file is being created properly.
Now you can add a display map page to webERP.
displaymap.php
Deletions:
Another script is run once per day, which generates an XML file, which contains all the data google maps needs... since google maps references the XML file and not the database, this saves database processing time.
Now you can add the display map page to webERP.
Revision [1094]
Edited on 2008-02-07 15:47:39 by EmDeeAdditions:
====Summary====
It gives webERP a menu option to display all customers via a google map.
====How to====
It gives webERP a menu option to display all customers via a google map.
====How to====
Revision [1093]
Edited on 2008-02-07 15:46:04 by EmDeeAdditions:
Finally, to add a facility to view and update the lat/lng and the customer type, you can make these changes to CustomerBranches.php, this will give you those options from within webERP.
This is a diff from 3.08 CustomerBranches.php.old, to the new CustomerBranches.php:
82a83,85
> lat = '" . DB_escape_string($_POST['lat']) . "',
> lng = '" . DB_escape_string($_POST['lng']) . "',
> type = '" . DB_escape_string($_POST['type']) . "',
126a130,132
> lat,
> lng,
> type,
155a162,164
> '" . DB_escape_string($_POST['lat']) . "',
> '" . DB_escape_string($_POST['lng']) . "',
> '" . DB_escape_string($_POST['type']) . "',
187a197,199
> lat,
> lng,
> type,
215a228,230
> '" . DB_escape_string($_POST['lat']) . "',
> '" . DB_escape_string($_POST['lng']) . "',
> '" . DB_escape_string($_POST['type']) . "',
312a328,330
> unset($_POST['lat']);
> unset($_POST['lng']);
> unset($_POST['type']);
527a546,548
> lat,
> lng,
> type,
561a583,585
> $_POST['lat'] = $myrow['lat'];
> $_POST['lng'] = $myrow['lng'];
> $_POST['type'] = $myrow['type'];
653a678,685
> // added long/lat coordinates - emdeex
> echo ''._('Latitude').': ';
> echo ' ';
> echo ''._('Longitude').': ';
> echo ' ';
> echo ''._('Type (commercial, domestic)').': ';
> echo ' ';
>
This is a diff from 3.08 CustomerBranches.php.old, to the new CustomerBranches.php:
82a83,85
> lat = '" . DB_escape_string($_POST['lat']) . "',
> lng = '" . DB_escape_string($_POST['lng']) . "',
> type = '" . DB_escape_string($_POST['type']) . "',
126a130,132
> lat,
> lng,
> type,
155a162,164
> '" . DB_escape_string($_POST['lat']) . "',
> '" . DB_escape_string($_POST['lng']) . "',
> '" . DB_escape_string($_POST['type']) . "',
187a197,199
> lat,
> lng,
> type,
215a228,230
> '" . DB_escape_string($_POST['lat']) . "',
> '" . DB_escape_string($_POST['lng']) . "',
> '" . DB_escape_string($_POST['type']) . "',
312a328,330
> unset($_POST['lat']);
> unset($_POST['lng']);
> unset($_POST['type']);
527a546,548
> lat,
> lng,
> type,
561a583,585
> $_POST['lat'] = $myrow['lat'];
> $_POST['lng'] = $myrow['lng'];
> $_POST['type'] = $myrow['type'];
653a678,685
> // added long/lat coordinates - emdeex
> echo '
> echo '
> echo '
> echo '
> echo '
> echo '
>
Revision [1092]
Edited on 2008-02-07 15:40:38 by EmDeeAdditions:
ADD `type` varchar(30) DEFAULT 'domestic' NOT NULL AFTER `lng`;
You'll need to change your customer branch types to either commercial or domestic manually.
You'll need to change your customer branch types to either commercial or domestic manually.
Deletions:
Revision [1091]
Edited on 2008-02-07 15:38:27 by EmDeeAdditions:
Then this script will generate a XML file, that google maps will access when displaying the map.
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
$connection=mysql_connect (localhost, $dbuser, $dbpassword);
die('Not connected : ' . mysql_error());
die ('Can\'t use db : ' . mysql_error());
// Select all the rows in the markers table
die('Invalid query: ' . mysql_error());
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '';
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo '
echo 'name="' . parseToXML($row['brname']) . '" ';
echo 'address="' . parseToXML($row["braddress1"] . ", " . $row["braddress2"] . ", " . $row["braddress3"] . ", " . $row["braddress4"]) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
// End XML file
echo ' ';
Now you can add the display map page to webERP.
Create a file called displaymap.php.
You need to set the API key again.
You need to set the centre of the map to where your business is, and the zoom level.
You also need to set the google map height and width to suit your screen resolution.
$PageSecurity = 3;
include ('includes/session.inc');
$title = _('Geocoded Customer Branches Report');
include ('includes/header.inc');
type="text/javascript">
include ('includes/footer.inc');
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
$connection=mysql_connect (localhost, $dbuser, $dbpassword);
die('Not connected : ' . mysql_error());
die ('Can\'t use db : ' . mysql_error());
// Select all the rows in the markers table
die('Invalid query: ' . mysql_error());
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo '
echo 'address="' . parseToXML($row["braddress1"] . ", " . $row["braddress2"] . ", " . $row["braddress3"] . ", " . $row["braddress4"]) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
// End XML file
echo '
Now you can add the display map page to webERP.
Create a file called displaymap.php.
You need to set the API key again.
You need to set the centre of the map to where your business is, and the zoom level.
You also need to set the google map height and width to suit your screen resolution.
$PageSecurity = 3;
include ('includes/session.inc');
$title = _('Geocoded Customer Branches Report');
include ('includes/header.inc');
type="text/javascript">
include ('includes/footer.inc');