Exemple #1
0
 /**
 * Cette fonction permet de dupliquer une Fiche Technique Article pour faire les actions suivantes:
 
  $action
  -------
  "totale":       Créer un nouveau dossier en recopiant l'intégralité de la fiche d'origine
  "selective":(pas géré)    Créer un nouveau dossier en ne recopiant que certains processus
  "version":      Créer une nouvelle fiche au sein du même dossier
 
  $option:
  --------
  - Dans le cas d'une duplication "selective", cette variable contient le tableau des id_processus des processus sélectionnés
  - Dans le cas d'une duplication "version", cette variable contient le nouvel état de la FTA (I, A, ...).
  Si vide, alors l'état par défaut sera de type I, initialisation
 
  Retour de la fonction:
  ----------------------
  La fonction renvoi l'id_fta nouvellement créé.
 * @param int $paramIdFta
 * @param string $paramAction
 * @param array $paramOption
 * @param int $paramIdFtaWorkflow
 * @return int
 */
 public static function buildDuplicationFta($paramIdFta, $paramAction, $paramOption, $paramIdFtaWorkflow)
 {
     /*         * ****************************************
               Déclaration et initialisation des variables
              * **************************************** */
     $globalConfig = new GlobalConfig();
     UserModel::checkUserSessionExpired($globalConfig);
     $idUser = $globalConfig->getAuthenticatedUser()->getKeyValue();
     $ftaModelOrig = new FtaModel($paramIdFta);
     //Identifiant de la fiche technique article à dupliquer
     if ($paramOption["id_version_dossier_fta"]) {
         $idFtaVersion = $paramOption["id_version_dossier_fta"];
     } else {
         $idFtaVersion = $ftaModelOrig->getDataField(FtaModel::FIELDNAME_VERSION_DOSSIER_FTA)->getFieldValue();
     }
     $idFtaOriginal = $paramIdFta;
     //Sauvegarde de la clef initiale.
     $paramOption["abreviation_etat_destination"];
     //Etat vers lequel doit aller la FTA
     $paramOption["selection_chapitre"];
     //Tableau contenant les id_fta_chapitre des chapitres à corriger
     $paramOption["designation_commerciale_fta"];
     //Nouveau nom commerciale de la FTA
     $paramOption["site_de_production"];
     //Nouveau site de production de la FTA
     $paramOption["nouveau_maj_fta"];
     //Nouveau commentaire de la nouvelle FTA
     $paramOption["id_version_dossier_fta"];
     //Id dossier version maximun
     switch ($paramAction) {
         case "version":
             //récupération de l'identifiant de l'état
             if ($paramOption["abreviation_etat_destination"] == "") {
                 //Si aucun Etat n'a été donné, l'état   Intialisation est choisi par défaut
                 $paramOption["abreviation_etat_destination"] = "I";
             }
             $arrayIdFtaEtat = DatabaseOperation::convertSqlStatementWithoutKeyToArray("SELECT " . FtaEtatModel::KEYNAME . " FROM " . FtaEtatModel::TABLENAME . " WHERE " . FtaEtatModel::FIELDNAME_ABREVIATION . "='" . $paramOption["abreviation_etat_destination"] . "'");
             foreach ($arrayIdFtaEtat as $value) {
                 $idFtaEtatNew = $value[FtaEtatModel::KEYNAME];
             }
     }
     /*         * *****************************************************************************
               Traitement Principal
              * ****************************************************************************** */
     /*         * *************************
               Traitement de la table "fta"
              * ************************* */
     $idFtaNew = FtaModel::duplicationIdFta($paramIdFta);
     //Récupération de la nouvelle clef
     /*
      * Enregsitrement des mises à jour
      */
     if (!$paramOption["site_de_production"]) {
         $paramOption["site_de_production"] = "NULL";
     }
     DatabaseOperation::execute("UPDATE " . FtaModel::TABLENAME . " SET " . FtaModel::FIELDNAME_DATE_CREATION . "='" . date("Y-m-d") . "', " . FtaModel::FIELDNAME_ACTIF . "=" . 0 . ", " . FtaModel::FIELDNAME_CODE_ARTICLE . "=" . 'NULL' . ", " . FtaModel::FIELDNAME_WORKFLOW . "=" . $paramIdFtaWorkflow . ", " . FtaModel::FIELDNAME_SITE_PRODUCTION . "=" . $paramOption["site_de_production"] . " WHERE " . FtaModel::KEYNAME . "=" . $idFtaNew);
     switch ($paramAction) {
         //Suivant l'action, certaines données sont à mettre à jour
         /*
          * //Création d'un nouveau dossier
          */
         case "totale":
             DatabaseOperation::execute("UPDATE " . FtaModel::TABLENAME . " SET " . FtaModel::FIELDNAME_DOSSIER_FTA . "=" . $idFtaNew . ", " . FtaModel::FIELDNAME_VERSION_DOSSIER_FTA . "=" . 0 . ", " . FtaModel::FIELDNAME_ID_FTA_ETAT . "=" . 1 . ", " . FtaModel::FIELDNAME_ARTICLE_AGROLOGIC . "=" . 0 . ", " . FtaModel::FIELDNAME_DATE_ECHEANCE_FTA . "=" . "0000-00-00" . ", " . FtaModel::FIELDNAME_DESIGNATION_COMMERCIALE . "=\"" . $paramOption["designation_commerciale_fta"] . "\", " . FtaModel::FIELDNAME_NOM_ABREGE . "=" . "NULL" . ", " . FtaModel::FIELDNAME_LIBELLE . "=" . "NULL" . ", " . FtaModel::FIELDNAME_CODE_ARTICLE_LDC . "=" . "0" . ", " . FtaModel::FIELDNAME_EAN_COLIS . "=" . "0" . ", " . FtaModel::FIELDNAME_EAN_UVC . "=" . "0" . ", " . FtaModel::FIELDNAME_EAN_PALETTE . "=" . "0" . ", " . FtaModel::FIELDNAME_POURCENTAGE_AVANCEMENT . "=" . "\"0%\"" . ", " . FtaModel::FIELDNAME_CREATEUR . "=" . $idUser . ", " . FtaModel::FIELDNAME_LISTE_ID_FTA_ROLE . "=" . "NULL" . " WHERE " . FtaModel::KEYNAME . "=" . $idFtaNew);
             break;
             /*
              *  //Création d'une nouvelle version de la FTA
              */
         /*
          *  //Création d'une nouvelle version de la FTA
          */
         case "version":
             $idFtaVersion = $idFtaVersion + 1;
             DatabaseOperation::execute("UPDATE " . self::TABLENAME . " SET " . self::FIELDNAME_VERSION_DOSSIER_FTA . "=\"" . $idFtaVersion . "\", " . self::FIELDNAME_ID_FTA_ETAT . "=\"" . $idFtaEtatNew . "\", " . self::FIELDNAME_DATE_ECHEANCE_FTA . "=\"" . $paramOption["date_echeance_fta"] . "\" WHERE " . self::KEYNAME . "=" . $idFtaNew);
             break;
     }
     /*         * ***************************
               Traitement des tables esclaves
              * *************************** */
     /*         * ******************************************************************************************
               Les tables esclaves sont des tables contenant le champ "id_fta" dans la liste de leurs champs
              * ****************************************************************************************** */
     FtaComposantModel::duplicateFtaComposantByIdFta($idFtaOriginal, $idFtaNew);
     FtaConditionnementModel::duplicateFtaConditionnementByIdFta($idFtaOriginal, $idFtaNew);
     FtaSuiviProjetModel::duplicateFtaSuiviProjetByIdFta($idFtaOriginal, $idFtaNew);
     // ClassificationFtaModel::DuplicateFtaClassificationByIdFta($idFtaOriginal, $idFtaNew);
     /*
      - Récupérér les composants de la nouvelle FTA
      - Pour chaque produit (id_fta_nomenclature)
      - Récupérer l'identifiant de la version précédente (noté: [last_id_fta_nomenclature])
      - Sur la FTA précédente, retrouver l'identifiant composant associé à cette ancienne version du produit (noté: [last_id_fta_composant])
      - Sur le nouvelle FTA, retrouver l'identifiant composant associé à ce [last_id_fta_composant]
      - Sur ce nouveau composant, remplacer l'association nomenclature par [id_fta_nomenclature]
     */
     /*         * *****************************************************************************
               Traitement POST
              * ****************************************************************************** */
     switch ($paramAction) {
         case "version":
             $newAbreviationFtaEtat = $paramOption["abreviation_etat_destination"];
             //Nouvel état
             //Récupération de la liste des chapitres a dévalider
             $selection_chapitre = $paramOption["selection_chapitre"];
             $paramOption["no_message_ecran"] = 1;
             $paramOption["mail_gestionnaire"] = 1;
             if ($selection_chapitre) {
                 foreach ($selection_chapitre as $id_fta_chapitre) {
                     //Correction des chapitres
                     $paramOption["correction_fta_suivi_projet"] = $paramOption["nouveau_maj_fta"];
                     FtaChapitreModel::buildCorrectionChapitre($idFtaNew, $id_fta_chapitre, $paramOption);
                 }
             }
             /*
              * Cette fonction est mise en pause car elle nécessite la création de processus cycle pour chaque workflow,
              * questionnement à boris.
              */
             if ($newAbreviationFtaEtat == FtaEtatModel::ETAT_ABREVIATION_VALUE_MODIFICATION and !$selection_chapitre) {
                 //Suppression des validations
                 //Recherche des chapitres affectés au cycle de vie correspondant à l'état
                 $arrayCycle = DatabaseOperation::convertSqlStatementWithoutKeyToArray("SELECT DISTINCT " . FtaProcessusCycleModel::FIELDNAME_PROCESSUS_INIT . "," . FtaWorkflowStructureModel::FIELDNAME_ID_FTA_CHAPITRE . " FROM " . FtaProcessusCycleModel::TABLENAME . ", " . FtaWorkflowStructureModel::TABLENAME . " WHERE " . FtaProcessusCycleModel::FIELDNAME_FTA_ETAT . "='" . $newAbreviationFtaEtat . "' AND " . FtaWorkflowStructureModel::TABLENAME . "." . FtaWorkflowStructureModel::FIELDNAME_ID_FTA_PROCESSUS . "=" . FtaProcessusCycleModel::TABLENAME . "." . FtaProcessusCycleModel::FIELDNAME_PROCESSUS_INIT . " AND " . FtaWorkflowStructureModel::TABLENAME . "." . FtaWorkflowStructureModel::FIELDNAME_ID_FTA_WORKFLOW . "=" . FtaProcessusCycleModel::TABLENAME . "." . FtaProcessusCycleModel::FIELDNAME_WORKFLOW . " AND " . FtaWorkflowStructureModel::TABLENAME . "." . FtaWorkflowStructureModel::FIELDNAME_ID_FTA_WORKFLOW . "=" . $paramIdFtaWorkflow);
                 if ($arrayCycle) {
                     //Si ce cycle de vie necessite l'intervention de processus, alors                            //On supprime la validation du suivi de projet des processus concernés
                     $req = "DELETE FROM " . FtaSuiviProjetModel::TABLENAME . " WHERE ";
                     $or = " ";
                     foreach ($arrayCycle as $rowsCycle) {
                         //Vérification qu'il ne s'agissent pas du processus initiateur du nouveau cycle de vie
                         $arrayFirst = DatabaseOperation::convertSqlStatementWithoutKeyToArray("SELECT " . FtaSuiviProjetModel::KEYNAME . " FROM " . FtaProcessusCycleModel::TABLENAME . ", " . FtaWorkflowStructureModel::TABLENAME . ", " . FtaSuiviProjetModel::TABLENAME . " WHERE " . FtaProcessusCycleModel::FIELDNAME_FTA_ETAT . "='" . $newAbreviationFtaEtat . "' AND " . FtaWorkflowStructureModel::TABLENAME . "." . FtaWorkflowStructureModel::FIELDNAME_ID_FTA_PROCESSUS . "=" . FtaProcessusCycleModel::TABLENAME . "." . FtaProcessusCycleModel::FIELDNAME_PROCESSUS_INIT . " AND " . FtaSuiviProjetModel::TABLENAME . "." . FtaSuiviProjetModel::FIELDNAME_ID_FTA_CHAPITRE . "=" . FtaWorkflowStructureModel::TABLENAME . "." . FtaWorkflowStructureModel::FIELDNAME_ID_FTA_CHAPITRE . " AND " . FtaSuiviProjetModel::TABLENAME . "." . FtaSuiviProjetModel::FIELDNAME_ID_FTA . "='" . $idFtaNew . "' " . " AND " . FtaProcessusCycleModel::TABLENAME . "." . FtaProcessusCycleModel::FIELDNAME_PROCESSUS_NEXT . "='" . $rowsCycle[FtaProcessusCycleModel::FIELDNAME_PROCESSUS_INIT] . "' ");
                         if ($arrayFirst) {
                             //Si il ne s'agit pas du chapitre appartenant au processus initial, on supprime
                             $req .= $or . "(" . FtaSuiviProjetModel::FIELDNAME_ID_FTA_CHAPITRE . "='" . $rowsCycle[FtaWorkflowStructureModel::FIELDNAME_ID_FTA_CHAPITRE] . "' AND " . FtaSuiviProjetModel::FIELDNAME_ID_FTA . "='" . $idFtaNew . "') ";
                             $or = " OR ";
                         } else {
                             //Sinon, Supprimer uniquement la validation et on notifie les chapitres
                             $req_update = "UPDATE " . FtaSuiviProjetModel::TABLENAME . " SET " . FtaSuiviProjetModel::FIELDNAME_SIGNATURE_VALIDATION_SUIVI_PROJET . "=''" . ", " . FtaSuiviProjetModel::FIELDNAME_DATE_VALIDATION_SUIVI_PROJET . "=''" . ", " . FtaSuiviProjetModel::FIELDNAME_DATE_DEMARRAGE_CHAPITRE_FTA_SUIVI_PROJET . "=''" . ", " . FtaSuiviProjetModel::FIELDNAME_NOTIFICATION_FTA_SUIVI_PROJET . "='1' " . " WHERE (" . FtaSuiviProjetModel::FIELDNAME_ID_FTA_CHAPITRE . "='" . $rowsCycle[FtaWorkflowStructureModel::FIELDNAME_ID_FTA_CHAPITRE] . "' AND " . FtaSuiviProjetModel::FIELDNAME_ID_FTA . "='" . $idFtaNew . "') ";
                             DatabaseOperation::execute($req_update);
                         }
                     }
                     DatabaseOperation::execute($req);
                 }
                 //Fin de Recherche des notifications relatives aux processus trouvées
             }
             //Fin de la dévalidation suite à une initialisation
             //Vérrouillage des chapitre ne correspondant pas au cycle de vie.
             if ($newAbreviationFtaEtat == "P") {
                 //Condition where
                 $where = "";
                 //Récupération des chapitres concernés par ce cycle de vie
                 $arrayCycle2 = DatabaseOperation::convertSqlStatementWithoutKeyToArray("SELECT DISTINCT " . FtaProcessusCycleModel::FIELDNAME_PROCESSUS_INIT . " FROM " . FtaProcessusCycleModel::TABLENAME . " WHERE " . FtaProcessusCycleModel::FIELDNAME_FTA_ETAT . " = '" . $newAbreviationFtaEtat . "' ");
                 foreach ($arrayCycle2 as $rowsCycle2) {
                     $where .= " AND " . FtaProcessusModel::TABLENAME . "." . FtaProcessusModel::KEYNAME . " <> " . $rowsCycle2[FtaProcessusCycleModel::FIELDNAME_PROCESSUS_INIT];
                 }
                 //Récupération des chapitres à vérrouiller
                 $arrayChapitreVerrouiller = DatabaseOperation::convertSqlStatementWithoutKeyToArray("SELECT DISTINCT  " . FtaWorkflowStructureModel::FIELDNAME_ID_FTA_CHAPITRE . " FROM " . FtaProcessusModel::TABLENAME . ", " . FtaWorkflowStructureModel::TABLENAME . " WHERE ( " . FtaProcessusModel::TABLENAME . "." . FtaProcessusModel::KEYNAME . " = " . FtaWorkflowStructureModel::TABLENAME . "." . FtaWorkflowStructureModel::FIELDNAME_ID_FTA_CHAPITRE . " ) " . " AND ( (  " . FtaProcessusModel::TABLENAME . "." . FtaProcessusModel::KEYNAME . " <>1 {$where} ) )" . " AND " . FtaWorkflowStructureModel::TABLENAME . "." . FtaWorkflowStructureModel::FIELDNAME_ID_FTA_WORKFLOW . " = " . $paramIdFtaWorkflow);
                 foreach ($arrayChapitreVerrouiller as $rowsChapitreVerrouiller) {
                     //Le suivi existe-il déjà ?
                     $arrayFtaSuiviProjet = DatabaseOperation::convertSqlStatementWithoutKeyToArray("SELECT " . FtaSuiviProjetModel::KEYNAME . ", " . FtaSuiviProjetModel::FIELDNAME_SIGNATURE_VALIDATION_SUIVI_PROJET . " FROM " . FtaSuiviProjetModel::TABLENAME . " WHERE " . FtaSuiviProjetModel::FIELDNAME_ID_FTA . "='" . $idFtaNew . "' AND " . FtaSuiviProjetModel::FIELDNAME_ID_FTA_CHAPITRE . "='" . $rowsChapitreVerrouiller[FtaWorkflowStructureModel::FIELDNAME_ID_FTA_CHAPITRE] . "' ");
                     if ($arrayFtaSuiviProjet) {
                         //Mise à jour de l'existant si il n'y a pas de vérrou existant
                         foreach ($arrayFtaSuiviProjet as $rowsFtaSuiviProjet) {
                             if (!$rowsFtaSuiviProjet[FtaSuiviProjetModel::FIELDNAME_SIGNATURE_VALIDATION_SUIVI_PROJET]) {
                                 $idFtaSuiviProjet = $rowsFtaSuiviProjet[FtaSuiviProjetModel::KEYNAME];
                                 $req = "UPDATE " . FtaSuiviProjetModel::TABLENAME . "SET " . FtaSuiviProjetModel::FIELDNAME_SIGNATURE_VALIDATION_SUIVI_PROJET . "='-1' " . "WHERE " . FtaSuiviProjetModel::KEYNAME . "='" . $idFtaSuiviProjet . "' ";
                                 DatabaseOperation::execute($req);
                             }
                         }
                     } else {
                         //Création des suivi
                         $req = "INSERT " . FtaSuiviProjetModel::TABLENAME . " SET " . FtaSuiviProjetModel::FIELDNAME_ID_FTA_CHAPITRE . "='" . $rowsChapitreVerrouiller[FtaWorkflowStructureModel::FIELDNAME_ID_FTA_CHAPITRE] . "', " . FtaSuiviProjetModel::FIELDNAME_ID_FTA . "='" . $idFtaNew . "', " . FtaSuiviProjetModel::FIELDNAME_SIGNATURE_VALIDATION_SUIVI_PROJET . "='-1' ";
                         DatabaseOperation::execute($req);
                     }
                 }
             }
             break;
             //Fin du post-traitement dans le cas d'une duplication de type "version"
         //Fin du post-traitement dans le cas d'une duplication de type "version"
         case "totale":
             $newAbreviationFtaEtat = $paramOption["abreviation_etat_destination"];
             //Nouvel état
             //Suppression de tout le suivi de dossier
             $req = "DELETE FROM " . FtaSuiviProjetModel::TABLENAME . " WHERE " . FtaSuiviProjetModel::TABLENAME . "." . FtaSuiviProjetModel::FIELDNAME_ID_FTA . "='" . $idFtaNew . "' ";
             DatabaseOperation::execute($req);
             break;
     }
     //Fin du post-traitement dans le cas d'une duplication de type "totale"
     return $idFtaNew;
 }
