diff --git a/.gitignore b/.gitignore index d8b5d9919508b3efbd1b1fdc1d91adb22b53876d..7b72a2ed59616f66cd60b7fe306b3f495bd57937 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ src/vitis/vas/rest/ws/* ! src/vitis/vas/rest/ws/vitis/ src/vitis/vas/sql/* ! src/vitis/vas/sql/sqlQueries.xml + +utils - Copie/ diff --git a/src/module_extraction/web_service/ws/Extraction.class.inc b/src/module_extraction/web_service/ws/Extraction.class.inc index 1351aa93719d4bbfd1d8836cc286ab3a51a79690..d99e46d26b0ac792818c76c61c38193a5925049e 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 __DIR__. '/../../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,38 @@ 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 +143,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 9aa4319a4344ef5f77c1e6ce2d14c83fb605fa39..770729dd15262e596170ea80a2079aac314417a4 100755 --- a/src/module_extraction/web_service/ws/ExtractionExtraction.class.inc +++ b/src/module_extraction/web_service/ws/ExtractionExtraction.class.inc @@ -1,41 +1,44 @@ <?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 __DIR__ . "/../../class/vitis_lib/DbClass.class.inc"; + require_once __DIR__ . '/../vitis/Vitis.class.inc'; require_once 'vmlib/logUtil.inc'; -class ExtractionExtraction extends Vitis { +class ExtractionExtraction extends Vitis +{ //Chemin du fichier de ressources contenant les requêtes SQL - var $sRessourcesFile = 'ws/extraction/ExtractionExtraction.class.sql.inc'; - + public $sRessourcesFile = 'ws/extraction/ExtractionExtraction.class.sql.inc'; + /** * Upload un document dans le ws_data du module Extraction. * @param type $sIndex * @param type $sFolder */ - function uploadDocument($sIndex, $sFolder) { + public function uploadDocument($sIndex, $sFolder) + { // Crée le répertoire si inexistant. $sDirPath = $this->aProperties['ws_data_dir'] . '/extraction/' . $sFolder . '/documents/' . $this->aValues["my_vitis_id"] . '/' . $sIndex . '/'; - if (!is_dir($sDirPath)) + if (!is_dir($sDirPath)) { mkdir($sDirPath, 0777, true); + } + // Ecrit le fichier. if (!empty($_FILES[$sIndex])) { $sErrorMessage = uploadFile($sIndex, "", $sDirPath . $_FILES[$sIndex]["name"], $_FILES[$sIndex]['size'] + 1); - if ($sErrorMessage != "") + if ($sErrorMessage != "") { writeToErrorLog($sErrorMessage); - } - else { + } + + } else { $sfileContentIndex = $sIndex . '_file'; - $sfileNameIndex = $sIndex . '_name'; + $sfileNameIndex = $sIndex . '_name'; if (!empty($this->aValues[$sfileContentIndex])) { $this->aValues[$sIndex] = $this->aValues[$sfileNameIndex]; - $fp = fopen($sDirPath . $this->aValues[$sfileNameIndex], "w"); + $fp = fopen($sDirPath . $this->aValues[$sfileNameIndex], "w"); fwrite($fp, $this->aValues[$sfileContentIndex]); fclose($fp); } } } } -?> \ No newline at end of file diff --git a/src/module_extraction/web_service/ws/Extraction_depots.class.inc b/src/module_extraction/web_service/ws/Extraction_depots.class.inc index 3285bfd4986a86f1ebab72662d343b8335295da1..8cebd171435fa8f256ece051d04017f3d0a81034 100755 --- a/src/module_extraction/web_service/ws/Extraction_depots.class.inc +++ b/src/module_extraction/web_service/ws/Extraction_depots.class.inc @@ -1,23 +1,23 @@ <?php - + /** * \file Extraction_depots.class.inc * \class Extraction_depots * * \author WAB <support.wab@veremes.com>. * - * \brief This file contains the Extraction_depots php class + * \brief This file contains the Extraction_depots php class * * This class defines Rest Api to Vitis Extraction_depots - * + * */ require_once __DIR__ . '/ExtractionExtraction.class.inc'; require_once 'Extraction_depot.class.inc'; -require_once(__DIR__ . '/../../class/wab_lib/BusinessObject.class.inc'); -require_once __DIR__ .'/Extractions.class.inc'; - - -class Extraction_depots extends ExtractionExtraction { +require_once __DIR__ . '/../../class/wab_lib/BusinessObject.class.inc'; +require_once __DIR__ . '/Extractions.class.inc'; + +class Extraction_depots extends ExtractionExtraction +{ /** * @SWG\Definition( * definition="/extraction_depots", @@ -30,7 +30,7 @@ class Extraction_depots extends ExtractionExtraction { * description="Operations about Extraction_depots" * ) */ - + /** * construct * @param type $aPath url of the request @@ -39,11 +39,11 @@ class Extraction_depots 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="/extraction_depots", * tags={"Extraction_depots"}, @@ -116,66 +116,56 @@ class Extraction_depots extends ExtractionExtraction { * ) * ) */ - + /** * get Extraction_depots * @return Extraction_depots */ - function GET() { - if (!empty($this->aPath[2])) - { - if ($this->aPath[2] == "Tree") - { - $sDirPath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot' ; + public function GET() + { + if (!empty($this->aPath[2])) { + if ($this->aPath[2] == "Tree") { + $sDirPath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot'; //Création du dossier extraction_depot - if (!is_dir($sDirPath)) - { + if (!is_dir($sDirPath)) { //Création du dossier du demandeur - if (!mkdir($sDirPath)) - { + if (!mkdir($sDirPath)) { //Mettre une erreur dans le log d'erreur } } - $sDirPath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/'.$_SERVER["REMOTE_ADDR"]; - if (!is_dir($sDirPath)) - { - if (!mkdir($sDirPath)) - { - //Mettre une erreur dans le log d'erreur + $sDirPath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/' . $_SERVER["REMOTE_ADDR"]; + if (!is_dir($sDirPath)) { + if (!mkdir($sDirPath)) { + //Mettre une erreur dans le log d'erreur } } - $sDirPath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/'.$_SERVER["REMOTE_ADDR"]."/Fichiers déposés"; - if (!is_dir($sDirPath)) - { - if (!mkdir($sDirPath)) - { + $sDirPath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/' . $_SERVER["REMOTE_ADDR"] . "/Fichiers déposés"; + if (!is_dir($sDirPath)) { + if (!mkdir($sDirPath)) { //Mettre une erreur dans le log d'erreur } } - $sDirPath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/'.$_SERVER["REMOTE_ADDR"]."/Résultats"; - if (!is_dir($sDirPath)) - { - if (!mkdir($sDirPath)) - { + $sDirPath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/' . $_SERVER["REMOTE_ADDR"] . "/Résultats"; + if (!is_dir($sDirPath)) { + if (!mkdir($sDirPath)) { //Mettre une erreur dans le log d'erreur } } - $sDirPath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/'.$_SERVER["REMOTE_ADDR"]; + $sDirPath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/' . $_SERVER["REMOTE_ADDR"]; return json_encode($this->getFolderInfos($sDirPath)); - } - elseif ($this->aPath[2] == "File") - { + } elseif ($this->aPath[2] == "File") { $this->getWorkspaceFile(); } } } - - /** + + /** * Get file. */ - function getWorkspaceFile() { - $aReturn = array('status' => 1, 'message' => ''); - $sFilePath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/'.$_SERVER["REMOTE_ADDR"]."/".$this->aValues['file_name']; + public function getWorkspaceFile() + { + $aReturn = array('status' => 1, 'message' => ''); + $sFilePath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/' . $_SERVER["REMOTE_ADDR"] . "/" . $this->aValues['file_name']; // Le fichier existe ? if (file_exists($sFilePath)) { header("Content-Type: application/octet-stream"); @@ -185,58 +175,60 @@ class Extraction_depots extends ExtractionExtraction { error_log(readfile($sFilePath)); } } - + /** - * + * * @param string $sDirectoryPath * @return array $aTree */ - function getFolderInfos($sDirectoryPath){ - - if(is_dir($sDirectoryPath)){ + public function getFolderInfos($sDirectoryPath) + { + + if (is_dir($sDirectoryPath)) { $aContentDir = scandir($sDirectoryPath); - $aTree = $this->getFileInfos($sDirectoryPath); - $aDir = array(); - for ($i =0 ; $i < count($aContentDir); $i++){ - if($aContentDir[$i] !== "." && $aContentDir[$i] !== ".."){ + $aTree = $this->getFileInfos($sDirectoryPath); + $aDir = array(); + for ($i = 0; $i < count($aContentDir); $i++) { + if ($aContentDir[$i] !== "." && $aContentDir[$i] !== "..") { array_push($aDir, $this->getFolderInfos($sDirectoryPath . "/" . $aContentDir[$i])); } } - + $aTree["content"] = $aDir; - $aTree["status"] = 1; + $aTree["status"] = 1; return $aTree; } else { return $this->getFileInfos($sDirectoryPath); } } - + /** - * + * * @param string $sFilePath * @return array */ - function getFileInfos ($sFilePath){ + public function getFileInfos($sFilePath) + { $iFileSize = filesize($sFilePath); - + $sFileSize = $iFileSize . "octets"; - if($iFileSize > 1024){ - if($iFileSize > 1024*1024){ - if($iFileSize > 1024*1024*1024){ + if ($iFileSize > 1024) { + if ($iFileSize > 1024 * 1024) { + if ($iFileSize > 1024 * 1024 * 1024) { $sFileSize = "-"; } else { - $sFileSize = (ceil($iFileSize/(1024*1024))) . "Mo"; + $sFileSize = (ceil($iFileSize / (1024 * 1024))) . "Mo"; } - }else{ - $sFileSize = (ceil($iFileSize/1024)) . "Ko"; + } else { + $sFileSize = (ceil($iFileSize / 1024)) . "Ko"; } } - + $aFileName = explode(DIRECTORY_SEPARATOR, $sFilePath); - - return array("filename"=>$aFileName[count($aFileName) - 1], "size"=>$sFileSize, "lastModification"=> date ("d/m/Y H:i:s", filemtime($sFilePath))); + + return array("filename" => $aFileName[count($aFileName) - 1], "size" => $sFileSize, "lastModification" => date("d/m/Y H:i:s", filemtime($sFilePath))); } - + /** * @SWG\Delete(path="/[Class_name]s", * tags={"[Class_name_upper]s"}, @@ -294,20 +286,20 @@ class Extraction_depots extends ExtractionExtraction { * ) * ) */ - + /** * delete [Class_name]s * @return id of [Class_name]s deleted or error object if a [Class_name]s is not deleted */ - function DELETES() { - $sDirPath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/'.$_SERVER["REMOTE_ADDR"]; + public function DELETES() + { + $sDirPath = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/' . $_SERVER["REMOTE_ADDR"]; //On supprime le fichier - $sMessage = unlink($sDirPath."/".$this->aValues['file_name']); + $sMessage = unlink($sDirPath . "/" . $this->aValues['file_name']); return $sMessage; - } - - - /** + } + + /** * @SWG\Put(path="/[Class_name]s/{id_[Class_name]}", * tags={"[Class_name_upper]s"}, * summary="update [Class_name_upper]s", @@ -336,92 +328,89 @@ class Extraction_depots extends ExtractionExtraction { * ) * ) */ - + /** * update [Class_name]s * @return id of [Class_name]s updated or error object if a [Class_name]s is not updated */ - function PUT() { + public function PUT() + { if (!empty($this->aValues["action"]) && $this->aValues["action"] == "Metadata") { $aReturn = $this->reintegrateMetadata(); - + $aXmlRacineAttribute['status'] = $aReturn['status']; - $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 { - $sDirName = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/'.$_SERVER["REMOTE_ADDR"]; + $sDirName = $this->aProperties['ws_data_dir'] . '/extraction/extraction_depot/' . $_SERVER["REMOTE_ADDR"]; $error_message = ""; - + // Si le dossier {id} n'existe pas (Important pour gérer les erreurs) if (!is_dir($sDirName)) { $error_message .= $sDirName . " does not exist"; writeToErrorLog("WARNING: " . $error_message); - + $aXmlRacineAttribute['status'] = 0; - $this->aFields = array(); + $this->aFields = array(); $this->aFields['errorMessage'] = $error_message; - $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']); return $sMessage; } // Si le dossier {id}/Fichiers déposés n'existe pas (Important pour gérer les erreurs) if (!is_dir($sDirName . "/Fichiers déposés")) { $error_message .= $sDirName . "/Fichiers déposés does not exist"; writeToErrorLog("WARNING: " . $error_message); - + $aXmlRacineAttribute['status'] = 0; - $this->aFields = array(); + $this->aFields = array(); $this->aFields['errorMessage'] = $error_message; - $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']); return $sMessage; } - + // Si le dossier {id}/form n'existe pas il est crée if (!is_dir($sDirName . "/Résultats")) { writeToErrorLog("WARNING: " . $sDirName . "/Résultats"); @mkdir($sDirName . "/Résultats"); } - + if (!empty($this->aValues["control_file_file"])) { $this->aValues["control_file"] = $this->aValues["control_file_name"]; } - if (!empty($this->aValues["control_file_file"])) { - //if ($aReturn['sStatus'] == 1) { - $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["control_file_name"]), "w"); - fwrite($fp, $this->aValues["control_file_file"]); - fclose($fp); - - //error_log($sDirPath.'/'.$this->aValues["control_file_name"]); - $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']); - $this->oBO->insertOrder('EM0160AYYTK48', 'sourceDir='.end(explode("/", $sDirPath)).'/'.$this->aValues["control_file_name"].'|sourceMotif=*.shp'); - //$this->Extractions = new Extractions(__DIR__, $this->aValues, $this->aProperties); - - //$fp = fopen($sDirName . "/Fichiers déposés/" . utf8_decode($this->aValues["control_file_name"]), "w"); - //fwrite($fp, $this->aValues["control_file_file"]); - //fclose($fp); - //error_log(print_r($this->oBO,true)); - //$this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']); - //$this->oBO->insertOrder('EM0160AYYTK48', 'bo_id='.$this->aValues['bo_id']); + if (!empty($this->aValues["control_file_file"])) { + //if ($aReturn['sStatus'] == 1) { + $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["control_file_name"]), "w"); + fwrite($fp, $this->aValues["control_file_file"]); + fclose($fp); + + $sExtension = '*.' . end(explode(".", $this->aValues["control_file_name"])); + if (in_array($sExtension, explode("|", $this->aProperties['sig'])) or in_array($sExtension, explode("|", $this->aProperties['dao']))) { + $this->oBO = new WabBusinessObject($this->oConnection->oBd, array(), $this->aValues, $this->aProperties, 'extraction', $this->aValues['bo_id']); + $this->oBO->insertOrder('EM0160AYYTK48', 'sourceDir=' . end(explode("/", $sDirPath)) . '/' . $this->aValues["control_file_name"] . '|sourceMotif='.$sExtension); + } else { + //Si l'extension n'est pas bonne + $error_message .= $this->aValues["control_file_name"] . " format is not authaurized (". $sExtension . ")"; + writeToErrorLog("WARNING: " . $error_message); + + $aXmlRacineAttribute['status'] = 0; + $this->aFields = array(); + $this->aFields['errorMessage'] = $error_message; + $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], true, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); + return $sMessage; + } + } } - + return $sMessage; } - - - - - + } - -?> \ No newline at end of file diff --git a/src/module_extraction/web_service/ws/Extractions.class.inc b/src/module_extraction/web_service/ws/Extractions.class.inc index 0b22a30c4a138b708b99bcbfcaf6765fd1cdb482..a2607092da2009ee9134d42215079d8c0cf20a36 100755 --- a/src/module_extraction/web_service/ws/Extractions.class.inc +++ b/src/module_extraction/web_service/ws/Extractions.class.inc @@ -1,22 +1,24 @@ <?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'); -class Extractions extends ExtractionExtraction { - +require_once __DIR__ . '/../../class/wab_lib/BusinessObject.class.inc'; + +class Extractions extends ExtractionExtraction +{ + protected $iIdExtraction; /** * @SWG\Definition( @@ -30,7 +32,7 @@ class Extractions extends ExtractionExtraction { * description="Operations about Extractions" * ) */ - + /** * construct * @param type $aPath url of the request @@ -39,82 +41,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 +139,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 +314,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 +376,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 +413,194 @@ 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