|
|
@@ -18,7 +18,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
|
|
|
var nbJoursFTTH = 300,
|
|
|
siteName = 'Eligibilité Manche Numérique',
|
|
|
siteUrl = 'http://eligibilite.manchenumerique.fr',
|
|
|
- siteEmail = 'ffth@manchenumerique.fr',
|
|
|
+ siteEmail = 'ftth@manchenumerique.fr',
|
|
|
siteAddresse= '235, rue Joseph Cugnot Zone Delta, 50000 SAINT LÔ';
|
|
|
|
|
|
var catTypeVoie = [
|
|
|
@@ -395,6 +395,21 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
|
|
|
};
|
|
|
|
|
|
|
|
|
+ var computeDateFTTH = function() {
|
|
|
+ if(!$scope.results.ftth) {return;}
|
|
|
+
|
|
|
+ // A date already exists
|
|
|
+ if($scope.results.ftth.DATE_OUV_SERVICE_REEL || $scope.results.ftth.DATE_OUV_SERVICE_PREV) {
|
|
|
+ $scope.results.ftth.date = $scope.results.ftth.DATE_OUV_SERVICE_REEL || $scope.results.ftth.DATE_OUV_SERVICE_PREV;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Compute Date
|
|
|
+ var momentDate = moment($scope.results.ftth.DATE_FIN_TRAV_PREV, 'DD/MM/YY');
|
|
|
+ momentDate.add(nbJoursFTTH, 'days');
|
|
|
+ $scope.results.ftth.date = momentDate.format('DD/MM/YYYY');
|
|
|
+ };
|
|
|
+
|
|
|
$scope.closeRight = function() {
|
|
|
$mdSidenav('right').close().then(function(){});
|
|
|
};
|
|
|
@@ -519,11 +534,9 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
|
|
|
return $sce.trustAsHtml($scope.getHtmlContent(identifier, results));
|
|
|
};
|
|
|
|
|
|
- $scope.computeDateFtthAvailable = function(date) {
|
|
|
+ $scope.formatDateFTTH = function(date) {
|
|
|
if(!date) {return;}
|
|
|
- var momentDate = formatDate(date);
|
|
|
-
|
|
|
- momentDate.add(nbJoursFTTH, 'days');
|
|
|
+ var momentDate = moment(date, 'DD/MM/YYYY');
|
|
|
|
|
|
var result = '<div class="popup-line"><div class="box-eligibilite-title">Date prévisionnelle abonnement FTTH</div><div style="font-weight: bold;" class="popup-value">' + momentDate.locale("fr").format('ddd, LL') + '</div><div class="popup-small-date">' + momentDate.locale("fr").fromNow() + '</div></div>';
|
|
|
return $sce.trustAsHtml(result);
|
|
|
@@ -660,7 +673,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
|
|
|
});
|
|
|
|
|
|
console.time('FTTH data');
|
|
|
- $http({method: 'POST', url: 'data/FFTH_zapm_partielle.json'}).success(function(data) {
|
|
|
+ $http({method: 'POST', url: 'data/FTTH_zapm_partielle.json'}).success(function(data) {
|
|
|
var style = {
|
|
|
color : $scope.colors.ftth,
|
|
|
fillColor: $scope.colors.ftth,
|
|
|
@@ -1068,7 +1081,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
|
|
|
};
|
|
|
|
|
|
var parseResults = function(records) {
|
|
|
- if(!records.length) {
|
|
|
+ if(!records || !records.length) {
|
|
|
return null;
|
|
|
}
|
|
|
if(records.length === 1) {
|
|
|
@@ -1123,9 +1136,43 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
|
|
|
|
|
|
var getResults = function() {
|
|
|
$scope.results = {};
|
|
|
- $scope.results.ftth = parseResults(getRecordsFor('ftth', $scope.geoCode));
|
|
|
- $scope.results.adsl = parseResults(getRecordsFor('adsl', $scope.geoCode));
|
|
|
- $scope.results.mimo = parseResults(getRecordsFor('mimo', $scope.geoCode));
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ method : "POST",
|
|
|
+ url : "ajax/oracle.php",
|
|
|
+ data : $scope.geoCode
|
|
|
+ })
|
|
|
+ .error(function(err) {
|
|
|
+ console.error('Oracle issue', err);
|
|
|
+
|
|
|
+ // Debug without Oracle access
|
|
|
+ onResults('{"x":-1.1060984089996,"y":49.119046582,"ftth":[{"ID_ZAPM_PARTIELLE":"203AP0","DATE_OUV_SERVICE_REEL":null,"DATE_OUV_SERVICE_PREV":null,"DATE_FIN_TRAV_PREV":"02\/05\/16"}],"adsl":[{"ID_FT_ADSL":"656","LEGENDE":"TV sur ADSL","NATURE":"0 - 37"}],"mimo":null}');
|
|
|
+ })
|
|
|
+ .done(function( msg ) {
|
|
|
+ onResults(msg);
|
|
|
+ });
|
|
|
+
|
|
|
+ var onResults = function(results) {
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ $scope.results = JSON.parse(results);
|
|
|
+
|
|
|
+ $scope.results.address = $scope.address;
|
|
|
+ $scope.results.ftth = parseResults($scope.results.ftth);
|
|
|
+ $scope.results.adsl = parseResults($scope.results.adsl);
|
|
|
+ $scope.results.mimo = parseResults($scope.results.mimo);
|
|
|
+
|
|
|
+ computeDateFTTH();
|
|
|
+ }
|
|
|
+ catch(e) {
|
|
|
+ console.error(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('$scope.results', $scope.results);
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
$scope.$evalAsync();
|
|
|
};
|
|
|
|