diff --git a/Controleur/ControleurGedadherent.php b/Controleur/ControleurGedadherent.php index 7a8eb07..a15ab7b 100644 --- a/Controleur/ControleurGedadherent.php +++ b/Controleur/ControleurGedadherent.php @@ -23,6 +23,17 @@ class ControleurGedadherent extends Controleur { $nouveau_fichier = "rien"; + $codeNaturePiece = $this->requete->getParametre("codeNaturePiece"); + + if($codeNaturePiece == "AUT"){ + $libelleDocument = $this->requete->getParametreFormulaire("libelleAutre"); + }else{ + $libelleDocument = $this->ged->getLibelleTypeDocument($codeNaturePiece); + } + + var_dump(array($codeNaturePiece, $libelleDocument)); + die(); + if(!empty($_POST)) { define('TARGET', $_SESSION['cheminGed']); // Repertoire cible @@ -37,6 +48,8 @@ class ControleurGedadherent extends Controleur { // Variables $extension = ''; + + if( !is_dir(TARGET) ) { if( !mkdir(TARGET, 0755) ) @@ -70,6 +83,7 @@ class ControleurGedadherent extends Controleur { // On renomme le fichier $nomOrigine = $_FILES['fichier_upload']['name']; $nouveau_fichier = dateJourSql()."_".uniqid().".".$extension; + // Si c'est OK, on teste l'upload if(move_uploaded_file($_FILES['fichier_upload']['tmp_name'], TARGET.$nouveau_fichier)) @@ -79,7 +93,7 @@ class ControleurGedadherent extends Controleur { : 'Chargé avec succès'; // on va envoyer dans la base de données - $this->ged->enregistrergedadherent($nomOrigine, $nouveau_fichier, $taille); + $this->ged->enregistrergedadherent($nomOrigine, $nouveau_fichier, $taille, $codeNaturePiece, $libelleDocument); $this->rediriger("Gedadherent"); } else diff --git a/Modele/Ged.php b/Modele/Ged.php index 7ae02ed..c2f5f15 100755 --- a/Modele/Ged.php +++ b/Modele/Ged.php @@ -73,22 +73,22 @@ class Ged extends Modele { { $idAdherent = $_SESSION['idAdherent_C']; - $sql = 'call sp_r_get_ged_adherent(?, ?, ?, ?)'; + $sql = 'call sp_get_ged_adherent_rh(?, ?, ?, ?)'; $resultat = $this->executerRequete($sql, array($idAdherent, $d1, $d2, $nomOrigine)); return $resultat->fetchAll(PDO::FETCH_ASSOC); } - public function enregistrergedadherent($nomOrigine, $nouveau_fichier, $taille) + public function enregistrergedadherent($nomOrigine, $nouveau_fichier, $taille, $codeNaturePiece, $libelleDocument) { $idAdherent = $_SESSION['idAdherent_C']; $user = $_SESSION['login']; $cheminFichier = $_SESSION['dossierGed'].$nouveau_fichier; - $sql = 'call sp_r_ajouter_ged_adherent(?, ?, ?, ?, ?)'; + $sql = 'call sp_ajouter_ged_adherent_rh(?, ?, ?, ?, ?)'; - $this->executerRequete($sql, array($idAdherent, $nomOrigine, $cheminFichier, $taille, $user)); + $this->executerRequete($sql, array($idAdherent, $nomOrigine, $cheminFichier, $taille, $user, $codeNaturePiece, $libelleDocument)); } public function getgedpolice($d1, $d2, $nomOrigine) @@ -226,10 +226,25 @@ class Ged extends Modele { $sql = 'call sp_a_get_ged_adherent_rd(?)'; - $resultat = $this->executerRequete($sql, array($idDemandeRemboursement)); return $resultat->fetchAll(PDO::FETCH_ASSOC); } - + + public function getLibelleTypeDocument($codeNaturePiece){ + + $codeSociete = $_SESSION['codeSociete']; + + if(est_anglophone()){ + $sql = 'SELECT fn_get_type_document_eng(?, ?) as libelleDocument'; + } else{ + $sql = 'SELECT fn_get_type_document(?, ?) as libelleDocument'; + } + + $resultat = $this->executerRequete($sql, array($codeNaturePiece, $codeSociete)); + + $ligne = $resultat->fetch(PDO::FETCH_ASSOC); + + return $ligne['libelleDocument']; + } } \ No newline at end of file diff --git a/Vue/Gedadherent/index.php b/Vue/Gedadherent/index.php index 129952c..5f0c01e 100644 --- a/Vue/Gedadherent/index.php +++ b/Vue/Gedadherent/index.php @@ -91,8 +91,8 @@ Date Src - - + +