From 8f7d8ff695f8197abdd0c44f1b896774de0f4221 Mon Sep 17 00:00:00 2001
From: Sofian pujo <sofian.pujo@veremes.com>
Date: Mon, 5 Nov 2018 16:05:27 +0100
Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20des=20require=5Fonce?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../web_service/ws/Extraction.class.inc       | 143 ++--
 .../ws/ExtractionExtraction.class.inc         |   5 +-
 .../web_service/ws/Extractions.class.inc      | 683 +++++++++---------
 3 files changed, 423 insertions(+), 408 deletions(-)

diff --git a/src/module_extraction/web_service/ws/Extraction.class.inc b/src/module_extraction/web_service/ws/Extraction.class.inc
index 1351aa93..1b97cb73 100755
--- a/src/module_extraction/web_service/ws/Extraction.class.inc
+++ b/src/module_extraction/web_service/ws/Extraction.class.inc
@@ -1,7 +1,7 @@
 <?php
-    
+
 require_once __DIR__ . '/ExtractionExtraction.class.inc';
-require_once dirname($_SERVER['SCRIPT_FILENAME']) . '/class/vitis_lib/Connection.class.inc';
+require_once $this->aProperties['vas_home'] . '/rest/class/vitis_lib/Connection.class.inc';
 
 /**
  * \file Extraction.class.inc
@@ -9,15 +9,16 @@ require_once dirname($_SERVER['SCRIPT_FILENAME']) . '/class/vitis_lib/Connection
  *
  * \author WAB <support.wab@veremes.com>.
  *
- * 	\brief This file contains the Extraction php class
+ *     \brief This file contains the Extraction php class
  *
  * This class defines operation for one Extraction
- * 
+ *
  */
