From: <dai...@us...> - 2014-02-06 08:43:02
|
Revision: 6565 http://sourceforge.net/p/web-erp/reponame/6565 Author: daintree Date: 2014-02-06 08:42:57 +0000 (Thu, 06 Feb 2014) Log Message: ----------- 6/2/14 Eduardo Marzolla: geocode integration Modified Paths: -------------- trunk/build/make_release.sh trunk/doc/Change.log trunk/geo_displaymap_customers.php trunk/geo_displaymap_suppliers.php trunk/geocode.php trunk/geocode_genxml_customers.php trunk/geocode_genxml_suppliers.php Modified: trunk/build/make_release.sh =================================================================== --- trunk/build/make_release.sh 2014-02-06 01:19:21 UTC (rev 6564) +++ trunk/build/make_release.sh 2014-02-06 08:42:57 UTC (rev 6565) @@ -9,37 +9,37 @@ xgettext --no-wrap --from-code=utf-8 --language=PHP -o locale/en_GB.utf8/LC_MESSAGES/messages.pot *php includes/*.php includes/*.inc reportwriter/*.php reportwriter/*.inc reportwriter/forms/*.html reportwriter/admin/*.php reportwriter/admin/*.inc reportwriter/admin/forms/*.html api/*.php install/*.php ../webSHOP/*.php ../webSHOP/includes/*.php -msgmerge -U --backup=off locale/ar_EG.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/cs_CZ.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/de_DE.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/en_US.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/el_GR.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/es_ES.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/et_EE.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/fa_IR.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/fr_CA.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/fr_FR.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/hi_IN.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/hr_HR.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/hu_HU.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/id_ID.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/it_IT.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/ja_JP.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/lv_LV.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/nl_NL.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/pl_PL.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/pt_BR.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/pt_PT.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/ru_RU.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/ro_RO.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/sq_AL.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/sv_SE.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/sw_KE.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/tr_TR.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/zh_CN.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/zh_HK.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/zh_TW.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot -msgmerge -U --backup=off locale/vi_VN.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/ar_EG.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/cs_CZ.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/de_DE.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/en_US.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/el_GR.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/es_ES.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/et_EE.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/fa_IR.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/fr_CA.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/fr_FR.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/hi_IN.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/hr_HR.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/hu_HU.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/id_ID.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/it_IT.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/ja_JP.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/lv_LV.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/nl_NL.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/pl_PL.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/pt_BR.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/pt_PT.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/ru_RU.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/ro_RO.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/sq_AL.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/sv_SE.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/sw_KE.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/tr_TR.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/zh_CN.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/zh_HK.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/zh_TW.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot +msgmerge -U -N --backup=off locale/vi_VN.utf8/LC_MESSAGES/messages.po locale/en_GB.utf8/LC_MESSAGES/messages.pot msgfmt -o locale/ar_EG.utf8/LC_MESSAGES/messages.mo locale/ar_EG.utf8/LC_MESSAGES/messages.po Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2014-02-06 01:19:21 UTC (rev 6564) +++ trunk/doc/Change.log 2014-02-06 08:42:57 UTC (rev 6565) @@ -1,10 +1,12 @@ webERP Change Log -6/2/14 icedlava: Payments.php - correct javascript to prevent error popup on every manual GL code entry, correct spacing. -6/2/14 icedlava: BankMatching.php - correct column heading order. + 2/2/14 Release 4.11.3 +6/2/14 Eduardo Marzolla: geocode integration geocode with google API v3. You need to get a API Key from google. The parameters to geocode must be: geocode key: your API key geocode lat: your lat geocode long: your long geocode height: 100 geocode width: 100 host geocode: maps.googleapis.com +6/2/14 icedlava: Payments.php - correct javascript to prevent error popup on every manual GL code entry, correct spacing. +6/2/14 icedlava: BankMatching.php - correct column heading order. 4/2/14 Tim: SalesTopCustomersInquiry.php - shows top customers over specified date range showing invoices/returns and net sales 3/2/14 Exson: Fixed installer now allows characters in the database name 3/2/14 Phil: Fix bug in Payments.php that was duplicating payments for mutliple GL analysis entries. Now just a single bank trans is created for the payment which can be analysed to any number of GL accounts Modified: trunk/geo_displaymap_customers.php =================================================================== --- trunk/geo_displaymap_customers.php 2014-02-06 01:19:21 UTC (rev 6564) +++ trunk/geo_displaymap_customers.php 2014-02-06 08:42:57 UTC (rev 6565) @@ -2,14 +2,14 @@ /* $Id$*/ -$Title = _('Geocoded Customer Branches Report'); +$Title = _('Geocoded Customers Report'); include ('includes/session.inc'); include ('includes/header.inc'); include('includes/SQL_CommonFunctions.inc'); $sql="SELECT * FROM geocode_param WHERE 1"; -$ErrMsg = _('An error occurred in retrieving the currency information');; +$ErrMsg = _('An error occurred in retrieving the currency information'); $result = DB_query($sql, $db, $ErrMsg); $myrow = DB_fetch_array($result); @@ -20,72 +20,100 @@ $Map_Width = $myrow['map_width']; $Map_Host = $myrow['map_host']; -echo '<script src="http://' . $Map_Host . '/maps?file=api&v=2&key=' . $Api_Key . '"'; +?> + +<style> + html, body, #map-canvas { + height: 100%; + width: 100%; + margin: 0px; + padding: 0px + } +</style> + +<? +echo '<script src="http://' . $Map_Host . '/maps/api/js?key=' . $Api_Key . '&sensor=false"'; echo ' type="text/javascript"></script>'; echo ' <script type="text/javascript">'; echo " //<![CDATA[ "; ?> +?> - var iconBlue = new GIcon(); - iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png'; - iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; - iconBlue.iconSize = new GSize(12, 20); - iconBlue.shadowSize = new GSize(22, 20); - iconBlue.iconAnchor = new GPoint(6, 20); - iconBlue.infoWindowAnchor = new GPoint(5, 1); +var customIcons = { +4: { +icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png' +}, +5: { +icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png' +} +}; -var iconRed = new GIcon(); - iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png'; - iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; - iconRed.iconSize = new GSize(12, 20); - iconRed.shadowSize = new GSize(22, 20); - iconRed.iconAnchor = new GPoint(6, 20); - iconRed.infoWindowAnchor = new GPoint(5, 1); +function load() { +var map = new google.maps.Map(document.getElementById("map"), { +<? echo 'center:new google.maps.LatLng(' . $Center_Lat . ', ' . $Center_Long . '),'; ?> +zoom: 4, +mapTypeId: 'roadmap' +}); +var infoWindow = new google.maps.InfoWindow; - var customIcons = []; - customIcons["commercial"] = iconBlue; - customIcons["domestic"] = iconRed; +// Change this depending on the name of your PHP file +downloadUrl("geocode_genxml_customers.php", function(data) { +var xml = data.responseXML; +var markers = xml.documentElement.getElementsByTagName("marker"); +for (var i = 0; i < markers.length; i++) { +var name = markers[i].getAttribute("name"); +var address = markers[i].getAttribute("address"); +var type = markers[i].getAttribute("type"); +var point = new google.maps.LatLng( +parseFloat(markers[i].getAttribute("lat")), +parseFloat(markers[i].getAttribute("lng"))); +var html = "<b>" + name + "</b> <br/>" + address; +var icon = 'http://labs.google.com/ridefinder/images/mm_20_blue.png' || {}; +var marker = new google.maps.Marker({ +map: map, +position: point, +icon: icon.icon +}); +bindInfoWindow(marker, map, infoWindow, html); +} +}); +} - function load() { - if (GBrowserIsCompatible()) { - var map = new GMap2(document.getElementById("map")); - map.addControl(new GSmallMapControl()); - map.addControl(new GMapTypeControl()); -<? echo 'map.setCenter(new GLatLng(' . $Center_Lat . ', ' . $Center_Long . '), 10);'; ?> +function bindInfoWindow(marker, map, infoWindow, html) { +google.maps.event.addListener(marker, 'click', function() { +infoWindow.setContent(html); +infoWindow.open(map, marker); +}); +} - GDownloadUrl("geocode_genxml_customers.php", function(data) { - var xml = GXml.parse(data); - var markers = xml.documentElement.getElementsByTagName("marker"); - for (var i = 0; i < markers.length; i++) { - var name = markers[i].getAttribute("name"); - var address = markers[i].getAttribute("address"); - var type = markers[i].getAttribute("type"); - var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), - parseFloat(markers[i].getAttribute("lng"))); - var marker = createMarker(point, name, address, type); - map.addOverlay(marker); - } - }); - } - } - function createMarker(point, name, address, type) { - var marker = new GMarker(point, customIcons[type]); - var html = "<b>" + name + "</b> <br/>" + address; - GEvent.addListener(marker, 'click', function() { - marker.openInfoWindowHtml(html); - }); - return marker; +function downloadUrl(url, callback) { +var request = window.ActiveXObject ? +new ActiveXObject('Microsoft.XMLHTTP') : +new XMLHttpRequest; + +request.onreadystatechange = function() { +if (request.readyState == 4) { +request.onreadystatechange = doNothing; +callback(request, request.status); } +}; - //]]> - </script> - </head> +request.open('GET', url, true); +request.send(null); +} - <body onload="load()" onunload="GUnload()"> -<p> -<? echo '<div class="centre" id="map" style="width: ' . $Map_Width . 'px; height: ' . $Map_Height . 'px"></div>'; ?> -</p> - </body> +function doNothing() {} + +//]]> + +</script> +</head> + +<body onload="load()" onunload="GUnload()"> + <p> + <? echo '<div class="centre" id="map" style="width: ' . $Map_Width . 'px; height: ' . $Map_Height . 'px"></div>'; ?> + </p> +</body> <? echo '<div class="centre"><a href="' . $RootPath . '/GeocodeSetup.php">' . _('Go to Geocode Setup') . '</a></div></p>'; include ('includes/footer.inc'); Modified: trunk/geo_displaymap_suppliers.php =================================================================== --- trunk/geo_displaymap_suppliers.php 2014-02-06 01:19:21 UTC (rev 6564) +++ trunk/geo_displaymap_suppliers.php 2014-02-06 08:42:57 UTC (rev 6565) @@ -9,7 +9,7 @@ include('includes/SQL_CommonFunctions.inc'); $sql="SELECT * FROM geocode_param WHERE 1"; -$ErrMsg = _('An error occurred in retrieving the currency information');; +$ErrMsg = _('An error occurred in retrieving the currency information'); $result = DB_query($sql, $db, $ErrMsg); $myrow = DB_fetch_array($result); @@ -20,72 +20,100 @@ $Map_Width = $myrow['map_width']; $Map_Host = $myrow['map_host']; -echo '<script src="http://' . $Map_Host . '/maps?file=api&v=2&key=' . $Api_Key . '"'; +?> + +<style> + html, body, #map-canvas { + height: 100%; + width: 100%; + margin: 0px; + padding: 0px + } +</style> + +<? +echo '<script src="http://' . $Map_Host . '/maps/api/js?key=' . $Api_Key . '&sensor=false"'; echo ' type="text/javascript"></script>'; echo ' <script type="text/javascript">'; echo " //<![CDATA[ "; ?> +?> - var iconBlue = new GIcon(); - iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png'; - iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; - iconBlue.iconSize = new GSize(12, 20); - iconBlue.shadowSize = new GSize(22, 20); - iconBlue.iconAnchor = new GPoint(6, 20); - iconBlue.infoWindowAnchor = new GPoint(5, 1); +var customIcons = { + 4: { + icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png' + }, + 5: { + icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png' + } +}; -var iconRed = new GIcon(); - iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png'; - iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; - iconRed.iconSize = new GSize(12, 20); - iconRed.shadowSize = new GSize(22, 20); - iconRed.iconAnchor = new GPoint(6, 20); - iconRed.infoWindowAnchor = new GPoint(5, 1); +function load() { + var map = new google.maps.Map(document.getElementById("map"), { + <? echo 'center:new google.maps.LatLng(' . $Center_Lat . ', ' . $Center_Long . '),'; ?> + zoom: 4, + mapTypeId: 'roadmap' + }); + var infoWindow = new google.maps.InfoWindow; - var customIcons = []; - customIcons["commercial"] = iconBlue; - customIcons["domestic"] = iconRed; + // Change this depending on the name of your PHP file + downloadUrl("geocode_genxml_suppliers.php", function(data) { + var xml = data.responseXML; + var markers = xml.documentElement.getElementsByTagName("marker"); + for (var i = 0; i < markers.length; i++) { + var name = markers[i].getAttribute("name"); + var address = markers[i].getAttribute("address"); + var type = markers[i].getAttribute("type"); + var point = new google.maps.LatLng( + parseFloat(markers[i].getAttribute("lat")), + parseFloat(markers[i].getAttribute("lng"))); + var html = "<b>" + name + "</b> <br/>" + address; + var icon = 'http://labs.google.com/ridefinder/images/mm_20_blue.png' || {}; + var marker = new google.maps.Marker({ + map: map, + position: point, + icon: icon.icon + }); + bindInfoWindow(marker, map, infoWindow, html); + } + }); +} - function load() { - if (GBrowserIsCompatible()) { - var map = new GMap2(document.getElementById("map")); - map.addControl(new GSmallMapControl()); - map.addControl(new GMapTypeControl()); -<? echo 'map.setCenter(new GLatLng(' . $Center_Lat . ', ' . $Center_Long . '), 10);'; ?> +function bindInfoWindow(marker, map, infoWindow, html) { +google.maps.event.addListener(marker, 'click', function() { +infoWindow.setContent(html); +infoWindow.open(map, marker); +}); +} - GDownloadUrl("geocode_genxml_suppliers.php", function(data) { - var xml = GXml.parse(data); - var markers = xml.documentElement.getElementsByTagName("marker"); - for (var i = 0; i < markers.length; i++) { - var name = markers[i].getAttribute("name"); - var address = markers[i].getAttribute("address"); - var type = markers[i].getAttribute("type"); - var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), - parseFloat(markers[i].getAttribute("lng"))); - var marker = createMarker(point, name, address, type); - map.addOverlay(marker); - } - }); - } - } - function createMarker(point, name, address, type) { - var marker = new GMarker(point, customIcons[type]); - var html = "<b>" + name + "</b> <br/>" + address; - GEvent.addListener(marker, 'click', function() { - marker.openInfoWindowHtml(html); - }); - return marker; +function downloadUrl(url, callback) { +var request = window.ActiveXObject ? +new ActiveXObject('Microsoft.XMLHTTP') : +new XMLHttpRequest; + +request.onreadystatechange = function() { +if (request.readyState == 4) { +request.onreadystatechange = doNothing; +callback(request, request.status); } +}; - //]]> - </script> - </head> +request.open('GET', url, true); +request.send(null); +} - <body onload="load()" onunload="GUnload()"> -<p> -<? echo '<div class="centre" id="map" style="width: ' . $Map_Width . 'px; height: ' . $Map_Height . 'px"></div>'; ?> -</p> - </body> +function doNothing() {} + +//]]> + +</script> +</head> + +<body onload="load()" onunload="GUnload()"> + <p> + <? echo '<div class="centre" id="map" style="width: ' . $Map_Width . 'px; height: ' . $Map_Height . 'px"></div>'; ?> + </p> +</body> <? echo '<div class="centre"><a href="' . $RootPath . '/GeocodeSetup.php">' . _('Go to Geocode Setup') . '</a></div></p>'; include ('includes/footer.inc'); Modified: trunk/geocode.php =================================================================== --- trunk/geocode.php 2014-02-06 01:19:21 UTC (rev 6564) +++ trunk/geocode.php 2014-02-06 08:42:57 UTC (rev 6565) @@ -6,7 +6,7 @@ include ('includes/session.inc'); include ('includes/header.inc'); -include('includes/SQL_CommonFunctions.inc'); +//include ('includes/SQL_CommonFunctions.inc'); $sql = "SELECT * FROM geocode_param WHERE 1"; $ErrMsg = _('An error occurred in retrieving the information'); @@ -29,58 +29,64 @@ $sql = "SELECT * FROM custbranch WHERE 1"; $ErrMsg = _('An error occurred in retrieving the information'); $result = DB_query($sql, $db, $ErrMsg); -$row = DB_fetch_array($result); + // select all the suppliers $sql = "SELECT * FROM suppliers WHERE 1"; $ErrMsg = _('An error occurred in retrieving the information'); $result2 = DB_query($sql, $db, $ErrMsg); -$row2 = DB_fetch_array($result2); // Initialize delay in geocode speed $delay = 0; -$base_url = "http://" . MAPS_HOST . "/maps/geo?output=xml" . "&key=" . KEY; +$base_url = "http://" . MAPS_HOST . "/maps/api/geocode/xml?address="; // Iterate through the customer branch rows, geocoding each address -while ($row = @mysql_fetch_assoc($result)) { + + +while ($row = DB_fetch_array($result)) { $geocode_pending = true; while ($geocode_pending) { - $address = $row["braddress1"] . ", " . $row["braddress2"] . ", " . $row["braddress3"] . ", " . $row["braddress4"]; + $address = urlencode($row["braddress1"] . "," . $row["braddress2"] . "," . $row["braddress3"] . "," . $row["braddress4"]); $id = $row["branchcode"]; $debtorno =$row["debtorno"]; - $request_url = $base_url . "&q=" . urlencode($address); + $request_url = $base_url . $address . ',&sensor=true'; + + echo '<br \>' . _('Customer Code: ') . $id; + + $xml = simplexml_load_string(utf8_encode(file_get_contents($request_url))) or die("url not loading"); // $xml = simplexml_load_file($request_url) or die("url not loading"); - $status = $xml->Response->Status->code; - if (strcmp($status, "200") == 0) { + $status = $xml->status; + + if (strcmp($status, "OK") == 0) { // Successful geocode $geocode_pending = false; - $coordinates = $xml->Response->Placemark->Point->coordinates; + $coordinates = $xml->GeocodeResponse->result->geometry->location; $coordinatesSplit = explode(",", $coordinates); // Format: Longitude, Latitude, Altitude - $lat = $coordinatesSplit[1]; - $lng = $coordinatesSplit[0]; + $lat = $xml->result->geometry->location->lat; + $lng = $xml->result->geometry->location->lng; $query = sprintf("UPDATE custbranch " . " SET lat = '%s', lng = '%s' " . " WHERE branchcode = '%s' " . " AND debtorno = '%s' LIMIT 1;", - mysql_real_escape_string($lat), - mysql_real_escape_string($lng), - mysql_real_escape_string($id), - mysql_real_escape_string($debtorno)); - $update_result = mysql_query($query); - if (!$update_result) { - die("Invalid query: " . mysql_error()); - } - } else if (strcmp($status, "620") == 0) { - // sent geocodes too fast - $delay += 100000; + ($lat), + ($lng), + ($id), + ($debtorno)); + + $update_result = DB_query($query,$db); + + if ($update_result==1) { + echo '<br />'. 'Address: ' . $address . ' updated to geocode.'; + echo '<br />'. 'Received status ' . $status . '<br />'; + } } else { // failure to geocode $geocode_pending = false; - echo '<p>' . _('Customer Branch Code:') . $id . ', Address: ' . $address . _('failed to geocode.'); + echo '<br />' . 'Address: ' . $address . _('failed to geocode.'); echo 'Received status ' . $status . '<br />'; } usleep($delay); @@ -88,50 +94,54 @@ } // Iterate through the Supplier rows, geocoding each address -while ($row2 = @mysql_fetch_assoc($result2)) { +while ($row2 = DB_fetch_array($result2)) { $geocode_pending = true; while ($geocode_pending) { - $address = $row2["address1"] . ", " . $row2["address2"] . ", " . $row2["address3"] . ", " . $row2["address4"]; + $address = $row2["address1"] . ",+" . $row2["address2"] . ",+" . $row2["address3"] . ",+" . $row2["address4"]; + $address = urlencode($row2["address1"] . "," . $row2["address2"] . "," . $row2["address3"] . "," . $row2["address4"]); $id = $row2["supplierid"]; - $request_url = $base_url . "&q=" . urlencode($address); + $request_url = $base_url . $address . ',&sensor=true'; + + echo '<p>' . _('Supplier Code: ') . $id; + $xml = simplexml_load_string(utf8_encode(file_get_contents($request_url))) or die("url not loading"); // $xml = simplexml_load_file($request_url) or die("url not loading"); - $status = $xml->Response->Status->code; - if (strcmp($status, "200") == 0) { + $status = $xml->status; + + if (strcmp($status, "OK") == 0) { // Successful geocode $geocode_pending = false; - $coordinates = $xml->Response->Placemark->Point->coordinates; + $coordinates = $xml->GeocodeResponse->result->geometry->location; $coordinatesSplit = explode(",", $coordinates); // Format: Longitude, Latitude, Altitude - $lat = $coordinatesSplit[1]; - $lng = $coordinatesSplit[0]; + $lat = $xml->result->geometry->location->lat; + $lng = $xml->result->geometry->location->lng; + $query = sprintf("UPDATE suppliers " . " SET lat = '%s', lng = '%s' " . " WHERE supplierid = '%s' LIMIT 1;", - mysql_real_escape_string($lat), - mysql_real_escape_string($lng), - mysql_real_escape_string($id)); - $update_result = mysql_query($query); - if (!$update_result) { - die("Invalid query: " . mysql_error()); + ($lat), + ($lng), + ($id)); + + $update_result = DB_query($query,$db); + + if ($update_result==1) { + echo '<br />' . 'Address: ' . $address . ' updated to geocode.'; + echo '<br />' . 'Received status ' . $status . '<br />'; } - } else if (strcmp($status, "620") == 0) { - // sent geocodes too fast - $delay += 100000; } else { // failure to geocode $geocode_pending = false; - echo '<p>' . _('Supplier Code: ') . $id . ', Address: ' . $address . ' failed to geocode.'; - echo 'Received status ' . $status . '<br />'; + echo '<br />' . 'Address: ' . $address . ' failed to geocode.'; + echo '<br />' . 'Received status ' . $status . '<br />'; } usleep($delay); } } -echo '</p>'; - echo '<br /><div class="centre"><a href="' . $RootPath . '/GeocodeSetup.php">' . _('Go back to Geocode Setup') . '</a></div>'; include ('includes/footer.inc'); ?> Modified: trunk/geocode_genxml_customers.php =================================================================== --- trunk/geocode_genxml_customers.php 2014-02-06 01:19:21 UTC (rev 6564) +++ trunk/geocode_genxml_customers.php 2014-02-06 08:42:57 UTC (rev 6565) @@ -9,34 +9,32 @@ 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; + $xmlStr=str_replace('<','<',$htmlStr); + $xmlStr=str_replace('>','>',$xmlStr); + $xmlStr=str_replace('"','"',$xmlStr); + $xmlStr=str_replace("'",''',$xmlStr); + $xmlStr=str_replace("&",'&',$xmlStr); + return $xmlStr; } $sql = "SELECT * FROM custbranch WHERE 1"; $ErrMsg = _('An error occurred in retrieving the information');; $result = DB_query($sql, $db, $ErrMsg); -$myrow = DB_fetch_array($result); header("Content-type: text/xml"); -// Start XML file, echo parent node +// Iterate through the rows, printing XML nodes for each echo '<markers>'; -// Iterate through the rows, printing XML nodes for each -while ($myrow = @mysql_fetch_assoc($result)){ - // ADD TO XML DOCUMENT NODE - echo '<marker '; - echo 'name="' . parseToXML($myrow['brname']) . '" '; - echo 'address="' . parseToXML($myrow["braddress1"] . ", " . $myrow["braddress2"] . ", " . $myrow["braddress3"] . ", " . $myrow["braddress4"]) . '" '; - echo 'lat="' . $myrow['lat'] . '" '; - echo 'lng="' . $myrow['lng'] . '" '; - echo 'type="' . $myrow['type'] . '" '; - echo '/>'; +while ($myrow = DB_fetch_array($result)){ + // ADD TO XML DOCUMENT NODE + echo '<marker '; + echo 'name="' . parseToXML($myrow['brname']) . '" '; + echo 'address="' . parseToXML($myrow["braddress1"] . ", " . $myrow["braddress2"] . ", " . $myrow["braddress3"] . ", " . $myrow["braddress4"]) . '" '; + echo 'lat="' . $myrow['lat'] . '" '; + echo 'lng="' . $myrow['lng'] . '" '; + echo 'type="' . $myrow['area'] . '" '; + echo '/>'; } // End XML file Modified: trunk/geocode_genxml_suppliers.php =================================================================== --- trunk/geocode_genxml_suppliers.php 2014-02-06 01:19:21 UTC (rev 6564) +++ trunk/geocode_genxml_suppliers.php 2014-02-06 08:42:57 UTC (rev 6565) @@ -20,22 +20,20 @@ $sql = "SELECT * FROM suppliers WHERE 1"; $ErrMsg = _('An error occurred in retrieving the information');; $result = DB_query($sql, $db, $ErrMsg); -$myrow = DB_fetch_array($result); header("Content-type: text/xml"); -// Start XML file, echo parent node +// Iterate through the rows, printing XML nodes for each echo '<markers>'; -// Iterate through the rows, printing XML nodes for each -while ($myrow = @mysql_fetch_assoc($result)){ +while ($myrow = DB_fetch_array($result)){ // ADD TO XML DOCUMENT NODE echo '<marker '; echo 'name="' . parseToXML($myrow['suppname']) . '" '; echo 'address="' . parseToXML($myrow["address1"] . ", " . $myrow["address2"] . ", " . $myrow["address3"] . ", " . $myrow["address4"]) . '" '; echo 'lat="' . $myrow['lat'] . '" '; echo 'lng="' . $myrow['lng'] . '" '; - echo 'type="' . $myrow['type'] . '" '; + echo 'type="' . $myrow['supptype'] . '" '; echo '/>'; } |