Exemple #2
0
 protected static function buildChapitreCore()
 {
     $return = '';
     switch (self::$ftaChapitreModel->getDataField(FtaChapitreModel::FIELDNAME_NOM_CHAPITRE)->getFieldValue()) {
         case 'identite':
             self::$html_chapitre_identite = self::buildChapitreIdentite();
             $return = self::$html_chapitre_identite;
             break;
         case 'commerce':
             self::$html_chapitre_commerce = self::buildChapitreDonneClient();
             $return = self::$html_chapitre_commerce;
             break;
         case 'production':
             self::$html_chapitre_production = self::buildChapitreProduction();
             $return = self::$html_chapitre_production;
             break;
         case 'qualite':
             self::$html_chapitre_qualite = self::buildChapitreQualite();
             $return = self::$html_chapitre_qualite;
             break;
         case 'decoupe':
             self::$html_chapitre_decoupe = self::buildChapitreDecoupe();
             $return = self::$html_chapitre_decoupe;
             break;
         case 'conditionnement_piece_entiere':
             self::$html_chapitre_conditionnement_piece_entiere = self::buildChapitreConditionnementPieceEntiere();
             $return = self::$html_chapitre_conditionnement_piece_entiere;
             break;
         case 'conditionnement_decoupe':
             self::$html_chapitre_conditionnement_decoupe = self::buildChapitreConditionnementDecoupe();
             $return = self::$html_chapitre_conditionnement_decoupe;
             break;
         case 'codification':
             self::$html_chapitre_codification = self::buildChapitreCodification();
             $return = self::$html_chapitre_codification;
             break;
         case 'codification_externe':
             self::$html_chapitre_codification_externe = self::buildChapitreCodificationExterne();
             $return = self::$html_chapitre_codification_externe;
             break;
         case 'etiquette':
             self::$html_chapitre_etiquette = self::buildChapitreEtiquette();
             $return = self::$html_chapitre_etiquette;
             break;
         case 'expedition':
             self::$html_chapitre_expedition = self::buildChapitreExpedition();
             $return = self::$html_chapitre_expedition;
             break;
         case 'composition':
             self::$html_chapitre_composition = self::buildChapitreComposition();
             $return = self::$html_chapitre_composition;
             break;
         case 'activation_des_produits':
             self::$html_chapitre_activation_des_produits = self::buildChapitreActivationDesProduits();
             $return = self::$html_chapitre_activation_des_produits;
             break;
         case 'nomenclature':
             self::$html_chapitre_nomenclature = self::buildChapitreNomenclature();
             $return = self::$html_chapitre_nomenclature;
             break;
         case 'commentaire':
             self::$html_chapitre_commentaire = self::buildChapitreCommentaire();
             $return = self::$html_chapitre_commentaire;
             break;
         case 'palettisation':
             self::$html_chapitre_palettisation = self::buildChapitrePalettisation();
             $return = self::$html_chapitre_palettisation;
             break;
         case 'dictionnaire_de_donnees':
             self::$html_chapitre_dictionnaire_de_donnees = self::buildChapitreDictionnaireDeDonnees();
             $return = self::$html_chapitre_dictionnaire_de_donnees;
             break;
         default:
         case 'site_expedition':
             self::$html_chapitre_site_expedition = self::buildChapitreExpeditionEtEANS();
             $return = self::$html_chapitre_site_expedition;
             break;
         default:
         case 'site_production':
             self::$html_chapitre_site_production = self::buildChapitreSiteProduction();
             $return = self::$html_chapitre_site_production;
             break;
         default:
         case 'exigence_client':
             self::$html_chapitre_exigence_client = self::buildChapitreExigenceClient();
             $return = self::$html_chapitre_exigence_client;
             break;
         default:
         case 'exigence_client_MDD':
             self::$html_chapitre_exigence_client_MDD = self::buildChapitreExigenceClientMDD();
             $return = self::$html_chapitre_exigence_client_MDD;
             break;
         default:
         case 'etiquette_client':
             self::$html_chapitre_etiquette_client = self::buildChapitreEtiquetteClient();
             $return = self::$html_chapitre_etiquette_client;
             break;
         default:
         case 'etiquette_client_FEAvecEtiq':
             self::$html_chapitre_etiquette_client_FEAvecEtiq = self::buildChapitreEtiquetteClient_FE();
             $return = self::$html_chapitre_etiquette_client_FEAvecEtiq;
             break;
         default:
         case 'etiquette_client_MDDAvecEtiq':
             self::$html_chapitre_etiquette_client_MDDAvecEtiq = self::buildChapitreEtiquetteClient_MDD();
             $return = self::$html_chapitre_etiquette_client_MDDAvecEtiq;
             break;
         default:
         case 'pcb':
             self::$html_chapitre_pcb = self::buildChapitrePcb();
             $return = self::$html_chapitre_pcb;
             break;
         default:
         case 'emballage':
             self::$html_chapitre_emballage = self::buildChapitreEmballagePrimaire();
             $return = self::$html_chapitre_emballage;
             break;
         default:
         case 'emballage_colis':
             self::$html_chapitre_emballage_colis = self::buildChapitreEmballageDuColis();
             $return = self::$html_chapitre_emballage_colis;
             break;
         default:
         case 'etiquette_r_d':
             self::$html_chapitre_etiquette_r_d = self::buildChapitreEtiquetteRD();
             $return = self::$html_chapitre_etiquette_r_d;
             break;
         default:
         case 'etiquette_article':
             self::$html_chapitre_etiquette_article = self::buildChapitreEtiquetteArticle();
             $return = self::$html_chapitre_etiquette_article;
             break;
         default:
         case 'etiquette_article_FEAvecEtiq':
             self::$html_chapitre_etiquette_article_FEAvecEtiq = self::buildChapitreEtiquetteArticle_FEAvecEtiq();
             $return = self::$html_chapitre_etiquette_article_FEAvecEtiq;
             break;
         default:
         case 'etiquette_article_MDDAvecEtiq':
             self::$html_chapitre_etiquette_article_MDDAvecEtiq = self::buildChapitreEtiquetteArticle_MDDAvecEtiq();
             $return = self::$html_chapitre_etiquette_article_MDDAvecEtiq;
             break;
         default:
         case 'etiquette_composant':
             self::$html_chapitre_etiquette_composant = self::buildChapitreEtiquetteComposant();
             $return = self::$html_chapitre_etiquette_composant;
             break;
         default:
         case 'etiquette_composant_FEAvecEtiq':
             self::$html_chapitre_etiquette_composant_FEAvecEtiq = self::buildChapitreEtiquetteComposant_FEAvecEtiq();
             $return = self::$html_chapitre_etiquette_composant_FEAvecEtiq;
             break;
         default:
         case 'etiquette_composant_MDDAvecEtiq':
             self::$html_chapitre_etiquette_composant_MDDAvecEtiq = self::buildChapitreEtiquetteComposant_MDDAvecEtiq();
             $return = self::$html_chapitre_etiquette_composant_MDDAvecEtiq;
             break;
         default:
         case 'donnees_clients':
             self::$html_chapitre_donnees_clients_w1 = self::buildChapitreDonneClient();
             $return = self::$html_chapitre_donnees_clients_w1;
             break;
         default:
         case 'codification':
             self::$html_chapitre_codification_w1 = self::buildChapitreCodification();
             $return = self::$html_chapitre_codification_w1;
             break;
         default:
         case 'duree_de_vie':
             self::$html_chapitre_duree_de_vie = self::buildChapitreDureeDeVie();
             $return = self::$html_chapitre_duree_de_vie;
             break;
         default:
         case 'activation_cody':
             self::$html_chapitre_activation_cody = self::buildChapitreActivationCody();
             $return = self::$html_chapitre_activation_cody;
             break;
         default:
     }
     return $return;
 }
 */
 case '':
     //Redirection
     header('Location: index.php');
     /**
      * Version avec le module rewrite
      */
     //        header('Location: index.html');
     break;
     //Gestion des Erreurs
 //Gestion des Erreurs
 case 'correction':
     if ($new_correction_fta_suivi_projet) {
         $paramIdFtaChapitre = $paramIdFtaChapitreEncours;
         $option[FtaSuiviProjetModel::FIELDNAME_CORRECTION_FTA_SUIVI_PROJET] = $new_correction_fta_suivi_projet;
         $noredirection = FtaChapitreModel::buildCorrectionChapitre($paramIdFta, $paramIdFtaChapitre, $option);
     } else {
         $titre = 'Informations manquantes';
         $message = 'Vous devez spécifier l\'objet de votre correction.';
         Lib::showMessage($titre, $message);
         $noredirection = 1;
     }
     break;
 case 'suppression_classification_chemin':
     //Suppresion du chemin
     //$id_classification_fta;             //From URL
     //$id_fta;                            //From URL
     //mysql_table_operation('classification_fta', 'delete');
     ObjectFta::deleteClassification();
     break;
 case 'valider':
 /**
  * On obtient les corrections de chaque chapitres
  * @param int $paramIdFta
  * @param int $paramIdFtaWorkflow
  * @return int
  */
 public static function getAllCorrectionsFromChapitres($paramIdFta, $paramIdFtaWorkflow)
 {
     $arrayCommentaireAllChapitre = DatabaseOperation::convertSqlStatementWithoutKeyToArray("SELECT " . FtaSuiviProjetModel::FIELDNAME_CORRECTION_FTA_SUIVI_PROJET . "," . UserModel::FIELDNAME_PRENOM . "," . UserModel::FIELDNAME_NOM . "," . FtaSuiviProjetModel::TABLENAME . "." . FtaSuiviProjetModel::FIELDNAME_ID_FTA_CHAPITRE . "," . FtaSuiviProjetModel::TABLENAME . "." . FtaSuiviProjetModel::FIELDNAME_DATE_VALIDATION_SUIVI_PROJET . " FROM " . FtaSuiviProjetModel::TABLENAME . ", " . UserModel::TABLENAME . ", " . FtaWorkflowStructureModel::TABLENAME . " WHERE ( " . FtaSuiviProjetModel::TABLENAME . "." . FtaSuiviProjetModel::FIELDNAME_SIGNATURE_VALIDATION_SUIVI_PROJET . " = " . UserModel::TABLENAME . "." . UserModel::KEYNAME . " ) " . " AND " . FtaSuiviProjetModel::TABLENAME . "." . FtaSuiviProjetModel::FIELDNAME_ID_FTA . " = " . $paramIdFta . " AND " . FtaWorkflowStructureModel::TABLENAME . "." . FtaWorkflowStructureModel::FIELDNAME_ID_FTA_WORKFLOW . " = " . $paramIdFtaWorkflow . " AND " . FtaWorkflowStructureModel::TABLENAME . "." . FtaWorkflowStructureModel::FIELDNAME_ID_FTA_CHAPITRE . " = " . FtaSuiviProjetModel::TABLENAME . "." . FtaSuiviProjetModel::FIELDNAME_ID_FTA_CHAPITRE . " ORDER BY " . FtaSuiviProjetModel::FIELDNAME_DATE_VALIDATION_SUIVI_PROJET . " DESC ");
     if ($arrayCommentaireAllChapitre) {
         foreach ($arrayCommentaireAllChapitre as $rowsCommentaireAllChapitre) {
             if ($rowsCommentaireAllChapitre[FtaSuiviProjetModel::FIELDNAME_CORRECTION_FTA_SUIVI_PROJET]) {
                 $idFtaChapitre = $rowsCommentaireAllChapitre[FtaSuiviProjetModel::FIELDNAME_ID_FTA_CHAPITRE];
                 $dateDeValidation = $rowsCommentaireAllChapitre[FtaSuiviProjetModel::FIELDNAME_DATE_VALIDATION_SUIVI_PROJET];
                 $ftaChapitreModel = new FtaChapitreModel($idFtaChapitre);
                 $nomChapitre = $ftaChapitreModel->getDataField(FtaChapitreModel::FIELDNAME_NOM_USUEL_CHAPITRE)->getFieldValue();
                 $action = "Chapitre " . $nomChapitre;
                 $nomPrenom = $rowsCommentaireAllChapitre[UserModel::FIELDNAME_PRENOM] . " " . $rowsCommentaireAllChapitre[UserModel::FIELDNAME_NOM];
                 $comment = $rowsCommentaireAllChapitre[FtaSuiviProjetModel::FIELDNAME_CORRECTION_FTA_SUIVI_PROJET];
                 $return .= FtaController::getComment($action, $nomPrenom, $comment, $dateDeValidation) . "\n";
             }
         }
         $return = "<tr class=contenu><td> Récapitulatif des corrections</td><td>" . $return . "</td></tr>";
     } else {
         $return = "<tr class=contenu><td> Récapitulatif des corrections</td><td></td></tr>";
     }
     return str_replace("  ", "&nbsp;&nbsp;", nl2br($return));
 }
 /**
  * On obtient le chapitre par défaut en redirection
  * @param int $paramIdFtaRole
  * @param int $paramIdFtaWorkflow
  * @param array $paramListeDesChapitres
  * @return array
  */
 public static function getIdFtaChapitreByDefault($paramIdFtaRole, $paramIdFtaWorkflow, $paramListeDesChapitres)
 {
     $arrayProcessusAcces = FtaWorkflowStructureModel::getArrayProcessusByRoleAndWorkflow($paramIdFtaRole, $paramIdFtaWorkflow);
     $ListeDesChapitresByUser = FtaChapitreModel::getIdFtaChapitreByArrayProcessusAndWorkflow($arrayProcessusAcces, $paramIdFtaWorkflow);
     if ($paramListeDesChapitres) {
         $ListeDesChapitresAcces = array_intersect($paramListeDesChapitres, $ListeDesChapitresByUser);
     }
     foreach ($ListeDesChapitresAcces as $key => $value) {
         $idFtaChapitre = $value;
     }
     if (!$idFtaChapitre) {
         $idFtaChapitre = FtaChapitreModel::ID_CHAPITRE_IDENTITE;
     }
     return $idFtaChapitre;
 }
     if (Lib::getParameterFromRequest(FtaChapitreModel::FIELDNAME_NOM_CHAPITRE . '_' . $rowsChapitre[FtaWorkflowStructureModel::FIELDNAME_ID_FTA_CHAPITRE]) == 1) {
         $ListeDesChapitres[] = $rowsChapitre[FtaChapitreModel::KEYNAME];
     }
 }
 if ($ListeDesChapitres) {
     foreach ($ListeDesChapitres as $idChapitre) {
         $idFtaWorkflowStructure = FtaWorkflowStructureModel::getIdFtaWorkflowStructureByIdFtaAndIdChapitre($idFta, $idChapitre);
         $ftaWorkflowStructureModel = new FtaWorkflowStructureModel($idFtaWorkflowStructure, $idChapitre);
         $idFtaProcessus = $ftaWorkflowStructureModel->getDataField(FtaWorkflowStructureModel::FIELDNAME_ID_FTA_PROCESSUS)->getFieldValue();
         $return = FtaProcessusModel::getProcessusNextFromIdFtaChapitres($idFta, $idFtaProcessus, $idFtaWorkflow, "I", $htmlResult, $idFtaProcessusEffectue);
         $ListeDesChapitresSuivant[] = FtaChapitreModel::getIdFtaChapitreByArrayProcessusAndWorkflow($return['processus'], $idFtaWorkflow);
         $redirectionSelectionne .= '&' . FtaChapitreModel::FIELDNAME_NOM_CHAPITRE . '_' . $idChapitre . '=1';
     }
     $ListeDesChapitresSuivant = array_unique($ListeDesChapitresSuivant);
     if ($ListeDesChapitresSuivant["0"]) {
         $arrayChapitreDescription = DatabaseOperation::convertSqlStatementWithoutKeyToArray('SELECT DISTINCT ' . FtaChapitreModel::FIELDNAME_NOM_USUEL_CHAPITRE . ',' . FtaChapitreModel::KEYNAME . ' FROM ' . FtaChapitreModel::TABLENAME . ' WHERE ( 0' . FtaChapitreModel::addIdFtaChapitre($ListeDesChapitresSuivant["0"]) . ' )');
         foreach ($arrayChapitreDescription as $rowsChapitreDescription) {
             $bloc .= $rowsChapitreDescription[FtaChapitreModel::FIELDNAME_NOM_USUEL_CHAPITRE] . ' / ';
             $redirection .= '&' . FtaChapitreModel::FIELDNAME_NOM_CHAPITRE . '_' . $rowsChapitreDescription[FtaChapitreModel::KEYNAME] . '=2';
         }
     } else {
         $bloc = "<i>Les chapitres sélectionnés sont les seuls à être dévalidé </i>";
     }
 } else {
     //Averissement
     $titre = UserInterfaceMessage::FR_WARNING_CHAPITRES_TITLE;
     $message = UserInterfaceMessage::FR_WARNING_CHAPITRES;
     Lib::showMessage($titre, $message, $redirection);
 }
 $bouton_retour_vers_transiter = FtaView::getHtmlButtonReturnTransition($idFta, $action, $idFtaRole, "", "");
 $bouton_confirmation = FtaView::getHtmlButtonConfirmationTransition($idFta, $action, $idFtaRole, $redirectionSelectionne, $redirection);
     $ok = 0;
     foreach ($arrayChapitre as $rowsChapitre) {
         if (Lib::getParameterFromRequest(FtaChapitreModel::FIELDNAME_NOM_CHAPITRE . '_' . $rowsChapitre[FtaChapitreModel::KEYNAME]) == 1) {
             $ListeDesChapitres[] = $rowsChapitre[FtaChapitreModel::KEYNAME];
             $ListeDesChapitresComment .= " " . $rowsChapitre[FtaChapitreModel::FIELDNAME_NOM_USUEL_CHAPITRE];
             $ok = 1;
         }
     }
     if (!$ok) {
         $titre = 'Informations manquantes';
         $message = 'Vous devez sélectionner au moins un chapitre à mettre à jour.';
         Lib::showMessage($titre, $message, $redirection);
         $error = 1;
     }
     $new_commentaire_maj_fta = $new_commentaire_maj_fta . "-" . $ListeDesChapitresComment;
     $idFtaChapitreByDefault = FtaChapitreModel::getIdFtaChapitreByDefault($idFtaRole, $idFtaWorkflow, $ListeDesChapitres);
 }
 // Fin du controle d'intégrité *************************************************
 //Si pas d'erreur, lancement de la transition
 if (!$error) {
     foreach ($selection_fta as $idFta) {
         //Transition de la FTA
         $commentaire_maj_fta = $new_commentaire_maj_fta;
         $t = FtaTransitionModel::buildTransitionFta($idFta, $abreviation_fta_transition, $commentaire_maj_fta, $idFtaWorkflow, $ListeDesChapitres, $dateEcheanceFta);
         //Codes de retour de la fonction:
         //   0: FTA correctement transitée
         //   1: FTA non transité car risque de doublon
         //   3: Erreur autre
         if ($abreviation_fta_transition == FtaEtatModel::ETAT_ABREVIATION_VALUE_VALIDE) {
             //Seules les FTA validées entrent dans un système de diffusion
             switch ($t["0"]) {