Browse Source

Open inscription 2 months after "Etudes"

boutils 10 năm trước cách đây
mục cha
commit
fa45ece7ca
2 tập tin đã thay đổi với 22 bổ sung5 xóa
  1. 5 3
      index.html
  2. 17 2
      js/app.js

+ 5 - 3
index.html

@@ -257,20 +257,22 @@
               <span>
 
                 <span
-                  ng-if = "results.ftth.date"
+                  ng-if = "results.ftth.date && isInscriptionOpen()"
                   class = "box-eligibilite-yes">
 
                   OUI
                 </span>
 
                 <span
-                  ng-if = "!results.ftth.date"
+                  ng-if = "!results.ftth.date || !isInscriptionOpen()"
                   class = "box-eligibilite-no">
 
                   NON
                 </span>
 
-                <div ng-if = "results.ftth.date" style="text-align: center; margin-top: 14px;">
+                <div
+                  ng-if = "results.ftth.date && isInscriptionOpen()"
+                  style = "text-align: center; margin-top: 14px;">
 
                   <button
                     type        = "button"

+ 17 - 2
js/app.js

@@ -41,8 +41,11 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
   $scope.title = "Manche Numerique";
   $scope.$sce  = $sce;
 
+//DATE_DEB_ETUDES_PREV
+
   var getGeoCodeInProgress = false,
       nbJoursFTTH          = 244,
+      nbJoursInscription   = 60,
       siteName             = 'Eligibilité Manche Numérique',
       siteUrl              = 'http://eligibilite.manchenumerique.fr',
       siteEmail            = 'ftth@manchenumerique.fr',
@@ -587,11 +590,10 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
 
       //[{"ID_ZAPM_PARTIELLE":"119CP0","DATE_OUV_SERVICE_REEL":null,"DATE_OUV_SERVICE_PREV":null,"DATE_FIN_TRAV_PREV":null}]
       // 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":"04\/05\/16"}],"adsl":[{"ID_FT_ADSL":"656","LEGENDE":"TV sur ADSL","NATURE":"0 - 37"}],"mimo":null}');
+      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":"04\/05\/16","DATE_DEB_ETUDES_PREV":"01\/12\/14"}],"adsl":[{"ID_FT_ADSL":"656","LEGENDE":"TV sur ADSL","NATURE":"0 - 37"}],"mimo":null}');
     })
     .done(function( msg ) {
       onResults(msg);
-
     });
 
     var onResults = function(results) {
@@ -608,9 +610,13 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
         computeDateFTTH();
       }
       catch(e) {
+        /*
         console.error(e);
         alert('Probleme de connexion à la base de donnée Oracle.');
         $scope.hideResultPane();
+        */
+        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":"04\/05\/16","DATE_DEB_ETUDES_PREV":"01\/12\/14"}],"adsl":[{"ID_FT_ADSL":"656","LEGENDE":"TV sur ADSL","NATURE":"0 - 37"}],"mimo":null}');
+
       }
 
       //console.log('$scope.results', results, '=>', $scope.results);
@@ -1078,6 +1084,15 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
     return isValid;
   };
 
+  $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');
+    var now           = moment();
+    var diffDays      = now.diff(dateDebEtudes) / 1000 / 3600 / 24;
+
+    return diffDays > nbJoursInscription;
+  };
+
   $scope.onSubmitAddress = function($item, $model, $label) {
 
     // console.log('onSubmitAddress address', $scope.address);