|
|
@@ -28,8 +28,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
|
|
|
$scope.$sce = $sce;
|
|
|
|
|
|
var getGeoCodeInProgress = false,
|
|
|
- nbJoursFTTH = 244,
|
|
|
- nbJoursInscription = 60,
|
|
|
+ nbJoursFTTH = 365,
|
|
|
siteName = 'Eligibilité Manche Numérique',
|
|
|
siteUrl = 'http://eligibilite.manchenumerique.fr',
|
|
|
siteEmail = 'ftth@manchenumerique.fr',
|
|
|
@@ -510,25 +509,38 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
|
|
|
|
|
|
var computeDateFTTH = function() {
|
|
|
if(!$scope.results.ftth) {return;}
|
|
|
+ $scope.results.ftth.eligible = false;
|
|
|
+
|
|
|
+ var momentDate;
|
|
|
|
|
|
// Already deployed
|
|
|
if($scope.results.ftth.PHASE_TRAV === 'Perimetre deploye FTTH MT') {
|
|
|
- $scope.results.ftth.date = true;
|
|
|
- return;
|
|
|
+ $scope.results.ftth.eligible = true;
|
|
|
}
|
|
|
|
|
|
- // A date already exists
|
|
|
- else 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;
|
|
|
+ // Si date de début de travaux réelle est renseignée
|
|
|
+ if ($scope.results.ftth.DATE_DEB_TRAV_REEL) {
|
|
|
+ // Compute Date
|
|
|
+ momentDate = moment($scope.results.ftth.DATE_DEB_TRAV_REEL, 'DD/MM/YY');
|
|
|
+
|
|
|
+ momentDate.add(nbJoursFTTH, 'days');
|
|
|
+
|
|
|
+ $scope.results.ftth.date = momentDate.format('MM/YYYY');
|
|
|
}
|
|
|
|
|
|
- else if($scope.results.ftth.DATE_FIN_TRAV_PREV) {
|
|
|
+ // Si date de début de travaux prévisionnelle est renseignée
|
|
|
+ else if(($scope.results.ftth.PHASE_TRAV === 'Tranche 1 Travaux' || $scope.results.ftth.PHASE_TRAV === 'Tranche 1 Travaux completude') && $scope.results.ftth.DATE_DEB_TRAV_PREV) {
|
|
|
|
|
|
// Compute Date
|
|
|
- var momentDate = moment($scope.results.ftth.DATE_FIN_TRAV_PREV, 'DD/MM/YY');
|
|
|
+ momentDate = moment($scope.results.ftth.DATE_ABONNEMENT_PREV, 'DD/MM/YY');
|
|
|
momentDate.add(nbJoursFTTH, 'days');
|
|
|
- $scope.results.ftth.date = momentDate.format('DD/MM/YYYY');
|
|
|
+
|
|
|
+ var semester = '1er';
|
|
|
+ if(parseInt(momentDate.format('M'), 10) > 5) {
|
|
|
+ semester = '2nd';
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.results.ftth.date = semester + ' semestre ' + momentDate.format('YYYY');
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -855,9 +867,8 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
|
|
|
|
|
|
$scope.formatDateFTTH = function(date) {
|
|
|
if(!date || date === "Invalid date") {return;}
|
|
|
- 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('MMMM YYYY') + '</div><div class="popup-small-date">' + momentDate.locale("fr").fromNow() + '</div></div>';
|
|
|
+ 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">' + date + '</div></div>';
|
|
|
return $sce.trustAsHtml(result);
|
|
|
};
|
|
|
|
|
|
@@ -991,12 +1002,15 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
|
|
|
};
|
|
|
|
|
|
$scope.isInscriptionOpen = function() {
|
|
|
- if(!$scope.results.ftth || !$scope.results.ftth.DATE_DEB_ETUDES_PREV) {return false;}
|
|
|
- var dateDebEtudes = moment($scope.results.ftth.DATE_DEB_ETUDES_PREV, 'DD/MM/YY');
|
|
|
+ if(!$scope.results.ftth || !$scope.results.ftth.DATE_OUV_BUL_PRERACCO) {return false;}
|
|
|
+
|
|
|
+ var dateDeb = moment($scope.results.ftth.DATE_OUV_BUL_PRERACCO, 'DD/MM/YY');
|
|
|
+ var dateFin = moment($scope.results.ftth.DATE_FERM_BUL_PRERACCO, 'DD/MM/YY');
|
|
|
var now = moment();
|
|
|
- var diffDays = now.diff(dateDebEtudes) / 1000 / 3600 / 24;
|
|
|
+ var diffDaysDeb = now.diff(dateDeb) / 1000 / 3600 / 24;
|
|
|
+ var diffDaysFin = now.diff(dateFin) / 1000 / 3600 / 24;
|
|
|
|
|
|
- return diffDays > nbJoursInscription;
|
|
|
+ return diffDaysDeb > 0 && diffDaysFin < 0;
|
|
|
};
|
|
|
|
|
|
$scope.onSubmitAddress = function($item, $model, $label) {
|
|
|
@@ -1302,4 +1316,4 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
|
|
|
});
|
|
|
|
|
|
init();
|
|
|
-});
|
|
|
+});
|