diff --git a/conf/requires/config.js b/conf/requires/config.js
index 5f087772bf18a4dc42440f6b0df3c2e73d6222dd..a76b12e0ab554c3d616897c0c7577139edb82bd2 100755
--- a/conf/requires/config.js
+++ b/conf/requires/config.js
@@ -38,7 +38,9 @@ var oApplicationFiles = {
         'css/lib/jquery/plugins/bootstrap-treeview/bootstrap-treeview.min.css',
         'css/lib/jquery/plugins/bootstrap-tagsinput/bootstrap-tagsinput.css',
         'css/lib/jquery/plugins/bootstrap-colorpicker/css/bootstrap-colorpicker.min.css',
-        'css/lib/viewer/viewer.min.css'
+        'css/lib/viewer/viewer.min.css',
+        // Urbalyon
+        'modules/suivi_prod_immo/less/main.less'
     ],
     'css_mobile': [
         // Vitis
diff --git a/src/module_suivi_prod_immo/module/component/fiche_operation/fiche_operation.html b/src/module_suivi_prod_immo/module/component/fiche_operation/fiche_operation.html
new file mode 100644
index 0000000000000000000000000000000000000000..cd563ae416fb4a66311967e5cb60530c3e52ecb8
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/component/fiche_operation/fiche_operation.html
@@ -0,0 +1,19 @@
+<div id="select_display_form_reader" app-form-reader app-form-definition="formOperation" app-form-definition-name="'display'" app-form-values="formOperationValues"> </div>
+
+
+	<div class="row mt-5" style="margin-left: 15px;">
+		<form>
+			<div class="form-group">
+				<label for="l_operation">Opération</label>
+				<select class="form-control select_id_operation" id="l_operation" ng-model="operation_selected">
+					<option ng-repeat="operation in operations" ng-value="operation.id_operation">{{ operation.nom_operation }}</option>
+				</select>
+			</div>
+
+			<div class="btn-group" role="group" aria-label="Basic example">
+			  <button id="get_operation" type="button" class="btn btn-outline-secondary button_fiche" ng-click="getFicheOperation(operation_selected)">Afficher la fiche</button>
+			  <button id="get_operation_excel" type="button" class="btn btn-outline-secondary button_fiche" ng-click="getFicheOperationXls(operation_selected)" disabled><span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> Export</button>
+			</div>
+
+		</form>
+	</div>
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/module/component/fiche_operation/fiche_operation.js b/src/module_suivi_prod_immo/module/component/fiche_operation/fiche_operation.js
new file mode 100644
index 0000000000000000000000000000000000000000..36f04ab76113a2cf040935858b464e65e0c5a91b
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/component/fiche_operation/fiche_operation.js
@@ -0,0 +1,51 @@
+goog.provide('vmap.suivi_prod_immo.fiche_operation');
+goog.require('oVmap');
+
+/**
+ * Fiche operation Directive
+ *
+ * @return {angular.Directive} The directive specs.
+ * @export
+ * @constructor
+ */
+vitisApp.fiche_operationDirective = function () {
+
+  return {
+    restrict: 'A',
+    templateUrl: 'modules/suivi_prod_immo/component/fiche_operation/fiche_operation.html',
+    link: function (scope, element, attrs) {
+      scope.getFicheOperation = function (id_operation) {
+        if(id_operation==null){
+          alert('Veuillez sélectionner une opération dans la liste déroulante !');
+        }else{
+          window.open(oVmap['properties']['web_server_name'] +'/doc/suivi_prod_immo/get_1_operation.php?token='+oVmap['properties']['token']+'&id_operation='+id_operation, '_blank');
+          //window.open('https://geo.urbalyon.org/doc/suivi_prod_immo/get_1_operation.php?id_operation='+id_operation, '_blank');
+        }
+        
+      }
+      scope.getFicheOperationXls = function (id_operation) {
+        alert('En cours de développement');
+      }
+
+      scope.operation_selected = null;
+      scope.operations = [];
+
+      // récupération du contenu de la liste déroulante
+      ajaxRequest({
+        "method": "GET",
+        "url": oVmap['properties']['web_server_name'] + "/" + oVmap['properties']['services_alias'] + "/suivi_prod_immo/getlist/getoperationlist",
+        'async': false,
+        'responseType': '',
+        "success": function (response) {
+            data = JSON.parse(response.data);
+            // data.forEach(operation_value => scope.operations.push(operation_value));
+			for (var operation_value in data) {
+				scope.operations.push(data[operation_value]);
+			}
+        }
+      });
+
+    }
+  };
+};
+vitisApp.module.directive("appFicheoperation", vitisApp.fiche_operationDirective);
diff --git a/src/module_suivi_prod_immo/module/component/fiche_operation/fiche_operation.less b/src/module_suivi_prod_immo/module/component/fiche_operation/fiche_operation.less
new file mode 100644
index 0000000000000000000000000000000000000000..f0b5d029bceba76dc2e099cacced55c6137a630f
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/component/fiche_operation/fiche_operation.less
@@ -0,0 +1,14 @@
+
+.select_id_operation{
+    width:500px;
+}
+
+.title_fiche{
+    padding-left: 20px;
+    font-size: 35px;
+}
+
+.button_fiche{
+    border-color: gainsboro;
+    border: 1px solid;
+}
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/module/component/porteur/porteur.html b/src/module_suivi_prod_immo/module/component/porteur/porteur.html
new file mode 100644
index 0000000000000000000000000000000000000000..cd3583734a70f707f1a140c8c895a64d8e368386
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/component/porteur/porteur.html
@@ -0,0 +1,17 @@
+<div class="row mt-5" style="margin-left: 15px;">
+    <form>
+        <div class="form-group">
+            <label for="l_nom_amenageur">Opérateurs et partenaires</label>
+            <select class="form-control select_nom_amenageur" id="l_nom_amenageur" ng-model="nom_amenageur_selected">
+                <option ng-repeat="nom_amenageur in nom_amenageurs" ng-value="nom_amenageur.code_amenageur">{{ nom_amenageur.nom_amenageur }}</option>
+            </select>
+            <span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="color:blue"></span> Le nombre d'opération de l'opérateur est affiché entre parenthèse.
+        </div>
+
+        <div class="btn-group" role="group" aria-label="Basic example">
+          <button id="get_nom_amenageur" type="button" class="btn btn-outline-secondary button_fiche" ng-click="getPorteur(nom_amenageur_selected)">Afficher la fiche</button>
+          <button id="get_nom_amenageur_excel" type="button" class="btn btn-outline-secondary button_fiche" ng-click="getPorteurXls(nom_amenageur_selected)" disabled><span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> Export</button>
+        </div>
+
+    </form>
+</div>
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/module/component/porteur/porteur.js b/src/module_suivi_prod_immo/module/component/porteur/porteur.js
new file mode 100644
index 0000000000000000000000000000000000000000..bac8f0ad0f4e18a0255df40e5c5b949ca20e92e8
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/component/porteur/porteur.js
@@ -0,0 +1,50 @@
+goog.provide('vmap.suivi_prod_immo.porteur');
+goog.require('oVmap');
+
+/**
+ * Fiche porteur de projets Directive
+ *
+ * @return {angular.Directive} The directive specs.
+ * @export
+ * @constructor
+ */
+vitisApp.porteurDirective = function () {
+
+  return {
+    restrict: 'A',
+    templateUrl: 'modules/suivi_prod_immo/component/porteur/porteur.html',
+    link: function (scope, element, attrs) {
+      scope.getPorteur = function (nom_amenageur) {
+        if(nom_amenageur==null){
+          alert('Veuillez sélectionner un aménageur ou un partenaire dans la liste déroulante !');
+        }else{
+          window.open(oVmap['properties']['web_server_name'] +'/doc/suivi_prod_immo/get_3_porteur.php?token='+oVmap['properties']['token']+'&concessionnaire_amenagement='+nom_amenageur, '_blank');
+          //window.open('https://geo.urbalyon.org/doc/suivi_prod_immo/get_3_porteur.php?nom_amenageur='+nom_amenageur, '_blank');
+        }
+      }
+      scope.getPorteurXls = function (nom_amenageur) {
+        alert('En cours de développement');
+      }
+
+      scope.nom_amenageur_selected = null;
+      scope.nom_amenageurs = [];
+
+      // récupération du contenu de la liste déroulante
+      ajaxRequest({
+        "method": "GET",
+        "url": oVmap['properties']['web_server_name'] + "/" + oVmap['properties']['services_alias'] + "/suivi_prod_immo/getlist/getamenageurlist",
+        'async': false,
+        'responseType': '',
+        "success": function (response) {
+			data = JSON.parse(response.data);
+			// data.forEach(nom_amenageur_value => scope.nom_amenageurs.push(nom_amenageur_value));
+			for (var nom_amenageur_value in data) {
+				scope.nom_amenageurs.push(data[nom_amenageur_value]);
+			}
+        }
+      });
+
+    }
+  };
+};
+vitisApp.module.directive("appPorteur", vitisApp.porteurDirective);
diff --git a/src/module_suivi_prod_immo/module/component/porteur/porteur.less b/src/module_suivi_prod_immo/module/component/porteur/porteur.less
new file mode 100644
index 0000000000000000000000000000000000000000..d506999f11c2cdb4c8fc52965ddd09d5d576a9a2
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/component/porteur/porteur.less
@@ -0,0 +1,14 @@
+
+.select_nom_amenageur{
+    width:500px;
+}
+
+.title_fiche{
+    padding-left: 20px;
+    font-size: 35px;
+}
+
+.button_fiche{
+    border-color: gainsboro;
+    border: 1px solid;
+}
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/module/component/programme_logement/programme_logement.html b/src/module_suivi_prod_immo/module/component/programme_logement/programme_logement.html
new file mode 100644
index 0000000000000000000000000000000000000000..7c582b51bbdf55a1b67be67723237a644ad248a9
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/component/programme_logement/programme_logement.html
@@ -0,0 +1,29 @@
+
+	<div class="row mt-5" style="margin-left: 15px;">
+		<form>
+			<div class="form-group">
+				<label for="l_financement">Mode de financement</label>
+				<select class="form-control select_code_financement_equ_public" id="l_financement" ng-model="code_financement_equ_public_selected">
+					<option ng-repeat="financement in code_financement_equ_publics" ng-value="financement.code_financement_equ_public">{{ financement.financement_equ_public }}</option>
+				</select>
+			</div>
+			<div class="form-group">
+				<label for="l_ctm">Conférence Territoriale des Maires</label>
+				<select class="form-control select_id_ctm" id="l_ctm" ng-model="id_ctm_selected">
+					<option ng-repeat="ctm in nom_ctms" ng-value="ctm.id_ctm">{{ ctm.nom_ctm }}</option>
+				</select>
+			</div>
+			<div class="form-group">
+				<label for="l_commune">Communes</label>
+				<select class="form-control select_id_commune" id="l_commune" ng-model="id_commune_selected">
+					<option ng-repeat="commune in nom_communes" ng-value="commune.id_commune">{{ commune.nom_commune }}</option>
+				</select>
+			</div>
+
+			<div class="btn-group" role="group" aria-label="Basic example">
+			  <button id="get_type_operation" type="button" class="btn btn-outline-secondary button_fiche" ng-click="getLogement(id_ctm_selected,id_commune_selected,code_financement_equ_public_selected)">Afficher la fiche</button>
+			  <button id="get_type_operation_excel" type="button" class="btn btn-outline-secondary button_fiche" ng-click="getLogementXls(id_ctm_selected,id_commune_selected,code_financement_equ_public_selected)" disabled><span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> Export</button>
+			</div>
+
+		</form>
+	</div>
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/module/component/programme_logement/programme_logement.js b/src/module_suivi_prod_immo/module/component/programme_logement/programme_logement.js
new file mode 100644
index 0000000000000000000000000000000000000000..75436fc107b43c3425b9e1895a78b4ecaf6eab20
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/component/programme_logement/programme_logement.js
@@ -0,0 +1,88 @@
+goog.provide('vmap.suivi_prod_immo.programme_logement');
+goog.require('oVmap');
+
+/**
+ * Fiche programme logement Directive
+ *
+ * @return {angular.Directive} The directive specs.
+ * @export
+ * @constructor
+ */
+vitisApp.programme_logementDirective = function () {
+
+  return {
+    restrict: 'A',
+    templateUrl: 'modules/suivi_prod_immo/component/programme_logement/programme_logement.html',
+    link: function (scope, element, attrs) {
+      scope.getLogement = function (id_ctm,id_commune,code_financement_equ_public) {
+		params = '';
+		if(id_commune==null){
+			if(id_ctm!=null){
+				params='&id_ctm='+id_ctm;
+			}
+		}else{
+			params='&id_commune='+id_commune;
+		}
+        if(code_financement_equ_public!=null) params=params+'&code_financement='+code_financement_equ_public;
+		window.open(oVmap['properties']['web_server_name'] +'/doc/suivi_prod_immo/get_4_logement.php?token='+oVmap['properties']['token']+params, '_blank');
+		//window.open('https://geo.urbalyon.org/doc/suivi_prod_immo/get_4_logement.php?nom_amenageur='+nom_amenageur, '_blank');
+		//https://geo.urbalyon.org/doc/suivi_prod_immo/get_4_logement.php?token=40969f02da2acbefbb09dc353c2142a6&code_financement=FINZAC&id_commune=7
+      }
+      scope.getLogementXls = function (nom_amenageur) {
+        alert('En cours de développement');
+      }
+
+      scope.id_ctm_selected = null;
+      scope.id_commune_selected = null;
+      scope.code_financement_equ_public_selected = null;
+      scope.nom_ctms = [];
+      scope.nom_communes = [];
+      scope.code_financement_equ_publics = [];
+
+      // récupération du contenu de la liste déroulante
+      ajaxRequest({
+        "method": "GET",
+        "url": oVmap['properties']['web_server_name'] + "/" + oVmap['properties']['services_alias'] + "/suivi_prod_immo/getlist/getctmlist",
+        'async': false,
+        'responseType': '',
+        "success": function (response) {
+            data = JSON.parse(response.data);
+            // data.forEach(nom_ctm_value => scope.nom_ctms.push(nom_ctm_value));
+			for (var nom_ctm_value in data) {
+				scope.nom_ctms.push(data[nom_ctm_value]);
+			}
+        }
+      });
+      // récupération du contenu de la liste déroulante
+      ajaxRequest({
+        "method": "GET",
+        "url": oVmap['properties']['web_server_name'] + "/" + oVmap['properties']['services_alias'] + "/suivi_prod_immo/getlist/getcommunelist",
+        'async': false,
+        'responseType': '',
+        "success": function (response) {
+            data = JSON.parse(response.data);
+            // data.forEach(nom_commune_value => scope.nom_communes.push(nom_commune_value));
+			for (var nom_commune_value in data) {
+				scope.nom_communes.push(data[nom_commune_value]);
+			}
+        }
+      });
+      // récupération du contenu de la liste déroulante
+      ajaxRequest({
+        "method": "GET",
+        "url": oVmap['properties']['web_server_name'] + "/" + oVmap['properties']['services_alias'] + "/suivi_prod_immo/getlist/getfinancementlist",
+        'async': false,
+        'responseType': '',
+        "success": function (response) {
+            data = JSON.parse(response.data);
+            // data.forEach(code_financement_value => scope.code_financement_equ_publics.push(code_financement_value));
+			for (var code_financement_value in data) {
+				scope.code_financement_equ_publics.push(data[code_financement_value]);
+			}
+        }
+      });
+
+    }
+  };
+};
+vitisApp.module.directive("appProgrammelogement", vitisApp.programme_logementDirective);
diff --git a/src/module_suivi_prod_immo/module/component/programme_logement/programme_logement.less b/src/module_suivi_prod_immo/module/component/programme_logement/programme_logement.less
new file mode 100644
index 0000000000000000000000000000000000000000..56cfc85294203981990c8e899aa31be726d8edac
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/component/programme_logement/programme_logement.less
@@ -0,0 +1,14 @@
+
+.select_programme_logement{
+    width:500px;
+}
+
+.title_fiche{
+    padding-left: 20px;
+    font-size: 35px;
+}
+
+.button_fiche{
+    border-color: gainsboro;
+    border: 1px solid;
+}
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/module/component/type_operation/type_operation.html b/src/module_suivi_prod_immo/module/component/type_operation/type_operation.html
new file mode 100644
index 0000000000000000000000000000000000000000..d8480246026b78fcc1486040278a36b0e6a12178
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/component/type_operation/type_operation.html
@@ -0,0 +1,41 @@
+
+	<div class="row mt-5" style="margin-left: 15px;">
+		<form>
+			<div class="form-group">
+				<label for="l_ctm">Conférence Territoriale des Maires</label>
+				<select class="form-control select_id_ctm" id="l_ctm" ng-model="id_ctm_selected">
+					<option ng-repeat="ctm in ctms" ng-value="ctm.id_ctm">{{ ctm.nom_ctm }}</option>
+				</select>
+			</div>
+			<div class="form-group">
+				<label for="l_commune">Communes</label>
+				<select class="form-control select_id_commune" id="l_commune" ng-model="id_commune_selected">
+					<option ng-repeat="commune in communes" ng-value="commune.id_commune">{{ commune.nom_commune }}</option>
+				</select>
+			</div>
+			<div class="form-group">
+				<label for="l_procedure_amenagement">Procédure d'aménagement</label>
+				<select class="form-control select_code_procedure_amenagement" id="l_procedure_amenagement" ng-model="code_procedure_amenagement_selected">
+					<option ng-repeat="procedure_amenagement in procedure_amenagements" ng-value="procedure_amenagement.code_procedure_amenagement">{{ procedure_amenagement.procedure_amenagement }}</option>
+				</select>
+			</div>
+			<div class="form-group">
+				<label for="l_financement">Mode de financement</label>
+				<select class="form-control select_code_financement_equ_public" id="l_financement" ng-model="code_financement_equ_public_selected">
+					<option ng-repeat="financement in financement_equ_publics" ng-value="financement.code_financement_equ_public">{{ financement.financement_equ_public }}</option>
+				</select>
+			</div>
+			<div class="form-group">
+				<label for="l_suivi">Suivi de l'opération</label>
+				<select class="form-control select_code_suivi" id="l_suivi" ng-model="code_suivi_selected">
+					<option ng-repeat="suivi in suivis" ng-value="suivi.code_suivi">{{ suivi.suivi }}</option>
+				</select>
+			</div>
+
+			<div class="btn-group" role="group" aria-label="Basic example">
+			  <button id="get_type_operation" type="button" class="btn btn-outline-secondary button_fiche" ng-click="getTypeOperation(id_ctm_selected,id_commune_selected,code_procedure_amenagement_selected,code_financement_equ_public_selected,code_suivi_selected)">Afficher la fiche</button>
+			  <button id="get_type_operation_excel" type="button" class="btn btn-outline-secondary button_fiche" ng-click="getTypeOperationXls(id_ctm_selected,id_commune_selected,code_procedure_amenagement_selected,code_financement_equ_public_selected,code_suivi_selected)" disabled><span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> Export</button>
+			</div>
+
+		</form>
+	</div>
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/module/component/type_operation/type_operation.js b/src/module_suivi_prod_immo/module/component/type_operation/type_operation.js
new file mode 100644
index 0000000000000000000000000000000000000000..d57893292b818e039f40956c2ea7baf2f4cd45ca
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/component/type_operation/type_operation.js
@@ -0,0 +1,122 @@
+goog.provide('vmap.suivi_prod_immo.type_operation');
+goog.require('oVmap');
+
+/**
+ * Fiche type opération Directive
+ *
+ * @return {angular.Directive} The directive specs.
+ * @export
+ * @constructor
+ */
+vitisApp.type_operationDirective = function () {
+
+  return {
+    restrict: 'A',
+    templateUrl: 'modules/suivi_prod_immo/component/type_operation/type_operation.html',
+    link: function (scope, element, attrs) {
+      scope.getTypeOperation = function (id_ctm,id_commune,code_procedure_amenagement,code_financement_equ_public,code_suivi) {
+		params = '';
+		if(id_commune==null){
+			if(id_ctm!=null){
+				params='&id_ctm='+id_ctm;
+			}
+		}else{
+			params='&id_commune='+id_commune;
+		}
+        if(code_financement_equ_public!=null) params=params+'&code_financement='+code_financement_equ_public;
+        if(code_procedure_amenagement!=null) params=params+'&code_procedure_amenagement='+code_procedure_amenagement;
+        if(code_suivi!=null) params=params+'&code_suivi='+code_suivi;
+        window.open(oVmap['properties']['web_server_name'] +'/doc/suivi_prod_immo/get_2_type.php?token='+oVmap['properties']['token']+params, '_blank');
+        //window.open('https://geo.urbalyon.org/doc/suivi_prod_immo/get_2_type.php?nom_amenageur='+nom_amenageur, '_blank');
+        
+      }
+      scope.getTypeOperationXls = function (id_ctm,id_commune,code_procedure_amenagement,code_financement_equ_public,code_suivi) {
+        alert('En cours de développement');
+      }
+
+      scope.id_ctm_selected = null;
+      scope.id_commune_selected = null;
+      scope.code_financement_equ_public_selected = null;
+      scope.code_procedure_amenagement_selected = null;
+      scope.code_suivi_selected = null;
+      scope.ctms = [];
+      scope.communes = [];
+      scope.financement_equ_publics = [];
+      scope.procedure_amenagements = [];
+      scope.suivis = [];
+
+      // récupération du contenu de la liste déroulante
+      ajaxRequest({
+        "method": "GET",
+        "url": oVmap['properties']['web_server_name'] + "/" + oVmap['properties']['services_alias'] + "/suivi_prod_immo/getlist/getctmlist",
+        'async': false,
+        'responseType': '',
+        "success": function (response) {
+            data = JSON.parse(response.data);
+            // data.forEach(nom_ctm_value => scope.ctms.push(nom_ctm_value));
+			for (var nom_ctm_value in data) {
+				scope.ctms.push(data[nom_ctm_value]);
+			}
+        }
+      });
+      // récupération du contenu de la liste déroulante
+      ajaxRequest({
+        "method": "GET",
+        "url": oVmap['properties']['web_server_name'] + "/" + oVmap['properties']['services_alias'] + "/suivi_prod_immo/getlist/getcommunelist",
+        'async': false,
+        'responseType': '',
+        "success": function (response) {
+            data = JSON.parse(response.data);
+            // data.forEach(nom_commune_value => scope.communes.push(nom_commune_value));
+			for (var nom_commune_value in data) {
+				scope.communes.push(data[nom_commune_value]);
+			}
+        }
+      });
+      // récupération du contenu de la liste déroulante
+      ajaxRequest({
+        "method": "GET",
+        "url": oVmap['properties']['web_server_name'] + "/" + oVmap['properties']['services_alias'] + "/suivi_prod_immo/getlist/getfinancementlist",
+        'async': false,
+        'responseType': '',
+        "success": function (response) {
+            data = JSON.parse(response.data);
+            // data.forEach(code_financement_value => scope.financement_equ_publics.push(code_financement_value));
+			for (var code_financement_value in data) {
+				scope.financement_equ_publics.push(data[code_financement_value]);
+			}
+        }
+      });
+      // récupération du contenu de la liste déroulante
+      ajaxRequest({
+        "method": "GET",
+        "url": oVmap['properties']['web_server_name'] + "/" + oVmap['properties']['services_alias'] + "/suivi_prod_immo/getlist/getprocedureamenagementlist",
+        'async': false,
+        'responseType': '',
+        "success": function (response) {
+            data = JSON.parse(response.data);
+            // data.forEach(code_procedure_amenagement_value => scope.procedure_amenagements.push(code_procedure_amenagement_value));
+			for (var code_procedure_amenagement_value in data) {
+				scope.procedure_amenagements.push(data[code_procedure_amenagement_value]);
+			}
+        }
+      });
+      // récupération du contenu de la liste déroulante
+      ajaxRequest({
+        "method": "GET",
+        "url": oVmap['properties']['web_server_name'] + "/" + oVmap['properties']['services_alias'] + "/suivi_prod_immo/getlist/getsuivilist",
+        'async': false,
+        'responseType': '',
+        "success": function (response) {
+            data = JSON.parse(response.data);
+            // data.forEach(code_suivi_value => scope.suivis.push(code_suivi_value));
+			for (var code_suivi_value in data) {
+				scope.suivis.push(data[code_suivi_value]);
+			}
+        }
+      });
+
+    }
+  };
+};
+vitisApp.module.directive("appTypeoperation", vitisApp.type_operationDirective);
diff --git a/src/module_suivi_prod_immo/module/component/type_operation/type_operation.less b/src/module_suivi_prod_immo/module/component/type_operation/type_operation.less
new file mode 100644
index 0000000000000000000000000000000000000000..281d7d3c36fa31be8538333b07ef3c60740326a5
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/component/type_operation/type_operation.less
@@ -0,0 +1,30 @@
+
+.select_id_ctm{
+    width:500px;
+}
+
+.select_id_commune{
+    width:500px;
+}
+
+.select_code_procedure_amenagement{
+    width:500px;
+}
+
+.select_code_financement_equ_public{
+    width:500px;
+}
+
+.select_code_suivi{
+    width:500px;
+}
+
+.title_fiche{
+    padding-left: 20px;
+    font-size: 35px;
+}
+
+.button_fiche{
+    border-color: gainsboro;
+    border: 1px solid;
+}
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/module/index_fiche_operation.html b/src/module_suivi_prod_immo/module/index_fiche_operation.html
new file mode 100644
index 0000000000000000000000000000000000000000..bcf3e085ebf5480c619c953320f6080758a77414
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/index_fiche_operation.html
@@ -0,0 +1,4 @@
+<br>
+<div class="title_fiche">Fiche opération</div>
+<br>
+<div app-ficheoperation id="app-ficheoperation"></div>
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/module/index_porteur.html b/src/module_suivi_prod_immo/module/index_porteur.html
new file mode 100644
index 0000000000000000000000000000000000000000..dc66171180709b4cee5faf90c2d8f4d7e3c5a4fb
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/index_porteur.html
@@ -0,0 +1,4 @@
+<br>
+<div class="title_fiche">Porteurs de programmes immobiliers</div>
+<br>
+<div app-porteur id="app-porteur"></div>
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/module/index_programme_logement.html b/src/module_suivi_prod_immo/module/index_programme_logement.html
new file mode 100644
index 0000000000000000000000000000000000000000..e4bacde535b8bff82b79a2c19312e8635768ff1b
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/index_programme_logement.html
@@ -0,0 +1,4 @@
+<br>
+<div class="title_fiche">Fiche des programmes immobiliers de logements</div>
+<br>
+<div app-programmelogement id="app-programmelogement"></div>
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/module/index_type_operation.html b/src/module_suivi_prod_immo/module/index_type_operation.html
new file mode 100644
index 0000000000000000000000000000000000000000..d25b37dc61c5eec2545c7112a37fe2b051152ec0
--- /dev/null
+++ b/src/module_suivi_prod_immo/module/index_type_operation.html
@@ -0,0 +1,4 @@
+<br>
+<div class="title_fiche">Type d'opération</div>
+<br>
+<div app-typeoperation id="app-typeoperation"></div>
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/module/javascript/script_module.js b/src/module_suivi_prod_immo/module/javascript/script_module.js
index dbabe56de8919053ee3bf9c8d11b52c78d088405..5a8a53b7c166f3fdc21f537ea5763ec592645f8b 100644
--- a/src/module_suivi_prod_immo/module/javascript/script_module.js
+++ b/src/module_suivi_prod_immo/module/javascript/script_module.js
@@ -3,6 +3,11 @@
 'use strict';
 goog.provide('vmap.suivi_prod_immo.script_module');
 goog.require('vmap.suivi_prod_immo.dashboard');
+goog.require('vmap.suivi_prod_immo.fiche_operation');
+goog.require('vmap.suivi_prod_immo.porteur');
+goog.require('vmap.suivi_prod_immo.type_operation');
+goog.require('vmap.suivi_prod_immo.programme_logement');
+
 vitisApp.on('appMainDrtvLoaded', function () {
 
     /**
diff --git a/src/module_suivi_prod_immo/module/lang/lang-en.json b/src/module_suivi_prod_immo/module/lang/lang-en.json
index 2aa13bbe59b0113eef12ed39b9e680ebbaf51a60..21bb0cd2287c0a1c25e7b32a7cd5e5b8e9b4fffa 100644
--- a/src/module_suivi_prod_immo/module/lang/lang-en.json
+++ b/src/module_suivi_prod_immo/module/lang/lang-en.json
@@ -2,5 +2,7 @@
     "TEXT_MODE_SUIVI_PROD_IMMO_SAISIE" : "Suivi de la production immobilière dans les opérations d'aménagement sous pilotage de la Métropole de Lyon",
     "TITLE_MODE_SUIVI_PROD_IMMO_SAISIE" : "Suivi de la production immobilière",
     "TEXT_MODE_SUIVI_PROD_IMMO_BI" : "Indicateurs sur le suivi de la production immobilière",
-    "TITLE_MODE_SUIVI_PROD_IMMO_BI" : "Indicateurs de la production immobilière"
+    "TITLE_MODE_SUIVI_PROD_IMMO_BI" : "Indicateurs de la production immobilière",
+    "TEXT_MODE_SUIVI_PROD_IMMO_DASHBOARD" : "Module d'analyse sur le suivi de la production immobilière",
+    "TITLE_MODE_SUIVI_PROD_IMMO_DASHBOARD" : "Module d'analyse sur la production immobilière"
 }
diff --git a/src/module_suivi_prod_immo/module/lang/lang-fr.json b/src/module_suivi_prod_immo/module/lang/lang-fr.json
index e2394bbc606f2c82e678f7627484cb9eebb237ba..e408d7ab5b386de06d6d49182d6ff6cccdf8f37b 100644
--- a/src/module_suivi_prod_immo/module/lang/lang-fr.json
+++ b/src/module_suivi_prod_immo/module/lang/lang-fr.json
@@ -3,6 +3,8 @@
     "TITLE_MODE_SUIVI_PROD_IMMO_SAISIE" : "Suivi de la production immobilière",
     "TEXT_MODE_SUIVI_PROD_IMMO_BI" : "Indicateurs sur le suivi de la production immobilière",
     "TITLE_MODE_SUIVI_PROD_IMMO_BI" : "Indicateurs sur la production immobilière",
+    "TEXT_MODE_SUIVI_PROD_IMMO_DASHBOARD" : "Module d'analyse sur le suivi de la production immobilière",
+    "TITLE_MODE_SUIVI_PROD_IMMO_DASHBOARD" : "Module d'analyse sur la production immobilière",
     "SUIVI_PROD_IMMO_SAISIE_OPERATION_TITLE" : "",
     "SUIVI_PROD_IMMO_SAISIE_OPERATION_TITLE_INSERT" : "Opération",
     "SUIVI_PROD_IMMO_SAISIE_OPERATION_TITLE_UPDATE" : "Opération {{nom_operation}}",
diff --git a/src/module_suivi_prod_immo/module/less/main.less b/src/module_suivi_prod_immo/module/less/main.less
index dc471d4831a3c0aaa7c7eeb359791606edb7c91c..07fa8dd66537fdfc1d461632bc5cbb435e56af2a 100644
--- a/src/module_suivi_prod_immo/module/less/main.less
+++ b/src/module_suivi_prod_immo/module/less/main.less
@@ -1,5 +1,15 @@
 @import '../component/dashboard/dashboard.less';
+@import '../component/fiche_operation/fiche_operation.less';
+@import '../component/porteur/porteur.less';
+@import '../component/type_operation/type_operation.less';
+@import '../component/programme_logement/programme_logement.less';
 
+.icon-suivi_prod_immo_saisie:before {
+  content: "\e94e";
+}
+.icon-suivi_prod_immo_bi:before {
+  content: "\f043";
+}
 .icon-suivi_prod_immo_dashboard:before {
-    content: 'h';
+  content: "\f043";
 }
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/web_service/ws/GetList.class.inc b/src/module_suivi_prod_immo/web_service/ws/GetList.class.inc
new file mode 100644
index 0000000000000000000000000000000000000000..149c81aa975c3ef256266ef1be10f0dae5f1de29
--- /dev/null
+++ b/src/module_suivi_prod_immo/web_service/ws/GetList.class.inc
@@ -0,0 +1,273 @@
+<?php
+
+require_once __DIR__ . '/Suivi_prod_immo.class.inc';
+require_once dirname($_SERVER['SCRIPT_FILENAME']) . '/ws/vitis/Vitis.class.inc';
+require_once dirname($_SERVER['SCRIPT_FILENAME']) . '/class/vitis_lib/Connection.class.inc';
+require_once dirname($_SERVER['SCRIPT_FILENAME']) . '/class/vmlib/BdDataAccess.inc';
+
+/**
+ * \file GetList.class.inc
+ * \class GetList
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ * \author Fabien Marty <f.marty@urbalyon.org>.
+ *
+ * 	\brief This file contains the GetList php class
+ *
+ * This class defines the rest api for getlist
+ *
+ */
+class GetList extends Suivi_prod_immo {
+    /**
+     * @SWG\Definition(
+     *   definition="/getlist",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/getlist")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="GetList",
+     *   description="Operations about GetList"
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+    }
+
+    /**
+     * @SWG\Get(path="/getlist",
+     *   tags={"Parcelle"},
+     *   summary="Get the operation list",
+     *   description="Request to get the operation list",
+     *   operationId="GET",
+     *   produces={"application/json"},
+     * @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="sListName",
+     *     in="path",
+     *     description="sListName",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="GetList Response",
+     *         @SWG\Schema(ref="#/definitions/getlist")
+     *     )
+     *  )
+     */
+
+    /**
+     * Get function to get the list
+     * @return the list values
+     */
+    function GET() {
+		$sListName = $this->aPath[2];
+		
+		switch ($sListName) {
+			case "getoperationlist":
+				$aRecords=$this->getOperationList();
+				break;
+			case "getamenageurlist":
+				$aRecords=$this->getAmenageurList();
+				break;
+			case "getctmlist":
+				$aRecords=$this->getCTMList();
+				break;
+			case "getcommunelist":
+				$aRecords=$this->getCommuneList();
+				break;
+			case "getfinancementlist":
+				$aRecords=$this->getFinancementList();
+				break;
+			case "getsuivilist":
+				$aRecords=$this->getSuiviList();
+				break;
+			case "getprocedureamenagementlist":
+				$aRecords=$this->getProcedureAmenagementList();
+				break;
+		}
+
+		// error_log(json_encode($aRecords[0]));
+        return json_encode($aRecords);
+    }
+
+    /**
+     * Get function to get the operation list
+     * @return the list values
+     */
+	function getOperationList(){
+		require $this->sRessourcesFile;
+        $aRecords = Array();
+		$aSQLParams = array();
+		$oResult = $this->oConnection->oBd->executeWithParams($aSql['getListOperation'], $aSQLParams);
+        if ($this->oConnection->oBd->enErreur()) {
+            $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+            return $this->oError->aFields;
+        }
+
+        if (gettype($oResult) == 'object') {
+            while ($aLigne = $this->oConnection->oBd->ligneSuivante($oResult)) {
+                array_push($aRecords, $aLigne);
+            }
+        }
+		
+		return $aRecords;
+	}
+
+    /**
+     * Get function to get the amenageur list
+     * @return the list values
+     */
+	function getAmenageurList(){
+		require $this->sRessourcesFile;
+        $aRecords = Array();
+		$aSQLParams = array();
+		$oResult = $this->oConnection->oBd->executeWithParams($aSql['getListAmenageur'], $aSQLParams);
+        if ($this->oConnection->oBd->enErreur()) {
+            $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+            return $this->oError->aFields;
+        }
+
+        if (gettype($oResult) == 'object') {
+            while ($aLigne = $this->oConnection->oBd->ligneSuivante($oResult)) {
+                array_push($aRecords, array("code_amenageur"=>urlencode($aLigne['nom_amenageur']), "nom_amenageur"=>$aLigne['nom_amenageur']." (".$aLigne['count'].")"));
+            }
+        }
+
+		return $aRecords;
+    }
+
+    /**
+     * Get function to get the ctm list
+     * @return the list values
+     */
+	function getCTMList(){
+		require $this->sRessourcesFile;
+        $aRecords = Array();
+		$aSQLParams = array();
+		$oResult = $this->oConnection->oBd->executeWithParams($aSql['getListCTM'], $aSQLParams);
+        if ($this->oConnection->oBd->enErreur()) {
+            $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+            return $this->oError->aFields;
+        }
+
+        if (gettype($oResult) == 'object') {
+            while ($aLigne = $this->oConnection->oBd->ligneSuivante($oResult)) {
+                array_push($aRecords, array("id_ctm"=>urlencode($aLigne['id_ctm']), "nom_ctm"=>$aLigne['nom_ctm']));
+            }
+        }
+
+		return $aRecords;
+    }
+
+    /**
+     * Get function to get the commune list
+     * @return the list values
+     */
+	function getCommuneList(){
+		require $this->sRessourcesFile;
+        $aRecords = Array();
+		$aSQLParams = array();
+		$oResult = $this->oConnection->oBd->executeWithParams($aSql['getListCommune'], $aSQLParams);
+        if ($this->oConnection->oBd->enErreur()) {
+            $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+            return $this->oError->aFields;
+        }
+
+        if (gettype($oResult) == 'object') {
+            while ($aLigne = $this->oConnection->oBd->ligneSuivante($oResult)) {
+                array_push($aRecords, array("id_commune"=>urlencode($aLigne['id_commune']), "nom_commune"=>$aLigne['nom_commune']));
+            }
+        }
+
+		return $aRecords;
+    }
+
+    /**
+     * Get function to get the financement list
+     * @return the list values
+     */
+	function getFinancementList(){
+		require $this->sRessourcesFile;
+        $aRecords = Array();
+		$aSQLParams = array();
+		$oResult = $this->oConnection->oBd->executeWithParams($aSql['getListFinancement'], $aSQLParams);
+        if ($this->oConnection->oBd->enErreur()) {
+            $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+            return $this->oError->aFields;
+        }
+
+        if (gettype($oResult) == 'object') {
+            while ($aLigne = $this->oConnection->oBd->ligneSuivante($oResult)) {
+                array_push($aRecords, array("code_financement_equ_public"=>urlencode($aLigne['code_financement_equ_public']), "financement_equ_public"=>$aLigne['financement_equ_public']));
+            }
+        }
+
+		return $aRecords;
+    }
+
+    /**
+     * Get function to get the suivi list
+     * @return the list values
+     */
+	function getSuiviList(){
+		require $this->sRessourcesFile;
+        $aRecords = Array();
+		$aSQLParams = array();
+		$oResult = $this->oConnection->oBd->executeWithParams($aSql['getListSuivi'], $aSQLParams);
+        if ($this->oConnection->oBd->enErreur()) {
+            $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+            return $this->oError->aFields;
+        }
+
+        if (gettype($oResult) == 'object') {
+            while ($aLigne = $this->oConnection->oBd->ligneSuivante($oResult)) {
+                array_push($aRecords, array("code_suivi"=>urlencode($aLigne['code_suivi']), "suivi"=>$aLigne['suivi']));
+            }
+        }
+
+		return $aRecords;
+    }
+
+    /**
+     * Get function to get the procedure amenagement list
+     * @return the list values
+     */
+	function getProcedureAmenagementList(){
+		require $this->sRessourcesFile;
+        $aRecords = Array();
+		$aSQLParams = array();
+		$oResult = $this->oConnection->oBd->executeWithParams($aSql['getListProcedureAmenagement'], $aSQLParams);
+        if ($this->oConnection->oBd->enErreur()){
+            $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+            return $this->oError->aFields;
+        }
+
+        if (gettype($oResult) == 'object'){
+            while ($aLigne = $this->oConnection->oBd->ligneSuivante($oResult)){
+                array_push($aRecords, array("code_procedure_amenagement"=>urlencode($aLigne['code_procedure_amenagement']), "procedure_amenagement"=>$aLigne['procedure_amenagement']));
+            }
+        }
+
+		return $aRecords;
+    }
+
+}
+
+?>
diff --git a/src/module_suivi_prod_immo/web_service/ws/Ilots.class.inc b/src/module_suivi_prod_immo/web_service/ws/Ilots.class.inc
index 11e4c97317e8687ce2eb804b0f84a3bb6fddf280..a75c7a4b110b01c63a7711a6b1b9a262ea3dea63 100644
--- a/src/module_suivi_prod_immo/web_service/ws/Ilots.class.inc
+++ b/src/module_suivi_prod_immo/web_service/ws/Ilots.class.inc
@@ -1,322 +1,322 @@
-<?php
-
-/**
- * \file Ilots.class.inc
- * \class Ilots
- *
- * \author Fabien Marty <f.marty@urbalyon.org>.
- *
- * 	\brief This file contains the Ilots php class
- *
- * This class defines Rest Api to Vitis Ilots
- * 
- */
-require_once __DIR__ . '/Suivi_prod_immo.class.inc';
-require_once 'Ilot.class.inc';
-
-
-class Ilots extends Suivi_prod_immo {
-    /**
-     * @SWG\Definition(
-     *   definition="/ilots",
-     *   allOf={
-     *     @SWG\Schema(ref="#/definitions/ilots")
-     *   }
-     * )
-     * * @SWG\Tag(
-     *   name="Ilots",
-     *   description="Ilots about Ilots"
-     * )
-     */
-
-    /**
-     * construct
-     * @param type $aPath url of the request
-     * @param type $aValues parameters of the request
-     * @param type $properties properties
-     */
-    function __construct($aPath, $aValues, $properties) {
-        $this->aValues = $aValues;
-        $this->aPath = $aPath;
-        $this->aProperties = $properties;
-        $this->oConnection = new Connection($this->aValues, $properties);
-    }
-
-    /**
-     * @SWG\Get(path="/ilots",
-     *   tags={"Ilots"},
-     *   summary="Get Ilots",
-     *   description="Request to get Ilots",
-     *   operationId="GET",
-     *   produces={"application/xml", "application/json", "application/x-vm-json"},
-     *   @SWG\Parameter(
-     *     name="token",
-     *     in="query",
-     *     description="user token",
-     *     required=true,
-     *     type="string"
-     *   ),
-     * @SWG\Parameter(
-     *     name="order_by",
-     *     in="query",
-     *     description="list of ordering fields",
-     *     required=false,
-     *     type="string"
-     *   ),
-     * @SWG\Parameter(
-     *     name="sort_order",
-     *     in="query",
-     *     description="sort_order",
-     *     required=false,
-     *     type="string"
-     *   ),
-     * @SWG\Parameter(
-     *     name="limit",
-     *     in="query",
-     *     description="number of element",
-     *     required=false,
-     *     type="integer",
-     *     format="int32"
-     *   ),
-     * @SWG\Parameter(
-     *     name="offset",
-     *     in="query",
-     *     description="index of first element",
-     *     required=false,
-     *     type="string",
-     *     format="int32"
-     *   ),
-     * @SWG\Parameter(
-     *     name="attributs",
-     *     in="query",
-     *     description="list of attributs",
-     *     required=false,
-     *     type="string"
-     *   ),
-     * @SWG\Parameter(
-     *     name="filter",
-     *     in="query",
-     *     description="filter results",
-     *     required=false,
-     *     type="string"
-     *   ),
-     * @SWG\Parameter(
-     *     name="distinct",
-     *     in="query",
-     *     description="delete duplicates",
-     *     required=false,
-     *     type="boolean"
-     *   ),
-     *   @SWG\Response(
-     *         response=200,
-     *         description="traitement Response",
-     *         @SWG\Schema(ref="#/definitions/ilots")
-     *     )
-     *  )
-     */
-
-    /**
-     * get Ilots
-     * @return  Ilots
-     */
-    function GET(){
-		if($this->setRestriction()){
-			$aReturn = $this->genericGet('prod_immo', "ilot", "id_ilot");
-			$sMessage = $aReturn['sMessage'];
-			return $sMessage;
-		}else{
-			// si pas d'autorisation, on retourne une liste vide
-			return json_encode(array("list_count"=>0,"total_row_number"=>0,"status"=>1));
-		}
-    }
-
-
-    /**
-     *  set filter restriction for user connected
-     */
-	function setRestriction(){
-        require $this->sRessourcesFile;
-		$aParams = array();
-		$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
-		$oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getRestrictionUpdate'], $aParams);
-		if($oPDOresult->rowCount()==1){
-			// le user existe dans la table de restriction
-			$oPDOresult = $this->oConnection->oBd->fermeResultat();
-			$oPDOresult2 = $this->oConnection->oBd->executeWithParams($aSql['getRestrictionUpdateIdOperation'], $aParams);
-			if($oPDOresult2->rowCount()>0){
-				// il y a un ou plusieurs ID pour le user, on filtre
-				$aID=array();
-				while ($aIdOperation = $this->oConnection->oBd->ligneSuivante($oPDOresult2)){
-					$aID[] = $aIdOperation["id_operation"];
-				}
-				$oPDOresult2 = $this->oConnection->oBd->fermeResultat();
-				// injection du filtre
-				if (isset($this->aValues['filter'])){
-					// il existe déjà un filtre
-					$aFilter=json_decode($this->aValues['filter'],true);
-					$aOperators=$aFilter['operators'];
-					$aOperators[]=array("column"=>"id_operation","compare_operator"=>"IN","value"=>$aID);
-					$aFilter['operators']=$aOperators;
-					$this->aValues['filter']=json_encode($aFilter);
-				}else{
-					// il n'y a pas de filtre, on le crée
-					$this->aValues['filter']=json_encode(array('relation'=>'AND','operators'=>array(array("column"=>"id_operation","compare_operator"=>"IN","value"=>$aID))));
-				}
-				return true;
-			}else{
-				return false;
-			}
-		}else{
-			// le user n'existe pas dans la table de restriction, on affiche rien
-			$oPDOresult = $this->oConnection->oBd->fermeResultat();
-			error_log("Aucunes opérations autorisées en saisie, ajouter l'utilisateur dans la table prod_immo.user_restriction .");
-			return false;
-		}
-	}
-    /**
-     * @SWG\Post(path="/ilots",
-     *   tags={"Ilots"},
-     *   summary="Add traitement",
-     *   description="Request to add Ilots",
-     *   operationId="POST",
-     *   produces={"application/xml", "application/json"},
-     *   @SWG\Parameter(
-     *     name="token",
-     *     in="query",
-     *     description="user token",
-     *     required=true,
-     *     type="string"
-     *   ),
-     *   @SWG\Response(
-     *         response=200,
-     *         description="traitement Response",
-     *         @SWG\Schema(ref="#/definitions/ilots")
-     *     )
-     *  )
-     */
-
-    /**
-     * insert traitement
-     * @return id of the traitement created
-     */
-    function POST() {
-        //$this->aValues['create'] = $_SESSION["ses_Login"];
-        //$this->aValues['create_date'] = date('Y-m-d');
-        $aReturn = $this->genericPost('prod_immo', 'ilot', 'prod_immo.ilot_id_ilot_seq', 'id_ilot');
-        return $aReturn['sMessage'];
-    }
-
-    /**
-     * @SWG\Put(path="/ilots/{id_ilot}",
-     *   tags={"Ilots"},
-     *   summary="update Ilots",
-     *   description="Request to update Ilots",
-     *   operationId="PUT",
-     *   produces={"application/xml", "application/json"},
-     *   @SWG\Parameter(
-     *     name="token",
-     *     in="query",
-     *     description="Traitement token",
-     *     required=true,
-     *     type="string"
-     *   ),
-     * * @SWG\Parameter(
-     *     name="id_ilot",
-     *     in="path",
-     *     description="id of the Ilots",
-     *     required=true,
-     *     type="integer",
-     *     format = "int32"
-     *   ),
-     * @SWG\Response(
-     *         response=200,
-     *         description="Poprerties Response",
-     *         @SWG\Schema(ref="#/definitions/ilots")
-     *     )
-     *  )
-     */
-
-    /**
-     * update ilots
-     * @return id of ilots updated or error object if a ilots is not updated
-     */
-    function PUT() {
-        /*if (empty($this->aValues['maj']))
-            $this->aValues['maj'] = $_SESSION["ses_Login"];
-        if (empty($this->aValues['maj_date']))
-            $this->aValues['maj_date'] = date('Y-m-d');*/
-        $aReturn = $this->genericPut('prod_immo', 'ilot', 'id_ilot');
-        return $aReturn['sMessage'];
-    }
-
-    /**
-     * @SWG\Delete(path="/ilots",
-     *   tags={"Ilots"},
-     *   summary="delete Ilots",
-     *   description="Request to delete Ilots",
-     *   operationId="DELETE",
-     *   produces={"application/xml", "application/json"},
-     *   @SWG\Parameter(
-     *     name="token",
-     *     in="query",
-     *     description="token",
-     *     required=true,
-     *     type="string"
-     *   ),
-     * * @SWG\Parameter(
-     *     name="idList",
-     *     in="query",
-     *     description="id of the traitement",
-     *     required=true,
-     *     type="string"
-     *   ),
-     * @SWG\Response(
-     *         response=200,
-     *         description="traitement Response",
-     *         @SWG\Schema(ref="#/definitions/ilots")
-     *     )
-     *  )
-     */
-    /**
-     * @SWG\Delete(path="/ilots/{id_ilot}",
-     *   tags={"Ilots"},
-     *   summary="delete Ilots",
-     *   description="Request to delete Ilots",
-     *   operationId="DELETE",
-     *   produces={"application/xml", "application/json"},
-     *   @SWG\Parameter(
-     *     name="token",
-     *     in="query",
-     *     description="Traitement token",
-     *     required=true,
-     *     type="string"
-     *   ),
-     * * @SWG\Parameter(
-     *     name="id_ilot",
-     *     in="path",
-     *     description="id of the Ilots",
-     *     required=true,
-     *     type="integer",
-     *     format = "int32"
-     *   ),
-     * @SWG\Response(
-     *         response=200,
-     *         description="Poprerties Response",
-     *         @SWG\Schema(ref="#/definitions/ilots")
-     *     )
-     *  )
-     */
-
-    /**
-     * delete ilots
-     * @return id of ilots deleted or error object if a ilots is not deleted
-     */
-    function DELETE() {
-        $aReturn = $this->genericDelete('prod_immo', 'ilot', 'id_ilot');
-        return $aReturn['sMessage'];
-    }
-
-    
-}
-
+<?php
+
+/**
+ * \file Ilots.class.inc
+ * \class Ilots
+ *
+ * \author Fabien Marty <f.marty@urbalyon.org>.
+ *
+ * 	\brief This file contains the Ilots php class
+ *
+ * This class defines Rest Api to Vitis Ilots
+ * 
+ */
+require_once __DIR__ . '/Suivi_prod_immo.class.inc';
+require_once 'Ilot.class.inc';
+
+
+class Ilots extends Suivi_prod_immo {
+    /**
+     * @SWG\Definition(
+     *   definition="/ilots",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/ilots")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="Ilots",
+     *   description="Ilots about Ilots"
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     */
+    function __construct($aPath, $aValues, $properties) {
+        $this->aValues = $aValues;
+        $this->aPath = $aPath;
+        $this->aProperties = $properties;
+        $this->oConnection = new Connection($this->aValues, $properties);
+    }
+
+    /**
+     * @SWG\Get(path="/ilots",
+     *   tags={"Ilots"},
+     *   summary="Get Ilots",
+     *   description="Request to get Ilots",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort_order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="boolean"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="traitement Response",
+     *         @SWG\Schema(ref="#/definitions/ilots")
+     *     )
+     *  )
+     */
+
+    /**
+     * get Ilots
+     * @return  Ilots
+     */
+    function GET(){
+		if($this->setRestriction()){
+			$aReturn = $this->genericGet('prod_immo', "ilot", "id_ilot");
+			$sMessage = $aReturn['sMessage'];
+			return $sMessage;
+		}else{
+			// si pas d'autorisation, on retourne une liste vide
+			return json_encode(array("list_count"=>0,"total_row_number"=>0,"status"=>1));
+		}
+    }
+
+
+    /**
+     *  set filter restriction for user connected
+     */
+	function setRestriction(){
+        require $this->sRessourcesFile;
+		$aParams = array();
+		$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
+		$oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getRestrictionUpdate'], $aParams);
+		if($oPDOresult->rowCount()==1){
+			// le user existe dans la table de restriction
+			$oPDOresult = $this->oConnection->oBd->fermeResultat();
+			$oPDOresult2 = $this->oConnection->oBd->executeWithParams($aSql['getRestrictionUpdateIdOperation'], $aParams);
+			if($oPDOresult2->rowCount()>0){
+				// il y a un ou plusieurs ID pour le user, on filtre
+				$aID=array();
+				while ($aIdOperation = $this->oConnection->oBd->ligneSuivante($oPDOresult2)){
+					$aID[] = $aIdOperation["id_operation"];
+				}
+				$oPDOresult2 = $this->oConnection->oBd->fermeResultat();
+				// injection du filtre
+				if (isset($this->aValues['filter'])){
+					// il existe d�j� un filtre
+					$aFilter=json_decode($this->aValues['filter'],true);
+					$aOperators=$aFilter['operators'];
+					$aOperators[]=array("column"=>"id_operation","compare_operator"=>"IN","value"=>$aID);
+					$aFilter['operators']=$aOperators;
+					$this->aValues['filter']=json_encode($aFilter);
+				}else{
+					// il n'y a pas de filtre, on le cr�e
+					$this->aValues['filter']=json_encode(array('relation'=>'AND','operators'=>array(array("column"=>"id_operation","compare_operator"=>"IN","value"=>$aID))));
+				}
+				return true;
+			}else{
+				return false;
+			}
+		}else{
+			// le user n'existe pas dans la table de restriction, on affiche rien
+			$oPDOresult = $this->oConnection->oBd->fermeResultat();
+			error_log("Aucunes op�rations autoris�es en saisie, ajouter l'utilisateur dans la table prod_immo.user_restriction .");
+			return false;
+		}
+	}
+    /**
+     * @SWG\Post(path="/ilots",
+     *   tags={"Ilots"},
+     *   summary="Add traitement",
+     *   description="Request to add Ilots",
+     *   operationId="POST",
+     *   produces={"application/xml", "application/json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="traitement Response",
+     *         @SWG\Schema(ref="#/definitions/ilots")
+     *     )
+     *  )
+     */
+
+    /**
+     * insert traitement
+     * @return id of the traitement created
+     */
+    function POST() {
+        //$this->aValues['create'] = $_SESSION["ses_Login"];
+        //$this->aValues['create_date'] = date('Y-m-d');
+        $aReturn = $this->genericPost('prod_immo', 'ilot', 'prod_immo.ilot_id_ilot_seq', 'id_ilot');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Put(path="/ilots/{id_ilot}",
+     *   tags={"Ilots"},
+     *   summary="update Ilots",
+     *   description="Request to update Ilots",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="Traitement token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="id_ilot",
+     *     in="path",
+     *     description="id of the Ilots",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/ilots")
+     *     )
+     *  )
+     */
+
+    /**
+     * update ilots
+     * @return id of ilots updated or error object if a ilots is not updated
+     */
+    function PUT() {
+        /*if (empty($this->aValues['maj']))
+            $this->aValues['maj'] = $_SESSION["ses_Login"];
+        if (empty($this->aValues['maj_date']))
+            $this->aValues['maj_date'] = date('Y-m-d');*/
+        $aReturn = $this->genericPut('prod_immo', 'ilot', 'id_ilot');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Delete(path="/ilots",
+     *   tags={"Ilots"},
+     *   summary="delete Ilots",
+     *   description="Request to delete Ilots",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="idList",
+     *     in="query",
+     *     description="id of the traitement",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="traitement Response",
+     *         @SWG\Schema(ref="#/definitions/ilots")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Delete(path="/ilots/{id_ilot}",
+     *   tags={"Ilots"},
+     *   summary="delete Ilots",
+     *   description="Request to delete Ilots",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="Traitement token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="id_ilot",
+     *     in="path",
+     *     description="id of the Ilots",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/ilots")
+     *     )
+     *  )
+     */
+
+    /**
+     * delete ilots
+     * @return id of ilots deleted or error object if a ilots is not deleted
+     */
+    function DELETE() {
+        $aReturn = $this->genericDelete('prod_immo', 'ilot', 'id_ilot');
+        return $aReturn['sMessage'];
+    }
+
+    
+}
+
 ?>
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/web_service/ws/Programmes.class.inc b/src/module_suivi_prod_immo/web_service/ws/Programmes.class.inc
index 886f35616c3c37271d29b5cd561e1ec3a75b6f50..16bc88b41fc7469594998d8aaf2e11979a70c96a 100644
--- a/src/module_suivi_prod_immo/web_service/ws/Programmes.class.inc
+++ b/src/module_suivi_prod_immo/web_service/ws/Programmes.class.inc
@@ -1,425 +1,425 @@
-<?php
-
-/**
- * \file Programmes.class.inc
- * \class Programmes
- *
- * \author Fabien Marty <f.marty@urbalyon.org>.
- *
- * 	\brief This file contains the Programmes php class
- *
- * This class defines Rest Api to Vitis Programmes
- * 
- */
-require_once __DIR__ . '/Suivi_prod_immo.class.inc';
-require_once 'Programme.class.inc';
-
-
-class Programmes extends Suivi_prod_immo {
-    /**
-     * @SWG\Definition(
-     *   definition="/programmes",
-     *   allOf={
-     *     @SWG\Schema(ref="#/definitions/programmes")
-     *   }
-     * )
-     * * @SWG\Tag(
-     *   name="Programmes",
-     *   description="Programmes about Programmes"
-     * )
-     */
-
-    /**
-     * construct
-     * @param type $aPath url of the request
-     * @param type $aValues parameters of the request
-     * @param type $properties properties
-     */
-    function __construct($aPath, $aValues, $properties) {
-        $this->aValues = $aValues;
-        $this->aPath = $aPath;
-        $this->aProperties = $properties;
-        $this->oConnection = new Connection($this->aValues, $properties);
-    }
-
-    /**
-     * @SWG\Get(path="/programmes",
-     *   tags={"Programmes"},
-     *   summary="Get Programmes",
-     *   description="Request to get Programmes",
-     *   operationId="GET",
-     *   produces={"application/xml", "application/json", "application/x-vm-json"},
-     *   @SWG\Parameter(
-     *     name="token",
-     *     in="query",
-     *     description="user token",
-     *     required=true,
-     *     type="string"
-     *   ),
-     * @SWG\Parameter(
-     *     name="order_by",
-     *     in="query",
-     *     description="list of ordering fields",
-     *     required=false,
-     *     type="string"
-     *   ),
-     * @SWG\Parameter(
-     *     name="sort_order",
-     *     in="query",
-     *     description="sort_order",
-     *     required=false,
-     *     type="string"
-     *   ),
-     * @SWG\Parameter(
-     *     name="limit",
-     *     in="query",
-     *     description="number of element",
-     *     required=false,
-     *     type="integer",
-     *     format="int32"
-     *   ),
-     * @SWG\Parameter(
-     *     name="offset",
-     *     in="query",
-     *     description="index of first element",
-     *     required=false,
-     *     type="string",
-     *     format="int32"
-     *   ),
-     * @SWG\Parameter(
-     *     name="attributs",
-     *     in="query",
-     *     description="list of attributs",
-     *     required=false,
-     *     type="string"
-     *   ),
-     * @SWG\Parameter(
-     *     name="filter",
-     *     in="query",
-     *     description="filter results",
-     *     required=false,
-     *     type="string"
-     *   ),
-     * @SWG\Parameter(
-     *     name="distinct",
-     *     in="query",
-     *     description="delete duplicates",
-     *     required=false,
-     *     type="boolean"
-     *   ),
-     *   @SWG\Response(
-     *         response=200,
-     *         description="traitement Response",
-     *         @SWG\Schema(ref="#/definitions/programmes")
-     *     )
-     *  )
-     */
-
-    /**
-     * get Programmes
-     * @return  Programmes
-     */
-    function GET() {
-		if($this->setRestriction()){
-			$aReturn = $this->genericGet('prod_immo', "programme_immobilier", "id_programme");
-			$aProgrammes=json_decode($aReturn['sMessage'],true);
-			$aProgrammes2=array();
-			foreach ($aProgrammes['programmes'] as $aProgramme){
-				unset($aProgramme['geom']);
-				$aProgramme['nom_commune']= $this->getCommune($aProgramme['id_commune']);
-				$aProgramme['nom_ilot']= $this->getIlot($aProgramme['id_ilot']);
-				$aProgramme['nom_operation']= $this->getOperation($aProgramme['id_ilot']);
-				$aProgrammes2[count($aProgrammes2)]=$aProgramme;
-			}
-			$sProgrammes=json_encode(array("programmes"=>$aProgrammes2,"list_count"=>$aProgrammes['list_count'],"total_row_number"=>$aProgrammes['total_row_number'],"status"=>$aProgrammes['status']));
-			return $sProgrammes;
-		}else{
-			// si pas d'autorisation, on retourne une liste vide
-			return json_encode(array("list_count"=>0,"total_row_number"=>0,"status"=>1));
-		}
-    }
-	
-    /**
-     *  get commune of programme
-     */
-    function getCommune($iId) {
-        if(isset($iId) and !is_null($iId)){
-			require $this->sRessourcesFile;
-			$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
-			$aParams['id_commune'] = array('value' => $iId, 'type' => 'number');
-			$oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getCommune'], $aParams);
-			$aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult);
-			$oPDOresult = $this->oConnection->oBd->fermeResultat();
-			return $aLigne["nom_commune"];
-		}else{
-			return null;
-		}
-    }
-	
-    /**
-     *  get ilot of programme
-     */
-    function getIlot($iId) {
-        if(isset($iId) and !is_null($iId)){
-			require $this->sRessourcesFile;
-			$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
-			$aParams['id_ilot'] = array('value' => $iId, 'type' => 'number');
-			$oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getIlot'], $aParams);
-			$aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult);
-			$oPDOresult = $this->oConnection->oBd->fermeResultat();
-			return $aLigne["nom_ilot"];
-		}else{
-			return null;
-		}
-    }
-
-    /**
-     *  get operation of programme
-     */
-    function getOperation($iId) {
-        if(isset($iId) and !is_null($iId)){
-			require $this->sRessourcesFile;
-			$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
-			$aParams['id_ilot'] = array('value' => $iId, 'type' => 'number');
-			$oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getOperationIlot'], $aParams);
-			$aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult);
-			$oPDOresult = $this->oConnection->oBd->fermeResultat();
-			return $aLigne["nom_operation"];
-		}else{
-			return null;
-		}
-    }
-
-    /**
-     *  set filter restriction for user connected
-     */
-	function setRestriction(){
-        require $this->sRessourcesFile;
-		$aParams = array();
-		$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
-		$oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getRestrictionUpdate'], $aParams);
-		if($oPDOresult->rowCount()==1){
-			// le user existe dans la table de restriction
-			$oPDOresult = $this->oConnection->oBd->fermeResultat();
-			$oPDOresult2 = $this->oConnection->oBd->executeWithParams($aSql['getRestrictionUpdateIdIlot'], $aParams);
-			if($oPDOresult2->rowCount()>0){
-				// il y a un ou plusieurs ID pour le user, on filtre
-				$aID=array();
-				while ($aIdIlot=$this->oConnection->oBd->ligneSuivante($oPDOresult2)){
-					$aID[]=$aIdIlot["id_ilot"];
-				}
-				$oPDOresult2=$this->oConnection->oBd->fermeResultat();
-				// injection du filtre
-				if (isset($this->aValues['filter'])){
-					// il existe déjà un filtre
-					$aFilter=json_decode($this->aValues['filter'],true);
-					$aOperators=$aFilter['operators'];
-					$aOperators[]=array("column"=>"id_ilot","compare_operator"=>"IN","value"=>$aID);
-					$aFilter['operators']=$aOperators;
-					$this->aValues['filter']=json_encode($aFilter);
-				}else{
-					// il n'y a pas de filtre, on le crée
-					$this->aValues['filter']=json_encode(array('relation'=>'AND','operators'=>array(array("column"=>"id_ilot","compare_operator"=>"IN","value"=>$aID))));
-				}
-				return true;
-			}else{
-				return false;
-			}
-		}else{
-			// le user n'existe pas dans la table de restriction, on affiche rien
-			$oPDOresult = $this->oConnection->oBd->fermeResultat();
-			error_log("Aucunes opérations autorisées en saisie, ajouter l'utilisateur dans la table prod_immo.user_restriction .");
-			return false;
-		}
-	}
-
-    /**
-     * @SWG\Post(path="/programmes",
-     *   tags={"Programmes"},
-     *   summary="Add programme",
-     *   description="Request to add Programmes",
-     *   operationId="POST",
-     *   produces={"application/xml", "application/json"},
-     *   @SWG\Parameter(
-     *     name="token",
-     *     in="query",
-     *     description="user token",
-     *     required=true,
-     *     type="string"
-     *   ),
-     *   @SWG\Response(
-     *         response=200,
-     *         description= Response",
-     *         @SWG\Schema(ref="#/definitions/programmes")
-     *     )
-     *  )
-     */
-
-    /**
-     * insert programme
-     * @return id of the programme created
-     */
-    function POST() {
-        //$this->aValues['create'] = $_SESSION["ses_Login"];
-        //$this->aValues['create_date'] = date('Y-m-d');
-        $aReturn = $this->genericPost('prod_immo', 'programme_immobilier', 'prod_immo.programme_immobilier_id_programme_seq', 'id_programme');
-        return $aReturn['sMessage'];
-    }
-
-    /**
-     * @SWG\Put(path="/programmes/{id_programme}",
-     *   tags={"Programmes"},
-     *   summary="update Programmes",
-     *   description="Request to update Programmes",
-     *   operationId="PUT",
-     *   produces={"application/xml", "application/json"},
-     *   @SWG\Parameter(
-     *     name="token",
-     *     in="query",
-     *     description="Traitement token",
-     *     required=true,
-     *     type="string"
-     *   ),
-     * * @SWG\Parameter(
-     *     name="id_programme",
-     *     in="path",
-     *     description="id of the Programmes",
-     *     required=true,
-     *     type="integer",
-     *     format = "int32"
-     *   ),
-     * @SWG\Response(
-     *         response=200,
-     *         description="Poprerties Response",
-     *         @SWG\Schema(ref="#/definitions/programmes")
-     *     )
-     *  )
-     */
-
-    /**
-     * update programmes
-     * @return id of programmes updated or error object if a programmes is not updated
-     */
-    function PUT() {
-		require $this->sRessourcesFile;
-		$oConnection=$this->oConnection->oBd;
-		$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
-		$aParams['id_programme'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
-		if(isset($this->aValues['logement_familliaux_location_nom_bailleur'])){
-			$aParams['nom_bailleur'] = array('value' => $this->aValues['logement_familliaux_location_nom_bailleur'], 'type' => 'string');
-			$oPDOresult = $oConnection->executeWithParams($aSql['setLogementFamilliauxLocationNomBailleur'], $aParams);
-			if (!$oPDOresult){
-				$aError=$oConnection->errorInfo();
-				error_log($aError[2]);
-			}
-			$oPDOresult = $oConnection->fermeResultat();
-			unset($this->aValues['logement_familliaux_location_nom_bailleur']);
-			unset($aParams['nom_bailleur']);
-		}
-		if(isset($this->aValues['logement_familliaux_location_nom_investisseur'])){
-			$aParams['nom_investisseur'] = array('value' => $this->aValues['logement_familliaux_location_nom_investisseur'], 'type' => 'string');
-			$oPDOresult = $oConnection->executeWithParams($aSql['setLogementFamilliauxLocationNomInvestisseur'], $aParams);
-			if (!$oPDOresult){
-				$aError=$oConnection->errorInfo();
-				error_log($aError[2]);
-			}
-			$oPDOresult = $oConnection->fermeResultat();
-			unset($this->aValues['logement_familliaux_location_nom_investisseur']);
-			unset($aParams['nom_investisseur']);
-		}
-		if(isset($this->aValues['habitat_specifique_nom_bailleur'])){
-			$aParams['nom_bailleur'] = array('value' => $this->aValues['habitat_specifique_nom_bailleur'], 'type' => 'string');
-			$oPDOresult = $oConnection->executeWithParams($aSql['setHabitatSpecifiqueNomBailleur'], $aParams);
-			if (!$oPDOresult){
-				$aError=$oConnection->errorInfo();
-				error_log($aError[2]);
-			}
-			$oPDOresult = $oConnection->fermeResultat();
-			unset($this->aValues['habitat_specifique_nom_bailleur']);
-			unset($aParams['nom_bailleur']);
-		}
-		if(isset($this->aValues['habitat_specifique_nom_gestionnaire'])){
-			$aParams['nom_gestionnaire'] = array('value' => $this->aValues['habitat_specifique_nom_gestionnaire'], 'type' => 'string');
-			$oPDOresult = $oConnection->executeWithParams($aSql['setHabitatSpecifiqueNomGestionnaire'], $aParams);
-			if (!$oPDOresult){
-				$aError=$oConnection->errorInfo();
-				error_log($aError[2]);
-			}
-			$oPDOresult = $oConnection->fermeResultat();
-			unset($this->aValues['habitat_specifique_nom_gestionnaire']);
-		}
-        $aReturn = $this->genericPut('prod_immo', 'programme_immobilier', 'id_programme');
-        return $aReturn['sMessage'];
-    }
-
-    /**
-     * @SWG\Delete(path="/programmes",
-     *   tags={"Programmes"},
-     *   summary="delete Programmes",
-     *   description="Request to delete Programmes",
-     *   operationId="DELETE",
-     *   produces={"application/xml", "application/json"},
-     *   @SWG\Parameter(
-     *     name="token",
-     *     in="query",
-     *     description="token",
-     *     required=true,
-     *     type="string"
-     *   ),
-     * * @SWG\Parameter(
-     *     name="idList",
-     *     in="query",
-     *     description="id of the programme",
-     *     required=true,
-     *     type="string"
-     *   ),
-     * @SWG\Response(
-     *         response=200,
-     *         description="Response",
-     *         @SWG\Schema(ref="#/definitions/programmes")
-     *     )
-     *  )
-     */
-    /**
-     * @SWG\Delete(path="/programmes/{id_programme}",
-     *   tags={"Programmes"},
-     *   summary="delete Programmes",
-     *   description="Request to delete Programmes",
-     *   operationId="DELETE",
-     *   produces={"application/xml", "application/json"},
-     *   @SWG\Parameter(
-     *     name="token",
-     *     in="query",
-     *     description="token",
-     *     required=true,
-     *     type="string"
-     *   ),
-     * * @SWG\Parameter(
-     *     name="id_programme",
-     *     in="path",
-     *     description="id of the Programmes",
-     *     required=true,
-     *     type="integer",
-     *     format = "int32"
-     *   ),
-     * @SWG\Response(
-     *         response=200,
-     *         description="Poprerties Response",
-     *         @SWG\Schema(ref="#/definitions/programmes")
-     *     )
-     *  )
-     */
-
-    /**
-     * delete programmes
-     * @return id of programmes deleted or error object if a programmes is not deleted
-     */
-    function DELETE() {
-        $aReturn = $this->genericDelete('prod_immo', 'programme_immobilier', 'id_programme');
-        return $aReturn['sMessage'];
-    }
-
-    
-}
-
+<?php
+
+/**
+ * \file Programmes.class.inc
+ * \class Programmes
+ *
+ * \author Fabien Marty <f.marty@urbalyon.org>.
+ *
+ * 	\brief This file contains the Programmes php class
+ *
+ * This class defines Rest Api to Vitis Programmes
+ * 
+ */
+require_once __DIR__ . '/Suivi_prod_immo.class.inc';
+require_once 'Programme.class.inc';
+
+
+class Programmes extends Suivi_prod_immo {
+    /**
+     * @SWG\Definition(
+     *   definition="/programmes",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/programmes")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="Programmes",
+     *   description="Programmes about Programmes"
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     */
+    function __construct($aPath, $aValues, $properties) {
+        $this->aValues = $aValues;
+        $this->aPath = $aPath;
+        $this->aProperties = $properties;
+        $this->oConnection = new Connection($this->aValues, $properties);
+    }
+
+    /**
+     * @SWG\Get(path="/programmes",
+     *   tags={"Programmes"},
+     *   summary="Get Programmes",
+     *   description="Request to get Programmes",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort_order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="boolean"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="traitement Response",
+     *         @SWG\Schema(ref="#/definitions/programmes")
+     *     )
+     *  )
+     */
+
+    /**
+     * get Programmes
+     * @return  Programmes
+     */
+    function GET() {
+		if($this->setRestriction()){
+			$aReturn = $this->genericGet('prod_immo', "programme_immobilier", "id_programme");
+			$aProgrammes=json_decode($aReturn['sMessage'],true);
+			$aProgrammes2=array();
+			foreach ($aProgrammes['programmes'] as $aProgramme){
+				unset($aProgramme['geom']);
+				$aProgramme['nom_commune']= $this->getCommune($aProgramme['id_commune']);
+				$aProgramme['nom_ilot']= $this->getIlot($aProgramme['id_ilot']);
+				$aProgramme['nom_operation']= $this->getOperation($aProgramme['id_ilot']);
+				$aProgrammes2[count($aProgrammes2)]=$aProgramme;
+			}
+			$sProgrammes=json_encode(array("programmes"=>$aProgrammes2,"list_count"=>$aProgrammes['list_count'],"total_row_number"=>$aProgrammes['total_row_number'],"status"=>$aProgrammes['status']));
+			return $sProgrammes;
+		}else{
+			// si pas d'autorisation, on retourne une liste vide
+			return json_encode(array("list_count"=>0,"total_row_number"=>0,"status"=>1));
+		}
+    }
+	
+    /**
+     *  get commune of programme
+     */
+    function getCommune($iId) {
+        if(isset($iId) and !is_null($iId)){
+			require $this->sRessourcesFile;
+			$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
+			$aParams['id_commune'] = array('value' => $iId, 'type' => 'number');
+			$oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getCommune'], $aParams);
+			$aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult);
+			$oPDOresult = $this->oConnection->oBd->fermeResultat();
+			return $aLigne["nom_commune"];
+		}else{
+			return null;
+		}
+    }
+	
+    /**
+     *  get ilot of programme
+     */
+    function getIlot($iId) {
+        if(isset($iId) and !is_null($iId)){
+			require $this->sRessourcesFile;
+			$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
+			$aParams['id_ilot'] = array('value' => $iId, 'type' => 'number');
+			$oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getIlot'], $aParams);
+			$aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult);
+			$oPDOresult = $this->oConnection->oBd->fermeResultat();
+			return $aLigne["nom_ilot"];
+		}else{
+			return null;
+		}
+    }
+
+    /**
+     *  get operation of programme
+     */
+    function getOperation($iId) {
+        if(isset($iId) and !is_null($iId)){
+			require $this->sRessourcesFile;
+			$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
+			$aParams['id_ilot'] = array('value' => $iId, 'type' => 'number');
+			$oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getOperationIlot'], $aParams);
+			$aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult);
+			$oPDOresult = $this->oConnection->oBd->fermeResultat();
+			return $aLigne["nom_operation"];
+		}else{
+			return null;
+		}
+    }
+
+    /**
+     *  set filter restriction for user connected
+     */
+	function setRestriction(){
+        require $this->sRessourcesFile;
+		$aParams = array();
+		$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
+		$oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getRestrictionUpdate'], $aParams);
+		if($oPDOresult->rowCount()==1){
+			// le user existe dans la table de restriction
+			$oPDOresult = $this->oConnection->oBd->fermeResultat();
+			$oPDOresult2 = $this->oConnection->oBd->executeWithParams($aSql['getRestrictionUpdateIdIlot'], $aParams);
+			if($oPDOresult2->rowCount()>0){
+				// il y a un ou plusieurs ID pour le user, on filtre
+				$aID=array();
+				while ($aIdIlot=$this->oConnection->oBd->ligneSuivante($oPDOresult2)){
+					$aID[]=$aIdIlot["id_ilot"];
+				}
+				$oPDOresult2=$this->oConnection->oBd->fermeResultat();
+				// injection du filtre
+				if (isset($this->aValues['filter'])){
+					// il existe d�j� un filtre
+					$aFilter=json_decode($this->aValues['filter'],true);
+					$aOperators=$aFilter['operators'];
+					$aOperators[]=array("column"=>"id_ilot","compare_operator"=>"IN","value"=>$aID);
+					$aFilter['operators']=$aOperators;
+					$this->aValues['filter']=json_encode($aFilter);
+				}else{
+					// il n'y a pas de filtre, on le cr�e
+					$this->aValues['filter']=json_encode(array('relation'=>'AND','operators'=>array(array("column"=>"id_ilot","compare_operator"=>"IN","value"=>$aID))));
+				}
+				return true;
+			}else{
+				return false;
+			}
+		}else{
+			// le user n'existe pas dans la table de restriction, on affiche rien
+			$oPDOresult = $this->oConnection->oBd->fermeResultat();
+			error_log("Aucunes op�rations autoris�es en saisie, ajouter l'utilisateur dans la table prod_immo.user_restriction .");
+			return false;
+		}
+	}
+
+    /**
+     * @SWG\Post(path="/programmes",
+     *   tags={"Programmes"},
+     *   summary="Add programme",
+     *   description="Request to add Programmes",
+     *   operationId="POST",
+     *   produces={"application/xml", "application/json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description= Response",
+     *         @SWG\Schema(ref="#/definitions/programmes")
+     *     )
+     *  )
+     */
+
+    /**
+     * insert programme
+     * @return id of the programme created
+     */
+    function POST() {
+        //$this->aValues['create'] = $_SESSION["ses_Login"];
+        //$this->aValues['create_date'] = date('Y-m-d');
+        $aReturn = $this->genericPost('prod_immo', 'programme_immobilier', 'prod_immo.programme_immobilier_id_programme_seq', 'id_programme');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Put(path="/programmes/{id_programme}",
+     *   tags={"Programmes"},
+     *   summary="update Programmes",
+     *   description="Request to update Programmes",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="Traitement token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="id_programme",
+     *     in="path",
+     *     description="id of the Programmes",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/programmes")
+     *     )
+     *  )
+     */
+
+    /**
+     * update programmes
+     * @return id of programmes updated or error object if a programmes is not updated
+     */
+    function PUT() {
+		require $this->sRessourcesFile;
+		$oConnection=$this->oConnection->oBd;
+		$aParams['sSchemaFramework'] = array('value' => 'prod_immo', 'type' => 'schema_name');
+		$aParams['id_programme'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
+		if(isset($this->aValues['logement_familliaux_location_nom_bailleur'])){
+			$aParams['nom_bailleur'] = array('value' => $this->aValues['logement_familliaux_location_nom_bailleur'], 'type' => 'string');
+			$oPDOresult = $oConnection->executeWithParams($aSql['setLogementFamilliauxLocationNomBailleur'], $aParams);
+			if (!$oPDOresult){
+				$aError=$oConnection->errorInfo();
+				error_log($aError[2]);
+			}
+			$oPDOresult = $oConnection->fermeResultat();
+			unset($this->aValues['logement_familliaux_location_nom_bailleur']);
+			unset($aParams['nom_bailleur']);
+		}
+		if(isset($this->aValues['logement_familliaux_location_nom_investisseur'])){
+			$aParams['nom_investisseur'] = array('value' => $this->aValues['logement_familliaux_location_nom_investisseur'], 'type' => 'string');
+			$oPDOresult = $oConnection->executeWithParams($aSql['setLogementFamilliauxLocationNomInvestisseur'], $aParams);
+			if (!$oPDOresult){
+				$aError=$oConnection->errorInfo();
+				error_log($aError[2]);
+			}
+			$oPDOresult = $oConnection->fermeResultat();
+			unset($this->aValues['logement_familliaux_location_nom_investisseur']);
+			unset($aParams['nom_investisseur']);
+		}
+		if(isset($this->aValues['habitat_specifique_nom_bailleur'])){
+			$aParams['nom_bailleur'] = array('value' => $this->aValues['habitat_specifique_nom_bailleur'], 'type' => 'string');
+			$oPDOresult = $oConnection->executeWithParams($aSql['setHabitatSpecifiqueNomBailleur'], $aParams);
+			if (!$oPDOresult){
+				$aError=$oConnection->errorInfo();
+				error_log($aError[2]);
+			}
+			$oPDOresult = $oConnection->fermeResultat();
+			unset($this->aValues['habitat_specifique_nom_bailleur']);
+			unset($aParams['nom_bailleur']);
+		}
+		if(isset($this->aValues['habitat_specifique_nom_gestionnaire'])){
+			$aParams['nom_gestionnaire'] = array('value' => $this->aValues['habitat_specifique_nom_gestionnaire'], 'type' => 'string');
+			$oPDOresult = $oConnection->executeWithParams($aSql['setHabitatSpecifiqueNomGestionnaire'], $aParams);
+			if (!$oPDOresult){
+				$aError=$oConnection->errorInfo();
+				error_log($aError[2]);
+			}
+			$oPDOresult = $oConnection->fermeResultat();
+			unset($this->aValues['habitat_specifique_nom_gestionnaire']);
+		}
+        $aReturn = $this->genericPut('prod_immo', 'programme_immobilier', 'id_programme');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Delete(path="/programmes",
+     *   tags={"Programmes"},
+     *   summary="delete Programmes",
+     *   description="Request to delete Programmes",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="idList",
+     *     in="query",
+     *     description="id of the programme",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Response",
+     *         @SWG\Schema(ref="#/definitions/programmes")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Delete(path="/programmes/{id_programme}",
+     *   tags={"Programmes"},
+     *   summary="delete Programmes",
+     *   description="Request to delete Programmes",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="id_programme",
+     *     in="path",
+     *     description="id of the Programmes",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/programmes")
+     *     )
+     *  )
+     */
+
+    /**
+     * delete programmes
+     * @return id of programmes deleted or error object if a programmes is not deleted
+     */
+    function DELETE() {
+        $aReturn = $this->genericDelete('prod_immo', 'programme_immobilier', 'id_programme');
+        return $aReturn['sMessage'];
+    }
+
+    
+}
+
 ?>
\ No newline at end of file
diff --git a/src/module_suivi_prod_immo/web_service/ws/Suivi_prod_immo.class.sql.inc b/src/module_suivi_prod_immo/web_service/ws/Suivi_prod_immo.class.sql.inc
index 1008084c92185e0fc1e3dcd3f5728d93837af870..5228e39e7cf0e991f6118cdaab2c25187c89ff74 100644
--- a/src/module_suivi_prod_immo/web_service/ws/Suivi_prod_immo.class.sql.inc
+++ b/src/module_suivi_prod_immo/web_service/ws/Suivi_prod_immo.class.sql.inc
@@ -1,96 +1,105 @@
-<?php
-//Définition des requêtes de l'api Vitis
-$aSql['checkIP'] = "SELECT user_id, ip_constraint FROM [sSchemaFramework].user WHERE login ='[sLogin]'";
-$aSql['getGroups'] = "SELECT group_id FROM [sSchemaFramework].user_group WHERE user_id = [user_id]";
-$aSql['loginUnique'] = 'SELECT UPPER("login") FROM [sSchemaFramework]."user" WHERE UPPER("login")=UPPER(\'sLoginUser\')';
-$aSql['getLoginbyId'] = 'SELECT "login" FROM [sSchemaFramework]."user" WHERE user_id=[user_id]';
-$aSql['getTableColumn'] = 'SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = \'[sSchemaFramework]\' and table_name= \'[sTable]\'';
-$aSql['getUserPrivileges'] = 'SELECT groname FROM pg_user s LEFT OUTER JOIN pg_group g on (s.usesysid = any(g.grolist) )inner join [sSchemaFramework].user on "user".login = usename WHERE user_id = [user_id]';
-$aSql['listDomain'] = 'SELECT distinct domain, alias FROM [sSchemaFramework].domain WHERE "type" = \'AD\'';
-$aSql['createRolname'] = 'CREATE ROLE "vitis_[sDomain]" NOSUPERUSER INHERIT NOCREATEDB CREATEROLE;';
-$aSql['getInfoRolname'] = 'SELECT * FROM pg_catalog.pg_roles WHERE rolname = \'vitis_[sDomain]\'';
-// Communes
-$aSql['getOperationCommunes'] = "SELECT operation_commune.id_commune, \"commune\".nom_commune FROM [sSchemaFramework].operation_commune LEFT JOIN [sSchemaFramework].commune ON operation_commune.id_commune = \"commune\".id_commune WHERE operation_commune.id_operation = [id_operation]";
-$aSql['insertOperationCommunes'] = "INSERT INTO [sSchemaFramework].operation_commune(id_commune, id_operation) VALUES([id_commune], [id_operation])";
-// CTM
-$aSql['getOperationCTM'] = "SELECT operation_ctm.id_ctm, \"conference_territoriale_maire\".nom_ctm FROM [sSchemaFramework].operation_ctm LEFT JOIN [sSchemaFramework].conference_territoriale_maire ON operation_ctm.id_ctm = \"conference_territoriale_maire\".id_ctm WHERE operation_ctm.id_operation = [id_operation]";
-$aSql['insertOperationCTM'] = "INSERT INTO [sSchemaFramework].operation_ctm(id_ctm, id_operation) VALUES([id_ctm], [id_operation])";
-// Perimetres
-$aSql['getOperationPerimetre'] = "SELECT operation_perimetre.id_perimetre, \"perimetre\".nom_perimetre FROM [sSchemaFramework].operation_perimetre LEFT JOIN [sSchemaFramework].perimetre ON operation_perimetre.id_perimetre = \"perimetre\".id_perimetre WHERE operation_perimetre.id_operation = [id_operation]";
-$aSql['insertOperationPerimetre'] = "INSERT INTO [sSchemaFramework].operation_perimetre(id_perimetre, id_operation) VALUES([id_perimetre], [id_operation])";
-// Modes financement
-$aSql['getOperationModesFinancement'] = "SELECT operation_tr_financement_equ_public.code_financement_equ_public, \"tr_financement_equ_public\".financement_equ_public FROM [sSchemaFramework].operation_tr_financement_equ_public LEFT JOIN [sSchemaFramework].tr_financement_equ_public ON operation_tr_financement_equ_public.code_financement_equ_public = \"tr_financement_equ_public\".code_financement_equ_public WHERE operation_tr_financement_equ_public.id_operation = [id_operation]";
-$aSql['insertOperationModesFinancement'] = "INSERT INTO [sSchemaFramework].operation_tr_financement_equ_public(code_financement_equ_public, id_operation) VALUES([code_financement_equ_public], [id_operation])";
-// Commune
-$aSql['getCommune'] = "SELECT \"commune\".id_commune, \"commune\".nom_commune FROM [sSchemaFramework].commune WHERE id_commune = [id_commune]";
-// Type opérateur
-$aSql['getTypeOperateur'] = "SELECT \"tr_type_operateur\".code_type_operateur, \"tr_type_operateur\".type_operateur FROM [sSchemaFramework].tr_type_operateur WHERE code_type_operateur = [code_type_operateur]";
-// Mode consultation
-$aSql['getModeConsultation'] = "SELECT \"tr_consultation\".code_consultation, \"tr_consultation\".consultation FROM [sSchemaFramework].tr_consultation WHERE code_consultation = [code_consultation]";
-// Opération / Ilot
-$aSql['getOperationIlot'] = "SELECT nom_ilot, nom_operation FROM [sSchemaFramework].ilot INNER JOIN [sSchemaFramework].operation ON ilot.id_operation=operation.id_operation WHERE id_ilot=[id_ilot]";
-// Ilot
-$aSql['getIlot'] = "SELECT nom_ilot FROM [sSchemaFramework].ilot WHERE id_ilot=[id_ilot]";
-// Perimetre projet urbain
-$aSql['getPerimetre'] = "SELECT \"perimetre\".id_perimetre, \"perimetre\".nom_perimetre, \"perimetre\".type_perimetre FROM [sSchemaFramework].perimetre WHERE id_perimetre = [id_perimetre]";
-// Avancement
-$aSql['getAvancement'] = "SELECT \"tr_avancement\".code_avancement, \"tr_avancement\".avancement FROM [sSchemaFramework].tr_avancement WHERE code_avancement = [code_avancement]";
-// Contexte urbain
-$aSql['getContexteUrbain'] = "SELECT \"tr_contexte_urbain\".code_contexte_urbain, \"tr_contexte_urbain\".contexte_urbain FROM [sSchemaFramework].tr_contexte_urbain WHERE code_contexte_urbain = [code_contexte_urbain]";
-// Suivi de l'opération
-$aSql['getSuivi'] = "SELECT \"tr_suivi\".code_suivi, \"tr_suivi\".suivi FROM [sSchemaFramework].tr_suivi WHERE code_suivi = [code_suivi]";
-// Procédure d'aménagement
-$aSql['getProcedureAmenagement'] = "SELECT \"tr_procedure_amenagement\".code_procedure_amenagement, \"tr_procedure_amenagement\".procedure_amenagement FROM [sSchemaFramework].tr_procedure_amenagement WHERE code_procedure_amenagement = [code_procedure_amenagement]";
-// Vocation
-$aSql['getVocation'] = "SELECT \"tr_vocation\".code_vocation, \"tr_vocation\".vocation FROM [sSchemaFramework].tr_vocation WHERE code_vocation = [code_vocation]";
-//  Logement Familliaux Location
-$aSql['getLogementFamLocation'] = "SELECT nom_bailleur, nom_investisseur, id_logement_familliaux_location FROM [sSchemaFramework].logement_familliaux_location WHERE id_programme=[id_programme]";
-//  Logement Habitat spécifique
-$aSql['getHabitatSpecifique'] = "SELECT nom_bailleur, nom_gestionnaire, id_habitat_specifique FROM [sSchemaFramework].habitat_specifique WHERE id_programme =[id_programme]";
-//  Répartition logement
-$aSql['getRepartition'] = "SELECT repartition FROM prod_immo.repartition WHERE code_repartition =[code_repartition]";
-$aSql['getTypeLogement'] = "SELECT type_logement FROM prod_immo.type_logement WHERE code_type_logement =[code_type_logement]";
-$aSql['getSequenceRepartition_type_logement'] = "SELECT nextval('prod_immo.repartition_type_logement_id_repartition_type_logement_seq')";
-//  Granulométrie
-$aSql['getCompositionProgramme'] = "SELECT composition_programme FROM prod_immo.composition_programme WHERE code_composition_programme =[code_composition_programme]";
-$aSql['getTypeGranulometrie'] = "SELECT type_granulometrie FROM prod_immo.type_granulometrie WHERE code_type_granulometrie =[code_type_granulometrie]";
-$aSql['getSequenceGranulometrie'] = "SELECT nextval('prod_immo.granulometrie_id_granulometrie_seq')";
-// Logement familliaux en accession
-$aSql['getIndicateur_logement_familliaux_accession'] = "SELECT indicateur_logement_familliaux_accession FROM prod_immo.indicateur_logement_familliaux_accession WHERE id_indicateur_logement_familliaux_accession =[id_indicateur_logement_familliaux_accession]";
-$aSql['getSequenceLogement_familliaux_accession'] = "SELECT nextval('prod_immo.logement_familliaux_accession_id_logement_familliaux_access_seq')";
-// Profil acheteur accession libre
-$aSql['getType_acheteur_accession_libre'] = "SELECT type_acheteur_accession_libre FROM prod_immo.type_acheteur_accession_libre WHERE id_type_acheteur_accession_libre =[id_type_acheteur_accession_libre]";
-$aSql['getSequenceProfil_acheteur_accession_libre'] = "SELECT nextval('prod_immo.profil_acheteur_accession_lib_id_profil_acheteur_accession__seq')";
-// Logement familliaux en location
-$aSql['getIndicateur_logement_familliaux_location'] = "SELECT indicateur_logement_familliaux_location FROM prod_immo.indicateur_logement_familliaux_location WHERE id_indicateur_logement_familliaux_location =[id_indicateur_logement_familliaux_location]";
-$aSql['getSequenceComposition_logement_familliaux_location_cp'] = "SELECT nextval('prod_immo.composition_logement_famillia_id_composition_logement_famil_seq')";
-$aSql['setLogementFamilliauxLocationNomBailleur'] = "UPDATE [sSchemaFramework].logement_familliaux_location SET nom_bailleur=[nom_bailleur] WHERE id_programme=[id_programme]";
-$aSql['setLogementFamilliauxLocationNomInvestisseur'] = "UPDATE [sSchemaFramework].logement_familliaux_location SET nom_investisseur=[nom_investisseur] WHERE id_programme=[id_programme]";
-// Habitat spécifique
-$aSql['getIndicateur_habitat_specifique'] = "SELECT indicateur_habitat_specifique FROM prod_immo.indicateur_habitat_specifique WHERE id_indicateur_habitat_specifique =[id_indicateur_habitat_specifique]";
-$aSql['getSequenceComposition_habitat_specifique_cp'] = "SELECT nextval('prod_immo.composition_habitat_specifiqu_id_composition_habitat_specif_seq')";
-$aSql['setHabitatSpecifiqueNomBailleur'] = "UPDATE [sSchemaFramework].habitat_specifique SET nom_bailleur=[nom_bailleur] WHERE id_programme=[id_programme]";
-$aSql['setHabitatSpecifiqueNomGestionnaire'] = "UPDATE [sSchemaFramework].habitat_specifique SET nom_gestionnaire=[nom_gestionnaire] WHERE id_programme=[id_programme]";
-// Activité et industrie
-$aSql['getIndicateur_activite_industrie'] = "SELECT indicateur_activite_industrie FROM prod_immo.indicateur_activite_industrie WHERE id_indicateur_activite_industrie =[id_indicateur_activite_industrie]";
-$aSql['getSequenceActivite_industrie'] = "SELECT nextval('prod_immo.activite_industrie_id_activite_industrie_seq')";
-// Bureau
-$aSql['getIndicateur_bureau'] = "SELECT indicateur_bureau FROM prod_immo.indicateur_bureau WHERE id_indicateur_bureau =[id_indicateur_bureau]";
-$aSql['getSequenceBureau'] = "SELECT nextval('prod_immo.bureau_id_bureau_seq')";
-// Equipement de superstructure
-$aSql['getIndicateur_equipement_structure'] = "SELECT indicateur_equipement_structure FROM prod_immo.indicateur_equipement_structure WHERE id_indicateur_equipement_structure =[id_indicateur_equipement_structure]";
-$aSql['getSequenceEquipement_structure'] = "SELECT nextval('prod_immo.equipement_structure_id_equipement_structure_seq')";
-// Hotel commerce service
-$aSql['getIndicateur_hotel_commerce_service'] = "SELECT indicateur_hotel_commerce_service FROM prod_immo.indicateur_hotel_commerce_service WHERE id_indicateur_hotel_commerce_service =[id_indicateur_hotel_commerce_service]";
-$aSql['getSequenceHotel_commerce_service'] = "SELECT nextval('prod_immo.hotel_commerce_service_id_hotel_commerce_service_seq')";
-// Stationnement
-$aSql['getIndicateur_stationnement'] = "SELECT indicateur_stationnement FROM prod_immo.indicateur_stationnement WHERE id_indicateur_stationnement =[id_indicateur_stationnement]";
-$aSql['getSequenceStationnement'] = "SELECT nextval('prod_immo.stationnement_id_stationnement_seq')";
-// TooltipLastUpdate
-$aSql['getUpdateTrackingOperation'] = "SELECT \"user\" AS user_update, date AS date_update, old_value FROM prod_immo.update_tracking_operation WHERE id_operation=[iIdOperation] AND field='[sField]' ORDER BY date_update DESC LIMIT 1";
-$aSql['getUpdateTrackingProgramme'] = "SELECT \"user\" AS user_update, date AS date_update, old_value FROM prod_immo.update_tracking_programme WHERE id_programme=[iIdProgramme] AND field='[sField]' ORDER BY date_update DESC LIMIT 1";
-// Restriction
-$aSql['getRestrictionUpdate'] = 'SELECT restriction_update FROM [sSchemaFramework].user_restriction WHERE login::name = "current_user"()';
-$aSql['getRestrictionUpdateIdOperation'] = 'SELECT id_operation FROM [sSchemaFramework].operation WHERE id_operation::text ~ similar_escape(( SELECT restriction_update FROM [sSchemaFramework].user_restriction WHERE login::name = "current_user"()), NULL::text);';
-$aSql['getRestrictionUpdateIdIlot'] = 'SELECT id_ilot FROM [sSchemaFramework].ilot WHERE id_operation::text ~ similar_escape(( SELECT restriction_update FROM [sSchemaFramework].user_restriction WHERE login::name = "current_user"()), NULL::text);';
+<?php
+//Définition des requêtes de l'api Vitis
+$aSql['checkIP'] = "SELECT user_id, ip_constraint FROM [sSchemaFramework].user WHERE login ='[sLogin]'";
+$aSql['getGroups'] = "SELECT group_id FROM [sSchemaFramework].user_group WHERE user_id = [user_id]";
+$aSql['loginUnique'] = 'SELECT UPPER("login") FROM [sSchemaFramework]."user" WHERE UPPER("login")=UPPER(\'sLoginUser\')';
+$aSql['getLoginbyId'] = 'SELECT "login" FROM [sSchemaFramework]."user" WHERE user_id=[user_id]';
+$aSql['getTableColumn'] = 'SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = \'[sSchemaFramework]\' and table_name= \'[sTable]\'';
+$aSql['getUserPrivileges'] = 'SELECT groname FROM pg_user s LEFT OUTER JOIN pg_group g on (s.usesysid = any(g.grolist) )inner join [sSchemaFramework].user on "user".login = usename WHERE user_id = [user_id]';
+$aSql['listDomain'] = 'SELECT distinct domain, alias FROM [sSchemaFramework].domain WHERE "type" = \'AD\'';
+$aSql['createRolname'] = 'CREATE ROLE "vitis_[sDomain]" NOSUPERUSER INHERIT NOCREATEDB CREATEROLE;';
+$aSql['getInfoRolname'] = 'SELECT * FROM pg_catalog.pg_roles WHERE rolname = \'vitis_[sDomain]\'';
+// Communes
+$aSql['getOperationCommunes'] = "SELECT operation_commune.id_commune, \"commune\".nom_commune FROM [sSchemaFramework].operation_commune LEFT JOIN [sSchemaFramework].commune ON operation_commune.id_commune = \"commune\".id_commune WHERE operation_commune.id_operation = [id_operation]";
+$aSql['insertOperationCommunes'] = "INSERT INTO [sSchemaFramework].operation_commune(id_commune, id_operation) VALUES([id_commune], [id_operation])";
+// CTM
+$aSql['getOperationCTM'] = "SELECT operation_ctm.id_ctm, \"conference_territoriale_maire\".nom_ctm FROM [sSchemaFramework].operation_ctm LEFT JOIN [sSchemaFramework].conference_territoriale_maire ON operation_ctm.id_ctm = \"conference_territoriale_maire\".id_ctm WHERE operation_ctm.id_operation = [id_operation]";
+$aSql['insertOperationCTM'] = "INSERT INTO [sSchemaFramework].operation_ctm(id_ctm, id_operation) VALUES([id_ctm], [id_operation])";
+// Perimetres
+$aSql['getOperationPerimetre'] = "SELECT operation_perimetre.id_perimetre, \"perimetre\".nom_perimetre FROM [sSchemaFramework].operation_perimetre LEFT JOIN [sSchemaFramework].perimetre ON operation_perimetre.id_perimetre = \"perimetre\".id_perimetre WHERE operation_perimetre.id_operation = [id_operation]";
+$aSql['insertOperationPerimetre'] = "INSERT INTO [sSchemaFramework].operation_perimetre(id_perimetre, id_operation) VALUES([id_perimetre], [id_operation])";
+// Modes financement
+$aSql['getOperationModesFinancement'] = "SELECT operation_tr_financement_equ_public.code_financement_equ_public, \"tr_financement_equ_public\".financement_equ_public FROM [sSchemaFramework].operation_tr_financement_equ_public LEFT JOIN [sSchemaFramework].tr_financement_equ_public ON operation_tr_financement_equ_public.code_financement_equ_public = \"tr_financement_equ_public\".code_financement_equ_public WHERE operation_tr_financement_equ_public.id_operation = [id_operation]";
+$aSql['insertOperationModesFinancement'] = "INSERT INTO [sSchemaFramework].operation_tr_financement_equ_public(code_financement_equ_public, id_operation) VALUES([code_financement_equ_public], [id_operation])";
+// Commune
+$aSql['getCommune'] = "SELECT \"commune\".id_commune, \"commune\".nom_commune FROM [sSchemaFramework].commune WHERE id_commune = [id_commune]";
+// Type opérateur
+$aSql['getTypeOperateur'] = "SELECT \"tr_type_operateur\".code_type_operateur, \"tr_type_operateur\".type_operateur FROM [sSchemaFramework].tr_type_operateur WHERE code_type_operateur = [code_type_operateur]";
+// Mode consultation
+$aSql['getModeConsultation'] = "SELECT \"tr_consultation\".code_consultation, \"tr_consultation\".consultation FROM [sSchemaFramework].tr_consultation WHERE code_consultation = [code_consultation]";
+// Opération / Ilot
+$aSql['getOperationIlot'] = "SELECT nom_ilot, nom_operation FROM [sSchemaFramework].ilot INNER JOIN [sSchemaFramework].operation ON ilot.id_operation=operation.id_operation WHERE id_ilot=[id_ilot]";
+// Ilot
+$aSql['getIlot'] = "SELECT nom_ilot FROM [sSchemaFramework].ilot WHERE id_ilot=[id_ilot]";
+// Perimetre projet urbain
+$aSql['getPerimetre'] = "SELECT \"perimetre\".id_perimetre, \"perimetre\".nom_perimetre, \"perimetre\".type_perimetre FROM [sSchemaFramework].perimetre WHERE id_perimetre = [id_perimetre]";
+// Avancement
+$aSql['getAvancement'] = "SELECT \"tr_avancement\".code_avancement, \"tr_avancement\".avancement FROM [sSchemaFramework].tr_avancement WHERE code_avancement = [code_avancement]";
+// Contexte urbain
+$aSql['getContexteUrbain'] = "SELECT \"tr_contexte_urbain\".code_contexte_urbain, \"tr_contexte_urbain\".contexte_urbain FROM [sSchemaFramework].tr_contexte_urbain WHERE code_contexte_urbain = [code_contexte_urbain]";
+// Suivi de l'opération
+$aSql['getSuivi'] = "SELECT \"tr_suivi\".code_suivi, \"tr_suivi\".suivi FROM [sSchemaFramework].tr_suivi WHERE code_suivi = [code_suivi]";
+// Procédure d'aménagement
+$aSql['getProcedureAmenagement'] = "SELECT \"tr_procedure_amenagement\".code_procedure_amenagement, \"tr_procedure_amenagement\".procedure_amenagement FROM [sSchemaFramework].tr_procedure_amenagement WHERE code_procedure_amenagement = [code_procedure_amenagement]";
+// Vocation
+$aSql['getVocation'] = "SELECT \"tr_vocation\".code_vocation, \"tr_vocation\".vocation FROM [sSchemaFramework].tr_vocation WHERE code_vocation = [code_vocation]";
+//  Logement Familliaux Location
+$aSql['getLogementFamLocation'] = "SELECT nom_bailleur, nom_investisseur, id_logement_familliaux_location FROM [sSchemaFramework].logement_familliaux_location WHERE id_programme=[id_programme]";
+//  Logement Habitat spécifique
+$aSql['getHabitatSpecifique'] = "SELECT nom_bailleur, nom_gestionnaire, id_habitat_specifique FROM [sSchemaFramework].habitat_specifique WHERE id_programme =[id_programme]";
+//  Répartition logement
+$aSql['getRepartition'] = "SELECT repartition FROM prod_immo.repartition WHERE code_repartition =[code_repartition]";
+$aSql['getTypeLogement'] = "SELECT type_logement FROM prod_immo.type_logement WHERE code_type_logement =[code_type_logement]";
+$aSql['getSequenceRepartition_type_logement'] = "SELECT nextval('prod_immo.repartition_type_logement_id_repartition_type_logement_seq')";
+//  Granulométrie
+$aSql['getCompositionProgramme'] = "SELECT composition_programme FROM prod_immo.composition_programme WHERE code_composition_programme =[code_composition_programme]";
+$aSql['getTypeGranulometrie'] = "SELECT type_granulometrie FROM prod_immo.type_granulometrie WHERE code_type_granulometrie =[code_type_granulometrie]";
+$aSql['getSequenceGranulometrie'] = "SELECT nextval('prod_immo.granulometrie_id_granulometrie_seq')";
+// Logement familliaux en accession
+$aSql['getIndicateur_logement_familliaux_accession'] = "SELECT indicateur_logement_familliaux_accession FROM prod_immo.indicateur_logement_familliaux_accession WHERE id_indicateur_logement_familliaux_accession =[id_indicateur_logement_familliaux_accession]";
+$aSql['getSequenceLogement_familliaux_accession'] = "SELECT nextval('prod_immo.logement_familliaux_accession_id_logement_familliaux_access_seq')";
+// Profil acheteur accession libre
+$aSql['getType_acheteur_accession_libre'] = "SELECT type_acheteur_accession_libre FROM prod_immo.type_acheteur_accession_libre WHERE id_type_acheteur_accession_libre =[id_type_acheteur_accession_libre]";
+$aSql['getSequenceProfil_acheteur_accession_libre'] = "SELECT nextval('prod_immo.profil_acheteur_accession_lib_id_profil_acheteur_accession__seq')";
+// Logement familliaux en location
+$aSql['getIndicateur_logement_familliaux_location'] = "SELECT indicateur_logement_familliaux_location FROM prod_immo.indicateur_logement_familliaux_location WHERE id_indicateur_logement_familliaux_location =[id_indicateur_logement_familliaux_location]";
+$aSql['getSequenceComposition_logement_familliaux_location_cp'] = "SELECT nextval('prod_immo.composition_logement_famillia_id_composition_logement_famil_seq')";
+$aSql['setLogementFamilliauxLocationNomBailleur'] = "UPDATE [sSchemaFramework].logement_familliaux_location SET nom_bailleur=[nom_bailleur] WHERE id_programme=[id_programme]";
+$aSql['setLogementFamilliauxLocationNomInvestisseur'] = "UPDATE [sSchemaFramework].logement_familliaux_location SET nom_investisseur=[nom_investisseur] WHERE id_programme=[id_programme]";
+// Habitat spécifique
+$aSql['getIndicateur_habitat_specifique'] = "SELECT indicateur_habitat_specifique FROM prod_immo.indicateur_habitat_specifique WHERE id_indicateur_habitat_specifique =[id_indicateur_habitat_specifique]";
+$aSql['getSequenceComposition_habitat_specifique_cp'] = "SELECT nextval('prod_immo.composition_habitat_specifiqu_id_composition_habitat_specif_seq')";
+$aSql['setHabitatSpecifiqueNomBailleur'] = "UPDATE [sSchemaFramework].habitat_specifique SET nom_bailleur=[nom_bailleur] WHERE id_programme=[id_programme]";
+$aSql['setHabitatSpecifiqueNomGestionnaire'] = "UPDATE [sSchemaFramework].habitat_specifique SET nom_gestionnaire=[nom_gestionnaire] WHERE id_programme=[id_programme]";
+// Activité et industrie
+$aSql['getIndicateur_activite_industrie'] = "SELECT indicateur_activite_industrie FROM prod_immo.indicateur_activite_industrie WHERE id_indicateur_activite_industrie =[id_indicateur_activite_industrie]";
+$aSql['getSequenceActivite_industrie'] = "SELECT nextval('prod_immo.activite_industrie_id_activite_industrie_seq')";
+// Bureau
+$aSql['getIndicateur_bureau'] = "SELECT indicateur_bureau FROM prod_immo.indicateur_bureau WHERE id_indicateur_bureau =[id_indicateur_bureau]";
+$aSql['getSequenceBureau'] = "SELECT nextval('prod_immo.bureau_id_bureau_seq')";
+// Equipement de superstructure
+$aSql['getIndicateur_equipement_structure'] = "SELECT indicateur_equipement_structure FROM prod_immo.indicateur_equipement_structure WHERE id_indicateur_equipement_structure =[id_indicateur_equipement_structure]";
+$aSql['getSequenceEquipement_structure'] = "SELECT nextval('prod_immo.equipement_structure_id_equipement_structure_seq')";
+// Hotel commerce service
+$aSql['getIndicateur_hotel_commerce_service'] = "SELECT indicateur_hotel_commerce_service FROM prod_immo.indicateur_hotel_commerce_service WHERE id_indicateur_hotel_commerce_service =[id_indicateur_hotel_commerce_service]";
+$aSql['getSequenceHotel_commerce_service'] = "SELECT nextval('prod_immo.hotel_commerce_service_id_hotel_commerce_service_seq')";
+// Stationnement
+$aSql['getIndicateur_stationnement'] = "SELECT indicateur_stationnement FROM prod_immo.indicateur_stationnement WHERE id_indicateur_stationnement =[id_indicateur_stationnement]";
+$aSql['getSequenceStationnement'] = "SELECT nextval('prod_immo.stationnement_id_stationnement_seq')";
+// TooltipLastUpdate
+$aSql['getUpdateTrackingOperation'] = "SELECT \"user\" AS user_update, date AS date_update, old_value FROM prod_immo.update_tracking_operation WHERE id_operation=[iIdOperation] AND field='[sField]' ORDER BY date_update DESC LIMIT 1";
+$aSql['getUpdateTrackingProgramme'] = "SELECT \"user\" AS user_update, date AS date_update, old_value FROM prod_immo.update_tracking_programme WHERE id_programme=[iIdProgramme] AND field='[sField]' ORDER BY date_update DESC LIMIT 1";
+// Restriction
+$aSql['getRestrictionUpdate'] = 'SELECT restriction_update FROM [sSchemaFramework].user_restriction WHERE login::name = "current_user"()';
+$aSql['getRestrictionUpdateIdOperation'] = 'SELECT id_operation FROM [sSchemaFramework].operation WHERE id_operation::text ~ similar_escape(( SELECT restriction_update FROM [sSchemaFramework].user_restriction WHERE login::name = "current_user"()), NULL::text);';
+$aSql['getRestrictionUpdateIdIlot'] = 'SELECT id_ilot FROM [sSchemaFramework].ilot WHERE id_operation::text ~ similar_escape(( SELECT restriction_update FROM [sSchemaFramework].user_restriction WHERE login::name = "current_user"()), NULL::text);';
+// Module Analyse - LIST
+$aSql['getListOperation'] = "SELECT id_operation, nom_operation FROM prod_immo.operation ORDER BY nom_operation";
+$aSql['getListAmenageur'] = "SELECT DISTINCT nom_amenageur, count(nom_amenageur) FROM prod_immo.operation WHERE nom_amenageur IS NOT NULL GROUP BY nom_amenageur ORDER BY count DESC, nom_amenageur";
+$aSql['getListCTM'] = "SELECT id_ctm, nom_ctm FROM prod_immo.conference_territoriale_maire ORDER BY nom_ctm";
+$aSql['getListCommune'] = "SELECT id_commune, nom_commune FROM prod_immo.commune ORDER BY nom_commune";
+$aSql['getListFinancement'] = "SELECT code_financement_equ_public, financement_equ_public FROM prod_immo.tr_financement_equ_public ORDER BY financement_equ_public";
+$aSql['getListSuivi'] = "SELECT code_suivi, suivi FROM prod_immo.tr_suivi ORDER BY suivi";
+$aSql['getListProcedureAmenagement'] = "SELECT code_procedure_amenagement, procedure_amenagement FROM prod_immo.tr_procedure_amenagement ORDER BY procedure_amenagement";
+
 ?>
\ No newline at end of file
diff --git a/src/module_urbalyon/web_service/ws/Popup.class.inc b/src/module_urbalyon/web_service/ws/Popup.class.inc
new file mode 100644
index 0000000000000000000000000000000000000000..0f426e55eee09f832f213099ef61e8a3e741d2c5
--- /dev/null
+++ b/src/module_urbalyon/web_service/ws/Popup.class.inc
@@ -0,0 +1,98 @@
+<?php
+
+require_once __DIR__ . '/Urbalyon.class.inc';
+require_once dirname($_SERVER['SCRIPT_FILENAME']) . '/ws/vitis/Vitis.class.inc';
+require_once dirname($_SERVER['SCRIPT_FILENAME']) . '/class/vitis_lib/Connection.class.inc';
+require_once dirname($_SERVER['SCRIPT_FILENAME']) . '/class/vmlib/BdDataAccess.inc';
+
+/**
+ * \file Popup.class.inc
+ * \class Popup
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ * \author Fabien Marty <f.marty@urbalyon.org>.
+ *
+ * 	\brief This file contains the Popup php class
+ *
+ * This class defines the rest api for popup
+ *
+ */
+class Popup extends Urbalyon {
+    /**
+     * @SWG\Definition(
+     *   definition="/popup",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/popup")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="Popup",
+     *   description="Popup for map"
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+    }
+
+    /**
+     * @SWG\Get(path="/popup/{map_id}",
+     *   tags={"Popup"},
+     *   summary="Get the popup content",
+     *   description="Request to get popup content",
+     *   operationId="GET",
+     *   produces={"application/json"},
+     * @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="map_id",
+     *     in="path",
+     *     description="map Id",
+     *     required=true,
+     *     type="integer"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Popup Response",
+     *         @SWG\Schema(ref="#/definitions/popup")
+     *     )
+     *  )
+     */
+
+    /**
+     * Get function to get popup content
+     * @return the popup content values
+     */
+    function GET() {
+        $iMapId = $this->aPath[2];
+
+        if ($iMapId==28){
+            $sContent = file_get_contents('template_popup/'.$iMapId.'.html', true);
+            $aReturn=array("result"=>1, "title"=>'<p class="text-center mb-0" style="font-weight: bold;font-size: 30px;">Atlas numérique du sport</p>', "message"=>$sContent);
+        /*} elseif ($iMapId==-2) {
+            $sContent = file_get_contents('template_popup/'.$iMapId.'.html', true);
+            $aReturn=array("result"=>1, "title"=>'<p class="text-center mb-0" style="font-weight: bold;font-size: 30px;">Atlas numérique du sport</p>', "message"=>$sContent);
+		*/
+        }else{
+            $aReturn=array("result"=>0, "message"=>'carte numéro '.$iMapId.' inconnu');
+        }
+
+        return json_encode($aReturn);
+    }
+
+}
+
+?>
diff --git a/src/module_urbalyon/web_service/ws/Urbalyon.class.inc b/src/module_urbalyon/web_service/ws/Urbalyon.class.inc
new file mode 100644
index 0000000000000000000000000000000000000000..09809ab2f92544f4196294f70e0c46e9ac5e312f
--- /dev/null
+++ b/src/module_urbalyon/web_service/ws/Urbalyon.class.inc
@@ -0,0 +1,17 @@
+<?php
+
+require_once dirname($_SERVER['SCRIPT_FILENAME']) . "/class/vitis_lib/DbClass.class.inc";
+require_once dirname($_SERVER['SCRIPT_FILENAME']) . '/ws/vitis/Vitis.class.inc';
+require_once 'vmlib/logUtil.inc';
+
+class Urbalyon extends Vitis {
+
+    //Chemin du fichier de ressources contenant les requêtes SQL
+    var $sRessourcesFile = 'ws/urbalyon/Urbalyon.class.sql.inc';
+	
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+    }
+
+}
+?>
\ No newline at end of file
diff --git a/src/module_urbalyon/web_service/ws/Urbalyon.class.sql.inc b/src/module_urbalyon/web_service/ws/Urbalyon.class.sql.inc
new file mode 100644
index 0000000000000000000000000000000000000000..32e49d777219b99b4bd321549fa7125a6e2cd267
--- /dev/null
+++ b/src/module_urbalyon/web_service/ws/Urbalyon.class.sql.inc
@@ -0,0 +1,13 @@
+<?php
+//Définition des requêtes de l'api Vitis
+$aSql['checkIP'] = "SELECT user_id, ip_constraint FROM [sSchemaFramework].user WHERE login ='[sLogin]'";
+$aSql['getGroups'] = "SELECT group_id FROM [sSchemaFramework].user_group WHERE user_id = [user_id]";
+$aSql['loginUnique'] = 'SELECT UPPER("login") FROM [sSchemaFramework]."user" WHERE UPPER("login")=UPPER(\'sLoginUser\')';
+$aSql['getLoginbyId'] = 'SELECT "login" FROM [sSchemaFramework]."user" WHERE user_id=[user_id]';
+$aSql['getTableColumn'] = 'SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = \'[sSchemaFramework]\' and table_name= \'[sTable]\'';
+$aSql['getUserPrivileges'] = 'SELECT groname FROM pg_user s LEFT OUTER JOIN pg_group g on (s.usesysid = any(g.grolist) )inner join [sSchemaFramework].user on "user".login = usename WHERE user_id = [user_id]';
+$aSql['listDomain'] = 'SELECT distinct domain, alias FROM [sSchemaFramework].domain WHERE "type" = \'AD\'';
+$aSql['createRolname'] = 'CREATE ROLE "vitis_[sDomain]" NOSUPERUSER INHERIT NOCREATEDB CREATEROLE;';
+$aSql['getInfoRolname'] = 'SELECT * FROM pg_catalog.pg_roles WHERE rolname = \'vitis_[sDomain]\'';
+
+?>
\ No newline at end of file
diff --git a/src/module_urbalyon/web_service/ws/template_popup/-2.html b/src/module_urbalyon/web_service/ws/template_popup/-2.html
new file mode 100644
index 0000000000000000000000000000000000000000..8f054c8464eb198c5200bdf1e47f6d601d5ce75b
--- /dev/null
+++ b/src/module_urbalyon/web_service/ws/template_popup/-2.html
@@ -0,0 +1,32 @@
+<p class="text-center mb-0" style="font-weight: bold;font-size: 20px;">Observatoire métropolitain du sport</p>
+<br>
+<p class="text-center mb-0">Cartographies et atlas réalisés avec les données du RES et du Ministère des Sports de février 2019.</p>
+<br>
+Vous pouvez consulter :
+<ul>
+    <li>l'ensemble des équipement sportifs geolocalisés à l'adresse</li>
+    <li>des cartographhies dynamiques des taux d'équipement et de licence par commune et par CTM</li>
+    <li>des fiches détaillées sur las caractéristiques par équipements et des activités sportives pour chaque CTM (PDF)</li>
+    <li>des fiches synthètiques des équipements et des activités sportives pour chaque CTM</li>
+</ul>
+<br>
+<br>
+<p class="text-center mb-0" style="font-style: italic;font-size: 16px;">Cliquer sur le bouton <img height="35" src="images/urbalyon/btn_map_vmap.png"> pour afficher la légende, les cartes, ...</p>
+<p class="text-center mb-0" style="font-style: italic;font-size: 16px;">Utiliser l'outil de sélection pour consulter les données et accéder aux fiches ...</p>
+<br>
+<p class="text-center mb-0" style="font-style: italic;font-size: 19px;color: red;">Cliquer sur "Continuer" pour afficher la carte</p>
+<br>
+<br>
+<div class="row">
+    <div class="col-sm-4">
+        <img height="80" src="images/urbalyon/urbalyon_logo.png">
+    </div>
+    <div class="col-sm-4">
+        <img height="60" src="images/urbalyon/grand_lyon_logo.png">
+    </div>
+    <div class="col-sm-4">
+        <img height="70" src="images/urbalyon/ministere_logo.png">
+    </div>
+</div>
+<br>
+<p style="font-style: italic;font-size: 10px;">V1 septembre 2019</p>
\ No newline at end of file
diff --git a/src/module_urbalyon/web_service/ws/template_popup/28.html b/src/module_urbalyon/web_service/ws/template_popup/28.html
new file mode 100644
index 0000000000000000000000000000000000000000..8f054c8464eb198c5200bdf1e47f6d601d5ce75b
--- /dev/null
+++ b/src/module_urbalyon/web_service/ws/template_popup/28.html
@@ -0,0 +1,32 @@
+<p class="text-center mb-0" style="font-weight: bold;font-size: 20px;">Observatoire métropolitain du sport</p>
+<br>
+<p class="text-center mb-0">Cartographies et atlas réalisés avec les données du RES et du Ministère des Sports de février 2019.</p>
+<br>
+Vous pouvez consulter :
+<ul>
+    <li>l'ensemble des équipement sportifs geolocalisés à l'adresse</li>
+    <li>des cartographhies dynamiques des taux d'équipement et de licence par commune et par CTM</li>
+    <li>des fiches détaillées sur las caractéristiques par équipements et des activités sportives pour chaque CTM (PDF)</li>
+    <li>des fiches synthètiques des équipements et des activités sportives pour chaque CTM</li>
+</ul>
+<br>
+<br>
+<p class="text-center mb-0" style="font-style: italic;font-size: 16px;">Cliquer sur le bouton <img height="35" src="images/urbalyon/btn_map_vmap.png"> pour afficher la légende, les cartes, ...</p>
+<p class="text-center mb-0" style="font-style: italic;font-size: 16px;">Utiliser l'outil de sélection pour consulter les données et accéder aux fiches ...</p>
+<br>
+<p class="text-center mb-0" style="font-style: italic;font-size: 19px;color: red;">Cliquer sur "Continuer" pour afficher la carte</p>
+<br>
+<br>
+<div class="row">
+    <div class="col-sm-4">
+        <img height="80" src="images/urbalyon/urbalyon_logo.png">
+    </div>
+    <div class="col-sm-4">
+        <img height="60" src="images/urbalyon/grand_lyon_logo.png">
+    </div>
+    <div class="col-sm-4">
+        <img height="70" src="images/urbalyon/ministere_logo.png">
+    </div>
+</div>
+<br>
+<p style="font-style: italic;font-size: 10px;">V1 septembre 2019</p>
\ No newline at end of file
diff --git a/src/module_vmap/module/javascript/app/modules/Urbalyon/urbalyonpopup.js b/src/module_vmap/module/javascript/app/modules/Urbalyon/urbalyonpopup.js
new file mode 100644
index 0000000000000000000000000000000000000000..c03e7f55b94378d1be28e58dc148d3cdab3cdab6
--- /dev/null
+++ b/src/module_vmap/module/javascript/app/modules/Urbalyon/urbalyonpopup.js
@@ -0,0 +1,44 @@
+
+
+goog.provide('nsVmap.nsUrbalyon.popup');
+
+goog.require('oVmap');
+
+
+// Doc bootboxjs.com/v4.x/documentation.html
+nsVmap.nsUrbalyon.popup=function (map_id) {
+
+    //console.log(oVmap);
+
+    // récupération du contenu sur le serveur
+    ajaxRequest({
+        "method": "GET",
+        "url": oVmap['properties']['web_server_name'] + "/" + oVmap['properties']['services_alias'] + "/urbalyon/popup/"+ map_id,
+        'async': false,
+        'responseType': '',
+        "success": function (response) {
+            data = JSON.parse(response.data);
+            //console.log(data);
+            if(data.result==1){
+                var dialog = bootbox.dialog({
+                    title: data.title,
+                    message: data.message,
+                    size: 'large',
+                    buttons: {
+                        ok: {
+                            label: "Continuer",
+                            className: 'btn-info',
+                            callback: function(){
+                                console.log('Custom OK clicked');
+                            }
+                        }
+                    }
+                });
+            }else{
+                console.log(data.message);
+            }
+        }
+    });
+
+}
+
diff --git a/src/module_vmap/module/javascript/app/modules/modules.list.js b/src/module_vmap/module/javascript/app/modules/modules.list.js
index d5274a9245d10378ab26ac73b6000437cf1b7c64..d42d25138032cc3169901247773e105011928b25 100755
--- a/src/module_vmap/module/javascript/app/modules/modules.list.js
+++ b/src/module_vmap/module/javascript/app/modules/modules.list.js
@@ -8,4 +8,5 @@
 goog.provide('nsVmap.nsToolsManager.requireModules');
 
 goog.require('nsVmap.nsToolsManager.nsModules.Draw');
-goog.require('nsVmap.nsToolsManager.nsModules.Cadastre');
\ No newline at end of file
+goog.require('nsVmap.nsToolsManager.nsModules.Cadastre');
+goog.require('nsVmap.nsUrbalyon.popup');
\ No newline at end of file
diff --git a/src/module_vmap/module/javascript/app/vmap/mapmanager/layerstree.js b/src/module_vmap/module/javascript/app/vmap/mapmanager/layerstree.js
index cd184d684d5e97c71f56dedf1baa252bba066ffd..ce753f095d9939d8165ffbb0fdce6edd85a14956 100755
--- a/src/module_vmap/module/javascript/app/vmap/mapmanager/layerstree.js
+++ b/src/module_vmap/module/javascript/app/vmap/mapmanager/layerstree.js
@@ -498,6 +498,9 @@ nsVmap.nsMapManager.LayersTree.prototype.LayertreeController.prototype.loadTree
             });
         }
     }
+
+    // urbalyon get popup at init map
+    nsVmap.nsUrbalyon.popup(oVmap.getMapManager().oMapCatalog_.maps[oVmap.getMapManager().oMapCatalog_.usedMap].map_id);
 };
 
 /**
diff --git a/src/vitis/client/images/favicon.ico b/src/vitis/client/images/favicon.ico
old mode 100644
new mode 100755
diff --git a/src/vitis/client/images/urbalyon/btn_carte.png b/src/vitis/client/images/urbalyon/btn_carte.png
new file mode 100644
index 0000000000000000000000000000000000000000..1a0c9205e85d7daab44cced0ea1962744f908e55
Binary files /dev/null and b/src/vitis/client/images/urbalyon/btn_carte.png differ
diff --git a/src/vitis/client/images/urbalyon/btn_map_vmap.png b/src/vitis/client/images/urbalyon/btn_map_vmap.png
new file mode 100644
index 0000000000000000000000000000000000000000..b0cf73f8118a870adacb1ce2503f14852e546c40
Binary files /dev/null and b/src/vitis/client/images/urbalyon/btn_map_vmap.png differ
diff --git a/src/vitis/client/images/urbalyon/grand_lyon_logo.png b/src/vitis/client/images/urbalyon/grand_lyon_logo.png
new file mode 100644
index 0000000000000000000000000000000000000000..7ecc936312a5c68eef586224b011b81ddc58adae
Binary files /dev/null and b/src/vitis/client/images/urbalyon/grand_lyon_logo.png differ
diff --git a/src/vitis/client/images/urbalyon/map_vieux_1.png b/src/vitis/client/images/urbalyon/map_vieux_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..0829c0065bfcc0d2b1712df16e3332062ce11fc6
Binary files /dev/null and b/src/vitis/client/images/urbalyon/map_vieux_1.png differ
diff --git a/src/vitis/client/images/urbalyon/map_vieux_2.png b/src/vitis/client/images/urbalyon/map_vieux_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..105fa9c947b76d79d6eabd931bc0a89da2600a21
Binary files /dev/null and b/src/vitis/client/images/urbalyon/map_vieux_2.png differ
diff --git a/src/vitis/client/images/urbalyon/map_vieux_3.png b/src/vitis/client/images/urbalyon/map_vieux_3.png
new file mode 100644
index 0000000000000000000000000000000000000000..cc5be08d0c16bbb04f0f31d677653fe2f8eb6bc2
Binary files /dev/null and b/src/vitis/client/images/urbalyon/map_vieux_3.png differ
diff --git a/src/vitis/client/images/urbalyon/ministere_logo.png b/src/vitis/client/images/urbalyon/ministere_logo.png
new file mode 100644
index 0000000000000000000000000000000000000000..e6e7f278a8c9eb5be8ce611520908f86aa259bc3
Binary files /dev/null and b/src/vitis/client/images/urbalyon/ministere_logo.png differ
diff --git a/src/vitis/client/images/urbalyon/observa_metropo_sport.png b/src/vitis/client/images/urbalyon/observa_metropo_sport.png
new file mode 100644
index 0000000000000000000000000000000000000000..52593558f65b8e4675bb396c9136dc04417167d5
Binary files /dev/null and b/src/vitis/client/images/urbalyon/observa_metropo_sport.png differ
diff --git a/src/vitis/client/images/urbalyon/urbalyon_logo.png b/src/vitis/client/images/urbalyon/urbalyon_logo.png
new file mode 100644
index 0000000000000000000000000000000000000000..bb6f1787ae8cbb79e536c4702f0f45b77ab3c5be
Binary files /dev/null and b/src/vitis/client/images/urbalyon/urbalyon_logo.png differ
diff --git a/src/vitis/vas/doc/suivi_prod_immo/get_1_operation.old.php b/src/vitis/vas/doc/suivi_prod_immo/get_1_operation.old.php
new file mode 100644
index 0000000000000000000000000000000000000000..80cd62e827c0cbf8f3d79e3e32450a4786214364
--- /dev/null
+++ b/src/vitis/vas/doc/suivi_prod_immo/get_1_operation.old.php
@@ -0,0 +1,268 @@
+<?php
+// https://geo.urbalyon.org/doc/suivi_prod_immo/get_1_operation.php?id_operation=1041
+session_start();
+if (isset($_REQUEST['login'])) $_SESSION['login_bd_prod_immo']=$_REQUEST['login'];
+
+if(isset($_REQUEST['token']) && isset($_SESSION['token_bd_prod_immo'])){
+	if($_REQUEST['token']==$_SESSION['token_bd_prod_immo']){
+
+		if (isset($_REQUEST['id_operation']) && !is_null($_REQUEST['id_operation'])){
+			require_once("../../rest/conf/properties.inc");
+			require_once("properties_suivi_prod_immo.inc");
+			$sSchema=$properties['schema_prod_immo'];
+
+			try{
+				$oConn = new PDO('pgsql:host='.$properties['server'].';port='.$properties['port'].';dbname='.$properties['db_prod_immo'], $properties['db_user_prod_immo'], $properties['db_pass_prod_immo']);
+				$oConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+				$oConn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
+				
+				if($oConn){
+					// get data Opérations
+					$sWhereIdOperation=" WHERE id_operation=".$_REQUEST['id_operation'];
+					$oResult = $oConn->prepare("SELECT *, ST_XMin(ST_Buffer(geom,50)) AS xmin, ST_YMin(ST_Buffer(geom,50)) AS ymin, ST_XMax(ST_Buffer(geom,50)) AS xmax, ST_YMax(ST_Buffer(geom,50)) AS ymax FROM ".$sSchema.".v_operation_layer".$sWhereIdOperation);
+					$oResult->execute();
+
+					if ($oResult->rowCount()>0){
+						$aOperations = $oResult->fetchAll();
+						$oResult->closeCursor();
+						$aOperation =$aOperations[0];
+						$aOperation['date_mise_a_jour'] = date("d/m/Y", strtotime($aOperation['date_mise_a_jour']));
+						$sDataSdpPrev= $aOperation['sdp_logement'].",".$aOperation['sdp_bureau'].",".$aOperation['sdp_commerce_service'].",".$aOperation['sdp_locaux'].",".$aOperation['sdp_equipement'];
+						// get map image
+						$sNameMapImage=$_REQUEST['id_operation']."_operation.png";
+						$sCommand = escapeshellcmd('python get_map_image_1_operation.py '.$aOperation['xmin'].' '.$aOperation['ymin'].' '.$aOperation['xmax'].' '.$aOperation['ymax'].' '.$sNameMapImage.' '.$_REQUEST['id_operation']);
+						$output = shell_exec($sCommand);
+						$sUrlMapImage=$properties['web_server_name']."/ws_data/vm4ms/map/tmp/".$sNameMapImage;
+						
+						// get data ilot
+						$oResult1 = $oConn->prepare("SELECT count(id_ilot) FROM ".$sSchema.".ilot".$sWhereIdOperation);
+						$oResult1->execute();
+						$aIlot = $oResult1->fetch(PDO::FETCH_ASSOC);
+						$oResult1->closeCursor();
+						$oResult2 = $oConn->prepare("SELECT count(DISTINCT programme_immobilier.id_ilot) FROM ".$sSchema.".programme_immobilier INNER JOIN ".$sSchema.".ilot ON programme_immobilier.id_ilot=ilot.id_ilot".$sWhereIdOperation);
+						$oResult2->execute();
+						$aIlotProgramme = $oResult2->fetch(PDO::FETCH_ASSOC);
+						$iIlotSansProgramme = $aIlot['count']-$aIlotProgramme['count'];
+						$oResult2->closeCursor();
+						// get data programme
+						$oResult3 = $oConn->prepare("SELECT array_to_string(array_agg(id_programme), ',') AS id_programme, round(avg(cout_construction_moyen)) AS cout_construction_moyen,round( avg(charge_fonciere_nette)) AS charge_fonciere_nette FROM ".$sSchema.".programme_immobilier INNER JOIN ".$sSchema.".ilot ON ilot.id_ilot=programme_immobilier.id_ilot ".$sWhereIdOperation." GROUP BY id_operation");
+						$oResult3->execute();
+						if ($oResult3->rowCount()>0){
+							$aProgrammesStat=$oResult3->fetch(PDO::FETCH_ASSOC);
+							$sIdsProgramme = $aProgrammesStat['id_programme'];
+							$sWhereIdProgramme = " WHERE id_programme IN (".$sIdsProgramme.")";
+							//echo $sWhereIdProgramme;
+							$oResult3->closeCursor();
+							$oResult11=$oConn->prepare("SELECT nom_ilot, numero_pc, surface, id_programme, nom_programme, code_type_operateur, nom_demandeur, annee_debut, annee_fin FROM ".$sSchema.".programme_immobilier INNER JOIN ".$sSchema.".ilot ON ilot.id_ilot=programme_immobilier.id_ilot ".$sWhereIdOperation);
+							$oResult11->execute();
+							$aProgrammes = $oResult11->fetchAll();
+							$aSyntheseProgrammes=array();
+							foreach ($aProgrammes as $iKey => $aProgramme){
+								$aSyntheseProgrammes[$aProgramme['id_programme']]=array();
+								$sSql12="SELECT code_composition_programme, code_type_granulometrie, valeur FROM ".$sSchema.".granulometrie WHERE id_programme IN (".$aProgramme['id_programme'].") ORDER BY code_composition_programme, code_type_granulometrie";
+								foreach ($oConn->query($sSql12) as $aRow){
+									if (!isset($aSyntheseProgrammes[$aProgramme['id_programme']][$aRow['code_composition_programme']])) $aSyntheseProgrammes[$aProgramme['id_programme']][$aRow['code_composition_programme']]=array();
+									$aSyntheseProgrammes[$aProgramme['id_programme']][$aRow['code_composition_programme']][$aRow['code_type_granulometrie']]=$aRow['valeur'];
+								}
+							}
+							$oResult11->closeCursor();
+							
+
+							// get accession libre aidee
+							$sSql8="SELECT id_indicateur_logement_familliaux_accession, round(sum(accession_libre)::numeric) AS sum_accession_libre, round(coalesce(sum(accession_abordable),0)+coalesce(sum(accesion_sociale_securise),0)+coalesce(sum(psla),0)) AS sum_accession_aide, round(avg(accession_libre)::numeric) AS avg_accession_libre, round(avg(accession_abordable)) AS avg_accession_abordable, round(avg(accesion_sociale_securise)) AS avg_accesion_sociale_securise, round(avg(psla)) AS avg_psla FROM ".$sSchema.".logement_familliaux_accession".$sWhereIdProgramme." AND id_indicateur_logement_familliaux_accession IN (1,2,4,5,8,9) GROUP BY id_indicateur_logement_familliaux_accession";
+							foreach ($oConn->query($sSql8) as $aRow){
+								if ($aRow['id_indicateur_logement_familliaux_accession']==1){
+									isset($iNbLgtFam) ? $iNbLgtFam=$iNbLgtFam+$aRow['sum_accession_libre'] : $iNbLgtFam=$aRow['sum_accession_libre'];
+									isset($iNbLgtFam) ? $iNbLgtFam=$iNbLgtFam+$aRow['sum_accession_aide'] : $iNbLgtFam=$aRow['sum_accession_aide'];
+								}
+								if ($aRow['id_indicateur_logement_familliaux_accession']==2){
+									$iSdpAccessionLibre=$aRow['sum_accession_libre'];
+									$iSdpAccessionAide=$aRow['sum_accession_aide'];
+								}
+								if ($aRow['id_indicateur_logement_familliaux_accession']==4 or $aRow['id_indicateur_logement_familliaux_accession']==5){
+									if(!isset($aCFAccessionLibre)) $aCFAccessionLibre=array();
+									if(!is_null($aRow['avg_accession_libre'])) array_push($aCFAccessionLibre,$aRow['avg_accession_libre']);
+									if(!isset($aCFAccessionAidee)) $aCFAccessionAidee=array();
+									if(!is_null($aRow['avg_accession_abordable'])) array_push($aCFAccessionAidee,$aRow['avg_accession_abordable']);
+									if(!is_null($aRow['avg_accesion_sociale_securise'])) array_push($aCFAccessionAidee,$aRow['avg_accesion_sociale_securise']);
+									if(!is_null($aRow['avg_psla'])) array_push($aCFAccessionAidee,$aRow['avg_psla']);
+								}
+								if ($aRow['id_indicateur_logement_familliaux_accession']==8 or $aRow['id_indicateur_logement_familliaux_accession']==9){
+									if(!isset($aPVAccessionLibre)) $aPVAccessionLibre=array();
+									if(!is_null($aRow['avg_accession_libre'])) array_push($aPVAccessionLibre,$aRow['avg_accession_libre']);
+									if(!isset($aPVAccessionAidee)) $aPVAccessionAidee=array();
+									if(!is_null($aRow['avg_accession_abordable'])) array_push($aPVAccessionAidee,$aRow['avg_accession_abordable']);
+									if(!is_null($aRow['avg_accesion_sociale_securise'])) array_push($aPVAccessionAidee,$aRow['avg_accesion_sociale_securise']);
+									if(!is_null($aRow['avg_psla'])) array_push($aPVAccessionAidee,$aRow['avg_psla']);
+								}
+							}
+							if(isset($aPVAccessionLibre) and count($aPVAccessionLibre)>0) $iPVAccessionLibre = round(array_sum($aPVAccessionLibre)/count($aPVAccessionLibre));
+							if(isset($aPVAccessionAidee) and count($aPVAccessionAidee)>0) $iPVAccessionAidee = round(array_sum($aPVAccessionAidee)/count($aPVAccessionAidee));
+							if(isset($aCFAccessionLibre) and count($aCFAccessionLibre)>0) $iCFAccessionLibre = round(array_sum($aCFAccessionLibre)/count($aCFAccessionLibre));
+							if(isset($aCFAccessionAidee) and count($aCFAccessionAidee)>0) $iCFAccessionAidee = round(array_sum($aCFAccessionAidee)/count($aCFAccessionAidee));
+							// get locatif social
+							$sSql9="SELECT id_indicateur_logement_familliaux_location, round(coalesce(sum(social_pls),0)+coalesce(sum(social_plus_plai),0)) AS sum_social, round(coalesce(sum(intermediaire_pli),0)+coalesce(sum(intermediaire_afl),0)) AS sum_intermediaire, round(avg(social_pls)) AS avg_social_pls, round(avg(social_plus_plai)) AS avg_social_plus_plai, round(avg(intermediaire_pli)) AS avg_intermediaire_pli, round(avg(intermediaire_afl)) AS avg_intermediaire_afl FROM ".$sSchema.".composition_logement_familliaux_location_cp INNER JOIN ".$sSchema.".logement_familliaux_location ON logement_familliaux_location.id_logement_familliaux_location=composition_logement_familliaux_location_cp.id_logement_familliaux_location".$sWhereIdProgramme." AND id_indicateur_logement_familliaux_location IN (1,2,4,5,8) GROUP BY id_indicateur_logement_familliaux_location";
+							foreach ($oConn->query($sSql9) as $aRow){
+								if ($aRow['id_indicateur_logement_familliaux_location']==1){
+									isset($iNbLgtFam) ? $iNbLgtFam=$iNbLgtFam+$aRow['sum_social'] : $iNbLgtFam=$aRow['sum_social'];
+									isset($iNbLgtFam) ? $iNbLgtFam=$iNbLgtFam+$aRow['sum_intermediaire'] : $iNbLgtFam=$aRow['sum_intermediaire'];
+								}
+								if ($aRow['id_indicateur_logement_familliaux_location']==2){
+									$iSdpLocSocial=$aRow['sum_social'];
+									$iSdpLocIntermediaire=$aRow['sum_intermediaire'];
+								}
+								if ($aRow['id_indicateur_logement_familliaux_location']==4 or $aRow['id_indicateur_logement_familliaux_location']==5){
+									if(!isset($aCFSocial)) $aCFSocial=array();
+									if(!is_null($aRow['avg_social_pls'])) array_push($aCFSocial,$aRow['avg_social_pls']);
+									if(!is_null($aRow['avg_social_plus_plai'])) array_push($aCFSocial,$aRow['avg_social_plus_plai']);
+									if(!isset($aCFIntermediaire)) $aCFIntermediaire=array();
+									if(!is_null($aRow['avg_intermediaire_pli'])) array_push($aCFIntermediaire,$aRow['avg_intermediaire_pli']);
+									if(!is_null($aRow['avg_intermediaire_afl'])) array_push($aCFIntermediaire,$aRow['avg_intermediaire_afl']);
+								}
+								if ($aRow['id_indicateur_logement_familliaux_location']==8){
+									$aPrixVenteSocial=array();
+									if(!is_null($aRow['avg_social_pls'])) array_push($aPrixVenteSocial,$aRow['avg_social_pls']);
+									if(!is_null($aRow['avg_social_plus_plai'])) array_push($aPrixVenteSocial,$aRow['avg_social_plus_plai']);
+									if(count($aPrixVenteSocial)>0) $iPrixVenteSocial = round(array_sum($aPrixVenteSocial)/count($aPrixVenteSocial));
+									$aPrixVenteIntermediaire=array();
+									if(!is_null($aRow['avg_intermediaire_pli'])) array_push($aPrixVenteIntermediaire,$aRow['avg_intermediaire_pli']);
+									if(!is_null($aRow['avg_intermediaire_afl'])) array_push($aPrixVenteIntermediaire,$aRow['avg_intermediaire_afl']);
+									if(count($aPrixVenteIntermediaire)>0) $iPrixVenteIntermediaire = round(array_sum($aPrixVenteIntermediaire)/count($aPrixVenteIntermediaire));
+								}
+							}
+							if(isset($aCFSocial) and count($aCFSocial)>0) $iCFSocial = round(array_sum($aCFSocial)/count($aCFSocial));
+							if(isset($aCFIntermediaire)and count($aCFIntermediaire)>0) $iCFIntermediaire = round(array_sum($aCFIntermediaire)/count($aCFIntermediaire));
+							// get habitat spe
+							$oResult10=$oConn->prepare("SELECT id_indicateur_habitat_specifique, round(coalesce(sum(residence_etudiant),0)+coalesce(sum(residence_personne_agee),0)+coalesce(sum(autre),0)) AS total FROM ".$sSchema.".composition_habitat_specifique_cp INNER JOIN ".$sSchema.".habitat_specifique ON composition_habitat_specifique_cp.id_habitat_specifique=habitat_specifique.id_habitat_specifique".$sWhereIdProgramme."  AND id_indicateur_habitat_specifique IN (1,2) GROUP BY id_indicateur_habitat_specifique ORDER BY id_indicateur_habitat_specifique");
+							$oResult10->execute();
+							$iNbHabitatSpe=$oResult10->fetch(PDO::FETCH_ASSOC)['total'];
+							$iSdpHabitatSpe=$oResult10->fetch(PDO::FETCH_ASSOC)['total'];
+							$oResult10->closeCursor();
+							// get bureau
+							$sSql6="SELECT id_indicateur_bureau, round(sum(total)::numeric) AS sum, round(avg(total)::numeric) AS avg FROM ".$sSchema.".bureau".$sWhereIdProgramme." AND id_indicateur_bureau IN (1,2,3,6) GROUP BY id_indicateur_bureau";
+							foreach ($oConn->query($sSql6) as $aRow) {
+								if ($aRow['id_indicateur_bureau']==1) $iSdpBureau = $aRow['sum'];
+								if ($aRow['id_indicateur_bureau']==2 or $aRow['id_indicateur_bureau']==3)
+									isset($iCFBureau) ? array_push($iCFBureau,$aRow['avg']) : $iCFBureau=array($aRow['avg']);
+								if ($aRow['id_indicateur_bureau']==6) $iPrixVenteBureau = $aRow['avg'];
+							}
+							//echo print_r($iCFBureau,true);
+							if (isset($iCFBureau)) $iCFBureau = round(array_sum($iCFBureau)/count($iCFBureau));
+							//get commerce/hotel
+							$sSql4="SELECT id_indicateur_hotel_commerce_service, round(coalesce(sum(commerce),0)+coalesce(sum(loisir_marchand),0)+coalesce(sum(service_act_artisanale),0)) AS sum_commerce, round(sum(hotel)) AS sum_hotel, round(avg(commerce)) AS avg_commerce, round(avg(loisir_marchand)) AS avg_loisir_marchand, round(avg(service_act_artisanale)) AS avg_service_act_artisanale, round(avg(hotel)) AS avg_hotel FROM ".$sSchema.".hotel_commerce_service".$sWhereIdProgramme." AND id_indicateur_hotel_commerce_service IN (2,3,4,8) GROUP BY id_indicateur_hotel_commerce_service";
+							foreach ($oConn->query($sSql4) as $aRow) {
+								if ($aRow['id_indicateur_hotel_commerce_service']==2){
+									$iSdpCommerce=$aRow['sum_commerce'];
+									$iSdpHotel=$aRow['sum_hotel'];
+								}
+								if ($aRow['id_indicateur_hotel_commerce_service']==3 or $aRow['id_indicateur_hotel_commerce_service']==4){
+									if(!isset($aCFCommerce)) $aCFCommerce=array();
+									if(!is_null($aRow['avg_commerce'])) array_push($aCFCommerce,$aRow['avg_commerce']);
+									if(!is_null($aRow['avg_loisir_marchand'])) array_push($aCFCommerce,$aRow['avg_loisir_marchand']);
+									if(!is_null($aRow['avg_service_act_artisanale'])) array_push($aCFCommerce,$aRow['avg_service_act_artisanale']);
+									if(!isset($aCFHotel)) $aCFHotel=array();
+									if(!is_null($aRow['avg_hotel'])) array_push($aCFHotel,$aRow['avg_hotel']);
+								}
+								if ($aRow['id_indicateur_hotel_commerce_service']==8){
+									$aPrixVenteCommerce=array();
+									if(!is_null($aRow['avg_commerce'])) array_push($aPrixVenteCommerce,$aRow['avg_commerce']);
+									if(!is_null($aRow['avg_loisir_marchand'])) array_push($aPrixVenteCommerce,$aRow['avg_loisir_marchand']);
+									if(!is_null($aRow['avg_service_act_artisanale'])) array_push($aPrixVenteCommerce,$aRow['avg_service_act_artisanale']);
+									if(count($aPrixVenteCommerce)>0) $iPrixVenteCommerce = round(array_sum($aPrixVenteCommerce)/count($aPrixVenteCommerce));
+									$iPrixVenteHotel = $aRow['avg_hotel'];
+								}
+							}
+							if (isset($aCFCommerce)) $iCFCommerce = round(array_sum($aCFCommerce)/count($aCFCommerce));
+							if (isset($aCFHotel)) $iCFHotel = round(array_sum($aCFHotel)/count($aCFHotel));
+							//get prod/activite
+							$sSql7="SELECT id_indicateur_activite_industrie, round(sum(production_industrie_logistique)) AS sum_production_industrie_logistique, round(sum(autre)) AS sum_autre, round(avg(production_industrie_logistique)) AS avg_production_industrie_logistique, round(avg(autre)) AS avg_autre FROM ".$sSchema.".activite_industrie".$sWhereIdProgramme." AND id_indicateur_activite_industrie IN (2,3,4,7) GROUP BY id_indicateur_activite_industrie";
+							foreach ($oConn->query($sSql7) as $aRow){
+								if ($aRow['id_indicateur_activite_industrie']==2){
+									$iSdpProd=$aRow['sum_production_industrie_logistique'];
+									$iSdpActAutre=$aRow['avg_autre'];
+								}
+								if ($aRow['id_indicateur_activite_industrie']==3 or $aRow['id_indicateur_activite_industrie']==4){
+									isset($iCFProd) ? array_push($iCFProd,$aRow['avg_production_industrie_logistique']) : $iCFProd=array($aRow['avg_production_industrie_logistique']);
+									isset($iCFActAutre) ? array_push($iCFActAutre,$aRow['avg_autre']) : $iCFActAutre=array($aRow['avg_autre']);
+								}
+								if ($aRow['id_indicateur_activite_industrie']==7){
+									$iPrixVenteProd = $aRow['avg_production_industrie_logistique'];
+									$iPrixVenteActAutre = $aRow['avg_autre'];
+								}
+							}
+							if (isset($iCFProd)) $iCFProd = round(array_sum($iCFProd)/count($iCFProd));
+							if (isset($iCFActAutre)) $iCFActAutre = round(array_sum($iCFActAutre)/count($iCFActAutre));
+							// get equipement
+							$oResult5 = $oConn->prepare("SELECT round(sum(sdp)::numeric) AS sdp FROM ".$sSchema.".equipement_structure".$sWhereIdProgramme);
+							$oResult5->execute();
+							$iSdpEquipement = $oResult5->fetch(PDO::FETCH_ASSOC)['sdp'];
+							$oResult5->closeCursor();
+							//get profil
+							$sSql12="SELECT id_type_acheteur_accession_libre, round(sum(nb)) AS nb, round(avg(pourc)) AS pourc FROM ".$sSchema.".profil_acheteur_accession_libre".$sWhereIdProgramme." AND id_type_acheteur_accession_libre IN (1,2) GROUP BY id_type_acheteur_accession_libre";
+							foreach ($oConn->query($sSql12) as $aRow){
+								if ($aRow['id_type_acheteur_accession_libre']==1){
+									$iNbProprioOcc=$aRow['nb'];
+									$iPourcProprioOcc=$aRow['pourc'];
+								}
+								if ($aRow['id_type_acheteur_accession_libre']==2){
+									$iNbInvest=$aRow['nb'];
+									$iPourcInvest=$aRow['pourc'];
+								}
+							}
+							// get granulometrie
+							$aGranulometrie=array();
+							$aGranulometrie2=array('LG_FAM_ACC'=>array('T1'=>0,'T2'=>0,'T3'=>0,'T4'=>0,'T5'=>0,'T6'=>0), 'LG_FAM_LOC'=>array('T1'=>0,'T2'=>0,'T3'=>0,'T4'=>0,'T5'=>0,'T6'=>0), 'TOT_LG_SPE'=>array('T1'=>0,'T2'=>0,'T3'=>0,'T4'=>0,'T5'=>0,'T6'=>0));
+							$aTypeGranulometrie=array('T1','T2','T3','T4','T5','T6','NB');
+							foreach ($aTypeGranulometrie as $sTypeGranulometrie){
+								$aTmp=array();
+								$sSql13="SELECT code_composition_programme, sum(valeur) AS valeur FROM ".$sSchema.".granulometrie".$sWhereIdProgramme." AND code_type_granulometrie ='".$sTypeGranulometrie."' AND code_composition_programme IN ('TOT_LG_SPE','LG_FAM_ACC','LG_FAM_LOC','TOT_LG_FAM') GROUP BY code_composition_programme";
+								foreach ($oConn->query($sSql13) as $aRow){
+									if ($sTypeGranulometrie=='NB' && ($aRow['code_composition_programme']=='TOT_LG_FAM' || $aRow['code_composition_programme']=='TOT_LG_SPE')) $aTmp['TOT'] = $aTmp['TOT'] + $aRow['valeur'];
+									$aTmp[$aRow['code_composition_programme']]=$aRow['valeur'];
+								}
+								if (count($aTmp)>0) $aGranulometrie[$sTypeGranulometrie]=$aTmp;
+								if ($sTypeGranulometrie!='NB') 
+									if (isset($sDataGranulometrie))
+										$sDataGranulometrie=$sDataGranulometrie.','.array_sum($aTmp);
+									else
+										$sDataGranulometrie=array_sum($aTmp);
+							}
+							foreach ($aGranulometrie as $sTypeGranulometrie=>$aValues){
+								if ($sTypeGranulometrie!='NB')
+									foreach ($aValues as $sCodeCompo=>$iValue){
+										if (isset($aGranulometrie2[$sCodeCompo]))
+											$aGranulometrie2[$sCodeCompo][$sTypeGranulometrie]=$aGranulometrie2[$sCodeCompo][$sTypeGranulometrie]+$iValue;
+									}
+									
+							}
+							foreach ($aGranulometrie2 as $sCodeCompo=>$aValues)
+								$aGranulometrie2[$sCodeCompo] = implode(",", $aValues);
+							//echo '<br>'.print_r($aGranulometrie2,true);
+						}
+
+						
+						include ('get_1_operation.html');
+					}else{
+						$sError="Erreur : ".$oResult->rowCount()." opération(s) trouvée(s).";
+						$oResult->closeCursor();
+						include ('get_error.html');
+					}
+				}
+			}catch (PDOException $e){
+				$sError="ERROR : ".$e->getMessage();
+				include ('get_error.html');
+			}
+
+		}else{
+			$sError="ERREUR : Pas d'opération passée en paramètre !";
+			include ('get_error.html');
+		}
+	}else{
+		header ('location: signin.php');
+		exit();
+	}
+}else{
+	header ('location: signin.php');
+	exit();
+}
+?>
\ No newline at end of file
diff --git a/src/vitis/vas/doc/suivi_prod_immo/get_1_operation.php b/src/vitis/vas/doc/suivi_prod_immo/get_1_operation.php
index ae14f6b4489a8ab3cafd13bd608006f76d66a131..9147e6d69f96f457c1a041b74b277e9d239a7bd3 100644
--- a/src/vitis/vas/doc/suivi_prod_immo/get_1_operation.php
+++ b/src/vitis/vas/doc/suivi_prod_immo/get_1_operation.php
@@ -1,272 +1,275 @@
-<?php
-// https://geo.urbalyon.org/doc/suivi_prod_immo/get_1_operation.php?id_operation=1041
-session_start();
-if (isset($_REQUEST['login'])) $_SESSION['login_bd_prod_immo']=$_REQUEST['login'];
-
-if(isset($_REQUEST['token']) && isset($_SESSION['token_bd_prod_immo'])){
-	if($_REQUEST['token']==$_SESSION['token_bd_prod_immo']){
-
-		if (isset($_REQUEST['id_operation']) && !is_null($_REQUEST['id_operation'])){
-			require_once("../../rest/conf/properties.inc");
-			require_once("properties_suivi_prod_immo.inc");
-			$sSchema=$properties['schema_prod_immo'];
-
-			try{
-				$oConn = new PDO('pgsql:host='.$properties['server'].';port='.$properties['port'].';dbname='.$properties['db_prod_immo'], $properties['db_user_prod_immo'], $properties['db_pass_prod_immo']);
-				$oConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-				$oConn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
-				
-				if($oConn){
-					// get data Opérations
-					$sWhereIdOperation=" WHERE id_operation=".$_REQUEST['id_operation'];
-					$oResult = $oConn->prepare("SELECT *, ST_XMin(ST_Buffer(geom,50)) AS xmin, ST_YMin(ST_Buffer(geom,50)) AS ymin, ST_XMax(ST_Buffer(geom,50)) AS xmax, ST_YMax(ST_Buffer(geom,50)) AS ymax FROM ".$sSchema.".v_operation_layer".$sWhereIdOperation);
-					$oResult->execute();
-
-					if ($oResult->rowCount()>0){
-						$aOperations = $oResult->fetchAll();
-						$oResult->closeCursor();
-						$aOperation =$aOperations[0];
-						$aOperation['date_mise_a_jour'] = date("d/m/Y", strtotime($aOperation['date_mise_a_jour']));
-						$sDataSdpPrev= $aOperation['sdp_logement'].",".$aOperation['sdp_bureau'].",".$aOperation['sdp_commerce_service'].",".$aOperation['sdp_locaux'].",".$aOperation['sdp_equipement'];
-						// get map image
-						$sNameMapImage=$_REQUEST['id_operation']."_operation.png";
-						$sCommand = escapeshellcmd('python get_map_image_1_operation.py '.$aOperation['xmin'].' '.$aOperation['ymin'].' '.$aOperation['xmax'].' '.$aOperation['ymax'].' '.$sNameMapImage.' '.$_REQUEST['id_operation']);
-						$output = shell_exec($sCommand);
-						$sUrlMapImage=$properties['web_server_name']."/ws_data/vm4ms/map/tmp/".$sNameMapImage;
-						
-						// get data ilot
-						$oResult1 = $oConn->prepare("SELECT count(id_ilot) FROM ".$sSchema.".ilot".$sWhereIdOperation);
-						$oResult1->execute();
-						$aIlot = $oResult1->fetch(PDO::FETCH_ASSOC);
-						$oResult1->closeCursor();
-						$oResult2 = $oConn->prepare("SELECT count(DISTINCT programme_immobilier.id_ilot) FROM ".$sSchema.".programme_immobilier INNER JOIN ".$sSchema.".ilot ON programme_immobilier.id_ilot=ilot.id_ilot".$sWhereIdOperation);
-						$oResult2->execute();
-						$aIlotProgramme = $oResult2->fetch(PDO::FETCH_ASSOC);
-						$iIlotSansProgramme = $aIlot['count']-$aIlotProgramme['count'];
-						$oResult2->closeCursor();
-						// get data programme
-						$oResult3 = $oConn->prepare("SELECT array_to_string(array_agg(id_programme), ',') AS id_programme, round(avg(cout_construction_moyen)) AS cout_construction_moyen,round( avg(charge_fonciere_nette)) AS charge_fonciere_nette FROM ".$sSchema.".programme_immobilier INNER JOIN ".$sSchema.".ilot ON ilot.id_ilot=programme_immobilier.id_ilot ".$sWhereIdOperation." GROUP BY id_operation");
-						$oResult3->execute();
-						if ($oResult3->rowCount()>0){
-							$aProgrammesStat=$oResult3->fetch(PDO::FETCH_ASSOC);
-							$sIdsProgramme = $aProgrammesStat['id_programme'];
-							$sWhereIdProgramme = " WHERE id_programme IN (".$sIdsProgramme.")";
-							//echo $sWhereIdProgramme;
-							$oResult3->closeCursor();
-							$oResult11=$oConn->prepare("SELECT nom_ilot, numero_pc, surface, id_programme, nom_programme, code_type_operateur, nom_demandeur, annee_debut, annee_fin FROM ".$sSchema.".programme_immobilier INNER JOIN ".$sSchema.".ilot ON ilot.id_ilot=programme_immobilier.id_ilot ".$sWhereIdOperation);
-							$oResult11->execute();
-							$aProgrammes = $oResult11->fetchAll();
-							$aSyntheseProgrammes=array();
-							foreach ($aProgrammes as $iKey => $aProgramme){
-								$aSyntheseProgrammes[$aProgramme['id_programme']]=array();
-								$sSql12="SELECT code_composition_programme, code_type_granulometrie, valeur FROM ".$sSchema.".granulometrie WHERE id_programme IN (".$aProgramme['id_programme'].") ORDER BY code_composition_programme, code_type_granulometrie";
-								foreach ($oConn->query($sSql12) as $aRow){
-									if (!isset($aSyntheseProgrammes[$aProgramme['id_programme']][$aRow['code_composition_programme']])) $aSyntheseProgrammes[$aProgramme['id_programme']][$aRow['code_composition_programme']]=array();
-									$aSyntheseProgrammes[$aProgramme['id_programme']][$aRow['code_composition_programme']][$aRow['code_type_granulometrie']]=$aRow['valeur'];
-								}
-							}
-							$oResult11->closeCursor();
-							
-
-							// get accession libre aidee
-							$sSql8="SELECT id_indicateur_logement_familliaux_accession, round(sum(accession_libre::numeric)) AS sum_accession_libre, round(coalesce(sum(accession_abordable::numeric),0)+coalesce(sum(accession_sociale_securise ::numeric),0)+coalesce(sum(psla::numeric),0)) AS sum_accession_aide, round(avg(accession_libre::numeric)) AS avg_accession_libre, round(avg(accession_abordable::numeric)) AS avg_accession_abordable, round(avg(accession_sociale_securise ::numeric)) AS avg_accession_sociale_securise , round(avg(psla::numeric)) AS avg_psla FROM ".$sSchema.".logement_familliaux_accession".$sWhereIdProgramme." AND id_indicateur_logement_familliaux_accession IN (1,2,4,5,8,9) GROUP BY id_indicateur_logement_familliaux_accession";
-							foreach ($oConn->query($sSql8) as $aRow){
-								if ($aRow['id_indicateur_logement_familliaux_accession']==1){
-									isset($iNbLgtFam) ? $iNbLgtFam=$iNbLgtFam+$aRow['sum_accession_libre'] : $iNbLgtFam=$aRow['sum_accession_libre'];
-									isset($iNbLgtFam) ? $iNbLgtFam=$iNbLgtFam+$aRow['sum_accession_aide'] : $iNbLgtFam=$aRow['sum_accession_aide'];
-								}
-								if ($aRow['id_indicateur_logement_familliaux_accession']==2){
-									$iSdpAccessionLibre=$aRow['sum_accession_libre'];
-									$iSdpAccessionAide=$aRow['sum_accession_aide'];
-								}
-								if ($aRow['id_indicateur_logement_familliaux_accession']==4 or $aRow['id_indicateur_logement_familliaux_accession']==5){
-									if(!isset($aCFAccessionLibre)) $aCFAccessionLibre=array();
-									if(!is_null($aRow['avg_accession_libre'])) array_push($aCFAccessionLibre,$aRow['avg_accession_libre']);
-									if(!isset($aCFAccessionAidee)) $aCFAccessionAidee=array();
-									if(!is_null($aRow['avg_accession_abordable'])) array_push($aCFAccessionAidee,$aRow['avg_accession_abordable']);
-									if(!is_null($aRow['avg_accession_sociale_securise '])) array_push($aCFAccessionAidee,$aRow['avg_accession_sociale_securise ']);
-									if(!is_null($aRow['avg_psla'])) array_push($aCFAccessionAidee,$aRow['avg_psla']);
-								}
-								if ($aRow['id_indicateur_logement_familliaux_accession']==8 or $aRow['id_indicateur_logement_familliaux_accession']==9){
-									if(!isset($aPVAccessionLibre)) $aPVAccessionLibre=array();
-									if(!is_null($aRow['avg_accession_libre'])) array_push($aPVAccessionLibre,$aRow['avg_accession_libre']);
-									if(!isset($aPVAccessionAidee)) $aPVAccessionAidee=array();
-									if(!is_null($aRow['avg_accession_abordable'])) array_push($aPVAccessionAidee,$aRow['avg_accession_abordable']);
-									if(!is_null($aRow['avg_accession_sociale_securise '])) array_push($aPVAccessionAidee,$aRow['avg_accession_sociale_securise ']);
-									if(!is_null($aRow['avg_psla'])) array_push($aPVAccessionAidee,$aRow['avg_psla']);
-								}
-							}
-							if(isset($aPVAccessionLibre) and count($aPVAccessionLibre)>0) $iPVAccessionLibre = round(array_sum($aPVAccessionLibre)/count($aPVAccessionLibre));
-							if(isset($aPVAccessionAidee) and count($aPVAccessionAidee)>0) $iPVAccessionAidee = round(array_sum($aPVAccessionAidee)/count($aPVAccessionAidee));
-							if(isset($aCFAccessionLibre) and count($aCFAccessionLibre)>0) $iCFAccessionLibre = round(array_sum($aCFAccessionLibre)/count($aCFAccessionLibre));
-							if(isset($aCFAccessionAidee) and count($aCFAccessionAidee)>0) $iCFAccessionAidee = round(array_sum($aCFAccessionAidee)/count($aCFAccessionAidee));
-							// get locatif social
-							$sSql9="SELECT id_indicateur_logement_familliaux_location, round(coalesce(sum(social_pls),0)+coalesce(sum(social_plus_plai),0)) AS sum_social, round(coalesce(sum(intermediaire_pli),0)+coalesce(sum(intermediaire_afl),0)) AS sum_intermediaire, round(avg(social_pls)) AS avg_social_pls, round(avg(social_plus_plai)) AS avg_social_plus_plai, round(avg(intermediaire_pli)) AS avg_intermediaire_pli, round(avg(intermediaire_afl)) AS avg_intermediaire_afl FROM ".$sSchema.".composition_logement_familliaux_location_cp INNER JOIN ".$sSchema.".logement_familliaux_location ON logement_familliaux_location.id_logement_familliaux_location=composition_logement_familliaux_location_cp.id_logement_familliaux_location".$sWhereIdProgramme." AND id_indicateur_logement_familliaux_location IN (1,2,4,5,8) GROUP BY id_indicateur_logement_familliaux_location";
-							foreach ($oConn->query($sSql9) as $aRow){
-								if ($aRow['id_indicateur_logement_familliaux_location']==1){
-									isset($iNbLgtFam) ? $iNbLgtFam=$iNbLgtFam+$aRow['sum_social'] : $iNbLgtFam=$aRow['sum_social'];
-									isset($iNbLgtFam) ? $iNbLgtFam=$iNbLgtFam+$aRow['sum_intermediaire'] : $iNbLgtFam=$aRow['sum_intermediaire'];
-								}
-								if ($aRow['id_indicateur_logement_familliaux_location']==2){
-									$iSdpLocSocial=$aRow['sum_social'];
-									$iSdpLocIntermediaire=$aRow['sum_intermediaire'];
-								}
-								if ($aRow['id_indicateur_logement_familliaux_location']==4 or $aRow['id_indicateur_logement_familliaux_location']==5){
-									if(!isset($aCFSocial)) $aCFSocial=array();
-									if(!is_null($aRow['avg_social_pls'])) array_push($aCFSocial,$aRow['avg_social_pls']);
-									if(!is_null($aRow['avg_social_plus_plai'])) array_push($aCFSocial,$aRow['avg_social_plus_plai']);
-									if(!isset($aCFIntermediaire)) $aCFIntermediaire=array();
-									if(!is_null($aRow['avg_intermediaire_pli'])) array_push($aCFIntermediaire,$aRow['avg_intermediaire_pli']);
-									if(!is_null($aRow['avg_intermediaire_afl'])) array_push($aCFIntermediaire,$aRow['avg_intermediaire_afl']);
-								}
-								if ($aRow['id_indicateur_logement_familliaux_location']==8){
-									$aPrixVenteSocial=array();
-									if(!is_null($aRow['avg_social_pls'])) array_push($aPrixVenteSocial,$aRow['avg_social_pls']);
-									if(!is_null($aRow['avg_social_plus_plai'])) array_push($aPrixVenteSocial,$aRow['avg_social_plus_plai']);
-									if(count($aPrixVenteSocial)>0) $iPrixVenteSocial = round(array_sum($aPrixVenteSocial)/count($aPrixVenteSocial));
-									$aPrixVenteIntermediaire=array();
-									if(!is_null($aRow['avg_intermediaire_pli'])) array_push($aPrixVenteIntermediaire,$aRow['avg_intermediaire_pli']);
-									if(!is_null($aRow['avg_intermediaire_afl'])) array_push($aPrixVenteIntermediaire,$aRow['avg_intermediaire_afl']);
-									if(count($aPrixVenteIntermediaire)>0) $iPrixVenteIntermediaire = round(array_sum($aPrixVenteIntermediaire)/count($aPrixVenteIntermediaire));
-								}
-							}
-							if(isset($aCFSocial) and count($aCFSocial)>0) $iCFSocial = round(array_sum($aCFSocial)/count($aCFSocial));
-							if(isset($aCFIntermediaire)and count($aCFIntermediaire)>0) $iCFIntermediaire = round(array_sum($aCFIntermediaire)/count($aCFIntermediaire));
-							// get habitat spe
-							$oResult10=$oConn->prepare("SELECT id_indicateur_habitat_specifique, round(coalesce(sum(residence_etudiant),0)+coalesce(sum(residence_personne_agee),0)+coalesce(sum(autre),0)) AS total FROM ".$sSchema.".composition_habitat_specifique_cp INNER JOIN ".$sSchema.".habitat_specifique ON composition_habitat_specifique_cp.id_habitat_specifique=habitat_specifique.id_habitat_specifique".$sWhereIdProgramme."  AND id_indicateur_habitat_specifique IN (1,2) GROUP BY id_indicateur_habitat_specifique ORDER BY id_indicateur_habitat_specifique");
-							$oResult10->execute();
-							$iNbHabitatSpe=$oResult10->fetch(PDO::FETCH_ASSOC)['total'];
-							$iSdpHabitatSpe=$oResult10->fetch(PDO::FETCH_ASSOC)['total'];
-							$oResult10->closeCursor();
-							// get bureau
-							$sSql6="SELECT id_indicateur_bureau, round(sum(total)::numeric) AS sum, round(avg(total)::numeric) AS avg FROM ".$sSchema.".bureau".$sWhereIdProgramme." AND id_indicateur_bureau IN (1,2,3,6) GROUP BY id_indicateur_bureau";
-							foreach ($oConn->query($sSql6) as $aRow) {
-								if ($aRow['id_indicateur_bureau']==1) $iSdpBureau = $aRow['sum'];
-								if ($aRow['id_indicateur_bureau']==2 or $aRow['id_indicateur_bureau']==3)
-									isset($iCFBureau) ? array_push($iCFBureau,$aRow['avg']) : $iCFBureau=array($aRow['avg']);
-								if ($aRow['id_indicateur_bureau']==6) $iPrixVenteBureau = $aRow['avg'];
-							}
-							//echo print_r($iCFBureau,true);
-							if (isset($iCFBureau)) $iCFBureau = round(array_sum($iCFBureau)/count($iCFBureau));
-							//get commerce/hotel
-							$sSql4="SELECT id_indicateur_hotel_commerce_service, round(coalesce(sum(commerce),0)+coalesce(sum(loisir_marchand),0)+coalesce(sum(service_act_artisanale),0)) AS sum_commerce, round(sum(hotel)) AS sum_hotel, round(avg(commerce)) AS avg_commerce, round(avg(loisir_marchand)) AS avg_loisir_marchand, round(avg(service_act_artisanale)) AS avg_service_act_artisanale, round(avg(hotel)) AS avg_hotel FROM ".$sSchema.".hotel_commerce_service".$sWhereIdProgramme." AND id_indicateur_hotel_commerce_service IN (2,3,4,8) GROUP BY id_indicateur_hotel_commerce_service";
-							foreach ($oConn->query($sSql4) as $aRow) {
-								if ($aRow['id_indicateur_hotel_commerce_service']==2){
-									$iSdpCommerce=$aRow['sum_commerce'];
-									$iSdpHotel=$aRow['sum_hotel'];
-								}
-								if ($aRow['id_indicateur_hotel_commerce_service']==3 or $aRow['id_indicateur_hotel_commerce_service']==4){
-									if(!isset($aCFCommerce)) $aCFCommerce=array();
-									if(!is_null($aRow['avg_commerce'])) array_push($aCFCommerce,$aRow['avg_commerce']);
-									if(!is_null($aRow['avg_loisir_marchand'])) array_push($aCFCommerce,$aRow['avg_loisir_marchand']);
-									if(!is_null($aRow['avg_service_act_artisanale'])) array_push($aCFCommerce,$aRow['avg_service_act_artisanale']);
-									if(!isset($aCFHotel)) $aCFHotel=array();
-									if(!is_null($aRow['avg_hotel'])) array_push($aCFHotel,$aRow['avg_hotel']);
-								}
-								if ($aRow['id_indicateur_hotel_commerce_service']==8){
-									$aPrixVenteCommerce=array();
-									if(!is_null($aRow['avg_commerce'])) array_push($aPrixVenteCommerce,$aRow['avg_commerce']);
-									if(!is_null($aRow['avg_loisir_marchand'])) array_push($aPrixVenteCommerce,$aRow['avg_loisir_marchand']);
-									if(!is_null($aRow['avg_service_act_artisanale'])) array_push($aPrixVenteCommerce,$aRow['avg_service_act_artisanale']);
-									if(count($aPrixVenteCommerce)>0) $iPrixVenteCommerce = round(array_sum($aPrixVenteCommerce)/count($aPrixVenteCommerce));
-									$iPrixVenteHotel = $aRow['avg_hotel'];
-								}
-							}
-							if (isset($aCFCommerce)) $iCFCommerce = round(array_sum($aCFCommerce)/count($aCFCommerce));
-							if (isset($aCFHotel)) $iCFHotel = round(array_sum($aCFHotel)/count($aCFHotel));
-							//get prod/activite
-							$sSql7="SELECT id_indicateur_activite_industrie, round(sum(production_industrie)) AS sum_production_industrie, round(sum(logistique)) AS sum_logistique, round(sum(autre)) AS sum_autre, round(avg(production_industrie)) AS avg_production_industrie, round(avg(logistique)) AS avg_logistique, round(avg(autre)) AS avg_autre FROM ".$sSchema.".activite_industrie".$sWhereIdProgramme." AND id_indicateur_activite_industrie IN (2,3,4,7) GROUP BY id_indicateur_activite_industrie";
-							foreach ($oConn->query($sSql7) as $aRow){
-								if ($aRow['id_indicateur_activite_industrie']==2){
-									$iSdpProd=$aRow['sum_production_industrie'];
-									$iSdpLogistique=$aRow['sum_logistique'];
-									$iSdpActAutre=$aRow['avg_autre'];
-								}
-								if ($aRow['id_indicateur_activite_industrie']==3 or $aRow['id_indicateur_activite_industrie']==4){
-									isset($iCFProd) ? array_push($iCFProd,$aRow['avg_production_industrie']) : $iCFProd=array($aRow['avg_production_industrie']);
-									isset($iCFLogistique) ? array_push($iCFProd,$aRow['avg_logistique']) : $iCFProd=array($aRow['avg_logistique']);
-									isset($iCFActAutre) ? array_push($iCFActAutre,$aRow['avg_autre']) : $iCFActAutre=array($aRow['avg_autre']);
-								}
-								if ($aRow['id_indicateur_activite_industrie']==7){
-									$iPrixVenteProd = $aRow['avg_production_industrie'];
-									$iPrixVenteLogistique = $aRow['avg_logistique'];
-									$iPrixVenteActAutre = $aRow['avg_autre'];
-								}
-							}
-							if (isset($iCFProd)) $iCFProd = round(array_sum($iCFProd)/count($iCFProd));
-							if (isset($iCFLogistique)) $iCFLogistique = round(array_sum($iCFLogistique)/count($iCFLogistique));
-							if (isset($iCFActAutre)) $iCFActAutre = round(array_sum($iCFActAutre)/count($iCFActAutre));
-							// get equipement
-							$oResult5 = $oConn->prepare("SELECT round(sum(sdp)::numeric) AS sdp FROM ".$sSchema.".equipement_structure".$sWhereIdProgramme);
-							$oResult5->execute();
-							$iSdpEquipement = $oResult5->fetch(PDO::FETCH_ASSOC)['sdp'];
-							$oResult5->closeCursor();
-							//get profil
-							$sSql12="SELECT id_type_acheteur_accession_libre, round(sum(nb)) AS nb, round(avg(pourc)) AS pourc FROM ".$sSchema.".profil_acheteur_accession_libre".$sWhereIdProgramme." AND id_type_acheteur_accession_libre IN (1,2) GROUP BY id_type_acheteur_accession_libre";
-							foreach ($oConn->query($sSql12) as $aRow){
-								if ($aRow['id_type_acheteur_accession_libre']==1){
-									$iNbProprioOcc=$aRow['nb'];
-									$iPourcProprioOcc=$aRow['pourc'];
-								}
-								if ($aRow['id_type_acheteur_accession_libre']==2){
-									$iNbInvest=$aRow['nb'];
-									$iPourcInvest=$aRow['pourc'];
-								}
-							}
-							// get granulometrie
-							$aGranulometrie=array();
-							$aGranulometrie2=array('LG_FAM_ACC'=>array('T1'=>0,'T2'=>0,'T3'=>0,'T4'=>0,'T5'=>0,'T6'=>0), 'LG_FAM_LOC'=>array('T1'=>0,'T2'=>0,'T3'=>0,'T4'=>0,'T5'=>0,'T6'=>0), 'TOT_LG_SPE'=>array('T1'=>0,'T2'=>0,'T3'=>0,'T4'=>0,'T5'=>0,'T6'=>0));
-							$aTypeGranulometrie=array('T1','T2','T3','T4','T5','T6','NB');
-							foreach ($aTypeGranulometrie as $sTypeGranulometrie){
-								$aTmp=array();
-								$sSql13="SELECT code_composition_programme, sum(valeur) AS valeur FROM ".$sSchema.".granulometrie".$sWhereIdProgramme." AND code_type_granulometrie ='".$sTypeGranulometrie."' AND code_composition_programme IN ('TOT_LG_SPE','LG_FAM_ACC','LG_FAM_LOC','TOT_LG_FAM') GROUP BY code_composition_programme";
-								foreach ($oConn->query($sSql13) as $aRow){
-									if ($sTypeGranulometrie=='NB' && ($aRow['code_composition_programme']=='TOT_LG_FAM' || $aRow['code_composition_programme']=='TOT_LG_SPE')) $aTmp['TOT'] = $aTmp['TOT'] + $aRow['valeur'];
-									$aTmp[$aRow['code_composition_programme']]=$aRow['valeur'];
-								}
-								if (count($aTmp)>0) $aGranulometrie[$sTypeGranulometrie]=$aTmp;
-								if ($sTypeGranulometrie!='NB') 
-									if (isset($sDataGranulometrie))
-										$sDataGranulometrie=$sDataGranulometrie.','.array_sum($aTmp);
-									else
-										$sDataGranulometrie=array_sum($aTmp);
-							}
-							foreach ($aGranulometrie as $sTypeGranulometrie=>$aValues){
-								if ($sTypeGranulometrie!='NB')
-									foreach ($aValues as $sCodeCompo=>$iValue){
-										if (isset($aGranulometrie2[$sCodeCompo]))
-											$aGranulometrie2[$sCodeCompo][$sTypeGranulometrie]=$aGranulometrie2[$sCodeCompo][$sTypeGranulometrie]+$iValue;
-									}
-									
-							}
-							foreach ($aGranulometrie2 as $sCodeCompo=>$aValues)
-								$aGranulometrie2[$sCodeCompo] = implode(",", $aValues);
-							//echo '<br>'.print_r($aGranulometrie2,true);
-						}
-
-						
-						include ('get_1_operation.html');
-					}else{
-						$sError="Erreur : ".$oResult->rowCount()." opération(s) trouvée(s).";
-						$oResult->closeCursor();
-						include ('get_error.html');
-					}
-				}
-			}catch (PDOException $e){
-				$sError="ERROR : ".$e->getMessage();
-				include ('get_error.html');
-			}
-
-		}else{
-			$sError="ERREUR : Pas d'opération passée en paramètre !";
-			include ('get_error.html');
-		}
-	}else{
-		header ('location: signin.php');
-		exit();
-	}
-}else{
-	header ('location: signin.php');
-	exit();
-}
+<?php
+// https://geo.urbalyon.org/doc/suivi_prod_immo/get_1_operation.php?id_operation=1041
+
+if (isset($_REQUEST['token']) && !is_null($_REQUEST['token'])){
+	session_id($_REQUEST['token']);
+	if (session_status() == PHP_SESSION_NONE)
+		session_start();
+
+	if (empty($_SESSION)) {
+		$sError="ERREUR : token invalide.";
+		include ('get_error.html');
+	}else{
+		if (isset($_REQUEST['id_operation']) && !is_null($_REQUEST['id_operation'])){
+			require_once("../../rest/conf/properties.inc");
+			require_once("properties_suivi_prod_immo.inc");
+			$sSchema=$properties['schema_prod_immo'];
+
+			try{
+				$oConn = new PDO('pgsql:host='.$properties['server'].';port='.$properties['port'].';dbname='.$properties['db_prod_immo'], $properties['db_user_prod_immo'], $properties['db_pass_prod_immo']);
+				$oConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+				$oConn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
+				
+				if($oConn){
+					// get data Opérations
+					$sWhereIdOperation=" WHERE id_operation=".$_REQUEST['id_operation'];
+					$oResult = $oConn->prepare("SELECT *, ST_XMin(ST_Buffer(geom,50)) AS xmin, ST_YMin(ST_Buffer(geom,50)) AS ymin, ST_XMax(ST_Buffer(geom,50)) AS xmax, ST_YMax(ST_Buffer(geom,50)) AS ymax FROM ".$sSchema.".v_operation_layer".$sWhereIdOperation);
+					$oResult->execute();
+
+					if ($oResult->rowCount()>0){
+						$aOperations = $oResult->fetchAll();
+						$oResult->closeCursor();
+						$aOperation =$aOperations[0];
+						$aOperation['date_mise_a_jour'] = date("d/m/Y", strtotime($aOperation['date_mise_a_jour']));
+						$sDataSdpPrev= $aOperation['sdp_logement'].",".$aOperation['sdp_bureau'].",".$aOperation['sdp_commerce_service'].",".$aOperation['sdp_locaux'].",".$aOperation['sdp_equipement'];
+						// get map image
+						$sNameMapImage=$_REQUEST['id_operation']."_operation.png";
+						$sCommand = escapeshellcmd('python get_map_image_1_operation.py '.$aOperation['xmin'].' '.$aOperation['ymin'].' '.$aOperation['xmax'].' '.$aOperation['ymax'].' '.$sNameMapImage.' '.$_REQUEST['id_operation']);
+						$output = shell_exec($sCommand);
+						$sUrlMapImage=$properties['web_server_name']."/ws_data/vm4ms/map/tmp/".$sNameMapImage;
+						
+						// get data ilot
+						$oResult1 = $oConn->prepare("SELECT count(id_ilot) FROM ".$sSchema.".ilot".$sWhereIdOperation);
+						$oResult1->execute();
+						$aIlot = $oResult1->fetch(PDO::FETCH_ASSOC);
+						$oResult1->closeCursor();
+						$oResult2 = $oConn->prepare("SELECT count(DISTINCT programme_immobilier.id_ilot) FROM ".$sSchema.".programme_immobilier INNER JOIN ".$sSchema.".ilot ON programme_immobilier.id_ilot=ilot.id_ilot".$sWhereIdOperation);
+						$oResult2->execute();
+						$aIlotProgramme = $oResult2->fetch(PDO::FETCH_ASSOC);
+						$iIlotSansProgramme = $aIlot['count']-$aIlotProgramme['count'];
+						$oResult2->closeCursor();
+						// get data programme
+						$oResult3 = $oConn->prepare("SELECT array_to_string(array_agg(id_programme), ',') AS id_programme, round(avg(cout_construction_moyen)) AS cout_construction_moyen,round( avg(charge_fonciere_nette)) AS charge_fonciere_nette FROM ".$sSchema.".programme_immobilier INNER JOIN ".$sSchema.".ilot ON ilot.id_ilot=programme_immobilier.id_ilot ".$sWhereIdOperation." GROUP BY id_operation");
+						$oResult3->execute();
+						if ($oResult3->rowCount()>0){
+							$aProgrammesStat=$oResult3->fetch(PDO::FETCH_ASSOC);
+							$sIdsProgramme = $aProgrammesStat['id_programme'];
+							$sWhereIdProgramme = " WHERE id_programme IN (".$sIdsProgramme.")";
+							//echo $sWhereIdProgramme;
+							$oResult3->closeCursor();
+							$oResult11=$oConn->prepare("SELECT nom_ilot, numero_pc, surface, id_programme, nom_programme, code_type_operateur, nom_demandeur, annee_debut, annee_fin FROM ".$sSchema.".programme_immobilier INNER JOIN ".$sSchema.".ilot ON ilot.id_ilot=programme_immobilier.id_ilot ".$sWhereIdOperation);
+							$oResult11->execute();
+							$aProgrammes = $oResult11->fetchAll();
+							$aSyntheseProgrammes=array();
+							foreach ($aProgrammes as $iKey => $aProgramme){
+								$aSyntheseProgrammes[$aProgramme['id_programme']]=array();
+								$sSql12="SELECT code_composition_programme, code_type_granulometrie, valeur FROM ".$sSchema.".granulometrie WHERE id_programme IN (".$aProgramme['id_programme'].") ORDER BY code_composition_programme, code_type_granulometrie";
+								foreach ($oConn->query($sSql12) as $aRow){
+									if (!isset($aSyntheseProgrammes[$aProgramme['id_programme']][$aRow['code_composition_programme']])) $aSyntheseProgrammes[$aProgramme['id_programme']][$aRow['code_composition_programme']]=array();
+									$aSyntheseProgrammes[$aProgramme['id_programme']][$aRow['code_composition_programme']][$aRow['code_type_granulometrie']]=$aRow['valeur'];
+								}
+							}
+							$oResult11->closeCursor();
+							
+
+							// get accession libre aidee
+							$sSql8="SELECT id_indicateur_logement_familliaux_accession, round(sum(accession_libre::numeric)) AS sum_accession_libre, round(coalesce(sum(accession_abordable::numeric),0)+coalesce(sum(accession_sociale_securise ::numeric),0)+coalesce(sum(psla::numeric),0)) AS sum_accession_aide, round(avg(accession_libre::numeric)) AS avg_accession_libre, round(avg(accession_abordable::numeric)) AS avg_accession_abordable, round(avg(accession_sociale_securise ::numeric)) AS avg_accession_sociale_securise , round(avg(psla::numeric)) AS avg_psla FROM ".$sSchema.".logement_familliaux_accession".$sWhereIdProgramme." AND id_indicateur_logement_familliaux_accession IN (1,2,4,5,8,9) GROUP BY id_indicateur_logement_familliaux_accession";
+							foreach ($oConn->query($sSql8) as $aRow){
+								if ($aRow['id_indicateur_logement_familliaux_accession']==1){
+									isset($iNbLgtFam) ? $iNbLgtFam=$iNbLgtFam+$aRow['sum_accession_libre'] : $iNbLgtFam=$aRow['sum_accession_libre'];
+									isset($iNbLgtFam) ? $iNbLgtFam=$iNbLgtFam+$aRow['sum_accession_aide'] : $iNbLgtFam=$aRow['sum_accession_aide'];
+								}
+								if ($aRow['id_indicateur_logement_familliaux_accession']==2){
+									$iSdpAccessionLibre=$aRow['sum_accession_libre'];
+									$iSdpAccessionAide=$aRow['sum_accession_aide'];
+								}
+								if ($aRow['id_indicateur_logement_familliaux_accession']==4 or $aRow['id_indicateur_logement_familliaux_accession']==5){
+									if(!isset($aCFAccessionLibre)) $aCFAccessionLibre=array();
+									if(!is_null($aRow['avg_accession_libre'])) array_push($aCFAccessionLibre,$aRow['avg_accession_libre']);
+									if(!isset($aCFAccessionAidee)) $aCFAccessionAidee=array();
+									if(!is_null($aRow['avg_accession_abordable'])) array_push($aCFAccessionAidee,$aRow['avg_accession_abordable']);
+									if(!is_null($aRow['avg_accession_sociale_securise '])) array_push($aCFAccessionAidee,$aRow['avg_accession_sociale_securise ']);
+									if(!is_null($aRow['avg_psla'])) array_push($aCFAccessionAidee,$aRow['avg_psla']);
+								}
+								if ($aRow['id_indicateur_logement_familliaux_accession']==8 or $aRow['id_indicateur_logement_familliaux_accession']==9){
+									if(!isset($aPVAccessionLibre)) $aPVAccessionLibre=array();
+									if(!is_null($aRow['avg_accession_libre'])) array_push($aPVAccessionLibre,$aRow['avg_accession_libre']);
+									if(!isset($aPVAccessionAidee)) $aPVAccessionAidee=array();
+									if(!is_null($aRow['avg_accession_abordable'])) array_push($aPVAccessionAidee,$aRow['avg_accession_abordable']);
+									if(!is_null($aRow['avg_accession_sociale_securise '])) array_push($aPVAccessionAidee,$aRow['avg_accession_sociale_securise ']);
+									if(!is_null($aRow['avg_psla'])) array_push($aPVAccessionAidee,$aRow['avg_psla']);
+								}
+							}
+							if(isset($aPVAccessionLibre) and count($aPVAccessionLibre)>0) $iPVAccessionLibre = round(array_sum($aPVAccessionLibre)/count($aPVAccessionLibre));
+							if(isset($aPVAccessionAidee) and count($aPVAccessionAidee)>0) $iPVAccessionAidee = round(array_sum($aPVAccessionAidee)/count($aPVAccessionAidee));
+							if(isset($aCFAccessionLibre) and count($aCFAccessionLibre)>0) $iCFAccessionLibre = round(array_sum($aCFAccessionLibre)/count($aCFAccessionLibre));
+							if(isset($aCFAccessionAidee) and count($aCFAccessionAidee)>0) $iCFAccessionAidee = round(array_sum($aCFAccessionAidee)/count($aCFAccessionAidee));
+							// get locatif social
+							$sSql9="SELECT id_indicateur_logement_familliaux_location, round(coalesce(sum(social_pls),0)+coalesce(sum(social_plus_plai),0)) AS sum_social, round(coalesce(sum(intermediaire_pli),0)+coalesce(sum(intermediaire_afl),0)) AS sum_intermediaire, round(avg(social_pls)) AS avg_social_pls, round(avg(social_plus_plai)) AS avg_social_plus_plai, round(avg(intermediaire_pli)) AS avg_intermediaire_pli, round(avg(intermediaire_afl)) AS avg_intermediaire_afl FROM ".$sSchema.".composition_logement_familliaux_location_cp INNER JOIN ".$sSchema.".logement_familliaux_location ON logement_familliaux_location.id_logement_familliaux_location=composition_logement_familliaux_location_cp.id_logement_familliaux_location".$sWhereIdProgramme." AND id_indicateur_logement_familliaux_location IN (1,2,4,5,8) GROUP BY id_indicateur_logement_familliaux_location";
+							foreach ($oConn->query($sSql9) as $aRow){
+								if ($aRow['id_indicateur_logement_familliaux_location']==1){
+									isset($iNbLgtFam) ? $iNbLgtFam=$iNbLgtFam+$aRow['sum_social'] : $iNbLgtFam=$aRow['sum_social'];
+									isset($iNbLgtFam) ? $iNbLgtFam=$iNbLgtFam+$aRow['sum_intermediaire'] : $iNbLgtFam=$aRow['sum_intermediaire'];
+								}
+								if ($aRow['id_indicateur_logement_familliaux_location']==2){
+									$iSdpLocSocial=$aRow['sum_social'];
+									$iSdpLocIntermediaire=$aRow['sum_intermediaire'];
+								}
+								if ($aRow['id_indicateur_logement_familliaux_location']==4 or $aRow['id_indicateur_logement_familliaux_location']==5){
+									if(!isset($aCFSocial)) $aCFSocial=array();
+									if(!is_null($aRow['avg_social_pls'])) array_push($aCFSocial,$aRow['avg_social_pls']);
+									if(!is_null($aRow['avg_social_plus_plai'])) array_push($aCFSocial,$aRow['avg_social_plus_plai']);
+									if(!isset($aCFIntermediaire)) $aCFIntermediaire=array();
+									if(!is_null($aRow['avg_intermediaire_pli'])) array_push($aCFIntermediaire,$aRow['avg_intermediaire_pli']);
+									if(!is_null($aRow['avg_intermediaire_afl'])) array_push($aCFIntermediaire,$aRow['avg_intermediaire_afl']);
+								}
+								if ($aRow['id_indicateur_logement_familliaux_location']==8){
+									$aPrixVenteSocial=array();
+									if(!is_null($aRow['avg_social_pls'])) array_push($aPrixVenteSocial,$aRow['avg_social_pls']);
+									if(!is_null($aRow['avg_social_plus_plai'])) array_push($aPrixVenteSocial,$aRow['avg_social_plus_plai']);
+									if(count($aPrixVenteSocial)>0) $iPrixVenteSocial = round(array_sum($aPrixVenteSocial)/count($aPrixVenteSocial));
+									$aPrixVenteIntermediaire=array();
+									if(!is_null($aRow['avg_intermediaire_pli'])) array_push($aPrixVenteIntermediaire,$aRow['avg_intermediaire_pli']);
+									if(!is_null($aRow['avg_intermediaire_afl'])) array_push($aPrixVenteIntermediaire,$aRow['avg_intermediaire_afl']);
+									if(count($aPrixVenteIntermediaire)>0) $iPrixVenteIntermediaire = round(array_sum($aPrixVenteIntermediaire)/count($aPrixVenteIntermediaire));
+								}
+							}
+							if(isset($aCFSocial) and count($aCFSocial)>0) $iCFSocial = round(array_sum($aCFSocial)/count($aCFSocial));
+							if(isset($aCFIntermediaire)and count($aCFIntermediaire)>0) $iCFIntermediaire = round(array_sum($aCFIntermediaire)/count($aCFIntermediaire));
+							// get habitat spe
+							$oResult10=$oConn->prepare("SELECT id_indicateur_habitat_specifique, round(coalesce(sum(residence_etudiant),0)+coalesce(sum(residence_personne_agee),0)+coalesce(sum(autre),0)) AS total FROM ".$sSchema.".composition_habitat_specifique_cp INNER JOIN ".$sSchema.".habitat_specifique ON composition_habitat_specifique_cp.id_habitat_specifique=habitat_specifique.id_habitat_specifique".$sWhereIdProgramme."  AND id_indicateur_habitat_specifique IN (1,2) GROUP BY id_indicateur_habitat_specifique ORDER BY id_indicateur_habitat_specifique");
+							$oResult10->execute();
+							$iNbHabitatSpe=$oResult10->fetch(PDO::FETCH_ASSOC)['total'];
+							$iSdpHabitatSpe=$oResult10->fetch(PDO::FETCH_ASSOC)['total'];
+							$oResult10->closeCursor();
+							// get bureau
+							$sSql6="SELECT id_indicateur_bureau, round(sum(total)::numeric) AS sum, round(avg(total)::numeric) AS avg FROM ".$sSchema.".bureau".$sWhereIdProgramme." AND id_indicateur_bureau IN (1,2,3,6) GROUP BY id_indicateur_bureau";
+							foreach ($oConn->query($sSql6) as $aRow) {
+								if ($aRow['id_indicateur_bureau']==1) $iSdpBureau = $aRow['sum'];
+								if ($aRow['id_indicateur_bureau']==2 or $aRow['id_indicateur_bureau']==3)
+									isset($iCFBureau) ? array_push($iCFBureau,$aRow['avg']) : $iCFBureau=array($aRow['avg']);
+								if ($aRow['id_indicateur_bureau']==6) $iPrixVenteBureau = $aRow['avg'];
+							}
+							//echo print_r($iCFBureau,true);
+							if (isset($iCFBureau)) $iCFBureau = round(array_sum($iCFBureau)/count($iCFBureau));
+							//get commerce/hotel
+							$sSql4="SELECT id_indicateur_hotel_commerce_service, round(coalesce(sum(commerce),0)+coalesce(sum(loisir_marchand),0)+coalesce(sum(service_act_artisanale),0)) AS sum_commerce, round(sum(hotel)) AS sum_hotel, round(avg(commerce)) AS avg_commerce, round(avg(loisir_marchand)) AS avg_loisir_marchand, round(avg(service_act_artisanale)) AS avg_service_act_artisanale, round(avg(hotel)) AS avg_hotel FROM ".$sSchema.".hotel_commerce_service".$sWhereIdProgramme." AND id_indicateur_hotel_commerce_service IN (2,3,4,8) GROUP BY id_indicateur_hotel_commerce_service";
+							foreach ($oConn->query($sSql4) as $aRow) {
+								if ($aRow['id_indicateur_hotel_commerce_service']==2){
+									$iSdpCommerce=$aRow['sum_commerce'];
+									$iSdpHotel=$aRow['sum_hotel'];
+								}
+								if ($aRow['id_indicateur_hotel_commerce_service']==3 or $aRow['id_indicateur_hotel_commerce_service']==4){
+									if(!isset($aCFCommerce)) $aCFCommerce=array();
+									if(!is_null($aRow['avg_commerce'])) array_push($aCFCommerce,$aRow['avg_commerce']);
+									if(!is_null($aRow['avg_loisir_marchand'])) array_push($aCFCommerce,$aRow['avg_loisir_marchand']);
+									if(!is_null($aRow['avg_service_act_artisanale'])) array_push($aCFCommerce,$aRow['avg_service_act_artisanale']);
+									if(!isset($aCFHotel)) $aCFHotel=array();
+									if(!is_null($aRow['avg_hotel'])) array_push($aCFHotel,$aRow['avg_hotel']);
+								}
+								if ($aRow['id_indicateur_hotel_commerce_service']==8){
+									$aPrixVenteCommerce=array();
+									if(!is_null($aRow['avg_commerce'])) array_push($aPrixVenteCommerce,$aRow['avg_commerce']);
+									if(!is_null($aRow['avg_loisir_marchand'])) array_push($aPrixVenteCommerce,$aRow['avg_loisir_marchand']);
+									if(!is_null($aRow['avg_service_act_artisanale'])) array_push($aPrixVenteCommerce,$aRow['avg_service_act_artisanale']);
+									if(count($aPrixVenteCommerce)>0) $iPrixVenteCommerce = round(array_sum($aPrixVenteCommerce)/count($aPrixVenteCommerce));
+									$iPrixVenteHotel = $aRow['avg_hotel'];
+								}
+							}
+							if (isset($aCFCommerce)) $iCFCommerce = round(array_sum($aCFCommerce)/count($aCFCommerce));
+							if (isset($aCFHotel)) $iCFHotel = round(array_sum($aCFHotel)/count($aCFHotel));
+							//get prod/activite
+							$sSql7="SELECT id_indicateur_activite_industrie, round(sum(production_industrie)) AS sum_production_industrie, round(sum(logistique)) AS sum_logistique, round(sum(autre)) AS sum_autre, round(avg(production_industrie)) AS avg_production_industrie, round(avg(logistique)) AS avg_logistique, round(avg(autre)) AS avg_autre FROM ".$sSchema.".activite_industrie".$sWhereIdProgramme." AND id_indicateur_activite_industrie IN (2,3,4,7) GROUP BY id_indicateur_activite_industrie";
+							foreach ($oConn->query($sSql7) as $aRow){
+								if ($aRow['id_indicateur_activite_industrie']==2){
+									$iSdpProd=$aRow['sum_production_industrie'];
+									$iSdpLogistique=$aRow['sum_logistique'];
+									$iSdpActAutre=$aRow['avg_autre'];
+								}
+								if ($aRow['id_indicateur_activite_industrie']==3 or $aRow['id_indicateur_activite_industrie']==4){
+									isset($iCFProd) ? array_push($iCFProd,$aRow['avg_production_industrie']) : $iCFProd=array($aRow['avg_production_industrie']);
+									isset($iCFLogistique) ? array_push($iCFProd,$aRow['avg_logistique']) : $iCFProd=array($aRow['avg_logistique']);
+									isset($iCFActAutre) ? array_push($iCFActAutre,$aRow['avg_autre']) : $iCFActAutre=array($aRow['avg_autre']);
+								}
+								if ($aRow['id_indicateur_activite_industrie']==7){
+									$iPrixVenteProd = $aRow['avg_production_industrie'];
+									$iPrixVenteLogistique = $aRow['avg_logistique'];
+									$iPrixVenteActAutre = $aRow['avg_autre'];
+								}
+							}
+							if (isset($iCFProd)) $iCFProd = round(array_sum($iCFProd)/count($iCFProd));
+							if (isset($iCFLogistique)) $iCFLogistique = round(array_sum($iCFLogistique)/count($iCFLogistique));
+							if (isset($iCFActAutre)) $iCFActAutre = round(array_sum($iCFActAutre)/count($iCFActAutre));
+							// get equipement
+							$oResult5 = $oConn->prepare("SELECT round(sum(sdp)::numeric) AS sdp FROM ".$sSchema.".equipement_structure".$sWhereIdProgramme);
+							$oResult5->execute();
+							$iSdpEquipement = $oResult5->fetch(PDO::FETCH_ASSOC)['sdp'];
+							$oResult5->closeCursor();
+							//get profil
+							$sSql12="SELECT id_type_acheteur_accession_libre, round(sum(nb)) AS nb, round(avg(pourc)) AS pourc FROM ".$sSchema.".profil_acheteur_accession_libre".$sWhereIdProgramme." AND id_type_acheteur_accession_libre IN (1,2) GROUP BY id_type_acheteur_accession_libre";
+							foreach ($oConn->query($sSql12) as $aRow){
+								if ($aRow['id_type_acheteur_accession_libre']==1){
+									$iNbProprioOcc=$aRow['nb'];
+									$iPourcProprioOcc=$aRow['pourc'];
+								}
+								if ($aRow['id_type_acheteur_accession_libre']==2){
+									$iNbInvest=$aRow['nb'];
+									$iPourcInvest=$aRow['pourc'];
+								}
+							}
+							// get granulometrie
+							$aGranulometrie=array();
+							$aGranulometrie2=array('LG_FAM_ACC'=>array('T1'=>0,'T2'=>0,'T3'=>0,'T4'=>0,'T5'=>0,'T6'=>0), 'LG_FAM_LOC'=>array('T1'=>0,'T2'=>0,'T3'=>0,'T4'=>0,'T5'=>0,'T6'=>0), 'TOT_LG_SPE'=>array('T1'=>0,'T2'=>0,'T3'=>0,'T4'=>0,'T5'=>0,'T6'=>0));
+							$aTypeGranulometrie=array('T1','T2','T3','T4','T5','T6','NB');
+							foreach ($aTypeGranulometrie as $sTypeGranulometrie){
+								$aTmp=array();
+								$sSql13="SELECT code_composition_programme, sum(valeur) AS valeur FROM ".$sSchema.".granulometrie".$sWhereIdProgramme." AND code_type_granulometrie ='".$sTypeGranulometrie."' AND code_composition_programme IN ('TOT_LG_SPE','LG_FAM_ACC','LG_FAM_LOC','TOT_LG_FAM') GROUP BY code_composition_programme";
+								foreach ($oConn->query($sSql13) as $aRow){
+									if ($sTypeGranulometrie=='NB' && ($aRow['code_composition_programme']=='TOT_LG_FAM' || $aRow['code_composition_programme']=='TOT_LG_SPE')) $aTmp['TOT'] = $aTmp['TOT'] + $aRow['valeur'];
+									$aTmp[$aRow['code_composition_programme']]=$aRow['valeur'];
+								}
+								if (count($aTmp)>0) $aGranulometrie[$sTypeGranulometrie]=$aTmp;
+								if ($sTypeGranulometrie!='NB') 
+									if (isset($sDataGranulometrie))
+										$sDataGranulometrie=$sDataGranulometrie.','.array_sum($aTmp);
+									else
+										$sDataGranulometrie=array_sum($aTmp);
+							}
+							foreach ($aGranulometrie as $sTypeGranulometrie=>$aValues){
+								if ($sTypeGranulometrie!='NB')
+									foreach ($aValues as $sCodeCompo=>$iValue){
+										if (isset($aGranulometrie2[$sCodeCompo]))
+											$aGranulometrie2[$sCodeCompo][$sTypeGranulometrie]=$aGranulometrie2[$sCodeCompo][$sTypeGranulometrie]+$iValue;
+									}
+									
+							}
+							foreach ($aGranulometrie2 as $sCodeCompo=>$aValues)
+								$aGranulometrie2[$sCodeCompo] = implode(",", $aValues);
+							//echo '<br>'.print_r($aGranulometrie2,true);
+						}
+
+						
+						include ('get_1_operation.html');
+					}else{
+						$sError="Erreur : ".$oResult->rowCount()." opération(s) trouvée(s).";
+						$oResult->closeCursor();
+						include ('get_error.html');
+					}
+				}
+			}catch (PDOException $e){
+				$sError="ERROR : ".$e->getMessage();
+				include ('get_error.html');
+			}
+
+		}else{
+			$sError="ERREUR : Pas d'opération passée en paramètre !";
+			include ('get_error.html');
+		}
+	}
+	
+}else{
+	$sError="ERREUR : Pas de token passé.";
+	include ('get_error.html');
+}
+
 ?>
\ No newline at end of file
diff --git a/src/vitis/vas/doc/suivi_prod_immo/get_2_type.old.php b/src/vitis/vas/doc/suivi_prod_immo/get_2_type.old.php
new file mode 100644
index 0000000000000000000000000000000000000000..188fd2306bb8b10573d4f5acab049ce4200babdf
--- /dev/null
+++ b/src/vitis/vas/doc/suivi_prod_immo/get_2_type.old.php
@@ -0,0 +1,123 @@
+<?php
+// https://geo.urbalyon.org/doc/suivi_prod_immo/get_2_type.php?id_ctm=5
+session_start();
+if (isset($_REQUEST['login'])) $_SESSION['login_bd_prod_immo']=$_REQUEST['login'];
+
+if(isset($_REQUEST['token']) && isset($_SESSION['token_bd_prod_immo'])){
+	if($_REQUEST['token']==$_SESSION['token_bd_prod_immo']){
+
+		if ((isset($_REQUEST['id_ctm']) && !is_null($_REQUEST['id_ctm'])) or (isset($_REQUEST['id_commune']) && !is_null($_REQUEST['id_commune']))){
+			require_once("../../rest/conf/properties.inc");
+			require_once("properties_suivi_prod_immo.inc");
+			$sSchema=$properties['schema_prod_immo'];
+
+			try{
+				$oConn = new PDO('pgsql:host='.$properties['server'].';port='.$properties['port'].';dbname='.$properties['db_prod_immo'], $properties['db_user_prod_immo'], $properties['db_pass_prod_immo']);
+				$oConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+				$oConn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
+				
+				if($oConn){
+					$sFiltre="";
+					// get data Opérations
+					if (isset($_REQUEST['id_ctm'])) $sWhereClause=" WHERE id_ctm=".$_REQUEST['id_ctm'];
+					if (isset($_REQUEST['id_commune'])) $sWhereClause=" WHERE operation.id_commune=".$_REQUEST['id_commune'];
+					$sWhereClause2=$sWhereClause;
+					if (isset($_REQUEST['code_procedure_amenagement']) && !is_null($_REQUEST['code_procedure_amenagement'])){
+						if($sFiltre!='') $sFiltre.="<br>";
+						$sFiltre.="Procédure d'aménagement : ".$_REQUEST['code_procedure_amenagement'];
+						if($_REQUEST['code_procedure_amenagement']=='ND')
+							$sWhereClause2=$sWhereClause2." AND (code_procedure_amenagement='ND' OR code_procedure_amenagement IS NULL)";
+						else
+							$sWhereClause2=$sWhereClause2." AND code_procedure_amenagement='".$_REQUEST['code_procedure_amenagement']."'";
+					}
+					if (isset($_REQUEST['code_financement_equ_public']) && !is_null($_REQUEST['code_financement_equ_public'])){
+						if($sFiltre!='') $sFiltre.="<br>";
+						$sFiltre.="Type de financement : ".$_REQUEST['code_financement_equ_public'];
+						if($_REQUEST['code_financement_equ_public']=='ND')
+							$sWhereClause2=$sWhereClause2." AND (operation_tr_financement_equ_public.code_financement_equ_public='ND' OR operation_tr_financement_equ_public.code_financement_equ_public IS NULL) ";
+						else
+							$sWhereClause2=$sWhereClause2." AND operation_tr_financement_equ_public.code_financement_equ_public='".$_REQUEST['code_financement_equ_public']."'";
+					}
+					if (isset($_REQUEST['code_suivi']) && !is_null($_REQUEST['code_suivi'])){
+						if($sFiltre!='') $sFiltre.="<br>";
+						$sFiltre.="Suivi de l'opération : ".$_REQUEST['code_suivi'];
+						if($_REQUEST['code_suivi']=='ND')
+							$sWhereClause2=$sWhereClause2." AND (code_suivi='ND' OR code_suivi IS NULL) ";
+						else
+							$sWhereClause2=$sWhereClause2." AND code_suivi='".$_REQUEST['code_suivi']."'";
+					}
+					
+					if (isset($_REQUEST['id_ctm'])){
+						$oResult = $oConn->prepare("SELECT nom_ctm, ST_XMin(ST_Buffer(geom,150)) AS xmin, ST_YMin(ST_Buffer(geom,150)) AS ymin, ST_XMax(ST_Buffer(geom,150)) AS xmax, ST_YMax(ST_Buffer(geom,150)) AS ymax FROM ".$sSchema.".conference_territoriale_maire ".$sWhereClause);
+						$sNameMapImage="ctm_".$_REQUEST['id_ctm']."_porteur.png";
+					}
+					if (isset($_REQUEST['id_commune'])){
+						$oResult = $oConn->prepare("SELECT nom_commune, ST_XMin(ST_Buffer(geom,150)) AS xmin, ST_YMin(ST_Buffer(geom,150)) AS ymin, ST_XMax(ST_Buffer(geom,150)) AS xmax, ST_YMax(ST_Buffer(geom,150)) AS ymax FROM ".$sSchema.".commune WHERE id_commune=".$_REQUEST['id_commune']);
+						$sNameMapImage="commune_".$_REQUEST['id_commune']."_porteur.png";
+					}
+					$oResult->execute();
+
+					if ($oResult->rowCount()>0){
+						$aCTM = $oResult->fetchAll();
+						$aCTM = $aCTM[0];
+						$oResult->closeCursor();
+						// get map image
+						$aIdOperation=array();
+						// echo "SELECT id_ctm, array_to_string(array_agg(operation.id_operation), ',') AS id_operation	FROM (".$sSchema.".operation INNER JOIN ".$sSchema.".operation_ctm ON operation.id_operation=operation_ctm.id_operation) INNER JOIN ".$sSchema.".operation_tr_financement_equ_public ON operation.id_operation=operation_tr_financement_equ_public.id_operation ".$sWhereClause2." GROUP BY id_ctm";
+						$oResult2 = $oConn->prepare("SELECT id_ctm, array_to_string(array_agg(operation.id_operation), ',') AS id_operation	FROM (".$sSchema.".operation INNER JOIN ".$sSchema.".operation_ctm ON operation.id_operation=operation_ctm.id_operation) INNER JOIN ".$sSchema.".operation_tr_financement_equ_public ON operation.id_operation=operation_tr_financement_equ_public.id_operation ".$sWhereClause2." GROUP BY id_ctm");
+						$oResult2->execute();
+						$aOperations = $oResult2->fetchAll();
+						$oResult2->closeCursor();
+						if(count($aOperations[0])>0){
+							$aOperations = $aOperations[0];
+							$sCommand = escapeshellcmd('python get_map_image_2_type.py '.$aCTM['xmin'].' '.$aCTM['ymin'].' '.$aCTM['xmax'].' '.$aCTM['ymax'].' '.$sNameMapImage.' '.$aOperations['id_operation']);
+							// echo $sCommand;
+							$output = shell_exec($sCommand);/**/
+							$sUrlMapImage=$properties['web_server_name']."/ws_data/vm4ms/map/tmp/".$sNameMapImage;
+							$sSql="SELECT code_financement_equ_public, count(DISTINCT id_programme), array_to_string(array_agg(id_programme), ',') AS id_programme, round(avg(charge_fonciere_moy)) AS charge_fonciere_moy FROM (SELECT id_programme, CASE WHEN operation_tr_financement_equ_public.code_financement_equ_public='PUP' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='FINZAC' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='TA' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='TAM' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='AUT' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='PEPE' THEN operation_tr_financement_equ_public.code_financement_equ_public ELSE 'ND' END AS code_financement_equ_public, charge_fonciere_moy FROM (((".$sSchema.".operation LEFT JOIN ".$sSchema.".operation_tr_financement_equ_public ON operation.id_operation=operation_tr_financement_equ_public.id_operation) INNER JOIN ".$sSchema.".ilot ON ilot.id_operation=operation.id_operation) INNER JOIN ".$sSchema.".programme_immobilier ON programme_immobilier.id_ilot=ilot.id_ilot) INNER JOIN ".$sSchema.".operation_ctm ON operation_ctm.id_operation=operation.id_operation ".$sWhereClause2.") AS t GROUP BY code_financement_equ_public";
+							// echo $sSql;
+							$aPourcCFPV=$aPV=$aCF=$aNb=array();
+							foreach ($oConn->query($sSql) as $aRow){
+								if(!is_null($aRow['count'])) $aNb[$aRow['code_financement_equ_public']]=$aRow['count'];
+								if(!is_null($aRow['charge_fonciere_moy'])) $aCF[$aRow['code_financement_equ_public']]=$aRow['charge_fonciere_moy'];
+								$oResult3 = $oConn->prepare("SELECT round((COALESCE(avg1, 0) + COALESCE(avg2, 0) + COALESCE(avg3, 0) + COALESCE(avg4)) / ( CASE WHEN avg1 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg2 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg3 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg4 IS NULL THEN 0 ELSE 1 END)) AS pv_moy FROM (SELECT  round(avg(accession_libre)) AS avg1, round(avg(accession_abordable)) AS avg2, round(avg(accesion_sociale_securise)) AS avg3, round(avg(psla)) AS avg4	FROM ".$sSchema.".logement_familliaux_accession	WHERE id_programme IN (".$aRow['id_programme'].") AND id_indicateur_logement_familliaux_accession IN (8,9)) AS t");
+								$oResult3->execute();
+								$aPrixVenteMoy = $oResult3->fetchAll();
+								if (isset($aPrixVenteMoy[0])) $aPV[$aRow['code_financement_equ_public']]=$aPrixVenteMoy[0]['pv_moy'];
+								$oResult3->closeCursor();
+							}
+							if(isset($aCF['PUP']) && isset($aPV['PUP'])) $aPourcCFPV['PUP']=round(($aCF['PUP']/$aPV['PUP'])*100,1);
+							if(isset($aCF['FINZAC']) && isset($aPV['FINZAC'])) $aPourcCFPV['FINZAC']=round(($aCF['FINZAC']/$aPV['FINZAC'])*100,1);
+							if(isset($aCF['TA']) && isset($aPV['TA'])) $aPourcCFPV['TA']=round(($aCF['TA']/$aPV['TA'])*100,1);
+							if(isset($aCF['TAM']) && isset($aPV['TAM'])) $aPourcCFPV['TAM']=round(($aCF['TAM']/$aPV['TAM'])*100,1);
+							if(isset($aCF['PEPE']) && isset($aPV['PEPE'])) $aPourcCFPV['PEPE']=round(($aCF['PEPE']/$aPV['PEPE'])*100,1);
+							if(isset($aCF['AUT']) && isset($aPV['AUT'])) $aPourcCFPV['AUT']=round(($aCF['AUT']/$aPV['AUT'])*100,1);
+							if(isset($aCF['ND']) && isset($aPV['ND'])) $aPourcCFPV['ND']=round(($aCF['ND']/$aPV['ND'])*100,1);
+							// Moyenne pondérée au nombre d'opération total
+							// TODO pondérer au nombre d'opération ayant une valeur
+						}
+						include ('get_2_type.html');
+					}else{
+						$sError="Erreur : ".$oResult->rowCount()." conférence des maires trouvée.";
+						$oResult->closeCursor();
+						include ('get_error.html');
+					}
+				}
+			}catch (PDOException $e){
+				$sError="ERROR : ".$e->getMessage();
+				include ('get_error.html');
+			}
+
+		}else{
+			$sError="ERREUR : Pas de CTM ou de communes passé en paramètre !";
+			include ('get_error.html');
+		}
+	}else{
+		header ('location: signin.php');
+		exit();
+	}
+}else{
+	header ('location: signin.php');
+	exit();
+}
+?>
\ No newline at end of file
diff --git a/src/vitis/vas/doc/suivi_prod_immo/get_2_type.php b/src/vitis/vas/doc/suivi_prod_immo/get_2_type.php
index 7584b67d697a57b63a96ee32d1fb92ce7f2824c4..3a50e02bbf8f5486be7d75b52c9d2a88e64bc29f 100644
--- a/src/vitis/vas/doc/suivi_prod_immo/get_2_type.php
+++ b/src/vitis/vas/doc/suivi_prod_immo/get_2_type.php
@@ -1,123 +1,125 @@
-<?php
-// https://geo.urbalyon.org/doc/suivi_prod_immo/get_2_type.php?id_ctm=5
-session_start();
-if (isset($_REQUEST['login'])) $_SESSION['login_bd_prod_immo']=$_REQUEST['login'];
-
-if(isset($_REQUEST['token']) && isset($_SESSION['token_bd_prod_immo'])){
-	if($_REQUEST['token']==$_SESSION['token_bd_prod_immo']){
-
-		if ((isset($_REQUEST['id_ctm']) && !is_null($_REQUEST['id_ctm'])) or (isset($_REQUEST['id_commune']) && !is_null($_REQUEST['id_commune']))){
-			require_once("../../rest/conf/properties.inc");
-			require_once("properties_suivi_prod_immo.inc");
-			$sSchema=$properties['schema_prod_immo'];
-
-			try{
-				$oConn = new PDO('pgsql:host='.$properties['server'].';port='.$properties['port'].';dbname='.$properties['db_prod_immo'], $properties['db_user_prod_immo'], $properties['db_pass_prod_immo']);
-				$oConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-				$oConn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
-				
-				if($oConn){
-					$sFiltre="";
-					// get data Opérations
-					if (isset($_REQUEST['id_ctm'])) $sWhereClause=" WHERE id_ctm=".$_REQUEST['id_ctm'];
-					if (isset($_REQUEST['id_commune'])) $sWhereClause=" WHERE operation.id_commune=".$_REQUEST['id_commune'];
-					$sWhereClause2=$sWhereClause;
-					if (isset($_REQUEST['code_procedure_amenagement']) && !is_null($_REQUEST['code_procedure_amenagement'])){
-						if($sFiltre!='') $sFiltre.="<br>";
-						$sFiltre.="Procédure d'aménagement : ".$_REQUEST['code_procedure_amenagement'];
-						if($_REQUEST['code_procedure_amenagement']=='ND')
-							$sWhereClause2=$sWhereClause2." AND (code_procedure_amenagement='ND' OR code_procedure_amenagement IS NULL)";
-						else
-							$sWhereClause2=$sWhereClause2." AND code_procedure_amenagement='".$_REQUEST['code_procedure_amenagement']."'";
-					}
-					if (isset($_REQUEST['code_financement_equ_public']) && !is_null($_REQUEST['code_financement_equ_public'])){
-						if($sFiltre!='') $sFiltre.="<br>";
-						$sFiltre.="Type de financement : ".$_REQUEST['code_financement_equ_public'];
-						if($_REQUEST['code_financement_equ_public']=='ND')
-							$sWhereClause2=$sWhereClause2." AND (operation_tr_financement_equ_public.code_financement_equ_public='ND' OR operation_tr_financement_equ_public.code_financement_equ_public IS NULL) ";
-						else
-							$sWhereClause2=$sWhereClause2." AND operation_tr_financement_equ_public.code_financement_equ_public='".$_REQUEST['code_financement_equ_public']."'";
-					}
-					if (isset($_REQUEST['code_suivi']) && !is_null($_REQUEST['code_suivi'])){
-						if($sFiltre!='') $sFiltre.="<br>";
-						$sFiltre.="Suivi de l'opération : ".$_REQUEST['code_suivi'];
-						if($_REQUEST['code_suivi']=='ND')
-							$sWhereClause2=$sWhereClause2." AND (code_suivi='ND' OR code_suivi IS NULL) ";
-						else
-							$sWhereClause2=$sWhereClause2." AND code_suivi='".$_REQUEST['code_suivi']."'";
-					}
-					
-					if (isset($_REQUEST['id_ctm'])){
-						$oResult = $oConn->prepare("SELECT nom_ctm, ST_XMin(ST_Buffer(geom,150)) AS xmin, ST_YMin(ST_Buffer(geom,150)) AS ymin, ST_XMax(ST_Buffer(geom,150)) AS xmax, ST_YMax(ST_Buffer(geom,150)) AS ymax FROM ".$sSchema.".conference_territoriale_maire ".$sWhereClause);
-						$sNameMapImage="ctm_".$_REQUEST['id_ctm']."_porteur.png";
-					}
-					if (isset($_REQUEST['id_commune'])){
-						$oResult = $oConn->prepare("SELECT nom_commune, ST_XMin(ST_Buffer(geom,150)) AS xmin, ST_YMin(ST_Buffer(geom,150)) AS ymin, ST_XMax(ST_Buffer(geom,150)) AS xmax, ST_YMax(ST_Buffer(geom,150)) AS ymax FROM ".$sSchema.".commune WHERE id_commune=".$_REQUEST['id_commune']);
-						$sNameMapImage="commune_".$_REQUEST['id_commune']."_porteur.png";
-					}
-					$oResult->execute();
-
-					if ($oResult->rowCount()>0){
-						$aCTM = $oResult->fetchAll();
-						$aCTM = $aCTM[0];
-						$oResult->closeCursor();
-						// get map image
-						$aIdOperation=array();
-						// echo "SELECT id_ctm, array_to_string(array_agg(operation.id_operation), ',') AS id_operation	FROM (".$sSchema.".operation INNER JOIN ".$sSchema.".operation_ctm ON operation.id_operation=operation_ctm.id_operation) INNER JOIN ".$sSchema.".operation_tr_financement_equ_public ON operation.id_operation=operation_tr_financement_equ_public.id_operation ".$sWhereClause2." GROUP BY id_ctm";
-						$oResult2 = $oConn->prepare("SELECT id_ctm, array_to_string(array_agg(operation.id_operation), ',') AS id_operation	FROM (".$sSchema.".operation INNER JOIN ".$sSchema.".operation_ctm ON operation.id_operation=operation_ctm.id_operation) INNER JOIN ".$sSchema.".operation_tr_financement_equ_public ON operation.id_operation=operation_tr_financement_equ_public.id_operation ".$sWhereClause2." GROUP BY id_ctm");
-						$oResult2->execute();
-						$aOperations = $oResult2->fetchAll();
-						$oResult2->closeCursor();
-						if(count($aOperations[0])>0){
-							$aOperations = $aOperations[0];
-							$sCommand = escapeshellcmd('python get_map_image_2_type.py '.$aCTM['xmin'].' '.$aCTM['ymin'].' '.$aCTM['xmax'].' '.$aCTM['ymax'].' '.$sNameMapImage.' '.$aOperations['id_operation']);
-							// echo $sCommand;
-							$output = shell_exec($sCommand);/**/
-							$sUrlMapImage=$properties['web_server_name']."/ws_data/vm4ms/map/tmp/".$sNameMapImage;
-							$sSql="SELECT code_financement_equ_public, count(DISTINCT id_programme), array_to_string(array_agg(id_programme), ',') AS id_programme, round(avg(charge_fonciere_moy::numeric)) AS charge_fonciere_moy FROM (SELECT id_programme, CASE WHEN operation_tr_financement_equ_public.code_financement_equ_public='PUP' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='FINZAC' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='TA' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='TAM' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='AUT' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='PEPE' THEN operation_tr_financement_equ_public.code_financement_equ_public ELSE 'ND' END AS code_financement_equ_public, charge_fonciere_moy FROM (((".$sSchema.".operation LEFT JOIN ".$sSchema.".operation_tr_financement_equ_public ON operation.id_operation=operation_tr_financement_equ_public.id_operation) INNER JOIN ".$sSchema.".ilot ON ilot.id_operation=operation.id_operation) INNER JOIN ".$sSchema.".programme_immobilier ON programme_immobilier.id_ilot=ilot.id_ilot) INNER JOIN ".$sSchema.".operation_ctm ON operation_ctm.id_operation=operation.id_operation ".$sWhereClause2.") AS t GROUP BY code_financement_equ_public";
-							// echo $sSql;
-							$aPourcCFPV=$aPV=$aCF=$aNb=array();
-							foreach ($oConn->query($sSql) as $aRow){
-								if(!is_null($aRow['count'])) $aNb[$aRow['code_financement_equ_public']]=$aRow['count'];
-								if(!is_null($aRow['charge_fonciere_moy'])) $aCF[$aRow['code_financement_equ_public']]=$aRow['charge_fonciere_moy'];
-								$oResult3 = $oConn->prepare("SELECT round((COALESCE(avg1, 0) + COALESCE(avg2, 0) + COALESCE(avg3, 0) + COALESCE(avg4)) / ( CASE WHEN avg1 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg2 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg3 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg4 IS NULL THEN 0 ELSE 1 END)) AS pv_moy FROM (SELECT  round(avg(accession_libre::numeric)) AS avg1, round(avg(accession_abordable::numeric)) AS avg2, round(avg(accession_sociale_securise::numeric)) AS avg3, round(avg(psla::numeric)) AS avg4	FROM ".$sSchema.".logement_familliaux_accession	WHERE id_programme IN (".$aRow['id_programme'].") AND id_indicateur_logement_familliaux_accession IN (8,9)) AS t");
-								$oResult3->execute();
-								$aPrixVenteMoy = $oResult3->fetchAll();
-								if (isset($aPrixVenteMoy[0])) $aPV[$aRow['code_financement_equ_public']]=$aPrixVenteMoy[0]['pv_moy'];
-								$oResult3->closeCursor();
-							}
-							if(isset($aCF['PUP']) && isset($aPV['PUP'])) $aPourcCFPV['PUP']=round(($aCF['PUP']/$aPV['PUP'])*100,1);
-							if(isset($aCF['FINZAC']) && isset($aPV['FINZAC'])) $aPourcCFPV['FINZAC']=round(($aCF['FINZAC']/$aPV['FINZAC'])*100,1);
-							if(isset($aCF['TA']) && isset($aPV['TA'])) $aPourcCFPV['TA']=round(($aCF['TA']/$aPV['TA'])*100,1);
-							if(isset($aCF['TAM']) && isset($aPV['TAM'])) $aPourcCFPV['TAM']=round(($aCF['TAM']/$aPV['TAM'])*100,1);
-							if(isset($aCF['PEPE']) && isset($aPV['PEPE'])) $aPourcCFPV['PEPE']=round(($aCF['PEPE']/$aPV['PEPE'])*100,1);
-							if(isset($aCF['AUT']) && isset($aPV['AUT'])) $aPourcCFPV['AUT']=round(($aCF['AUT']/$aPV['AUT'])*100,1);
-							if(isset($aCF['ND']) && isset($aPV['ND'])) $aPourcCFPV['ND']=round(($aCF['ND']/$aPV['ND'])*100,1);
-							// Moyenne pondérée au nombre d'opération total
-							// TODO pondérer au nombre d'opération ayant une valeur
-						}
-						include ('get_2_type.html');
-					}else{
-						$sError="Erreur : ".$oResult->rowCount()." conférence des maires trouvée.";
-						$oResult->closeCursor();
-						include ('get_error.html');
-					}
-				}
-			}catch (PDOException $e){
-				$sError="ERROR : ".$e->getMessage();
-				include ('get_error.html');
-			}
-
-		}else{
-			$sError="ERREUR : Pas de CTM ou de communes passé en paramètre !";
-			include ('get_error.html');
-		}
-	}else{
-		header ('location: signin.php');
-		exit();
-	}
-}else{
-	header ('location: signin.php');
-	exit();
-}
+<?php
+// https://geo.urbalyon.org/doc/suivi_prod_immo/get_2_type.php?id_ctm=5
+if (isset($_REQUEST['token']) && !is_null($_REQUEST['token'])){
+	session_id($_REQUEST['token']);
+	if (session_status() == PHP_SESSION_NONE)
+		session_start();
+
+	if (empty($_SESSION)) {
+		$sError="ERREUR : token invalide.";
+		include ('get_error.html');
+	}else{
+
+		if ((isset($_REQUEST['id_ctm']) && !is_null($_REQUEST['id_ctm'])) or (isset($_REQUEST['id_commune']) && !is_null($_REQUEST['id_commune']))){
+			require_once("../../rest/conf/properties.inc");
+			require_once("properties_suivi_prod_immo.inc");
+			$sSchema=$properties['schema_prod_immo'];
+
+			try{
+				$oConn = new PDO('pgsql:host='.$properties['server'].';port='.$properties['port'].';dbname='.$properties['db_prod_immo'], $properties['db_user_prod_immo'], $properties['db_pass_prod_immo']);
+				$oConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+				$oConn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
+				
+				if($oConn){
+					$sFiltre="";
+					// get data Opérations
+					if (isset($_REQUEST['id_ctm'])) $sWhereClause=" WHERE id_ctm=".$_REQUEST['id_ctm'];
+					if (isset($_REQUEST['id_commune'])) $sWhereClause=" WHERE operation.id_commune=".$_REQUEST['id_commune'];
+					$sWhereClause2=$sWhereClause;
+					if (isset($_REQUEST['code_procedure_amenagement']) && !is_null($_REQUEST['code_procedure_amenagement'])){
+						if($sFiltre!='') $sFiltre.="<br>";
+						$sFiltre.="Procédure d'aménagement : ".$_REQUEST['code_procedure_amenagement'];
+						if($_REQUEST['code_procedure_amenagement']=='ND')
+							$sWhereClause2=$sWhereClause2." AND (code_procedure_amenagement='ND' OR code_procedure_amenagement IS NULL)";
+						else
+							$sWhereClause2=$sWhereClause2." AND code_procedure_amenagement='".$_REQUEST['code_procedure_amenagement']."'";
+					}
+					if (isset($_REQUEST['code_financement_equ_public']) && !is_null($_REQUEST['code_financement_equ_public'])){
+						if($sFiltre!='') $sFiltre.="<br>";
+						$sFiltre.="Type de financement : ".$_REQUEST['code_financement_equ_public'];
+						if($_REQUEST['code_financement_equ_public']=='ND')
+							$sWhereClause2=$sWhereClause2." AND (operation_tr_financement_equ_public.code_financement_equ_public='ND' OR operation_tr_financement_equ_public.code_financement_equ_public IS NULL) ";
+						else
+							$sWhereClause2=$sWhereClause2." AND operation_tr_financement_equ_public.code_financement_equ_public='".$_REQUEST['code_financement_equ_public']."'";
+					}
+					if (isset($_REQUEST['code_suivi']) && !is_null($_REQUEST['code_suivi'])){
+						if($sFiltre!='') $sFiltre.="<br>";
+						$sFiltre.="Suivi de l'opération : ".$_REQUEST['code_suivi'];
+						if($_REQUEST['code_suivi']=='ND')
+							$sWhereClause2=$sWhereClause2." AND (code_suivi='ND' OR code_suivi IS NULL) ";
+						else
+							$sWhereClause2=$sWhereClause2." AND code_suivi='".$_REQUEST['code_suivi']."'";
+					}
+					
+					if (isset($_REQUEST['id_ctm'])){
+						$oResult = $oConn->prepare("SELECT nom_ctm, ST_XMin(ST_Buffer(geom,150)) AS xmin, ST_YMin(ST_Buffer(geom,150)) AS ymin, ST_XMax(ST_Buffer(geom,150)) AS xmax, ST_YMax(ST_Buffer(geom,150)) AS ymax FROM ".$sSchema.".conference_territoriale_maire ".$sWhereClause);
+						$sNameMapImage="ctm_".$_REQUEST['id_ctm']."_porteur.png";
+					}
+					if (isset($_REQUEST['id_commune'])){
+						$oResult = $oConn->prepare("SELECT nom_commune, ST_XMin(ST_Buffer(geom,150)) AS xmin, ST_YMin(ST_Buffer(geom,150)) AS ymin, ST_XMax(ST_Buffer(geom,150)) AS xmax, ST_YMax(ST_Buffer(geom,150)) AS ymax FROM ".$sSchema.".commune WHERE id_commune=".$_REQUEST['id_commune']);
+						$sNameMapImage="commune_".$_REQUEST['id_commune']."_porteur.png";
+					}
+					$oResult->execute();
+
+					if ($oResult->rowCount()>0){
+						$aCTM = $oResult->fetchAll();
+						$aCTM = $aCTM[0];
+						$oResult->closeCursor();
+						// get map image
+						$aIdOperation=array();
+						// echo "SELECT id_ctm, array_to_string(array_agg(operation.id_operation), ',') AS id_operation	FROM (".$sSchema.".operation INNER JOIN ".$sSchema.".operation_ctm ON operation.id_operation=operation_ctm.id_operation) INNER JOIN ".$sSchema.".operation_tr_financement_equ_public ON operation.id_operation=operation_tr_financement_equ_public.id_operation ".$sWhereClause2." GROUP BY id_ctm";
+						$oResult2 = $oConn->prepare("SELECT id_ctm, array_to_string(array_agg(operation.id_operation), ',') AS id_operation	FROM (".$sSchema.".operation INNER JOIN ".$sSchema.".operation_ctm ON operation.id_operation=operation_ctm.id_operation) INNER JOIN ".$sSchema.".operation_tr_financement_equ_public ON operation.id_operation=operation_tr_financement_equ_public.id_operation ".$sWhereClause2." GROUP BY id_ctm");
+						$oResult2->execute();
+						$aOperations = $oResult2->fetchAll();
+						$oResult2->closeCursor();
+						if(count($aOperations[0])>0){
+							$aOperations = $aOperations[0];
+							$sCommand = escapeshellcmd('python get_map_image_2_type.py '.$aCTM['xmin'].' '.$aCTM['ymin'].' '.$aCTM['xmax'].' '.$aCTM['ymax'].' '.$sNameMapImage.' '.$aOperations['id_operation']);
+							// echo $sCommand;
+							$output = shell_exec($sCommand);/**/
+							$sUrlMapImage=$properties['web_server_name']."/ws_data/vm4ms/map/tmp/".$sNameMapImage;
+							$sSql="SELECT code_financement_equ_public, count(DISTINCT id_programme), array_to_string(array_agg(id_programme), ',') AS id_programme, round(avg(charge_fonciere_moy::numeric)) AS charge_fonciere_moy FROM (SELECT id_programme, CASE WHEN operation_tr_financement_equ_public.code_financement_equ_public='PUP' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='FINZAC' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='TA' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='TAM' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='AUT' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='PEPE' THEN operation_tr_financement_equ_public.code_financement_equ_public ELSE 'ND' END AS code_financement_equ_public, charge_fonciere_moy FROM (((".$sSchema.".operation LEFT JOIN ".$sSchema.".operation_tr_financement_equ_public ON operation.id_operation=operation_tr_financement_equ_public.id_operation) INNER JOIN ".$sSchema.".ilot ON ilot.id_operation=operation.id_operation) INNER JOIN ".$sSchema.".programme_immobilier ON programme_immobilier.id_ilot=ilot.id_ilot) INNER JOIN ".$sSchema.".operation_ctm ON operation_ctm.id_operation=operation.id_operation ".$sWhereClause2.") AS t GROUP BY code_financement_equ_public";
+							// echo $sSql;
+							$aPourcCFPV=$aPV=$aCF=$aNb=array();
+							foreach ($oConn->query($sSql) as $aRow){
+								if(!is_null($aRow['count'])) $aNb[$aRow['code_financement_equ_public']]=$aRow['count'];
+								if(!is_null($aRow['charge_fonciere_moy'])) $aCF[$aRow['code_financement_equ_public']]=$aRow['charge_fonciere_moy'];
+								$oResult3 = $oConn->prepare("SELECT round((COALESCE(avg1, 0) + COALESCE(avg2, 0) + COALESCE(avg3, 0) + COALESCE(avg4)) / ( CASE WHEN avg1 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg2 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg3 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg4 IS NULL THEN 0 ELSE 1 END)) AS pv_moy FROM (SELECT  round(avg(accession_libre::numeric)) AS avg1, round(avg(accession_abordable::numeric)) AS avg2, round(avg(accession_sociale_securise::numeric)) AS avg3, round(avg(psla::numeric)) AS avg4	FROM ".$sSchema.".logement_familliaux_accession	WHERE id_programme IN (".$aRow['id_programme'].") AND id_indicateur_logement_familliaux_accession IN (8,9)) AS t");
+								$oResult3->execute();
+								$aPrixVenteMoy = $oResult3->fetchAll();
+								if (isset($aPrixVenteMoy[0])) $aPV[$aRow['code_financement_equ_public']]=$aPrixVenteMoy[0]['pv_moy'];
+								$oResult3->closeCursor();
+							}
+							if(isset($aCF['PUP']) && isset($aPV['PUP'])) $aPourcCFPV['PUP']=round(($aCF['PUP']/$aPV['PUP'])*100,1);
+							if(isset($aCF['FINZAC']) && isset($aPV['FINZAC'])) $aPourcCFPV['FINZAC']=round(($aCF['FINZAC']/$aPV['FINZAC'])*100,1);
+							if(isset($aCF['TA']) && isset($aPV['TA'])) $aPourcCFPV['TA']=round(($aCF['TA']/$aPV['TA'])*100,1);
+							if(isset($aCF['TAM']) && isset($aPV['TAM'])) $aPourcCFPV['TAM']=round(($aCF['TAM']/$aPV['TAM'])*100,1);
+							if(isset($aCF['PEPE']) && isset($aPV['PEPE'])) $aPourcCFPV['PEPE']=round(($aCF['PEPE']/$aPV['PEPE'])*100,1);
+							if(isset($aCF['AUT']) && isset($aPV['AUT'])) $aPourcCFPV['AUT']=round(($aCF['AUT']/$aPV['AUT'])*100,1);
+							if(isset($aCF['ND']) && isset($aPV['ND'])) $aPourcCFPV['ND']=round(($aCF['ND']/$aPV['ND'])*100,1);
+							// Moyenne pondérée au nombre d'opération total
+							// TODO pondérer au nombre d'opération ayant une valeur
+						}
+						include ('get_2_type.html');
+					}else{
+						$sError="Erreur : ".$oResult->rowCount()." conférence des maires trouvée.";
+						$oResult->closeCursor();
+						include ('get_error.html');
+					}
+				}
+			}catch (PDOException $e){
+				$sError="ERROR : ".$e->getMessage();
+				include ('get_error.html');
+			}
+
+		}else{
+			$sError="ERREUR : Pas de CTM ou de communes passé en paramètre !";
+			include ('get_error.html');
+		}
+	}
+	
+}else{
+	$sError="ERREUR : Pas de token passé.";
+	include ('get_error.html');
+}
 ?>
\ No newline at end of file
diff --git a/src/vitis/vas/doc/suivi_prod_immo/get_3_porteur.old.php b/src/vitis/vas/doc/suivi_prod_immo/get_3_porteur.old.php
new file mode 100644
index 0000000000000000000000000000000000000000..eaa4aa375b480f6b96b1cf371baa5796c6cf454b
--- /dev/null
+++ b/src/vitis/vas/doc/suivi_prod_immo/get_3_porteur.old.php
@@ -0,0 +1,109 @@
+<?php
+// https://geo.urbalyon.org/doc/suivi_prod_immo/get_1_operation.php?id_operation=1041
+session_start();
+if (isset($_REQUEST['login'])) $_SESSION['login_bd_prod_immo']=$_REQUEST['login'];
+
+if(isset($_REQUEST['token']) && isset($_SESSION['token_bd_prod_immo'])){
+	if($_REQUEST['token']==$_SESSION['token_bd_prod_immo']){
+
+		if (isset($_REQUEST['nom_amenageur']) && !is_null($_REQUEST['nom_amenageur'])){
+			require_once("../../rest/conf/properties.inc");
+			require_once("properties_suivi_prod_immo.inc");
+			$sSchema=$properties['schema_prod_immo'];
+
+			try{
+				$oConn = new PDO('pgsql:host='.$properties['server'].';port='.$properties['port'].';dbname='.$properties['db_prod_immo'], $properties['db_user_prod_immo'], $properties['db_pass_prod_immo']);
+				$oConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+				$oConn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
+				
+				if($oConn){
+					// get data Opérations
+					$sWhereAmenageur=" WHERE nom_amenageur='".$_REQUEST['nom_amenageur']."'";
+					$oResult = $oConn->prepare("SELECT * FROM ".$sSchema.".v_operation_layer".$sWhereAmenageur);
+					$oResult->execute();
+
+					if ($oResult->rowCount()>0){
+						$iNbOperation=$oResult->rowCount();
+						$aOperations = $oResult->fetchAll();
+						$oResult->closeCursor();
+						// get map image
+						$aIdOperation=array();
+						foreach ($aOperations as $aOperation)
+							array_push($aIdOperation, $aOperation["id_operation"]);
+						$sNameMapImage=strtolower(preg_replace("#[^a-zA-Z]#", "", str_replace(' ', '_', $_REQUEST['nom_amenageur'])))."_porteur.png";
+						$oResult2 = $oConn->prepare("SELECT round(st_xmin(st_buffer(st_envelope(st_union(geom)),150))) AS xmin, round(st_ymin(st_buffer(st_envelope(st_union(geom)),150))) AS ymin, round(st_ymax(st_buffer(st_envelope(st_union(geom)),150))) AS ymax, round(st_xmax(st_buffer(st_envelope(st_union(geom)),150))) AS xmax FROM ".$sSchema.".operation".$sWhereAmenageur);
+						$oResult2->execute();
+						$aOperations2 = $oResult2->fetchAll();
+						$oResult2->closeCursor();
+						$aOperations2 = $aOperations2[0];
+						$sCommand = escapeshellcmd('python get_map_image_3_porteur.py '.$aOperations2['xmin'].' '.$aOperations2['ymin'].' '.$aOperations2['xmax'].' '.$aOperations2['ymax'].' '.$sNameMapImage.' '.implode(",", $aIdOperation));
+						// echo $sCommand;
+						$output = shell_exec($sCommand);/**/
+						$sUrlMapImage=$properties['web_server_name']."/ws_data/vm4ms/map/tmp/".$sNameMapImage;
+						
+						$sSql="SELECT code_financement_equ_public, count(DISTINCT id_programme), array_to_string(array_agg(id_programme), ',') AS id_programme, round(avg(charge_fonciere_moy)) AS charge_fonciere_moy FROM (SELECT id_programme, CASE WHEN operation_tr_financement_equ_public.code_financement_equ_public='PUP' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='FINZAC' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='TA' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='TAM' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='AUT' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='PEPE' THEN operation_tr_financement_equ_public.code_financement_equ_public ELSE 'ND' END AS code_financement_equ_public, charge_fonciere_moy FROM ((".$sSchema.".operation LEFT JOIN ".$sSchema.".operation_tr_financement_equ_public ON operation.id_operation=operation_tr_financement_equ_public.id_operation) INNER JOIN ".$sSchema.".ilot ON ilot.id_operation=operation.id_operation) INNER JOIN ".$sSchema.".programme_immobilier ON programme_immobilier.id_ilot=ilot.id_ilot ".$sWhereAmenageur.") AS t GROUP BY code_financement_equ_public";
+						$aPourcCFPV=$aPV=$aCF=$aNb=array();
+						foreach ($oConn->query($sSql) as $aRow){
+							if(!is_null($aRow['count'])) $aNb[$aRow['code_financement_equ_public']]=$aRow['count'];
+							if(!is_null($aRow['charge_fonciere_moy'])) $aCF[$aRow['code_financement_equ_public']]=$aRow['charge_fonciere_moy'];
+							$oResult3 = $oConn->prepare("SELECT round((COALESCE(avg1, 0) + COALESCE(avg2, 0) + COALESCE(avg3, 0) + COALESCE(avg4)) / ( CASE WHEN avg1 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg2 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg3 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg4 IS NULL THEN 0 ELSE 1 END)) AS pv_moy FROM (SELECT  round(avg(accession_libre)) AS avg1, round(avg(accession_abordable)) AS avg2, round(avg(accesion_sociale_securise)) AS avg3, round(avg(psla)) AS avg4	FROM ".$sSchema.".logement_familliaux_accession	WHERE id_programme IN (".$aRow['id_programme'].") AND id_indicateur_logement_familliaux_accession IN (8,9)) AS t");
+							$oResult3->execute();
+							$aPrixVenteMoy = $oResult3->fetchAll();
+							if (isset($aPrixVenteMoy[0])) $aPV[$aRow['code_financement_equ_public']]=$aPrixVenteMoy[0]['pv_moy'];
+							$oResult3->closeCursor();
+						}
+						if(isset($aCF['PUP']) && isset($aPV['PUP'])) $aPourcCFPV['PUP']=round(($aCF['PUP']/$aPV['PUP'])*100,1);
+						if(isset($aCF['FINZAC']) && isset($aPV['FINZAC'])) $aPourcCFPV['FINZAC']=round(($aCF['FINZAC']/$aPV['FINZAC'])*100,1);
+						if(isset($aCF['TA']) && isset($aPV['TA'])) $aPourcCFPV['TA']=round(($aCF['TA']/$aPV['TA'])*100,1);
+						if(isset($aCF['TAM']) && isset($aPV['TAM'])) $aPourcCFPV['TAM']=round(($aCF['TAM']/$aPV['TAM'])*100,1);
+						if(isset($aCF['PEPE']) && isset($aPV['PEPE'])) $aPourcCFPV['PEPE']=round(($aCF['PEPE']/$aPV['PEPE'])*100,1);
+						if(isset($aCF['AUT']) && isset($aPV['AUT'])) $aPourcCFPV['AUT']=round(($aCF['AUT']/$aPV['AUT'])*100,1);
+						if(isset($aCF['ND']) && isset($aPV['ND'])) $aPourcCFPV['ND']=round(($aCF['ND']/$aPV['ND'])*100,1);
+						$aNb['TOTAL']=array_sum($aNb);
+						// Moyenne pondérée au nombre d'opération total
+						// TODO pondérer au nombre d'opération ayant une valeur
+						$iCFTotal=$iPVTotal=$iCFPVTotal=0;
+						foreach ($aNb as $sFinancement=>$iNB){
+							$iCFTotal=$iCFTotal+($aCF[$sFinancement]*$iNB);
+							$iPVTotal=$iPVTotal+($aPV[$sFinancement]*$iNB);
+							$iCFPVTotal=$iCFPVTotal+($aPourcCFPV[$sFinancement]*$iNB);
+						}
+						$aCF['MOY']=round($iCFTotal/$aNb['TOTAL']);
+						$aPV['MOY']=round($iPVTotal/$aNb['TOTAL']);
+						$aPourcCFPV['MOY']=round($iCFPVTotal/$aNb['TOTAL'],1);
+						// label title
+						$sTitle="Opérateur immobilier";
+						$aPromoteurs=array("Cogedim", "Vinci Immobilier");
+						$aAmenageurs=array("SERL", "LMH");
+						$aRegies=array("Métropole de Lyon");
+						if (in_array($_REQUEST['nom_amenageur'], $aPromoteurs)) $sTitle="Promoteur immobilier";
+						if (in_array($_REQUEST['nom_amenageur'], $aAmenageurs)) $sTitle="Aménageur";
+						if (in_array($_REQUEST['nom_amenageur'], $aRegies)) $sTitle="Opération(s) suivi en régie";
+
+
+						
+						include ('get_3_porteur.html');
+					}else{
+						$sError="Erreur : ".$oResult->rowCount()." opération(s) trouvée(s) pour l'aménageur ".$_REQUEST['nom_amenageur'].".";
+						$oResult->closeCursor();
+						include ('get_error.html');
+					}
+				}
+			}catch (PDOException $e){
+				$sError="ERROR : ".$e->getMessage();
+				include ('get_error.html');
+			}
+
+		}else{
+			$sError="ERREUR : Pas de nom d'aménageur passé en paramètre !";
+			include ('get_error.html');
+		}
+	}else{
+		header ('location: signin.php');
+		exit();
+	}
+}else{
+	header ('location: signin.php');
+	exit();
+}
+?>
\ No newline at end of file
diff --git a/src/vitis/vas/doc/suivi_prod_immo/get_3_porteur.php b/src/vitis/vas/doc/suivi_prod_immo/get_3_porteur.php
index 1a86a24408dfd06f2b1d119fa308c306116a0ddf..64e8b46c18a8092d29b567fc90b9256902c4aec2 100644
--- a/src/vitis/vas/doc/suivi_prod_immo/get_3_porteur.php
+++ b/src/vitis/vas/doc/suivi_prod_immo/get_3_porteur.php
@@ -1,109 +1,111 @@
-<?php
-// https://geo.urbalyon.org/doc/suivi_prod_immo/get_3_porteur.php?concessionnaire_amenagement=1041
-session_start();
-if (isset($_REQUEST['login'])) $_SESSION['login_bd_prod_immo']=$_REQUEST['login'];
-
-if(isset($_REQUEST['token']) && isset($_SESSION['token_bd_prod_immo'])){
-	if($_REQUEST['token']==$_SESSION['token_bd_prod_immo']){
-
-		if (isset($_REQUEST['concessionnaire_amenagement']) && !is_null($_REQUEST['concessionnaire_amenagement'])){
-			require_once("../../rest/conf/properties.inc");
-			require_once("properties_suivi_prod_immo.inc");
-			$sSchema=$properties['schema_prod_immo'];
-
-			try{
-				$oConn = new PDO('pgsql:host='.$properties['server'].';port='.$properties['port'].';dbname='.$properties['db_prod_immo'], $properties['db_user_prod_immo'], $properties['db_pass_prod_immo']);
-				$oConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-				$oConn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
-				
-				if($oConn){
-					// get data Opérations
-					$sWhereAmenageur=" WHERE concessionnaire_amenagement='".$_REQUEST['concessionnaire_amenagement']."'";
-					$oResult = $oConn->prepare("SELECT * FROM ".$sSchema.".v_operation_layer".$sWhereAmenageur);
-					$oResult->execute();
-
-					if ($oResult->rowCount()>0){
-						$iNbOperation=$oResult->rowCount();
-						$aOperations = $oResult->fetchAll();
-						$oResult->closeCursor();
-						// get map image
-						$aIdOperation=array();
-						foreach ($aOperations as $aOperation)
-							array_push($aIdOperation, $aOperation["id_operation"]);
-						$sNameMapImage=strtolower(preg_replace("#[^a-zA-Z]#", "", str_replace(' ', '_', $_REQUEST['concessionnaire_amenagement'])))."_porteur.png";
-						$oResult2 = $oConn->prepare("SELECT round(st_xmin(st_buffer(st_envelope(st_union(geom)),150))) AS xmin, round(st_ymin(st_buffer(st_envelope(st_union(geom)),150))) AS ymin, round(st_ymax(st_buffer(st_envelope(st_union(geom)),150))) AS ymax, round(st_xmax(st_buffer(st_envelope(st_union(geom)),150))) AS xmax FROM ".$sSchema.".operation".$sWhereAmenageur);
-						$oResult2->execute();
-						$aOperations2 = $oResult2->fetchAll();
-						$oResult2->closeCursor();
-						$aOperations2 = $aOperations2[0];
-						$sCommand = escapeshellcmd('python get_map_image_3_porteur.py '.$aOperations2['xmin'].' '.$aOperations2['ymin'].' '.$aOperations2['xmax'].' '.$aOperations2['ymax'].' '.$sNameMapImage.' '.implode(",", $aIdOperation));
-						// echo $sCommand;
-						$output = shell_exec($sCommand);/**/
-						$sUrlMapImage=$properties['web_server_name']."/ws_data/vm4ms/map/tmp/".$sNameMapImage;
-						
-						$sSql="SELECT code_financement_equ_public, count(DISTINCT id_programme), array_to_string(array_agg(id_programme), ',') AS id_programme, round(avg(charge_fonciere_moy)) AS charge_fonciere_moy FROM (SELECT id_programme, CASE WHEN operation_tr_financement_equ_public.code_financement_equ_public='PUP' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='FINZAC' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='TA' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='TAM' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='AUT' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='PEPE' THEN operation_tr_financement_equ_public.code_financement_equ_public ELSE 'ND' END AS code_financement_equ_public, charge_fonciere_moy FROM ((".$sSchema.".operation LEFT JOIN ".$sSchema.".operation_tr_financement_equ_public ON operation.id_operation=operation_tr_financement_equ_public.id_operation) INNER JOIN ".$sSchema.".ilot ON ilot.id_operation=operation.id_operation) INNER JOIN ".$sSchema.".programme_immobilier ON programme_immobilier.id_ilot=ilot.id_ilot ".$sWhereAmenageur.") AS t GROUP BY code_financement_equ_public";
-						$aPourcCFPV=$aPV=$aCF=$aNb=array();
-						foreach ($oConn->query($sSql) as $aRow){
-							if(!is_null($aRow['count'])) $aNb[$aRow['code_financement_equ_public']]=$aRow['count'];
-							if(!is_null($aRow['charge_fonciere_moy'])) $aCF[$aRow['code_financement_equ_public']]=$aRow['charge_fonciere_moy'];
-							$oResult3 = $oConn->prepare("SELECT round((COALESCE(avg1, 0) + COALESCE(avg2, 0) + COALESCE(avg3, 0) + COALESCE(avg4)) / ( CASE WHEN avg1 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg2 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg3 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg4 IS NULL THEN 0 ELSE 1 END)) AS pv_moy FROM (SELECT  round(avg(accession_libre::numeric)) AS avg1, round(avg(accession_abordable::numeric)) AS avg2, round(avg(accession_sociale_securise::numeric)) AS avg3, round(avg(psla::numeric)) AS avg4	FROM ".$sSchema.".logement_familliaux_accession	WHERE id_programme IN (".$aRow['id_programme'].") AND id_indicateur_logement_familliaux_accession IN (8,9)) AS t");
-							$oResult3->execute();
-							$aPrixVenteMoy = $oResult3->fetchAll();
-							if (isset($aPrixVenteMoy[0])) $aPV[$aRow['code_financement_equ_public']]=$aPrixVenteMoy[0]['pv_moy'];
-							$oResult3->closeCursor();
-						}
-						if(isset($aCF['PUP']) && isset($aPV['PUP'])) $aPourcCFPV['PUP']=round(($aCF['PUP']/$aPV['PUP'])*100,1);
-						if(isset($aCF['FINZAC']) && isset($aPV['FINZAC'])) $aPourcCFPV['FINZAC']=round(($aCF['FINZAC']/$aPV['FINZAC'])*100,1);
-						if(isset($aCF['TA']) && isset($aPV['TA'])) $aPourcCFPV['TA']=round(($aCF['TA']/$aPV['TA'])*100,1);
-						if(isset($aCF['TAM']) && isset($aPV['TAM'])) $aPourcCFPV['TAM']=round(($aCF['TAM']/$aPV['TAM'])*100,1);
-						if(isset($aCF['PEPE']) && isset($aPV['PEPE'])) $aPourcCFPV['PEPE']=round(($aCF['PEPE']/$aPV['PEPE'])*100,1);
-						if(isset($aCF['AUT']) && isset($aPV['AUT'])) $aPourcCFPV['AUT']=round(($aCF['AUT']/$aPV['AUT'])*100,1);
-						if(isset($aCF['ND']) && isset($aPV['ND'])) $aPourcCFPV['ND']=round(($aCF['ND']/$aPV['ND'])*100,1);
-						$aNb['TOTAL']=array_sum($aNb);
-						// Moyenne pondérée au nombre d'opération total
-						// TODO pondérer au nombre d'opération ayant une valeur
-						$iCFTotal=$iPVTotal=$iCFPVTotal=0;
-						foreach ($aNb as $sFinancement=>$iNB){
-							$iCFTotal=$iCFTotal+($aCF[$sFinancement]*$iNB);
-							$iPVTotal=$iPVTotal+($aPV[$sFinancement]*$iNB);
-							$iCFPVTotal=$iCFPVTotal+($aPourcCFPV[$sFinancement]*$iNB);
-						}
-						$aCF['MOY']=round($iCFTotal/$aNb['TOTAL']);
-						$aPV['MOY']=round($iPVTotal/$aNb['TOTAL']);
-						$aPourcCFPV['MOY']=round($iCFPVTotal/$aNb['TOTAL'],1);
-						// label title
-						$sTitle="Opérateur immobilier";
-						$aPromoteurs=array("Cogedim", "Vinci Immobilier");
-						$aAmenageurs=array("SERL", "LMH");
-						$aRegies=array("Métropole de Lyon");
-						if (in_array($_REQUEST['concessionnaire_amenagement'], $aPromoteurs)) $sTitle="Promoteur immobilier";
-						if (in_array($_REQUEST['concessionnaire_amenagement'], $aAmenageurs)) $sTitle="Aménageur";
-						if (in_array($_REQUEST['concessionnaire_amenagement'], $aRegies)) $sTitle="Opération(s) suivi en régie";
-
-
-						
-						include ('get_3_porteur.html');
-					}else{
-						$sError="Erreur : ".$oResult->rowCount()." opération(s) trouvée(s) pour l'aménageur ".$_REQUEST['concessionnaire_amenagement'].".";
-						$oResult->closeCursor();
-						include ('get_error.html');
-					}
-				}
-			}catch (PDOException $e){
-				$sError="ERROR : ".$e->getMessage();
-				include ('get_error.html');
-			}
-
-		}else{
-			$sError="ERREUR : Pas de nom d'aménageur passé en paramètre !";
-			include ('get_error.html');
-		}
-	}else{
-		header ('location: signin.php');
-		exit();
-	}
-}else{
-	header ('location: signin.php');
-	exit();
-}
+<?php
+// https://geo.urbalyon.org/doc/suivi_prod_immo/get_3_porteur.php?concessionnaire_amenagement=1041
+if (isset($_REQUEST['token']) && !is_null($_REQUEST['token'])){
+	session_id($_REQUEST['token']);
+	if (session_status() == PHP_SESSION_NONE)
+		session_start();
+
+	if (empty($_SESSION)) {
+		$sError="ERREUR : token invalide.";
+		include ('get_error.html');
+	}else{
+
+		if (isset($_REQUEST['concessionnaire_amenagement']) && !is_null($_REQUEST['concessionnaire_amenagement'])){
+			require_once("../../rest/conf/properties.inc");
+			require_once("properties_suivi_prod_immo.inc");
+			$sSchema=$properties['schema_prod_immo'];
+
+			try{
+				$oConn = new PDO('pgsql:host='.$properties['server'].';port='.$properties['port'].';dbname='.$properties['db_prod_immo'], $properties['db_user_prod_immo'], $properties['db_pass_prod_immo']);
+				$oConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+				$oConn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
+				
+				if($oConn){
+					// get data Opérations
+					$sWhereAmenageur=" WHERE concessionnaire_amenagement='".$_REQUEST['concessionnaire_amenagement']."'";
+					$oResult = $oConn->prepare("SELECT * FROM ".$sSchema.".v_operation_layer".$sWhereAmenageur);
+					$oResult->execute();
+
+					if ($oResult->rowCount()>0){
+						$iNbOperation=$oResult->rowCount();
+						$aOperations = $oResult->fetchAll();
+						$oResult->closeCursor();
+						// get map image
+						$aIdOperation=array();
+						foreach ($aOperations as $aOperation)
+							array_push($aIdOperation, $aOperation["id_operation"]);
+						$sNameMapImage=strtolower(preg_replace("#[^a-zA-Z]#", "", str_replace(' ', '_', $_REQUEST['concessionnaire_amenagement'])))."_porteur.png";
+						$oResult2 = $oConn->prepare("SELECT round(st_xmin(st_buffer(st_envelope(st_union(geom)),150))) AS xmin, round(st_ymin(st_buffer(st_envelope(st_union(geom)),150))) AS ymin, round(st_ymax(st_buffer(st_envelope(st_union(geom)),150))) AS ymax, round(st_xmax(st_buffer(st_envelope(st_union(geom)),150))) AS xmax FROM ".$sSchema.".operation".$sWhereAmenageur);
+						$oResult2->execute();
+						$aOperations2 = $oResult2->fetchAll();
+						$oResult2->closeCursor();
+						$aOperations2 = $aOperations2[0];
+						$sCommand = escapeshellcmd('python get_map_image_3_porteur.py '.$aOperations2['xmin'].' '.$aOperations2['ymin'].' '.$aOperations2['xmax'].' '.$aOperations2['ymax'].' '.$sNameMapImage.' '.implode(",", $aIdOperation));
+						// echo $sCommand;
+						$output = shell_exec($sCommand);/**/
+						$sUrlMapImage=$properties['web_server_name']."/ws_data/vm4ms/map/tmp/".$sNameMapImage;
+						
+						$sSql="SELECT code_financement_equ_public, count(DISTINCT id_programme), array_to_string(array_agg(id_programme), ',') AS id_programme, round(avg(charge_fonciere_moy)) AS charge_fonciere_moy FROM (SELECT id_programme, CASE WHEN operation_tr_financement_equ_public.code_financement_equ_public='PUP' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='FINZAC' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='TA' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='TAM' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='AUT' THEN operation_tr_financement_equ_public.code_financement_equ_public WHEN operation_tr_financement_equ_public.code_financement_equ_public='PEPE' THEN operation_tr_financement_equ_public.code_financement_equ_public ELSE 'ND' END AS code_financement_equ_public, charge_fonciere_moy FROM ((".$sSchema.".operation LEFT JOIN ".$sSchema.".operation_tr_financement_equ_public ON operation.id_operation=operation_tr_financement_equ_public.id_operation) INNER JOIN ".$sSchema.".ilot ON ilot.id_operation=operation.id_operation) INNER JOIN ".$sSchema.".programme_immobilier ON programme_immobilier.id_ilot=ilot.id_ilot ".$sWhereAmenageur.") AS t GROUP BY code_financement_equ_public";
+						$aPourcCFPV=$aPV=$aCF=$aNb=array();
+						foreach ($oConn->query($sSql) as $aRow){
+							if(!is_null($aRow['count'])) $aNb[$aRow['code_financement_equ_public']]=$aRow['count'];
+							if(!is_null($aRow['charge_fonciere_moy'])) $aCF[$aRow['code_financement_equ_public']]=$aRow['charge_fonciere_moy'];
+							$oResult3 = $oConn->prepare("SELECT round((COALESCE(avg1, 0) + COALESCE(avg2, 0) + COALESCE(avg3, 0) + COALESCE(avg4)) / ( CASE WHEN avg1 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg2 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg3 IS NULL THEN 0 ELSE 1 END + CASE WHEN avg4 IS NULL THEN 0 ELSE 1 END)) AS pv_moy FROM (SELECT  round(avg(accession_libre::numeric)) AS avg1, round(avg(accession_abordable::numeric)) AS avg2, round(avg(accession_sociale_securise::numeric)) AS avg3, round(avg(psla::numeric)) AS avg4	FROM ".$sSchema.".logement_familliaux_accession	WHERE id_programme IN (".$aRow['id_programme'].") AND id_indicateur_logement_familliaux_accession IN (8,9)) AS t");
+							$oResult3->execute();
+							$aPrixVenteMoy = $oResult3->fetchAll();
+							if (isset($aPrixVenteMoy[0])) $aPV[$aRow['code_financement_equ_public']]=$aPrixVenteMoy[0]['pv_moy'];
+							$oResult3->closeCursor();
+						}
+						if(isset($aCF['PUP']) && isset($aPV['PUP'])) $aPourcCFPV['PUP']=round(($aCF['PUP']/$aPV['PUP'])*100,1);
+						if(isset($aCF['FINZAC']) && isset($aPV['FINZAC'])) $aPourcCFPV['FINZAC']=round(($aCF['FINZAC']/$aPV['FINZAC'])*100,1);
+						if(isset($aCF['TA']) && isset($aPV['TA'])) $aPourcCFPV['TA']=round(($aCF['TA']/$aPV['TA'])*100,1);
+						if(isset($aCF['TAM']) && isset($aPV['TAM'])) $aPourcCFPV['TAM']=round(($aCF['TAM']/$aPV['TAM'])*100,1);
+						if(isset($aCF['PEPE']) && isset($aPV['PEPE'])) $aPourcCFPV['PEPE']=round(($aCF['PEPE']/$aPV['PEPE'])*100,1);
+						if(isset($aCF['AUT']) && isset($aPV['AUT'])) $aPourcCFPV['AUT']=round(($aCF['AUT']/$aPV['AUT'])*100,1);
+						if(isset($aCF['ND']) && isset($aPV['ND'])) $aPourcCFPV['ND']=round(($aCF['ND']/$aPV['ND'])*100,1);
+						$aNb['TOTAL']=array_sum($aNb);
+						// Moyenne pondérée au nombre d'opération total
+						// TODO pondérer au nombre d'opération ayant une valeur
+						$iCFTotal=$iPVTotal=$iCFPVTotal=0;
+						foreach ($aNb as $sFinancement=>$iNB){
+							$iCFTotal=$iCFTotal+($aCF[$sFinancement]*$iNB);
+							$iPVTotal=$iPVTotal+($aPV[$sFinancement]*$iNB);
+							$iCFPVTotal=$iCFPVTotal+($aPourcCFPV[$sFinancement]*$iNB);
+						}
+						$aCF['MOY']=round($iCFTotal/$aNb['TOTAL']);
+						$aPV['MOY']=round($iPVTotal/$aNb['TOTAL']);
+						$aPourcCFPV['MOY']=round($iCFPVTotal/$aNb['TOTAL'],1);
+						// label title
+						$sTitle="Opérateur immobilier";
+						$aPromoteurs=array("Cogedim", "Vinci Immobilier");
+						$aAmenageurs=array("SERL", "LMH");
+						$aRegies=array("Métropole de Lyon");
+						if (in_array($_REQUEST['concessionnaire_amenagement'], $aPromoteurs)) $sTitle="Promoteur immobilier";
+						if (in_array($_REQUEST['concessionnaire_amenagement'], $aAmenageurs)) $sTitle="Aménageur";
+						if (in_array($_REQUEST['concessionnaire_amenagement'], $aRegies)) $sTitle="Opération(s) suivi en régie";
+
+
+						
+						include ('get_3_porteur.html');
+					}else{
+						$sError="Erreur : ".$oResult->rowCount()." opération(s) trouvée(s) pour l'aménageur ".$_REQUEST['concessionnaire_amenagement'].".";
+						$oResult->closeCursor();
+						include ('get_error.html');
+					}
+				}
+			}catch (PDOException $e){
+				$sError="ERROR : ".$e->getMessage();
+				include ('get_error.html');
+			}
+
+		}else{
+			$sError="ERREUR : Pas de nom d'aménageur passé en paramètre !";
+			include ('get_error.html');
+		}
+	}
+	
+}else{
+	$sError="ERREUR : Pas de token passé.";
+	include ('get_error.html');
+}
 ?>
\ No newline at end of file
diff --git a/src/vitis/vas/doc/suivi_prod_immo/get_4_logement.old.php b/src/vitis/vas/doc/suivi_prod_immo/get_4_logement.old.php
new file mode 100644
index 0000000000000000000000000000000000000000..7b39e3a03293ce4cabbb3c219fcc4c0e7d023d12
--- /dev/null
+++ b/src/vitis/vas/doc/suivi_prod_immo/get_4_logement.old.php
@@ -0,0 +1,265 @@
+<?php
+// https://geo.urbalyon.org/doc/suivi_prod_immo/get_4_logement.php?code_finanacment=TA
+session_start();
+if (isset($_REQUEST['login'])) $_SESSION['login_bd_prod_immo']=$_REQUEST['login'];
+
+if(isset($_REQUEST['token']) && isset($_SESSION['token_bd_prod_immo'])){
+	if($_REQUEST['token']==$_SESSION['token_bd_prod_immo']){
+
+		require_once("../../rest/conf/properties.inc");
+		require_once("properties_suivi_prod_immo.inc");
+		$sSchema=$properties['schema_prod_immo'];
+
+		function avg($sum=0,$count=0){
+			return ($count)? round($sum / $count): null;
+		}
+
+		try{
+			$oConn = new PDO('pgsql:host='.$properties['server'].';port='.$properties['port'].';dbname='.$properties['db_prod_immo'], $properties['db_user_prod_immo'], $properties['db_pass_prod_immo']);
+			$oConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+			$oConn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
+
+			$bSetAccessionLibre=$bSetAccessionAbordable=$bSetAccessionSecurisee=$bSetBRS=$bSetLogementSocial=$bSetLogementIntermediaire=false;
+			
+			if($oConn){
+				$sWhereOperation='';
+				$aOperations=array();
+				if (isset($_REQUEST['code_financement']) && !is_null($_REQUEST['code_financement'])){
+					$sWhereOperation="WHERE operation_tr_financement_equ_public.code_financement_equ_public='".$_REQUEST['code_financement']."'";
+				}
+
+				if (isset($_REQUEST['id_commune']) && !is_null($_REQUEST['id_commune'])){
+					if ($sWhereOperation=='')
+						$sWhereOperation="WHERE operation_commune.id_commune=".$_REQUEST['id_commune'];
+					else
+						$sWhereOperation=$sWhereOperation." AND operation_commune.id_commune=".$_REQUEST['id_commune'];
+				}else{
+					if (isset($_REQUEST['id_ctm']) && !is_null($_REQUEST['id_ctm'])){
+						$oResult2 = $oConn->prepare("SELECT array_to_string(array_agg(id_commune),', ') AS id_commune FROM ".$sSchema.".commune WHERE id_ctm=".$_REQUEST['id_ctm']." GROUP BY id_ctm");
+						$oResult2->execute();
+						if ($oResult2->rowCount()>0){
+							$aCTMs=$oResult2->fetchAll();
+							if ($sWhereOperation=='')
+								$sWhereOperation="WHERE operation_commune.id_commune IN (".$aCTMs[0]['id_commune'].")";
+							else
+								$sWhereOperation=$sWhereOperation." AND operation_commune.id_commune IN (".$aCTMs[0]['id_commune'].")";/**/
+						}
+						$oResult2->closeCursor();
+					}
+				}
+				$sSql='SELECT DISTINCT operation.id_operation, nom_operation, array_to_string(array_agg(DISTINCT operation_tr_financement_equ_public.code_financement_equ_public),\', \') AS code_financement_equ_public, array_to_string(array_agg(DISTINCT nom_commune),\', \') AS nom_commune, nom_ilot, ilot.id_ilot, id_programme, nom_demandeur FROM (((('.$sSchema.'.operation INNER JOIN '.$sSchema.'.operation_tr_financement_equ_public ON operation_tr_financement_equ_public.id_operation=operation.id_operation) INNER JOIN '.$sSchema.'.operation_commune  ON operation_commune.id_operation=operation.id_operation) INNER JOIN '.$sSchema.'.commune ON operation_commune.id_commune=commune.id_commune) INNER JOIN '.$sSchema.'.ilot ON ilot.id_operation=operation.id_operation) INNER JOIN '.$sSchema.'.programme_immobilier ON ilot.id_ilot=programme_immobilier.id_ilot '.$sWhereOperation.' GROUP BY id_programme, ilot.id_ilot, operation.id_operation ORDER BY nom_commune, nom_operation, nom_ilot';
+				$oResult = $oConn->prepare($sSql);
+				$oResult->execute();
+				if($oResult->rowCount()>0){
+					$aProgrammes=$oResult->fetchAll();
+					$aCptCommunes=array();
+					$aCptOperations=array();
+					$aCptIlots=array();
+					$aTotaux=array('sdp'=>0,'nb'=>0,'nb_accession_libre'=>0,'cfi_accession_libre'=>array(),'pv_accession_libre'=>array(),'nb_accession_abordable'=>0,'cfi_accession_abordable'=>array(),'pv_accession_abordable'=>array(),'nb_accession_sociale_securise'=>0,'cfi_accession_sociale_securise'=>array(),'pv_accession_sociale_securise'=>array(),'nb_lls'=>0,'cfi_lls'=>array(),'pv_lls'=>array(),'nb_lli'=>0,'cfi_lli'=>array());
+					$aProgrammes2=array();
+					foreach ($aProgrammes as $aProgramme){
+						// **** Compteurs pour fusion des cellules du tableau
+						if(isset($aCptCommunes[$aProgramme['nom_commune']]))
+							$aCptCommunes[$aProgramme['nom_commune']]=$aCptCommunes[$aProgramme['nom_commune']]+1;
+						else
+							$aCptCommunes[$aProgramme['nom_commune']]=1;
+						if(isset($aCptOperations[$aProgramme['id_operation']]))
+							$aCptOperations[$aProgramme['id_operation']]=$aCptOperations[$aProgramme['id_operation']]+1;
+						else
+							$aCptOperations[$aProgramme['id_operation']]=1;
+						if(isset($aCptIlots[$aProgramme['id_ilot']]))
+							$aCptIlots[$aProgramme['id_ilot']]=$aCptIlots[$aProgramme['id_ilot']]+1;
+						else
+							$aCptIlots[$aProgramme['id_ilot']]=1;
+						// **** Récupération des données tables associées
+						$iIdProgramme=$aProgramme['id_programme'];
+						$aProgramme2=array();
+						// Granulométrie
+						$oResult3=$oConn->prepare("SELECT id_programme, code_type_granulometrie, sum(valeur) AS valeur FROM ".$sSchema.".granulometrie WHERE id_programme=".$iIdProgramme." AND code_type_granulometrie IN ('NB','SDP') AND code_composition_programme='TOT_LG_FAM' GROUP BY id_programme, code_composition_programme, code_type_granulometrie");
+						$oResult3->execute();
+						if($oResult3->rowCount()>0){
+							$aGranulometries=$oResult3->fetchAll();
+							foreach ($aGranulometries as $aGranulometrie){
+								$aProgramme2[strtolower($aGranulometrie['code_type_granulometrie'])]=$aGranulometrie['valeur'];
+								$aTotaux[strtolower($aGranulometrie['code_type_granulometrie'])]=$aTotaux[strtolower($aGranulometrie['code_type_granulometrie'])]+$aGranulometrie['valeur'];
+							}
+						}
+						$oResult3->closeCursor();
+						// profil
+						$oResult6=$oConn->prepare("SELECT pourc FROM prod_immo.profil_acheteur_accession_libre WHERE id_type_acheteur_accession_libre=2 AND pourc IS NOT NULL AND id_programme=".$iIdProgramme);
+						$oResult6->execute();
+						if($oResult6->rowCount()>0){
+							$aProfil=$oResult6->fetchAll();
+							$aProgramme2['profil']=$aProfil[0]['pourc'].'%';
+						}
+						$oResult6->closeCursor();
+						// logement social
+						$oResult4=$oConn->prepare("SELECT id_programme, array_to_string(array_agg(DISTINCT nom_bailleur),',') AS nom_bailleur, id_indicateur_logement_familliaux_location, CASE WHEN id_indicateur_logement_familliaux_location=1 THEN sum(COALESCE(social_pls,0)) ELSE avg(COALESCE(social_pls,0)) END AS social_pls, CASE WHEN id_indicateur_logement_familliaux_location=1 THEN sum(COALESCE(social_plus_plai,0)) ELSE avg(COALESCE(social_plus_plai,0)) END AS social_plus_plai, CASE WHEN id_indicateur_logement_familliaux_location=1 THEN sum(COALESCE(intermediaire_pli,0)) ELSE avg(COALESCE(intermediaire_pli,0)) END AS intermediaire_pli, CASE WHEN id_indicateur_logement_familliaux_location=1 THEN sum(COALESCE(intermediaire_afl,0)) ELSE avg(COALESCE(intermediaire_afl,0)) END AS intermediaire_afl	FROM ".$sSchema.".logement_familliaux_location INNER JOIN ".$sSchema.".composition_logement_familliaux_location_cp ON logement_familliaux_location.id_logement_familliaux_location=composition_logement_familliaux_location_cp.id_logement_familliaux_location WHERE id_programme=".$iIdProgramme." AND id_indicateur_logement_familliaux_location IN (1,4,5,8) GROUP BY id_programme, composition_logement_familliaux_location_cp.id_logement_familliaux_location, id_indicateur_logement_familliaux_location");
+						$oResult4->execute();
+						if($oResult4->rowCount()>0){
+							$aLogSocials=$oResult4->fetchAll();
+							$aProgramme2['nom_bailleur']=$aLogSocials[0]['nom_bailleur'];
+							$aCFIlls=array();
+							$aCFIlli=array();
+							foreach ($aLogSocials as $aLogSocial){
+								switch ($aLogSocial['id_indicateur_logement_familliaux_location']) {
+									case 1:
+										if($aLogSocial['social_pls']>0 or $aLogSocial['social_plus_plai']>0){
+											$bSetLogementSocial=true;
+											$aProgramme2['nb_lls']=$aLogSocial['social_pls']+$aLogSocial['social_plus_plai'];
+											$aTotaux['nb_lls']=$aTotaux['nb_lls']+$aLogSocial['social_pls']+$aLogSocial['social_plus_plai'];
+										}
+										if($aLogSocial['intermediaire_pli']>0 or $aLogSocial['intermediaire_afl']>0){
+											$bSetLogementIntermediaire=true;
+											$aProgramme2['nb_lli']=$aLogSocial['intermediaire_pli']+$aLogSocial['intermediaire_afl'];
+											$aTotaux['nb_lli']=$aTotaux['nb_lli']+$aLogSocial['intermediaire_pli']+$aLogSocial['intermediaire_afl'];
+										}
+										break;
+									case 4:
+									case 5:
+										if(!is_null($aLogSocial['social_pls']) and $aLogSocial['social_pls']>0){
+											$bSetLogementSocial=true;
+											$aCFIlls[count($aCFIlls)]=$aLogSocial['social_pls'];
+											$aTotaux['cfi_lls'][count($aTotaux['cfi_lls'])]=$aLogSocial['social_pls'];
+										}
+										if(!is_null($aLogSocial['social_plus_plai']) and $aLogSocial['social_plus_plai']>0){
+											$bSetLogementSocial=true;
+											$aCFIlls[count($aCFIlls)]=$aLogSocial['social_plus_plai'];
+											$aTotaux['cfi_lls'][count($aTotaux['cfi_lls'])]=$aLogSocial['social_plus_plai'];
+										}
+										if(!is_null($aLogSocial['intermediaire_pli']) and $aLogSocial['intermediaire_pli']>0){
+											$bSetLogementIntermediaire=true;
+											$aCFIlli[count($aCFIlli)]=$aLogSocial['intermediaire_pli'];
+											$aTotaux['cfi_lli'][count($aTotaux['cfi_lli'])]=$aLogSocial['intermediaire_pli'];
+										}
+										if(!is_null($aLogSocial['intermediaire_afl']) and $aLogSocial['intermediaire_afl']>0){
+											$bSetLogementIntermediaire=true;
+											$aCFIlli[count($aCFIlli)]=$aLogSocial['intermediaire_afl'];
+											$aTotaux['cfi_lli'][count($aTotaux['cfi_lli'])]=$aLogSocial['intermediaire_afl'];
+										}
+										break;
+									case 8:
+										$aPVlls=array();
+										if(!is_null($aLogSocial['social_pls']) and $aLogSocial['social_pls']>0){
+											$bSetLogementSocial=true;
+											$aPVlls[count($aPVlls)]=$aLogSocial['social_pls'];
+											$aTotaux['pv_lls'][count($aTotaux['pv_lls'])]=$aLogSocial['social_pls'];
+										}
+										if(!is_null($aLogSocial['social_plus_plai']) and $aLogSocial['social_plus_plai']>0){
+											$bSetLogementSocial=true;
+											$aPVlls[count($aPVlls)]=$aLogSocial['social_plus_plai'];
+											$aTotaux['pv_lls'][count($aTotaux['pv_lls'])]=$aLogSocial['social_plus_plai'];
+										}
+										$aProgramme2['pv_lls']=avg(array_sum($aPVlls),count($aPVlls));
+										// pas de prix de vente en lli
+										break;
+								}
+							}
+							$aProgramme2['cfi_lls']=avg(array_sum($aCFIlls),count($aCFIlls));
+							$aProgramme2['cfi_lli']=avg(array_sum($aCFIlli),count($aCFIlli));
+						}
+						
+						$oResult4->closeCursor();
+						// logement accession
+						$oResult5=$oConn->prepare("SELECT id_programme, id_indicateur_logement_familliaux_accession, CASE WHEN id_indicateur_logement_familliaux_accession=1 THEN sum(COALESCE(accession_libre,0)) ELSE avg(COALESCE(accession_libre,0)) END AS accession_libre, CASE WHEN id_indicateur_logement_familliaux_accession=1 THEN sum(COALESCE(accession_abordable,0)) ELSE avg(COALESCE(accession_abordable,0)) END AS accession_abordable, CASE WHEN id_indicateur_logement_familliaux_accession=1 THEN sum(COALESCE(accesion_sociale_securise,0)) ELSE avg(COALESCE(accesion_sociale_securise,0)) END AS accesion_sociale_securise, CASE WHEN id_indicateur_logement_familliaux_accession=1 THEN sum(COALESCE(psla,0)) ELSE avg(COALESCE(psla,0)) END AS psla FROM ".$sSchema.".logement_familliaux_accession WHERE id_programme=".$iIdProgramme." AND id_indicateur_logement_familliaux_accession IN (1,4,5,8,9) GROUP BY id_programme, id_indicateur_logement_familliaux_accession");
+						$oResult5->execute();
+						if($oResult5->rowCount()>0){
+							$aLogAccessions=$oResult5->fetchAll();
+							$aCFIAccessionLibre=$aCFIAccessionAbordable=$aCFIAccessionSocialeSecurise=array();
+							$aPVAccessionLibre=$aPVAccessionAbordable=$aPVAccessionSocialeSecurise=array();
+							foreach ($aLogAccessions as $aLogAccession){
+								switch ($aLogAccession['id_indicateur_logement_familliaux_accession']){
+									case 1:
+										if($aLogAccession['accession_libre']>0){
+											$bSetAccessionLibre=true;
+											$aProgramme2['nb_accession_libre']=$aLogAccession['accession_libre'];
+											$aTotaux['nb_accession_libre']=$aTotaux['nb_accession_libre']+$aLogAccession['accession_libre'];
+										}
+										if($aLogAccession['accession_abordable']>0){
+											$bSetAccessionAbordable=true;
+											$aProgramme2['nb_accession_abordable']=$aLogAccession['accession_abordable'];
+											$aTotaux['nb_accession_abordable']=$aTotaux['nb_accession_abordable']+$aLogAccession['accession_abordable'];
+										}
+										if($aLogAccession['accesion_sociale_securise']>0){
+											$bSetAccessionSecurisee=true;
+											$aProgramme2['nb_accession_sociale_securise']=$aLogAccession['accesion_sociale_securise'];
+											$aTotaux['nb_accession_sociale_securise']=$aTotaux['nb_accession_sociale_securise']+$aLogAccession['accesion_sociale_securise'];
+										}
+										if($aLogAccession['psla']>0) $aProgramme2['nb_psla']=$aLogAccession['psla'];
+										break;
+									case 4:
+									case 5:
+										if(!is_null($aLogAccession['accession_libre']) and $aLogAccession['accession_libre']>0){
+											$bSetAccessionLibre=true;
+											$aCFIAccessionLibre[count($aCFIAccessionLibre)]=$aLogAccession['accession_libre'];
+											$aTotaux['cfi_accession_libre'][count($aTotaux['cfi_accession_libre'])]=$aLogAccession['accession_libre'];
+										}
+										if(!is_null($aLogAccession['accession_abordable']) and $aLogAccession['accession_abordable']>0){
+											$bSetAccessionAbordable=true;
+											$aCFIAccessionAbordable[count($aCFIAccessionAbordable)]=$aLogAccession['accession_abordable'];
+											$aTotaux['cfi_accession_abordable'][count($aTotaux['cfi_accession_abordable'])]=$aLogAccession['accession_abordable'];
+										}
+										if(!is_null($aLogAccession['accesion_sociale_securise']) and $aLogAccession['accesion_sociale_securise']>0){
+											$bSetAccessionSecurisee=true;
+											$aCFIAccessionSocialeSecurise[count($aCFIAccessionSocialeSecurise)]=$aLogAccession['accesion_sociale_securise'];
+											$aTotaux['cfi_accession_sociale_securise'][count($aTotaux['cfi_accession_sociale_securise'])]=$aLogAccession['accesion_sociale_securise'];
+										}
+										break;
+									case 8:
+									case 9:
+										if(!is_null($aLogAccession['accession_libre']) and $aLogAccession['accession_libre']>0){
+											$bSetAccessionLibre=true;
+											$aPVAccessionLibre[count($aPVAccessionLibre)]=$aLogAccession['accession_libre'];
+											$aTotaux['pv_accession_libre'][count($aTotaux['pv_accession_libre'])]=$aLogAccession['accession_libre'];
+										}
+										if(!is_null($aLogAccession['accession_abordable']) and $aLogAccession['accession_abordable']>0){
+											$bSetAccessionAbordable=true;
+											$aPVAccessionAbordable[count($aPVAccessionAbordable)]=$aLogAccession['accession_abordable'];
+											$aTotaux['pv_accession_abordable'][count($aTotaux['pv_accession_abordable'])]=$aLogAccession['accession_abordable'];
+										}
+										if(!is_null($aLogAccession['accesion_sociale_securise']) and $aLogAccession['accesion_sociale_securise']>0){
+											$bSetAccessionSecurisee=true;
+											$aPVAccessionSocialeSecurise[count($aPVAccessionSocialeSecurise)]=$aLogAccession['accesion_sociale_securise'];
+											$aTotaux['pv_accession_sociale_securise'][count($aTotaux['pv_accession_sociale_securise'])]=$aLogAccession['accesion_sociale_securise'];
+										}
+										break;
+								}
+							}
+							$aProgramme2['cfi_accession_libre']=avg(array_sum($aCFIAccessionLibre),count($aCFIAccessionLibre));
+							$aProgramme2['cfi_accession_abordable']=avg(array_sum($aCFIAccessionAbordable),count($aCFIAccessionAbordable));
+							$aProgramme2['cfi_accession_sociale_securise']=avg(array_sum($aCFIAccessionSocialeSecurise),count($aCFIAccessionSocialeSecurise));
+							$aProgramme2['pv_accession_libre']=avg(array_sum($aPVAccessionLibre),count($aPVAccessionLibre));
+							$aProgramme2['pv_accession_abordable']=avg(array_sum($aPVAccessionAbordable),count($aPVAccessionAbordable));
+							$aProgramme2['pv_accession_sociale_securise']=avg(array_sum($aPVAccessionSocialeSecurise),count($aPVAccessionSocialeSecurise));
+						}
+						$oResult5->closeCursor();
+						$aProgrammes2[$aProgramme['id_programme']]=$aProgramme2;
+					}
+					$oResult->closeCursor();
+					$aTotaux['cfi_accession_libre']=avg(array_sum($aTotaux['cfi_accession_libre']),count($aTotaux['cfi_accession_libre']));
+					$aTotaux['pv_accession_libre']=avg(array_sum($aTotaux['pv_accession_libre']),count($aTotaux['pv_accession_libre']));
+					$aTotaux['cfi_accession_abordable']=avg(array_sum($aTotaux['cfi_accession_abordable']),count($aTotaux['cfi_accession_abordable']));
+					$aTotaux['pv_accession_abordable']=avg(array_sum($aTotaux['pv_accession_abordable']),count($aTotaux['pv_accession_abordable']));
+					$aTotaux['cfi_accession_sociale_securise']=avg(array_sum($aTotaux['cfi_accession_sociale_securise']),count($aTotaux['cfi_accession_sociale_securise']));
+					$aTotaux['pv_accession_sociale_securise']=avg(array_sum($aTotaux['pv_accession_sociale_securise']),count($aTotaux['pv_accession_sociale_securise']));
+					$aTotaux['cfi_lls']=avg(array_sum($aTotaux['cfi_lls']),count($aTotaux['cfi_lls']));
+					$aTotaux['pv_lls']=avg(array_sum($aTotaux['pv_lls']),count($aTotaux['pv_lls']));
+					$aTotaux['cfi_lli']=avg(array_sum($aTotaux['cfi_lli']),count($aTotaux['cfi_lli']));
+				}
+				$sCssColor='blue';
+				include ('get_4_logement.html');
+			}
+		}catch (PDOException $e){
+			$sError="ERROR : ".$e->getMessage();
+			include ('get_error.html');
+		}
+	}else{
+		header ('location: signin.php');
+		exit();
+	}
+}else{
+	header ('location: signin.php');
+	exit();
+}
+
+?>
\ No newline at end of file
diff --git a/src/vitis/vas/doc/suivi_prod_immo/get_4_logement.php b/src/vitis/vas/doc/suivi_prod_immo/get_4_logement.php
index 647b0eccc54113679ef6b80a940634e3d9431c41..8c8d515e5a670ecd1f0cef6db8acbbc22518b39c 100644
--- a/src/vitis/vas/doc/suivi_prod_immo/get_4_logement.php
+++ b/src/vitis/vas/doc/suivi_prod_immo/get_4_logement.php
@@ -1,265 +1,267 @@
-<?php
-// https://geo.urbalyon.org/doc/suivi_prod_immo/get_4_logement.php?code_finanacment=TA
-session_start();
-if (isset($_REQUEST['login'])) $_SESSION['login_bd_prod_immo']=$_REQUEST['login'];
-
-if(isset($_REQUEST['token']) && isset($_SESSION['token_bd_prod_immo'])){
-	if($_REQUEST['token']==$_SESSION['token_bd_prod_immo']){
-
-		require_once("../../rest/conf/properties.inc");
-		require_once("properties_suivi_prod_immo.inc");
-		$sSchema=$properties['schema_prod_immo'];
-
-		function avg($sum=0,$count=0){
-			return ($count)? round($sum / $count): null;
-		}
-
-		try{
-			$oConn = new PDO('pgsql:host='.$properties['server'].';port='.$properties['port'].';dbname='.$properties['db_prod_immo'], $properties['db_user_prod_immo'], $properties['db_pass_prod_immo']);
-			$oConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-			$oConn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
-
-			$bSetAccessionLibre=$bSetAccessionAbordable=$bSetAccessionSecurisee=$bSetBRS=$bSetLogementSocial=$bSetLogementIntermediaire=false;
-			
-			if($oConn){
-				$sWhereOperation='';
-				$aOperations=array();
-				if (isset($_REQUEST['code_financement']) && !is_null($_REQUEST['code_financement'])){
-					$sWhereOperation="WHERE operation_tr_financement_equ_public.code_financement_equ_public='".$_REQUEST['code_financement']."'";
-				}
-
-				if (isset($_REQUEST['id_commune']) && !is_null($_REQUEST['id_commune'])){
-					if ($sWhereOperation=='')
-						$sWhereOperation="WHERE operation_commune.id_commune=".$_REQUEST['id_commune'];
-					else
-						$sWhereOperation=$sWhereOperation." AND operation_commune.id_commune=".$_REQUEST['id_commune'];
-				}else{
-					if (isset($_REQUEST['id_ctm']) && !is_null($_REQUEST['id_ctm'])){
-						$oResult2 = $oConn->prepare("SELECT array_to_string(array_agg(id_commune),', ') AS id_commune FROM ".$sSchema.".commune WHERE id_ctm=".$_REQUEST['id_ctm']." GROUP BY id_ctm");
-						$oResult2->execute();
-						if ($oResult2->rowCount()>0){
-							$aCTMs=$oResult2->fetchAll();
-							if ($sWhereOperation=='')
-								$sWhereOperation="WHERE operation_commune.id_commune IN (".$aCTMs[0]['id_commune'].")";
-							else
-								$sWhereOperation=$sWhereOperation." AND operation_commune.id_commune IN (".$aCTMs[0]['id_commune'].")";/**/
-						}
-						$oResult2->closeCursor();
-					}
-				}
-				$sSql='SELECT DISTINCT operation.id_operation, nom_operation, array_to_string(array_agg(DISTINCT operation_tr_financement_equ_public.code_financement_equ_public),\', \') AS code_financement_equ_public, array_to_string(array_agg(DISTINCT nom_commune),\', \') AS nom_commune, nom_ilot, ilot.id_ilot, id_programme, nom_demandeur FROM (((('.$sSchema.'.operation INNER JOIN '.$sSchema.'.operation_tr_financement_equ_public ON operation_tr_financement_equ_public.id_operation=operation.id_operation) INNER JOIN '.$sSchema.'.operation_commune  ON operation_commune.id_operation=operation.id_operation) INNER JOIN '.$sSchema.'.commune ON operation_commune.id_commune=commune.id_commune) INNER JOIN '.$sSchema.'.ilot ON ilot.id_operation=operation.id_operation) INNER JOIN '.$sSchema.'.programme_immobilier ON ilot.id_ilot=programme_immobilier.id_ilot '.$sWhereOperation.' GROUP BY id_programme, ilot.id_ilot, operation.id_operation ORDER BY nom_commune, nom_operation, nom_ilot';
-				$oResult = $oConn->prepare($sSql);
-				$oResult->execute();
-				if($oResult->rowCount()>0){
-					$aProgrammes=$oResult->fetchAll();
-					$aCptCommunes=array();
-					$aCptOperations=array();
-					$aCptIlots=array();
-					$aTotaux=array('sdp'=>0,'nb'=>0,'nb_accession_libre'=>0,'cfi_accession_libre'=>array(),'pv_accession_libre'=>array(),'nb_accession_abordable'=>0,'cfi_accession_abordable'=>array(),'pv_accession_abordable'=>array(),'nb_accession_sociale_securise'=>0,'cfi_accession_sociale_securise'=>array(),'pv_accession_sociale_securise'=>array(),'nb_lls'=>0,'cfi_lls'=>array(),'pv_lls'=>array(),'nb_lli'=>0,'cfi_lli'=>array());
-					$aProgrammes2=array();
-					foreach ($aProgrammes as $aProgramme){
-						// **** Compteurs pour fusion des cellules du tableau
-						if(isset($aCptCommunes[$aProgramme['nom_commune']]))
-							$aCptCommunes[$aProgramme['nom_commune']]=$aCptCommunes[$aProgramme['nom_commune']]+1;
-						else
-							$aCptCommunes[$aProgramme['nom_commune']]=1;
-						if(isset($aCptOperations[$aProgramme['id_operation']]))
-							$aCptOperations[$aProgramme['id_operation']]=$aCptOperations[$aProgramme['id_operation']]+1;
-						else
-							$aCptOperations[$aProgramme['id_operation']]=1;
-						if(isset($aCptIlots[$aProgramme['id_ilot']]))
-							$aCptIlots[$aProgramme['id_ilot']]=$aCptIlots[$aProgramme['id_ilot']]+1;
-						else
-							$aCptIlots[$aProgramme['id_ilot']]=1;
-						// **** Récupération des données tables associées
-						$iIdProgramme=$aProgramme['id_programme'];
-						$aProgramme2=array();
-						// Granulométrie
-						$oResult3=$oConn->prepare("SELECT id_programme, code_type_granulometrie, sum(valeur) AS valeur FROM ".$sSchema.".granulometrie WHERE id_programme=".$iIdProgramme." AND code_type_granulometrie IN ('NB','SDP') AND code_composition_programme='TOT_LG_FAM' GROUP BY id_programme, code_composition_programme, code_type_granulometrie");
-						$oResult3->execute();
-						if($oResult3->rowCount()>0){
-							$aGranulometries=$oResult3->fetchAll();
-							foreach ($aGranulometries as $aGranulometrie){
-								$aProgramme2[strtolower($aGranulometrie['code_type_granulometrie'])]=$aGranulometrie['valeur'];
-								$aTotaux[strtolower($aGranulometrie['code_type_granulometrie'])]=$aTotaux[strtolower($aGranulometrie['code_type_granulometrie'])]+$aGranulometrie['valeur'];
-							}
-						}
-						$oResult3->closeCursor();
-						// profil
-						$oResult6=$oConn->prepare("SELECT pourc FROM prod_immo.profil_acheteur_accession_libre WHERE id_type_acheteur_accession_libre=2 AND pourc IS NOT NULL AND id_programme=".$iIdProgramme);
-						$oResult6->execute();
-						if($oResult6->rowCount()>0){
-							$aProfil=$oResult6->fetchAll();
-							$aProgramme2['profil']=$aProfil[0]['pourc'].'%';
-						}
-						$oResult6->closeCursor();
-						// logement social
-						$oResult4=$oConn->prepare("SELECT id_programme, array_to_string(array_agg(DISTINCT nom_bailleur),',') AS nom_bailleur, id_indicateur_logement_familliaux_location, CASE WHEN id_indicateur_logement_familliaux_location=1 THEN sum(COALESCE(social_pls,0)) ELSE avg(COALESCE(social_pls,0)) END AS social_pls, CASE WHEN id_indicateur_logement_familliaux_location=1 THEN sum(COALESCE(social_plus_plai,0)) ELSE avg(COALESCE(social_plus_plai,0)) END AS social_plus_plai, CASE WHEN id_indicateur_logement_familliaux_location=1 THEN sum(COALESCE(intermediaire_pli,0)) ELSE avg(COALESCE(intermediaire_pli,0)) END AS intermediaire_pli, CASE WHEN id_indicateur_logement_familliaux_location=1 THEN sum(COALESCE(intermediaire_afl,0)) ELSE avg(COALESCE(intermediaire_afl,0)) END AS intermediaire_afl	FROM ".$sSchema.".logement_familliaux_location INNER JOIN ".$sSchema.".composition_logement_familliaux_location_cp ON logement_familliaux_location.id_logement_familliaux_location=composition_logement_familliaux_location_cp.id_logement_familliaux_location WHERE id_programme=".$iIdProgramme." AND id_indicateur_logement_familliaux_location IN (1,4,5,8) GROUP BY id_programme, composition_logement_familliaux_location_cp.id_logement_familliaux_location, id_indicateur_logement_familliaux_location");
-						$oResult4->execute();
-						if($oResult4->rowCount()>0){
-							$aLogSocials=$oResult4->fetchAll();
-							$aProgramme2['nom_bailleur']=$aLogSocials[0]['nom_bailleur'];
-							$aCFIlls=array();
-							$aCFIlli=array();
-							foreach ($aLogSocials as $aLogSocial){
-								switch ($aLogSocial['id_indicateur_logement_familliaux_location']) {
-									case 1:
-										if($aLogSocial['social_pls']>0 or $aLogSocial['social_plus_plai']>0){
-											$bSetLogementSocial=true;
-											$aProgramme2['nb_lls']=$aLogSocial['social_pls']+$aLogSocial['social_plus_plai'];
-											$aTotaux['nb_lls']=$aTotaux['nb_lls']+$aLogSocial['social_pls']+$aLogSocial['social_plus_plai'];
-										}
-										if($aLogSocial['intermediaire_pli']>0 or $aLogSocial['intermediaire_afl']>0){
-											$bSetLogementIntermediaire=true;
-											$aProgramme2['nb_lli']=$aLogSocial['intermediaire_pli']+$aLogSocial['intermediaire_afl'];
-											$aTotaux['nb_lli']=$aTotaux['nb_lli']+$aLogSocial['intermediaire_pli']+$aLogSocial['intermediaire_afl'];
-										}
-										break;
-									case 4:
-									case 5:
-										if(!is_null($aLogSocial['social_pls']) and $aLogSocial['social_pls']>0){
-											$bSetLogementSocial=true;
-											$aCFIlls[count($aCFIlls)]=$aLogSocial['social_pls'];
-											$aTotaux['cfi_lls'][count($aTotaux['cfi_lls'])]=$aLogSocial['social_pls'];
-										}
-										if(!is_null($aLogSocial['social_plus_plai']) and $aLogSocial['social_plus_plai']>0){
-											$bSetLogementSocial=true;
-											$aCFIlls[count($aCFIlls)]=$aLogSocial['social_plus_plai'];
-											$aTotaux['cfi_lls'][count($aTotaux['cfi_lls'])]=$aLogSocial['social_plus_plai'];
-										}
-										if(!is_null($aLogSocial['intermediaire_pli']) and $aLogSocial['intermediaire_pli']>0){
-											$bSetLogementIntermediaire=true;
-											$aCFIlli[count($aCFIlli)]=$aLogSocial['intermediaire_pli'];
-											$aTotaux['cfi_lli'][count($aTotaux['cfi_lli'])]=$aLogSocial['intermediaire_pli'];
-										}
-										if(!is_null($aLogSocial['intermediaire_afl']) and $aLogSocial['intermediaire_afl']>0){
-											$bSetLogementIntermediaire=true;
-											$aCFIlli[count($aCFIlli)]=$aLogSocial['intermediaire_afl'];
-											$aTotaux['cfi_lli'][count($aTotaux['cfi_lli'])]=$aLogSocial['intermediaire_afl'];
-										}
-										break;
-									case 8:
-										$aPVlls=array();
-										if(!is_null($aLogSocial['social_pls']) and $aLogSocial['social_pls']>0){
-											$bSetLogementSocial=true;
-											$aPVlls[count($aPVlls)]=$aLogSocial['social_pls'];
-											$aTotaux['pv_lls'][count($aTotaux['pv_lls'])]=$aLogSocial['social_pls'];
-										}
-										if(!is_null($aLogSocial['social_plus_plai']) and $aLogSocial['social_plus_plai']>0){
-											$bSetLogementSocial=true;
-											$aPVlls[count($aPVlls)]=$aLogSocial['social_plus_plai'];
-											$aTotaux['pv_lls'][count($aTotaux['pv_lls'])]=$aLogSocial['social_plus_plai'];
-										}
-										$aProgramme2['pv_lls']=avg(array_sum($aPVlls),count($aPVlls));
-										// pas de prix de vente en lli
-										break;
-								}
-							}
-							$aProgramme2['cfi_lls']=avg(array_sum($aCFIlls),count($aCFIlls));
-							$aProgramme2['cfi_lli']=avg(array_sum($aCFIlli),count($aCFIlli));
-						}
-						
-						$oResult4->closeCursor();
-						// logement accession
-						$oResult5=$oConn->prepare("SELECT id_programme, id_indicateur_logement_familliaux_accession, CASE WHEN id_indicateur_logement_familliaux_accession=1 THEN sum(COALESCE(accession_libre::numeric,0)) ELSE avg(COALESCE(accession_libre::numeric,0)) END AS accession_libre, CASE WHEN id_indicateur_logement_familliaux_accession=1 THEN sum(COALESCE(accession_abordable::numeric,0)) ELSE avg(COALESCE(accession_abordable::numeric,0)) END AS accession_abordable, CASE WHEN id_indicateur_logement_familliaux_accession=1 THEN sum(COALESCE(accession_sociale_securise::numeric,0)) ELSE avg(COALESCE(accession_sociale_securise::numeric,0)) END AS accession_sociale_securise, CASE WHEN id_indicateur_logement_familliaux_accession=1 THEN sum(COALESCE(psla::numeric,0)) ELSE avg(COALESCE(psla::numeric,0)) END AS psla FROM ".$sSchema.".logement_familliaux_accession WHERE id_programme=".$iIdProgramme." AND id_indicateur_logement_familliaux_accession IN (1,4,5,8,9) GROUP BY id_programme, id_indicateur_logement_familliaux_accession");
-						$oResult5->execute();
-						if($oResult5->rowCount()>0){
-							$aLogAccessions=$oResult5->fetchAll();
-							$aCFIAccessionLibre=$aCFIAccessionAbordable=$aCFIAccessionSocialeSecurise=array();
-							$aPVAccessionLibre=$aPVAccessionAbordable=$aPVAccessionSocialeSecurise=array();
-							foreach ($aLogAccessions as $aLogAccession){
-								switch ($aLogAccession['id_indicateur_logement_familliaux_accession']){
-									case 1:
-										if($aLogAccession['accession_libre']>0){
-											$bSetAccessionLibre=true;
-											$aProgramme2['nb_accession_libre']=$aLogAccession['accession_libre'];
-											$aTotaux['nb_accession_libre']=$aTotaux['nb_accession_libre']+$aLogAccession['accession_libre'];
-										}
-										if($aLogAccession['accession_abordable']>0){
-											$bSetAccessionAbordable=true;
-											$aProgramme2['nb_accession_abordable']=$aLogAccession['accession_abordable'];
-											$aTotaux['nb_accession_abordable']=$aTotaux['nb_accession_abordable']+$aLogAccession['accession_abordable'];
-										}
-										if($aLogAccession['accession_sociale_securise']>0){
-											$bSetAccessionSecurisee=true;
-											$aProgramme2['nb_accession_sociale_securise']=$aLogAccession['accession_sociale_securise'];
-											$aTotaux['nb_accession_sociale_securise']=$aTotaux['nb_accession_sociale_securise']+$aLogAccession['accession_sociale_securise'];
-										}
-										if($aLogAccession['psla']>0) $aProgramme2['nb_psla']=$aLogAccession['psla'];
-										break;
-									case 4:
-									case 5:
-										if(!is_null($aLogAccession['accession_libre']) and $aLogAccession['accession_libre']>0){
-											$bSetAccessionLibre=true;
-											$aCFIAccessionLibre[count($aCFIAccessionLibre)]=$aLogAccession['accession_libre'];
-											$aTotaux['cfi_accession_libre'][count($aTotaux['cfi_accession_libre'])]=$aLogAccession['accession_libre'];
-										}
-										if(!is_null($aLogAccession['accession_abordable']) and $aLogAccession['accession_abordable']>0){
-											$bSetAccessionAbordable=true;
-											$aCFIAccessionAbordable[count($aCFIAccessionAbordable)]=$aLogAccession['accession_abordable'];
-											$aTotaux['cfi_accession_abordable'][count($aTotaux['cfi_accession_abordable'])]=$aLogAccession['accession_abordable'];
-										}
-										if(!is_null($aLogAccession['accession_sociale_securise']) and $aLogAccession['accession_sociale_securise']>0){
-											$bSetAccessionSecurisee=true;
-											$aCFIAccessionSocialeSecurise[count($aCFIAccessionSocialeSecurise)]=$aLogAccession['accession_sociale_securise'];
-											$aTotaux['cfi_accession_sociale_securise'][count($aTotaux['cfi_accession_sociale_securise'])]=$aLogAccession['accession_sociale_securise'];
-										}
-										break;
-									case 8:
-									case 9:
-										if(!is_null($aLogAccession['accession_libre']) and $aLogAccession['accession_libre']>0){
-											$bSetAccessionLibre=true;
-											$aPVAccessionLibre[count($aPVAccessionLibre)]=$aLogAccession['accession_libre'];
-											$aTotaux['pv_accession_libre'][count($aTotaux['pv_accession_libre'])]=$aLogAccession['accession_libre'];
-										}
-										if(!is_null($aLogAccession['accession_abordable']) and $aLogAccession['accession_abordable']>0){
-											$bSetAccessionAbordable=true;
-											$aPVAccessionAbordable[count($aPVAccessionAbordable)]=$aLogAccession['accession_abordable'];
-											$aTotaux['pv_accession_abordable'][count($aTotaux['pv_accession_abordable'])]=$aLogAccession['accession_abordable'];
-										}
-										if(!is_null($aLogAccession['accession_sociale_securise']) and $aLogAccession['accession_sociale_securise']>0){
-											$bSetAccessionSecurisee=true;
-											$aPVAccessionSocialeSecurise[count($aPVAccessionSocialeSecurise)]=$aLogAccession['accession_sociale_securise'];
-											$aTotaux['pv_accession_sociale_securise'][count($aTotaux['pv_accession_sociale_securise'])]=$aLogAccession['accession_sociale_securise'];
-										}
-										break;
-								}
-							}
-							$aProgramme2['cfi_accession_libre']=avg(array_sum($aCFIAccessionLibre),count($aCFIAccessionLibre));
-							$aProgramme2['cfi_accession_abordable']=avg(array_sum($aCFIAccessionAbordable),count($aCFIAccessionAbordable));
-							$aProgramme2['cfi_accession_sociale_securise']=avg(array_sum($aCFIAccessionSocialeSecurise),count($aCFIAccessionSocialeSecurise));
-							$aProgramme2['pv_accession_libre']=avg(array_sum($aPVAccessionLibre),count($aPVAccessionLibre));
-							$aProgramme2['pv_accession_abordable']=avg(array_sum($aPVAccessionAbordable),count($aPVAccessionAbordable));
-							$aProgramme2['pv_accession_sociale_securise']=avg(array_sum($aPVAccessionSocialeSecurise),count($aPVAccessionSocialeSecurise));
-						}
-						$oResult5->closeCursor();
-						$aProgrammes2[$aProgramme['id_programme']]=$aProgramme2;
-					}
-					$oResult->closeCursor();
-					$aTotaux['cfi_accession_libre']=avg(array_sum($aTotaux['cfi_accession_libre']),count($aTotaux['cfi_accession_libre']));
-					$aTotaux['pv_accession_libre']=avg(array_sum($aTotaux['pv_accession_libre']),count($aTotaux['pv_accession_libre']));
-					$aTotaux['cfi_accession_abordable']=avg(array_sum($aTotaux['cfi_accession_abordable']),count($aTotaux['cfi_accession_abordable']));
-					$aTotaux['pv_accession_abordable']=avg(array_sum($aTotaux['pv_accession_abordable']),count($aTotaux['pv_accession_abordable']));
-					$aTotaux['cfi_accession_sociale_securise']=avg(array_sum($aTotaux['cfi_accession_sociale_securise']),count($aTotaux['cfi_accession_sociale_securise']));
-					$aTotaux['pv_accession_sociale_securise']=avg(array_sum($aTotaux['pv_accession_sociale_securise']),count($aTotaux['pv_accession_sociale_securise']));
-					$aTotaux['cfi_lls']=avg(array_sum($aTotaux['cfi_lls']),count($aTotaux['cfi_lls']));
-					$aTotaux['pv_lls']=avg(array_sum($aTotaux['pv_lls']),count($aTotaux['pv_lls']));
-					$aTotaux['cfi_lli']=avg(array_sum($aTotaux['cfi_lli']),count($aTotaux['cfi_lli']));
-				}
-				$sCssColor='blue';
-				include ('get_4_logement.html');
-			}
-		}catch (PDOException $e){
-			$sError="ERROR : ".$e->getMessage();
-			include ('get_error.html');
-		}
-	}else{
-		header ('location: signin.php');
-		exit();
-	}
-}else{
-	header ('location: signin.php');
-	exit();
-}
-
+<?php
+// https://geo.urbalyon.org/doc/suivi_prod_immo/get_4_logement.php?code_finanacment=TA
+if (isset($_REQUEST['token']) && !is_null($_REQUEST['token'])){
+	session_id($_REQUEST['token']);
+	if (session_status() == PHP_SESSION_NONE)
+		session_start();
+
+	if (empty($_SESSION)) {
+		$sError="ERREUR : token invalide.";
+		include ('get_error.html');
+	}else{
+
+		require_once("../../rest/conf/properties.inc");
+		require_once("properties_suivi_prod_immo.inc");
+		$sSchema=$properties['schema_prod_immo'];
+
+		function avg($sum=0,$count=0){
+			return ($count)? round($sum / $count): null;
+		}
+
+		try{
+			$oConn = new PDO('pgsql:host='.$properties['server'].';port='.$properties['port'].';dbname='.$properties['db_prod_immo'], $properties['db_user_prod_immo'], $properties['db_pass_prod_immo']);
+			$oConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+			$oConn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
+
+			$bSetAccessionLibre=$bSetAccessionAbordable=$bSetAccessionSecurisee=$bSetBRS=$bSetLogementSocial=$bSetLogementIntermediaire=false;
+			
+			if($oConn){
+				$sWhereOperation='';
+				$aOperations=array();
+				if (isset($_REQUEST['code_financement']) && !is_null($_REQUEST['code_financement'])){
+					$sWhereOperation="WHERE operation_tr_financement_equ_public.code_financement_equ_public='".$_REQUEST['code_financement']."'";
+				}
+
+				if (isset($_REQUEST['id_commune']) && !is_null($_REQUEST['id_commune'])){
+					if ($sWhereOperation=='')
+						$sWhereOperation="WHERE operation_commune.id_commune=".$_REQUEST['id_commune'];
+					else
+						$sWhereOperation=$sWhereOperation." AND operation_commune.id_commune=".$_REQUEST['id_commune'];
+				}else{
+					if (isset($_REQUEST['id_ctm']) && !is_null($_REQUEST['id_ctm'])){
+						$oResult2 = $oConn->prepare("SELECT array_to_string(array_agg(id_commune),', ') AS id_commune FROM ".$sSchema.".commune WHERE id_ctm=".$_REQUEST['id_ctm']." GROUP BY id_ctm");
+						$oResult2->execute();
+						if ($oResult2->rowCount()>0){
+							$aCTMs=$oResult2->fetchAll();
+							if ($sWhereOperation=='')
+								$sWhereOperation="WHERE operation_commune.id_commune IN (".$aCTMs[0]['id_commune'].")";
+							else
+								$sWhereOperation=$sWhereOperation." AND operation_commune.id_commune IN (".$aCTMs[0]['id_commune'].")";/**/
+						}
+						$oResult2->closeCursor();
+					}
+				}
+				$sSql='SELECT DISTINCT operation.id_operation, nom_operation, array_to_string(array_agg(DISTINCT operation_tr_financement_equ_public.code_financement_equ_public),\', \') AS code_financement_equ_public, array_to_string(array_agg(DISTINCT nom_commune),\', \') AS nom_commune, nom_ilot, ilot.id_ilot, id_programme, nom_demandeur FROM (((('.$sSchema.'.operation INNER JOIN '.$sSchema.'.operation_tr_financement_equ_public ON operation_tr_financement_equ_public.id_operation=operation.id_operation) INNER JOIN '.$sSchema.'.operation_commune  ON operation_commune.id_operation=operation.id_operation) INNER JOIN '.$sSchema.'.commune ON operation_commune.id_commune=commune.id_commune) INNER JOIN '.$sSchema.'.ilot ON ilot.id_operation=operation.id_operation) INNER JOIN '.$sSchema.'.programme_immobilier ON ilot.id_ilot=programme_immobilier.id_ilot '.$sWhereOperation.' GROUP BY id_programme, ilot.id_ilot, operation.id_operation ORDER BY nom_commune, nom_operation, nom_ilot';
+				$oResult = $oConn->prepare($sSql);
+				$oResult->execute();
+				if($oResult->rowCount()>0){
+					$aProgrammes=$oResult->fetchAll();
+					$aCptCommunes=array();
+					$aCptOperations=array();
+					$aCptIlots=array();
+					$aTotaux=array('sdp'=>0,'nb'=>0,'nb_accession_libre'=>0,'cfi_accession_libre'=>array(),'pv_accession_libre'=>array(),'nb_accession_abordable'=>0,'cfi_accession_abordable'=>array(),'pv_accession_abordable'=>array(),'nb_accession_sociale_securise'=>0,'cfi_accession_sociale_securise'=>array(),'pv_accession_sociale_securise'=>array(),'nb_lls'=>0,'cfi_lls'=>array(),'pv_lls'=>array(),'nb_lli'=>0,'cfi_lli'=>array());
+					$aProgrammes2=array();
+					foreach ($aProgrammes as $aProgramme){
+						// **** Compteurs pour fusion des cellules du tableau
+						if(isset($aCptCommunes[$aProgramme['nom_commune']]))
+							$aCptCommunes[$aProgramme['nom_commune']]=$aCptCommunes[$aProgramme['nom_commune']]+1;
+						else
+							$aCptCommunes[$aProgramme['nom_commune']]=1;
+						if(isset($aCptOperations[$aProgramme['id_operation']]))
+							$aCptOperations[$aProgramme['id_operation']]=$aCptOperations[$aProgramme['id_operation']]+1;
+						else
+							$aCptOperations[$aProgramme['id_operation']]=1;
+						if(isset($aCptIlots[$aProgramme['id_ilot']]))
+							$aCptIlots[$aProgramme['id_ilot']]=$aCptIlots[$aProgramme['id_ilot']]+1;
+						else
+							$aCptIlots[$aProgramme['id_ilot']]=1;
+						// **** Récupération des données tables associées
+						$iIdProgramme=$aProgramme['id_programme'];
+						$aProgramme2=array();
+						// Granulométrie
+						$oResult3=$oConn->prepare("SELECT id_programme, code_type_granulometrie, sum(valeur) AS valeur FROM ".$sSchema.".granulometrie WHERE id_programme=".$iIdProgramme." AND code_type_granulometrie IN ('NB','SDP') AND code_composition_programme='TOT_LG_FAM' GROUP BY id_programme, code_composition_programme, code_type_granulometrie");
+						$oResult3->execute();
+						if($oResult3->rowCount()>0){
+							$aGranulometries=$oResult3->fetchAll();
+							foreach ($aGranulometries as $aGranulometrie){
+								$aProgramme2[strtolower($aGranulometrie['code_type_granulometrie'])]=$aGranulometrie['valeur'];
+								$aTotaux[strtolower($aGranulometrie['code_type_granulometrie'])]=$aTotaux[strtolower($aGranulometrie['code_type_granulometrie'])]+$aGranulometrie['valeur'];
+							}
+						}
+						$oResult3->closeCursor();
+						// profil
+						$oResult6=$oConn->prepare("SELECT pourc FROM prod_immo.profil_acheteur_accession_libre WHERE id_type_acheteur_accession_libre=2 AND pourc IS NOT NULL AND id_programme=".$iIdProgramme);
+						$oResult6->execute();
+						if($oResult6->rowCount()>0){
+							$aProfil=$oResult6->fetchAll();
+							$aProgramme2['profil']=$aProfil[0]['pourc'].'%';
+						}
+						$oResult6->closeCursor();
+						// logement social
+						$oResult4=$oConn->prepare("SELECT id_programme, array_to_string(array_agg(DISTINCT nom_bailleur),',') AS nom_bailleur, id_indicateur_logement_familliaux_location, CASE WHEN id_indicateur_logement_familliaux_location=1 THEN sum(COALESCE(social_pls,0)) ELSE avg(COALESCE(social_pls,0)) END AS social_pls, CASE WHEN id_indicateur_logement_familliaux_location=1 THEN sum(COALESCE(social_plus_plai,0)) ELSE avg(COALESCE(social_plus_plai,0)) END AS social_plus_plai, CASE WHEN id_indicateur_logement_familliaux_location=1 THEN sum(COALESCE(intermediaire_pli,0)) ELSE avg(COALESCE(intermediaire_pli,0)) END AS intermediaire_pli, CASE WHEN id_indicateur_logement_familliaux_location=1 THEN sum(COALESCE(intermediaire_afl,0)) ELSE avg(COALESCE(intermediaire_afl,0)) END AS intermediaire_afl	FROM ".$sSchema.".logement_familliaux_location INNER JOIN ".$sSchema.".composition_logement_familliaux_location_cp ON logement_familliaux_location.id_logement_familliaux_location=composition_logement_familliaux_location_cp.id_logement_familliaux_location WHERE id_programme=".$iIdProgramme." AND id_indicateur_logement_familliaux_location IN (1,4,5,8) GROUP BY id_programme, composition_logement_familliaux_location_cp.id_logement_familliaux_location, id_indicateur_logement_familliaux_location");
+						$oResult4->execute();
+						if($oResult4->rowCount()>0){
+							$aLogSocials=$oResult4->fetchAll();
+							$aProgramme2['nom_bailleur']=$aLogSocials[0]['nom_bailleur'];
+							$aCFIlls=array();
+							$aCFIlli=array();
+							foreach ($aLogSocials as $aLogSocial){
+								switch ($aLogSocial['id_indicateur_logement_familliaux_location']) {
+									case 1:
+										if($aLogSocial['social_pls']>0 or $aLogSocial['social_plus_plai']>0){
+											$bSetLogementSocial=true;
+											$aProgramme2['nb_lls']=$aLogSocial['social_pls']+$aLogSocial['social_plus_plai'];
+											$aTotaux['nb_lls']=$aTotaux['nb_lls']+$aLogSocial['social_pls']+$aLogSocial['social_plus_plai'];
+										}
+										if($aLogSocial['intermediaire_pli']>0 or $aLogSocial['intermediaire_afl']>0){
+											$bSetLogementIntermediaire=true;
+											$aProgramme2['nb_lli']=$aLogSocial['intermediaire_pli']+$aLogSocial['intermediaire_afl'];
+											$aTotaux['nb_lli']=$aTotaux['nb_lli']+$aLogSocial['intermediaire_pli']+$aLogSocial['intermediaire_afl'];
+										}
+										break;
+									case 4:
+									case 5:
+										if(!is_null($aLogSocial['social_pls']) and $aLogSocial['social_pls']>0){
+											$bSetLogementSocial=true;
+											$aCFIlls[count($aCFIlls)]=$aLogSocial['social_pls'];
+											$aTotaux['cfi_lls'][count($aTotaux['cfi_lls'])]=$aLogSocial['social_pls'];
+										}
+										if(!is_null($aLogSocial['social_plus_plai']) and $aLogSocial['social_plus_plai']>0){
+											$bSetLogementSocial=true;
+											$aCFIlls[count($aCFIlls)]=$aLogSocial['social_plus_plai'];
+											$aTotaux['cfi_lls'][count($aTotaux['cfi_lls'])]=$aLogSocial['social_plus_plai'];
+										}
+										if(!is_null($aLogSocial['intermediaire_pli']) and $aLogSocial['intermediaire_pli']>0){
+											$bSetLogementIntermediaire=true;
+											$aCFIlli[count($aCFIlli)]=$aLogSocial['intermediaire_pli'];
+											$aTotaux['cfi_lli'][count($aTotaux['cfi_lli'])]=$aLogSocial['intermediaire_pli'];
+										}
+										if(!is_null($aLogSocial['intermediaire_afl']) and $aLogSocial['intermediaire_afl']>0){
+											$bSetLogementIntermediaire=true;
+											$aCFIlli[count($aCFIlli)]=$aLogSocial['intermediaire_afl'];
+											$aTotaux['cfi_lli'][count($aTotaux['cfi_lli'])]=$aLogSocial['intermediaire_afl'];
+										}
+										break;
+									case 8:
+										$aPVlls=array();
+										if(!is_null($aLogSocial['social_pls']) and $aLogSocial['social_pls']>0){
+											$bSetLogementSocial=true;
+											$aPVlls[count($aPVlls)]=$aLogSocial['social_pls'];
+											$aTotaux['pv_lls'][count($aTotaux['pv_lls'])]=$aLogSocial['social_pls'];
+										}
+										if(!is_null($aLogSocial['social_plus_plai']) and $aLogSocial['social_plus_plai']>0){
+											$bSetLogementSocial=true;
+											$aPVlls[count($aPVlls)]=$aLogSocial['social_plus_plai'];
+											$aTotaux['pv_lls'][count($aTotaux['pv_lls'])]=$aLogSocial['social_plus_plai'];
+										}
+										$aProgramme2['pv_lls']=avg(array_sum($aPVlls),count($aPVlls));
+										// pas de prix de vente en lli
+										break;
+								}
+							}
+							$aProgramme2['cfi_lls']=avg(array_sum($aCFIlls),count($aCFIlls));
+							$aProgramme2['cfi_lli']=avg(array_sum($aCFIlli),count($aCFIlli));
+						}
+						
+						$oResult4->closeCursor();
+						// logement accession
+						$oResult5=$oConn->prepare("SELECT id_programme, id_indicateur_logement_familliaux_accession, CASE WHEN id_indicateur_logement_familliaux_accession=1 THEN sum(COALESCE(accession_libre::numeric,0)) ELSE avg(COALESCE(accession_libre::numeric,0)) END AS accession_libre, CASE WHEN id_indicateur_logement_familliaux_accession=1 THEN sum(COALESCE(accession_abordable::numeric,0)) ELSE avg(COALESCE(accession_abordable::numeric,0)) END AS accession_abordable, CASE WHEN id_indicateur_logement_familliaux_accession=1 THEN sum(COALESCE(accession_sociale_securise::numeric,0)) ELSE avg(COALESCE(accession_sociale_securise::numeric,0)) END AS accession_sociale_securise, CASE WHEN id_indicateur_logement_familliaux_accession=1 THEN sum(COALESCE(psla::numeric,0)) ELSE avg(COALESCE(psla::numeric,0)) END AS psla FROM ".$sSchema.".logement_familliaux_accession WHERE id_programme=".$iIdProgramme." AND id_indicateur_logement_familliaux_accession IN (1,4,5,8,9) GROUP BY id_programme, id_indicateur_logement_familliaux_accession");
+						$oResult5->execute();
+						if($oResult5->rowCount()>0){
+							$aLogAccessions=$oResult5->fetchAll();
+							$aCFIAccessionLibre=$aCFIAccessionAbordable=$aCFIAccessionSocialeSecurise=array();
+							$aPVAccessionLibre=$aPVAccessionAbordable=$aPVAccessionSocialeSecurise=array();
+							foreach ($aLogAccessions as $aLogAccession){
+								switch ($aLogAccession['id_indicateur_logement_familliaux_accession']){
+									case 1:
+										if($aLogAccession['accession_libre']>0){
+											$bSetAccessionLibre=true;
+											$aProgramme2['nb_accession_libre']=$aLogAccession['accession_libre'];
+											$aTotaux['nb_accession_libre']=$aTotaux['nb_accession_libre']+$aLogAccession['accession_libre'];
+										}
+										if($aLogAccession['accession_abordable']>0){
+											$bSetAccessionAbordable=true;
+											$aProgramme2['nb_accession_abordable']=$aLogAccession['accession_abordable'];
+											$aTotaux['nb_accession_abordable']=$aTotaux['nb_accession_abordable']+$aLogAccession['accession_abordable'];
+										}
+										if($aLogAccession['accession_sociale_securise']>0){
+											$bSetAccessionSecurisee=true;
+											$aProgramme2['nb_accession_sociale_securise']=$aLogAccession['accession_sociale_securise'];
+											$aTotaux['nb_accession_sociale_securise']=$aTotaux['nb_accession_sociale_securise']+$aLogAccession['accession_sociale_securise'];
+										}
+										if($aLogAccession['psla']>0) $aProgramme2['nb_psla']=$aLogAccession['psla'];
+										break;
+									case 4:
+									case 5:
+										if(!is_null($aLogAccession['accession_libre']) and $aLogAccession['accession_libre']>0){
+											$bSetAccessionLibre=true;
+											$aCFIAccessionLibre[count($aCFIAccessionLibre)]=$aLogAccession['accession_libre'];
+											$aTotaux['cfi_accession_libre'][count($aTotaux['cfi_accession_libre'])]=$aLogAccession['accession_libre'];
+										}
+										if(!is_null($aLogAccession['accession_abordable']) and $aLogAccession['accession_abordable']>0){
+											$bSetAccessionAbordable=true;
+											$aCFIAccessionAbordable[count($aCFIAccessionAbordable)]=$aLogAccession['accession_abordable'];
+											$aTotaux['cfi_accession_abordable'][count($aTotaux['cfi_accession_abordable'])]=$aLogAccession['accession_abordable'];
+										}
+										if(!is_null($aLogAccession['accession_sociale_securise']) and $aLogAccession['accession_sociale_securise']>0){
+											$bSetAccessionSecurisee=true;
+											$aCFIAccessionSocialeSecurise[count($aCFIAccessionSocialeSecurise)]=$aLogAccession['accession_sociale_securise'];
+											$aTotaux['cfi_accession_sociale_securise'][count($aTotaux['cfi_accession_sociale_securise'])]=$aLogAccession['accession_sociale_securise'];
+										}
+										break;
+									case 8:
+									case 9:
+										if(!is_null($aLogAccession['accession_libre']) and $aLogAccession['accession_libre']>0){
+											$bSetAccessionLibre=true;
+											$aPVAccessionLibre[count($aPVAccessionLibre)]=$aLogAccession['accession_libre'];
+											$aTotaux['pv_accession_libre'][count($aTotaux['pv_accession_libre'])]=$aLogAccession['accession_libre'];
+										}
+										if(!is_null($aLogAccession['accession_abordable']) and $aLogAccession['accession_abordable']>0){
+											$bSetAccessionAbordable=true;
+											$aPVAccessionAbordable[count($aPVAccessionAbordable)]=$aLogAccession['accession_abordable'];
+											$aTotaux['pv_accession_abordable'][count($aTotaux['pv_accession_abordable'])]=$aLogAccession['accession_abordable'];
+										}
+										if(!is_null($aLogAccession['accession_sociale_securise']) and $aLogAccession['accession_sociale_securise']>0){
+											$bSetAccessionSecurisee=true;
+											$aPVAccessionSocialeSecurise[count($aPVAccessionSocialeSecurise)]=$aLogAccession['accession_sociale_securise'];
+											$aTotaux['pv_accession_sociale_securise'][count($aTotaux['pv_accession_sociale_securise'])]=$aLogAccession['accession_sociale_securise'];
+										}
+										break;
+								}
+							}
+							$aProgramme2['cfi_accession_libre']=avg(array_sum($aCFIAccessionLibre),count($aCFIAccessionLibre));
+							$aProgramme2['cfi_accession_abordable']=avg(array_sum($aCFIAccessionAbordable),count($aCFIAccessionAbordable));
+							$aProgramme2['cfi_accession_sociale_securise']=avg(array_sum($aCFIAccessionSocialeSecurise),count($aCFIAccessionSocialeSecurise));
+							$aProgramme2['pv_accession_libre']=avg(array_sum($aPVAccessionLibre),count($aPVAccessionLibre));
+							$aProgramme2['pv_accession_abordable']=avg(array_sum($aPVAccessionAbordable),count($aPVAccessionAbordable));
+							$aProgramme2['pv_accession_sociale_securise']=avg(array_sum($aPVAccessionSocialeSecurise),count($aPVAccessionSocialeSecurise));
+						}
+						$oResult5->closeCursor();
+						$aProgrammes2[$aProgramme['id_programme']]=$aProgramme2;
+					}
+					$oResult->closeCursor();
+					$aTotaux['cfi_accession_libre']=avg(array_sum($aTotaux['cfi_accession_libre']),count($aTotaux['cfi_accession_libre']));
+					$aTotaux['pv_accession_libre']=avg(array_sum($aTotaux['pv_accession_libre']),count($aTotaux['pv_accession_libre']));
+					$aTotaux['cfi_accession_abordable']=avg(array_sum($aTotaux['cfi_accession_abordable']),count($aTotaux['cfi_accession_abordable']));
+					$aTotaux['pv_accession_abordable']=avg(array_sum($aTotaux['pv_accession_abordable']),count($aTotaux['pv_accession_abordable']));
+					$aTotaux['cfi_accession_sociale_securise']=avg(array_sum($aTotaux['cfi_accession_sociale_securise']),count($aTotaux['cfi_accession_sociale_securise']));
+					$aTotaux['pv_accession_sociale_securise']=avg(array_sum($aTotaux['pv_accession_sociale_securise']),count($aTotaux['pv_accession_sociale_securise']));
+					$aTotaux['cfi_lls']=avg(array_sum($aTotaux['cfi_lls']),count($aTotaux['cfi_lls']));
+					$aTotaux['pv_lls']=avg(array_sum($aTotaux['pv_lls']),count($aTotaux['pv_lls']));
+					$aTotaux['cfi_lli']=avg(array_sum($aTotaux['cfi_lli']),count($aTotaux['cfi_lli']));
+				}
+				$sCssColor='blue';
+				include ('get_4_logement.html');
+			}
+		}catch (PDOException $e){
+			$sError="ERROR : ".$e->getMessage();
+			include ('get_error.html');
+		}
+	}
+	
+}else{
+	$sError="ERREUR : Pas de token passé.";
+	include ('get_error.html');
+}
+
 ?>
\ No newline at end of file
diff --git a/src/vitis/vas/rest/class/vitis_lib/Connection.class.inc b/src/vitis/vas/rest/class/vitis_lib/Connection.class.inc
index bb3bc4f69b73b5dedfe43b0584ece15860576a25..fa801dc5b0a03ce775b11fdb3f91faa739b9791e 100755
--- a/src/vitis/vas/rest/class/vitis_lib/Connection.class.inc
+++ b/src/vitis/vas/rest/class/vitis_lib/Connection.class.inc
@@ -235,7 +235,6 @@ class Connection {
             'sSchema' => array('value' => $sSchema, 'type' => 'column_name'),
             'sTable' => array('value' => $sTable, 'type' => 'column_name')
         );
-
         $sSql = "SELECT
     	has_table_privilege('\"[sSchema]\".\"[sTable]\"','insert') AS \"INSERT\",
     	has_table_privilege('\"[sSchema]\".\"[sTable]\"','select') AS \"SELECT\",