-class Extraction extends ExtractionExtraction {
-    
+class Extraction extends ExtractionExtraction
+{
+
     public $oError;
-        
+
     /**
      * construct
      * @param type $aPath url of the request
@@ -26,72 +27,75 @@ class Extraction extends ExtractionExtraction {
      * @param type $bShortcut false to reinit variables
      * @param type $oConnection connection object
      */
-    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false){
+    public function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false)
+    {
         parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
     }
-        
+
 /**
-     * @SWG\Get(path="/extractions/{id_extraction}", 
-     *   tags={"Extractions"},
-     *   summary="Get Extraction",
-     *   description="Request to get Extraction by id",
-     *   operationId="GET",
-     *   produces={"application/xml", "application/json"},
-     *   @SWG\Parameter(
-     *     name="token",
-     *     in="query",
-     *     description="user token",
-     *     required=true,
-     *     type="string"
-     *   ),
-     * @SWG\Parameter(
-     *     name="id_extraction",
-     *     in="path",
-     *     description="id_extraction",
-     *     required=true,
-     *     type="integer",
-     *   format="int32"
-     *   ),
-     * @SWG\Parameter(
-     *     name="attributs",
-     *     in="query",
-     *     description="list of attributs",
-     *     required=false,
-     *     type="string"
-     *   ),
-     *   @SWG\Response(
-     *         response=200,
-     *         description="Extraction Response",
-     *         @SWG\Schema(ref="#/definitions/extractions")
-     *     )
-     *  )
-     */
-         
+ * @SWG\Get(path="/extractions/{id_extraction}",
+ *   tags={"Extractions"},
+ *   summary="Get Extraction",
+ *   description="Request to get Extraction by id",
+ *   operationId="GET",
+ *   produces={"application/xml", "application/json"},
+ *   @SWG\Parameter(
+ *     name="token",
+ *     in="query",
+ *     description="user token",
+ *     required=true,
+ *     type="string"
+ *   ),
+ * @SWG\Parameter(
+ *     name="id_extraction",
+ *     in="path",
+ *     description="id_extraction",
+ *     required=true,
+ *     type="integer",
+ *   format="int32"
+ *   ),
+ * @SWG\Parameter(
+ *     name="attributs",
+ *     in="query",
+ *     description="list of attributs",
+ *     required=false,
+ *     type="string"
+ *   ),
+ *   @SWG\Response(
+ *         response=200,
+ *         description="Extraction Response",
+ *         @SWG\Schema(ref="#/definitions/extractions")
+ *     )
+ *  )
+ */
+
     /**
      * get informations about mode
      */
-    function GET() {
+    public function GET()
+    {
         require $this->sRessourcesFile;
         $this->aFields = $this->getFields($this->aProperties['schema_extraction'], "v_extraction", "bo_id");
         // Url vers l'acte d'engagement.
-        if (!empty($this->aFields['ae']))
+        if (!empty($this->aFields['ae'])) {
             $this->aFields['ae'] = $this->aProperties['web_server_name'] . '/' . $this->aProperties['ws_data_alias'] . '/extraction/extraction_extraction_extraction/documents/' . $this->aValues["my_vitis_id"] . '/ae/' . $this->aFields['ae'];
-                
+        }
+
         // Date au format Français.
         if ($this->aProperties["language"] == 'fr') {
-            $oDate = new DateTime($this->aFields['creation_date']);
+            $oDate                          = new DateTime($this->aFields['creation_date']);
             $this->aFields['creation_date'] = $oDate->format('d/m/Y');
         }
-            
+
         // Libellés du champ "Commune".
         if (!empty($this->aFields['id_com'])) {
             //On donne les paramètres à remplacer dans la requête
             $aSQLParams = array(
-            'id_com' => array('value' => $this->aFields['id_com'], 'type' => 'group')
+                'id_com' => array('value' => $this->aFields['id_com'], 'type' => 'group'),
             );
-                
-             $sSql = $aSql['getCommuneLabel'];
-                 
+
+            $sSql = $aSql['getCommuneLabel'];
+
             $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, $aSQLParams);
             if (!$this->oConnection->oBd->enErreur()) {
                 while ($aLine = $this->oConnection->oBd->ligneSuivante($oPDOresult)) {
@@ -100,34 +104,39 @@ class Extraction extends ExtractionExtraction {
                 $this->aFields['id_com_label'] = implode(',', $aCommune);
             }
         }
-            
+
         // Libellés du champ "Conseil de Territoire".
         if (!empty($this->aFields['id_conseil'])) {
-            
+
             $aSQLParams = array(
-            'id_conseil' => array('value' => $this->aFields['id_conseil'], 'type' => 'group')
+                'id_conseil' => array('value' => $this->aFields['id_conseil'], 'type' => 'group'),
             );
             //$sSql = str_replace('[id_conseil]', str_replace('|', ',', $this->aFields['id_conseil']), $aSql['getConseilLabel']);
-                
-            $sSql = $aSql['getConseilLabel'];
+            $aConseil = [];
+            $sSql       = $aSql['getConseilLabel'];
             $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, $aSQLParams);
             if (!$this->oConnection->oBd->enErreur()) {
                 while ($aLine = $this->oConnection->oBd->ligneSuivante($oPDOresult)) {
                     $aConseil[] = $aLine['nom_epci'];
                 }
-                $this->aFields['id_conseil_label'] = implode(',', $aConseil);
+                if (is_array($aConseil)) {
+                    $this->aFields['id_conseil_label'] = implode(',', $aConseil);
+                } else {
+                    $this->aFields['id_conseil_label'][0] = $aConseil;
+                }
             }
         }
-            
+
         // Nom de l'état de l'extraction.
         error_log(print_r($this->aFields['status'], true));
         $this->aFields['status_name'] = $this->aFields['status'];
     }
-        
+
 /**
-     * delete a Point_situation
-     */
-    function DELETE() {
+ * delete a Point_situation
+ */
+    public function DELETE()
+    {
         $this->oConnection->oBd->delete($this->aProperties['schema_extraction'], 'extraction', 'bo_id', $this->aValues["my_vitis_id"], 'integer');
         if ($this->oConnection->oBd->enErreur()) {
             $this->oError = new Error(1, $this->oConnection->oBd->getBDMessage());
@@ -135,7 +144,5 @@ class Extraction extends ExtractionExtraction {
             $this->aFields["bo_id"] = $this->aValues["my_vitis_id"];
         }
     }
-        
+
 }
-    
-?>
\ No newline at end of file
diff --git a/src/module_extraction/web_service/ws/ExtractionExtraction.class.inc b/src/module_extraction/web_service/ws/ExtractionExtraction.class.inc
index 9aa4319a..07b301b7 100755
--- a/src/module_extraction/web_service/ws/ExtractionExtraction.class.inc
+++ b/src/module_extraction/web_service/ws/ExtractionExtraction.class.inc
@@ -1,7 +1,6 @@
 <?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 $this->aProperties['vas_home'] . "/../vas/rest/class/vitis_lib/DbClass.class.inc";
+require_once $this->aProperties['vas_home'] . '/../vas/rest/ws/vitis/Vitis.class.inc';
 require_once 'vmlib/logUtil.inc';
 
 class ExtractionExtraction extends Vitis {
diff --git a/src/module_extraction/web_service/ws/Extractions.class.inc b/src/module_extraction/web_service/ws/Extractions.class.inc
index 0b22a30c..75b2d0b5 100755
--- a/src/module_extraction/web_service/ws/Extractions.class.inc
+++ b/src/module_extraction/web_service/ws/Extractions.class.inc
@@ -1,22 +1,23 @@
 <?php
-    
+
 /**
  * \file Extractions.class.inc
  * \class Extractions
  *
  * \author WAB <support.wab@veremes.com>.
  *
- * 	\brief This file contains the Extractions php class
+ *     \brief This file contains the Extractions php class
  *
  * This class defines Rest Api to Vitis Extractions
- * 
+ *
  */
 require_once __DIR__ . '/ExtractionExtraction.class.inc';
 require_once 'Extraction.class.inc';
-require_once(dirname($_SERVER['SCRIPT_FILENAME']) . '/class/wab_lib/BusinessObject.class.inc');
+require_once $this->aProperties['vas_home'] . '/rest/class/wab_lib/BusinessObject.class.inc';
+
+class Extractions extends ExtractionExtraction
+{
 
-class Extractions extends ExtractionExtraction {
-    
     protected $iIdExtraction;
     /**
      * @SWG\Definition(
@@ -30,7 +31,7 @@ class Extractions extends ExtractionExtraction {
      *   description="Operations about Extractions"
      * )
      */
-         
+
     /**
      * construct
      * @param type $aPath url of the request
@@ -39,82 +40,83 @@ class Extractions extends ExtractionExtraction {
      * @param type $bShortcut false to reinit variables
      * @param type $oConnection connection object
      */
-    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false){
+    public function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false)
+    {
         parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
     }
-        
+
 /**
-     * @SWG\Get(path="/extractions",
-     *   tags={"Extractions"},
-     *   summary="Get Extractions",
-     *   description="Request to get Extractions",
-     *   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="extraction Response",
-     *         @SWG\Schema(ref="#/definitions/extractions")
-     *     )
-     *  )
-     */
+ * @SWG\Get(path="/extractions",
+ *   tags={"Extractions"},
+ *   summary="Get Extractions",
+ *   description="Request to get Extractions",
+ *   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="extraction Response",
+ *         @SWG\Schema(ref="#/definitions/extractions")
+ *     )
+ *  )
+ */
     /**
      * @SWG\Get(path="/extractions/Layers",
      *   tags={"Extractions"},
@@ -136,151 +138,152 @@ class Extractions extends ExtractionExtraction {
      *     )
      *  )
      */
-         
+
     /**
      * get Extractions
      * @return  Extractions
      */
-    function GET() {
-        if (!empty($this->aPath[2]) && $this->aPath[2] == "Layers")
+    public function GET()
+    {
+        if (!empty($this->aPath[2]) && $this->aPath[2] == "Layers") {
             $sMessage = $this->getLayers();
-        else {
-            $aReturn = $this->genericGet($this->aProperties['schema_extraction'], "v_extraction", "bo_id");
+        } else {
+            $aReturn  = $this->genericGet($this->aProperties['schema_extraction'], "v_extraction", "bo_id");
             $sMessage = $aReturn['sMessage'];
         }
         return $sMessage;
     }
-        
+
 /**
-     * @SWG\Post(path="/extractions",
-     *   tags={"Extractions"},
-     *   summary="Add extraction",
-     *   description="Request to add Extractions",
-     *   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="extraction Response",
-     *         @SWG\Schema(ref="#/definitions/extractions")
-     *     )
-     *  )
-     */
-         
+ * @SWG\Post(path="/extractions",
+ *   tags={"Extractions"},
+ *   summary="Add extraction",
+ *   description="Request to add Extractions",
+ *   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="extraction Response",
+ *         @SWG\Schema(ref="#/definitions/extractions")
+ *     )
+ *  )
+ */
+
     /**
      * insert extraction
      * @return id of the extraction created
      */
-    function POST() {
-        $aReturn = $this->genericPost($this->aProperties['schema_extraction'], 'extraction', $this->aProperties['schema_extraction'].'.bo_id_extraction_seq', 'bo_id');
+    public function POST()
+    {
+        $aReturn                = $this->genericPost($this->aProperties['schema_extraction'], 'extraction', $this->aProperties['schema_extraction'] . '.bo_id_extraction_seq', 'bo_id');
         $this->aValues["bo_id"] = $this->aValues['my_vitis_id'];
-	eval('$this->' . $this->aValues['tr_status_method'] . '();');
+        eval('$this->' . $this->aValues['tr_status_method'] . '();');
         return $aReturn['sMessage'];
     }
-        
+
 /**
-     * @SWG\Put(path="/extractions/{id_extraction}",
-     *   tags={"Extractions"},
-     *   summary="update Extractions",
-     *   description="Request to update Extractions",
-     *   operationId="PUT",
-     *   produces={"application/xml", "application/json"},
-     *   @SWG\Parameter(
-     *     name="token",
-     *     in="query",
-     *     description="Extraction token",
-     *     required=true,
-     *     type="string"
-     *   ),
-     * * @SWG\Parameter(
-     *     name="id_extraction",
-     *     in="path",
-     *     description="id of the Extractions",
-     *     required=true,
-     *     type="integer",
-     *     format = "int32"
-     *   ),
-     * @SWG\Response(
-     *         response=200,
-     *         description="Poprerties Response",
-     *         @SWG\Schema(ref="#/definitions/extractions")
-     *     )
-     *  )
-     */
-         
+ * @SWG\Put(path="/extractions/{id_extraction}",
+ *   tags={"Extractions"},
+ *   summary="update Extractions",
+ *   description="Request to update Extractions",
+ *   operationId="PUT",
+ *   produces={"application/xml", "application/json"},
+ *   @SWG\Parameter(
+ *     name="token",
+ *     in="query",
+ *     description="Extraction token",
+ *     required=true,
+ *     type="string"
+ *   ),
+ * * @SWG\Parameter(
+ *     name="id_extraction",
+ *     in="path",
+ *     description="id of the Extractions",
+ *     required=true,
+ *     type="integer",
+ *     format = "int32"
+ *   ),
+ * @SWG\Response(
+ *         response=200,
+ *         description="Poprerties Response",
+ *         @SWG\Schema(ref="#/definitions/extractions")
+ *     )
+ *  )
+ */
+
     /**
      * update extractions
      * @return id of extractions updated or error object if a extractions is not updated
      */
-    function PUT() {
+    public function PUT()
+    {
         // Upload l'acte d'engagement.
         $this->uploadDocument('ae', 'extraction_extraction_extraction');
         //
-        $aReturn = $this->genericPut($this->aProperties['schema_extraction'], 'extraction', 'bo_id');
+        $aReturn                = $this->genericPut($this->aProperties['schema_extraction'], 'extraction', 'bo_id');
         $this->aValues["bo_id"] = $this->aValues['my_vitis_id'];
         // Méthode de transition.
-        if (!empty($this->aValues['tr_status_method']))
+        if (!empty($this->aValues['tr_status_method'])) {
             eval('$this->' . $this->aValues['tr_status_method'] . '();');
-             
+        }
+
         //On vérifie que le fichier existe et ne soit pas vide
-        if (!empty($this->aValues['input_deposit_file']))
-        {
-                        //On va déplacer le fichier dans un dossier temporaire
-                        $aXmlRacineAttribute['status'] = 1;
-                        $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
-                            $sDirPath = $this->aProperties["upload_dir"]."/".getUniqRandomId();
-                            while (is_dir($sDirPath))
-                            {
-                                $sDirPath = $this->aProperties["upload_dir"]."/".getUniqRandomId();
-                            }
-                            if (!mkdir($sDirPath))
-                            {
-                                return false;
-                            }
-                            // Sauvegarde le nouveau fichier.
-                            $fp = fopen($sDirPath .'/'. utf8_decode($this->aValues["input_deposit_name"]), "w");
-                            fwrite($fp, $this->aValues["input_deposit_file"]);
-                            fclose($fp);
-                            //Demande GTF
-                            $this->oBO->insertOrder('EM0160AYYTK48', 'sourceDir='.end(explode("/", $sDirPath)).'/'.$this->aValues["input_deposit_name"].'|sourceMotif=*.shp');
+        if (!empty($this->aValues['input_deposit_file'])) {
+            //On va déplacer le fichier dans un dossier temporaire
+            $aXmlRacineAttribute['status'] = 1;
+            $sMessage                      = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], true, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            $sDirPath                      = $this->aProperties["upload_dir"] . "/" . getUniqRandomId();
+            while (is_dir($sDirPath)) {
+                $sDirPath = $this->aProperties["upload_dir"] . "/" . getUniqRandomId();
+            }
+            if (!mkdir($sDirPath)) {
+                return false;
+            }
+            // Sauvegarde le nouveau fichier.
+            $fp = fopen($sDirPath . '/' . utf8_decode($this->aValues["input_deposit_name"]), "w");
+            fwrite($fp, $this->aValues["input_deposit_file"]);
+            fclose($fp);
+            //Demande GTF
+            $this->oBO->insertOrder('EM0160AYYTK48', 'sourceDir=' . end(explode("/", $sDirPath)) . '/' . $this->aValues["input_deposit_name"] . '|sourceMotif=*.shp');
         }
         return $aReturn['sMessage'];
     }
-        
+
 /**
-     * @SWG\Delete(path="/extractions",
-     *   tags={"Extractions"},
-     *   summary="delete Extractions",
-     *   description="Request to delete Extractions",
-     *   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 extraction",
-     *     required=true,
-     *     type="string"
-     *   ),
-     * @SWG\Response(
-     *         response=200,
-     *         description="extraction Response",
-     *         @SWG\Schema(ref="#/definitions/extractions")
-     *     )
-     *  )
-     */
+ * @SWG\Delete(path="/extractions",
+ *   tags={"Extractions"},
+ *   summary="delete Extractions",
+ *   description="Request to delete Extractions",
+ *   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 extraction",
+ *     required=true,
+ *     type="string"
+ *   ),
+ * @SWG\Response(
+ *         response=200,
+ *         description="extraction Response",
+ *         @SWG\Schema(ref="#/definitions/extractions")
+ *     )
+ *  )
+ */
     /**
      * @SWG\Delete(path="/extractions/{id_extraction}",
      *   tags={"Extractions"},
@@ -310,58 +313,59 @@ class Extractions extends ExtractionExtraction {
      *     )
      *  )
      */
-         
+
     /**
      * delete extractions
      * @return id of extractions deleted or error object if a extractions is not deleted
      */
-    function DELETE() {
+    public function DELETE()
+    {
         $aReturn = $this->genericDelete($this->aProperties['schema_extraction'], 'extraction', 'bo_id');
         return $aReturn['sMessage'];
     }
-        
-     /**
+
+    /**
      * Liste des couches.
      */
-    function getLayers() {
+    public function getLayers()
+    {
         require $this->sRessourcesFile;
         //On décode le json récupéré via le filtre
-        if (!empty($this->aValues["filter"]))
-        {
-            $decode = $this->decodeJSONFilter($this->aValues["filter"],$this->aProperties['schema_extraction'],$this->aValues["table"] );
+        if (!empty($this->aValues["filter"])) {
+            $decode = $this->decodeJSONFilter($this->aValues["filter"], $this->aProperties['schema_extraction'], $this->aValues["table"]);
         }
-            
+
         if (is_object($this->aValues) || is_array($this->aValues)) {
             $sJSONFilter = json_encode($this->aValues);
         }
-            
-        if (!empty($sJSONFilter))
-        {
+
+        if (!empty($sJSONFilter)) {
             $aJSONFilter = json_decode($sJSONFilter, true);
-        }
-            
-        if (is_object($aJSONFilter["filter"]) || is_array($aJSONFilter["filter"])) {
-            $sJSONFilter = json_encode($aJSONFilter["filter"]);
+
+            if (!empty($aJSONFilter["filter"])) {
+                if (is_object($aJSONFilter["filter"]) || is_array($aJSONFilter["filter"])) {
+                    $sJSONFilter = json_encode($aJSONFilter["filter"]);
+                }
+            }
         }
         $aSQLParams = array(
             'schema_framework' => array('value' => $this->aProperties['schema_framework'], 'type' => 'schema_name'),
-            'user_id' => array('value' => $_SESSION['ses_user_id'], 'type' => 'string')
+            'user_id'          => array('value' => $_SESSION['ses_user_id'], 'type' => 'string'),
         );
-            
-        $sSql = $aSql['getUserGroups'];
+
+        $sSql       = $aSql['getUserGroups'];
         $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, $aSQLParams);
         if (!$this->oConnection->oBd->enErreur()) {
             $aResult = $this->oConnection->oBd->getResultTableAssoc($oPDOresult);
             foreach ($aResult as $aUserGroup) {
                 $aUserGroups[] = $aUserGroup['name'];
             }
-                
-            if ($this->aValues["filter"])
-            {
+
+            if (!empty($aValues["filter"])) {
                 $aSQLParams = array(
                     'schema_extraction' => array('value' => $this->aProperties['schema_extraction'], 'type' => 'schema_name'),
-                    );
-                        
+                );
+
                 $sSql = $aSql['getCtId'];
                 //On donne la condition
                 if ($decode["request"]) {
@@ -371,36 +375,33 @@ class Extractions extends ExtractionExtraction {
                 }
                 //error_log(print_r($sSql, true));
                 $merge = array_merge($aSQLParams, $decode["params"]);
-                    
+
                 $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, $merge);
-                    
+
                 $aCtResult = $this->oConnection->oBd->getResultTableAssoc($oPDOresult);
             }
             // Restriction de l'utilisateur suivant ses groupes.
-            if (in_array('interne', $aUserGroups))
+            if (in_array('interne', $aUserGroups)) {
                 $sSqlParams = " ORDER BY category, layer_id;";
-            else if (in_array('restreint', $aUserGroups))
+            } else if (in_array('restreint', $aUserGroups)) {
                 $sSqlParams = " AND restriction <> 'interne' ORDER BY category, layer_id;";
-            else
+            } else {
                 $sSqlParams = " AND restriction = 'public' ORDER BY category, layer_id;";
+            }
+
             // Liste des cartes.
             $this->aFields['treeview_layers'] = array();
-                
+
             //Requête pour récupérer les couches
-            if ($this->aValues["filter"])
-            {
+            if (!empty($aValues["filter"])) {
                 $sSql = $aSql['getRtLayerWithCtId'] . $sSqlParams;
-            }
-            else
-            {
+            } else {
                 $sSql = $aSql['getRtLayer'] . $sSqlParams;
             }
-            //$ct_id = [];
-            if ($aCtResult)
-            {
-                for ($i = 0; $i < sizeof($aCtResult); $i++)
-                {
-                        $ct_id .=  $aCtResult[$i]["ct_id"]."|";
+            $ct_id;
+            if (!empty($aCtResult)) {
+                for ($i = 0; $i < sizeof($aCtResult); $i++) {
+                    $ct_id .= $aCtResult[$i]["ct_id"] . "|";
                 }
                 //On retire la dernière pipe qui ne sert à rien
                 $ct_idToSend = substr($ct_id, 0, -1);
@@ -411,187 +412,195 @@ class Extractions extends ExtractionExtraction {
             //error_log(print_r($aCtResult[$i]["ct_id"], true));
             $aSQLParams = array(
                 'schema_extraction' => array('value' => $this->aProperties['schema_extraction'], 'type' => 'schema_name'),
-                'aCtId' => array('value' => $ct_idToSend, 'type' => 'group')
+                'aCtId'             => array('value' => $ct_idToSend, 'type' => 'group'),
             );
             $oPDOresult = $this->oConnection->oBd->executeWithParams($sSql, $aSQLParams);
             if (!$this->oConnection->oBd->enErreur()) {
                 $aRtLayer = $this->oConnection->oBd->getResultTableAssoc($oPDOresult);
-                $aLayers = array();
+                $aLayers  = array();
                 if (!empty($aRtLayer)) {
-                    foreach ($aRtLayer as $aLayer)
-                    {
-                        
-                            $aLayers[$aLayer['category']][] = array("text" => $aLayer['layer'], "value" => $aLayer['layer_id'], "mutualized" => $aLayer['mutualized'], "statistique" => $aLayer['statistique']);
-                                
+                    foreach ($aRtLayer as $aLayer) {
+
+                        $aLayers[$aLayer['category']][] = array("text" => $aLayer['layer'], "value" => $aLayer['layer_id'], "mutualized" => $aLayer['mutualized'], "statistique" => $aLayer['statistique']);
+
                     }
                 }
-                $this->aFields['layers'] = $aLayers;
+                $this->aFields['layers']       = $aLayers;
                 $aXmlRacineAttribute['status'] = 1;
-                $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+                $sMessage                      = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], true, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
             } else {
                 $aXmlRacineAttribute['status'] = 0;
-                $this->aFields['error'] = "Request error.";
-                $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+                $this->aFields['error']        = "Request error.";
+                $sMessage                      = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], true, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
             }
         } else {
             $aXmlRacineAttribute['status'] = 0;
-            $this->aFields['error'] = "Request error.";
-            $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            $this->aFields['error']        = "Request error.";
+            $sMessage                      = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], true, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
         }
         //error_log(print_r($sMessage, true));
         return $sMessage;
     }
-        
-	
+
     /**
-    * Transition Method trNouveau
-    */
-    function trNouveau() {
+     * Transition Method trNouveau
+     */
+    public function trNouveau()
+    {
         $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']);
-            
-        // Check si la table existe si oui change l'état 
+
+        // Check si la table existe si oui change l'état
         $this->oBO->wabSetStatus($this->aProperties["schema_extraction"], "extraction", "bo_id", $this->aValues["bo_id"], "Nouveau");
-            
+
     }
-        
+
     /**
-    * Transition Method trGenerer
-    */
-    function trGenerer() {
+     * Transition Method trGenerer
+     */
+    public function trGenerer()
+    {
         $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']);
-            
-        // Check si la table existe si oui change l'état 
+
+        // Check si la table existe si oui change l'état
         $this->oBO->wabSetStatus($this->aProperties["schema_extraction"], "extraction", "bo_id", $this->aValues["bo_id"], "AE Généré");
-            
+
     }
-        
+
     /**
-    * Transition Method trResoumettre
-    */
-    function trResoumettre() {
+     * Transition Method trResoumettre
+     */
+    public function trResoumettre()
+    {
         $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']);
-            
-        // Check si la table existe si oui change l'état 
+
+        // Check si la table existe si oui change l'état
         $this->oBO->wabSetStatus($this->aProperties["schema_extraction"], "extraction", "bo_id", $this->aValues["bo_id"], "AE Généré");
 //$this->sendmail(9904);
         $this->sendmail(171);
     }
-        
+
     /**
-    * Transition Method trSoumettre
-    */
-    function trSoumettre() {
+     * Transition Method trSoumettre
+     */
+    public function trSoumettre()
+    {
         $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']);
-            
-        // Check si la table existe si oui change l'état 
+
+        // Check si la table existe si oui change l'état
         $this->oBO->wabSetStatus($this->aProperties["schema_extraction"], "extraction", "bo_id", $this->aValues["bo_id"], "AE Soumis");
         //$this->oBO->sendmail(39);
         $this->oBO->sendmail(174);
     }
-        
+
     /**
-    * Transition Method trDemander
-    */
-    function trDemander() {
+     * Transition Method trDemander
+     */
+    public function trDemander()
+    {
         $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']);
-        $this->oBO->insertOrder('832HZ8J2PTCSG', 'bo_id='.$this->aValues['bo_id']);
-        // Check si la table existe si oui change l'état 
+        $this->oBO->insertOrder('832HZ8J2PTCSG', 'bo_id=' . $this->aValues['bo_id']);
+        // Check si la table existe si oui change l'état
         $this->oBO->wabSetStatus($this->aProperties["schema_extraction"], "extraction", "bo_id", $this->aValues["bo_id"], "AE Demandé");
-            
+
     }
-        
+
     /**
-    * Transition Method trReception
-    */
-    function trReception() {
+     * Transition Method trReception
+     */
+    public function trReception()
+    {
         $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']);
-            
-        // Check si la table existe si oui change l'état 
+
+        // Check si la table existe si oui change l'état
         $this->oBO->wabSetStatus($this->aProperties["schema_extraction"], "extraction", "bo_id", $this->aValues["bo_id"], "Dépôt terminé");
-            
+
     }
-        
+
     /**
-    * Transition Method trDeposer
-    */
-    function trDeposer() {
+     * Transition Method trDeposer
+     */
+    public function trDeposer()
+    {
         $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']);
-        // Check si la table existe si oui change l'état 
+        // Check si la table existe si oui change l'état
         $this->oBO->wabSetStatus($this->aProperties["schema_extraction"], "extraction", "bo_id", $this->aValues["bo_id"], "Fichier déposé");
-            
+
     }
-        
+
     /**
-    * Transition Method trAutoriser
-    */
-    function trAutoriser() {
+     * Transition Method trAutoriser
+     */
+    public function trAutoriser()
+    {
         $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']);
-        $this->oBO->insertOrder('8BCP8WGIOW4KO', 'bo_id='.$this->aValues['bo_id']);
-        // Check si la table existe si oui change l'état 
+        $this->oBO->insertOrder('8BCP8WGIOW4KO', 'bo_id=' . $this->aValues['bo_id']);
+        // Check si la table existe si oui change l'état
         $this->oBO->wabSetStatus($this->aProperties["schema_extraction"], "extraction", "bo_id", $this->aValues["bo_id"], "Autorisée");
-            
+
     }
-        
+
     /**
-    * Transition Method trAccepter
-    */
-    function trAccepter() {
+     * Transition Method trAccepter
+     */
+    public function trAccepter()
+    {
         $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']);
-            
-        // Check si la table existe si oui change l'état 
+
+        // Check si la table existe si oui change l'état
         $this->oBO->wabSetStatus($this->aProperties["schema_extraction"], "extraction", "bo_id", $this->aValues["bo_id"], "Fichier accepté");
         //$this->oBO->sendmail(id_du_mail_pour_dire_que_le_fichier_est_accepté);
         $this->trReception();
-            
+
     }
-        
+
     /**
-    * Transition Method trInvalider
-    */
-    function trInvalider() {
+     * Transition Method trInvalider
+     */
+    public function trInvalider()
+    {
         $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']);
-            
-        // Check si la table existe si oui change l'état 
+
+        // Check si la table existe si oui change l'état
         $this->oBO->wabSetStatus($this->aProperties["schema_extraction"], "extraction", "bo_id", $this->aValues["bo_id"], "Fichier invalidé");
         //$this->oBO->sendmail(id_du_mail_pour_dire_que_le_fichier_est_invalidé);
         $this->trRetour();
-        
-            
+
     }
-        
+
     /**
-    * Transition Method trRetour
-    */
-    function trRetour() {
+     * Transition Method trRetour
+     */
+    public function trRetour()
+    {
         $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']);
-            
-        // Check si la table existe si oui change l'état 
+
+        // Check si la table existe si oui change l'état
         $this->oBO->wabSetStatus($this->aProperties["schema_extraction"], "extraction", "bo_id", $this->aValues["bo_id"], "Extraction terminée");
-            
+
     }
-        
+
     /**
-    * Transition Method trTerminerExtraction
-    */
-    function trTerminerExtraction() {
+     * Transition Method trTerminerExtraction
+     */
+    public function trTerminerExtraction()
+    {
         $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']);
-        // Check si la table existe si oui change l'état 
+        // Check si la table existe si oui change l'état
         $this->oBO->wabSetStatus($this->aProperties["schema_extraction"], "extraction", "bo_id", $this->aValues["bo_id"], "Extraction terminée");
-            
+
     }
-        
+
     /**
-    * Transition Method trRefuser
-    */
-    function trRefuser() {
+     * Transition Method trRefuser
+     */
+    public function trRefuser()
+    {
         $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']);
-            
-        // Check si la table existe si oui change l'état 
+
+        // Check si la table existe si oui change l'état
         $this->oBO->wabSetStatus($this->aProperties["schema_extraction"], "extraction", "bo_id", $this->aValues["bo_id"], "Refusée");
 //$this->sendmail(9902);
         $this->oBO->sendmail(175);
     }
-        
+
 }
-    
-?>
\ No newline at end of file
-- 
GitLab