From 7fb4bdc300cc4d4dfdb1ede27967bad3f551ede6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Carretero?=
 <frederic.carretero@veremes.com>
Date: Fri, 18 Jan 2019 09:01:50 +0100
Subject: [PATCH] =?UTF-8?q?Resolve=20"[ANC]=20Am=C3=A9lioration=20du=20cha?=
 =?UTF-8?q?mp=20commune=20de=20l'onglet=20entreprise"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../anc_parametrage_anc_entreprise.json       | 48 +++++++++----------
 src/module_anc/web_service/sql/sqlQueries.xml |  8 ++++
 .../web_service/ws/Entreprise.class.inc       |  8 ++--
 .../web_service/ws/Entreprises.class.inc      |  8 ++--
 4 files changed, 40 insertions(+), 32 deletions(-)

diff --git a/src/module_anc/module/forms/anc_parametrage/anc_parametrage_anc_entreprise.json b/src/module_anc/module/forms/anc_parametrage/anc_parametrage_anc_entreprise.json
index 27f8a47c..c09edf1e 100755
--- a/src/module_anc/module/forms/anc_parametrage/anc_parametrage_anc_entreprise.json
+++ b/src/module_anc/module/forms/anc_parametrage/anc_parametrage_anc_entreprise.json
@@ -23,12 +23,12 @@
                 "fields":[
                     {
                         "type":"label",
-                        "name":"id_com",
+                        "name":"commune",
                         "label":"Commune",
                         "disabled":false,
                         "required":false,
                         "nb_cols":6,
-                        "id":"id_com_2_1"
+                        "id":"commune_2_1"
                     },
                     {
                         "type":"label",
@@ -343,7 +343,7 @@
                     "label":"Tab 0",
                     "elements":[
                         "id_parametre_entreprises",
-                        "id_com",
+                        "commune",
                         "siret",
                         "raison_sociale",
                         "nom_entreprise",
@@ -382,8 +382,8 @@
             {
                 "fields":[
                     {
-                        "type":"select",
-                        "name":"id_com",
+                        "type":"editable_select",
+                        "name":"commune",
                         "label":"Commune",
                         "required":false,
                         "nb_cols":4,
@@ -395,8 +395,8 @@
                             "distinct":"true",
                             "label_key":"nom",
                             "order_by":"nom",
-                            "id_key":"id_com",
-                            "attributs":"id_com|nom"
+                            "id_key":"nom",
+                            "attributs":"nom"
                         }
                     },
                     {
@@ -454,7 +454,7 @@
                     "label":"Tab 0",
                     "elements":[
                         "search_button",
-                        "id_com",
+                        "commune",
                         "raison_sociale",
                         "nom_entreprise"
                     ]
@@ -472,22 +472,22 @@
             {
                 "fields":[
                     {
-                        "type":"select",
-                        "name":"id_com",
+                        "type":"editable_select",
+                        "name":"commune",
                         "label":"Commune",
                         "required":true,
                         "nb_cols":6,
-                        "id":"id_com_2_1",
+                        "id":"commune_2_1",
                         "datasource":{
                             "datasource_id":"datasource_1",
                             "sort_order":"ASC",
                             "distinct":"true",
                             "label_key":"nom",
                             "order_by":"nom",
-                            "id_key":"id_com",
-                            "attributs":"id_com|nom"
+                            "id_key":"nom",
+                            "attributs":"nom"
                         },
-                        "id_from":"id_com_2_1_from"
+                        "id_from":"commune_2_1_from"
                     },
                     {
                         "type":"text",
@@ -830,7 +830,7 @@
                 {
                     "label":"Tab 0",
                     "elements":[
-                        "id_com",
+                        "commune",
                         "siret",
                         "raison_sociale",
                         "nom_entreprise",
@@ -876,22 +876,22 @@
             {
                 "fields":[
                     {
-                        "type":"select",
-                        "name":"id_com",
+                        "type":"editable_select",
+                        "name":"commune",
                         "label":"Commune",
                         "required":true,
                         "nb_cols":6,
-                        "id":"id_com_2_1",
+                        "id":"commune_2_1",
                         "datasource":{
                             "datasource_id":"datasource_1",
                             "sort_order":"ASC",
                             "distinct":"true",
                             "label_key":"nom",
                             "order_by":"nom",
-                            "id_key":"id_com",
-                            "attributs":"id_com|nom"
+                            "id_key":"nom",
+                            "attributs":"nom"
                         },
-                        "id_from":"id_com_2_1_from"
+                        "id_from":"commune_2_1_from"
                     },
                     {
                         "type":"text",
@@ -1283,7 +1283,7 @@
                     "label":"Tab 0",
                     "elements":[
                         "id_parametre_entreprises",
-                        "id_com",
+                        "commune",
                         "siret",
                         "raison_sociale",
                         "nom_entreprise",
@@ -1316,7 +1316,7 @@
         "datasource_1":{
             "type":"web_service",
             "dataType":"tableValue",
-            "name":"id_com",
+            "name":"commune",
             "description":"",
             "parameters":{
                 "schema":"s_cadastre",
@@ -1326,4 +1326,4 @@
             "id":"datasource_1"
         }
     }
-}
\ No newline at end of file
+}
diff --git a/src/module_anc/web_service/sql/sqlQueries.xml b/src/module_anc/web_service/sql/sqlQueries.xml
index a68f318b..9a417429 100644
--- a/src/module_anc/web_service/sql/sqlQueries.xml
+++ b/src/module_anc/web_service/sql/sqlQueries.xml
@@ -3119,10 +3119,18 @@
 			<version>2019.01.00</version>
 			<code>
 				<![CDATA[
+					-- Frédéric le 16/01/2019 10:15
+					UPDATE s_vitis.vm_table_field SET name = 'commune', width = 200 WHERE tab_id = (SELECT tab_id FROM s_vitis.vm_tab WHERE vm_tab.name = 'anc_entreprise') AND name = 'id_com';
 					DELETE FROM s_vitis.vm_table_button WHERE tab_id = (SELECT tab_id FROM s_vitis.vm_tab WHERE vm_tab.name = 'anc_installation') AND label_id IN ('anc_13', 'anc_14');
 					INSERT INTO s_vitis.vm_table_button (button_class, table_button_id, event, label_id, ressource_id, tab_id) VALUES ('add_smallFlexigrid',(SELECT nextval('s_vitis.seq_vm'::regclass)), 'AddSectionForm', 'anc_14', (SELECT ressource_id FROM s_vitis.vm_tab WHERE vm_tab.name = 'anc_installation'), (SELECT tab_id FROM s_vitis.vm_tab WHERE vm_tab.name = 'anc_installation'));
 					INSERT INTO s_vitis.vm_table_button (button_class, table_button_id, event, label_id, ressource_id, tab_id) VALUES ('deleteFlexigrid',(SELECT nextval('s_vitis.seq_vm'::regclass)), 'DeleteSelection', 'anc_13', (SELECT ressource_id FROM s_vitis.vm_tab WHERE vm_tab.name = 'anc_installation'), (SELECT tab_id FROM s_vitis.vm_tab WHERE vm_tab.name = 'anc_installation'));
 					UPDATE s_vitis.vm_tab SET sorted_dir = 'DESC' WHERE name = 'anc_installation';
+
+					-- Frédéric le 16/01/2019 15:52
+					ALTER TABLE s_anc.param_entreprise ADD COLUMN commune character varying(50);
+					UPDATE s_anc.param_entreprise SET commune = id_com;
+					UPDATE s_anc.param_entreprise as "pe" SET commune = (SELECT texte FROM s_cadastre.commune WHERE id_com = "pe".id_com) WHERE (SELECT texte FROM s_cadastre.commune WHERE id_com = "pe".id_com) is not null;
+					ALTER TABLE s_anc.param_entreprise ALTER COLUMN commune SET NOT NULL;
 				]]>
 			</code>
 		</query>
diff --git a/src/module_anc/web_service/ws/Entreprise.class.inc b/src/module_anc/web_service/ws/Entreprise.class.inc
index 00bb4aec..acb6df42 100755
--- a/src/module_anc/web_service/ws/Entreprise.class.inc
+++ b/src/module_anc/web_service/ws/Entreprise.class.inc
@@ -12,7 +12,7 @@ require_once dirname($_SERVER['SCRIPT_FILENAME']) . '/class/vitis_lib/Connection
  * 	\brief This file contains the Entreprise php class
  *
  * This class defines operation for one Entreprise
- * 
+ *
  */
 class Entreprise extends Anc {
 
@@ -30,11 +30,11 @@ class Entreprise extends Anc {
         $this->aPath = $aPath;
         $this->aProperties = $properties;
         $this->oConnection = new Connection($this->aValues, $this->aProperties);
-        $this->aSelectedFields = Array("id_parametre_entreprises", "id_com", "siret", "raison_sociale", "nom_entreprise", "nom_contact", "telephone_fixe", "telephone_mobile", "web", "mail", "code_postal", "voie", "bureau_etude", "concepteur", "constructeur", "installateur", "vidangeur", "en_activite", "observations", "creat", "creat_date", "maj", "maj_date", "geom");
+        $this->aSelectedFields = Array("id_parametre_entreprises", "commune", "siret", "raison_sociale", "nom_entreprise", "nom_contact", "telephone_fixe", "telephone_mobile", "web", "mail", "code_postal", "voie", "bureau_etude", "concepteur", "constructeur", "installateur", "vidangeur", "en_activite", "observations", "creat", "creat_date", "maj", "maj_date", "geom");
     }
 
     /**
-     * @SWG\Get(path="/entreprises/{id_entreprise}", 
+     * @SWG\Get(path="/entreprises/{id_entreprise}",
      *   tags={"Entreprises"},
      *   summary="Get Entreprise",
      *   description="Request to get Entreprise by id",
@@ -91,4 +91,4 @@ class Entreprise extends Anc {
 
 }
 
-?>
\ No newline at end of file
+?>
diff --git a/src/module_anc/web_service/ws/Entreprises.class.inc b/src/module_anc/web_service/ws/Entreprises.class.inc
index 625e0089..25cdc54b 100755
--- a/src/module_anc/web_service/ws/Entreprises.class.inc
+++ b/src/module_anc/web_service/ws/Entreprises.class.inc
@@ -9,7 +9,7 @@
  * 	\brief This file contains the Entreprises php class
  *
  * This class defines Rest Api to Vitis Entreprises
- * 
+ *
  */
 require_once __DIR__ . '/Anc.class.inc';
 require_once 'Entreprise.class.inc';
@@ -40,7 +40,7 @@ class Entreprises extends Anc {
         $this->aPath = $aPath;
         $this->aProperties = $properties;
         $this->oConnection = new Connection($this->aValues, $this->aProperties);
-        $this->aSelectedFields = Array("id_parametre_entreprises", "id_com", "siret", "raison_sociale", "nom_entreprise", "nom_contact", "telephone_fixe", "telephone_mobile", "web", "mail", "code_postal", "voie", "bureau_etude", "concepteur", "constructeur", "installateur", "vidangeur", "en_activite", "observations", "creat", "creat_date", "maj", "maj_date", "geom");
+        $this->aSelectedFields = Array("id_parametre_entreprises", "commune", "siret", "raison_sociale", "nom_entreprise", "nom_contact", "telephone_fixe", "telephone_mobile", "web", "mail", "code_postal", "voie", "bureau_etude", "concepteur", "constructeur", "installateur", "vidangeur", "en_activite", "observations", "creat", "creat_date", "maj", "maj_date", "geom");
     }
 
     /**
@@ -154,7 +154,7 @@ class Entreprises extends Anc {
      */
     function POST() {
         $this->aValues['creat'] = $_SESSION["ses_Login"];
-        $this->aValues['creat_date'] = date('Y-m-d');        
+        $this->aValues['creat_date'] = date('Y-m-d');
         $aReturn = $this->genericPost($this->aProperties['schema_anc'], 'param_entreprise', $this->aProperties['schema_anc'].'.param_entreprise_id_parametre_entreprises_seq', 'id_parametre_entreprises');
         return $aReturn['sMessage'];
     }
@@ -269,4 +269,4 @@ class Entreprises extends Anc {
         return $aReturn['sMessage'];
     }
 }
-?>
\ No newline at end of file
+?>
-- 
GitLab