| 296 | aurelien | 1 | <?php
 | 
        
           |  |  | 2 | class Cotisation extends AppControleur {
 | 
        
           |  |  | 3 |   | 
        
           |  |  | 4 | 	public function Cotisation() {
 | 
        
           |  |  | 5 |   | 
        
           |  |  | 6 | 		parent::__construct();
 | 
        
           |  |  | 7 | 	}
 | 
        
           |  |  | 8 |   | 
        
           |  |  | 9 |     /**
 | 
        
           |  |  | 10 |      * Initialisation du controleur principal en fonction des paramètres de l'url.
 | 
        
           |  |  | 11 |      */
 | 
        
           |  |  | 12 |     public function executerPlugin() {
 | 
        
           |  |  | 13 |   | 
        
           |  |  | 14 |     	$plugin_action = Config::get('plugin_variable_action');
 | 
        
           |  |  | 15 |   | 
        
           |  |  | 16 |         if (isset($_GET[$plugin_action])) {
 | 
        
           |  |  | 17 |             $action = $_GET[$plugin_action];
 | 
        
           |  |  | 18 |         } else {
 | 
        
           |  |  | 19 |         	$action = Config::get('plugin_action_defaut');
 | 
        
           |  |  | 20 |         }
 | 
        
           |  |  | 21 |   | 
        
           |  |  | 22 |         if(!$this->controleAccesAdmin($action)) {
 | 
        
           |  |  | 23 |         	return;
 | 
        
           |  |  | 24 |         }
 | 
        
           |  |  | 25 |   | 
        
           |  |  | 26 |         unset($_GET[$plugin_action]);
 | 
        
           |  |  | 27 |   | 
        
           |  |  | 28 |         $resultat_action_plugin = $this->$action($_GET);
 | 
        
           |  |  | 29 |   | 
        
           |  |  | 30 |         return $resultat_action_plugin ;
 | 
        
           |  |  | 31 |     }
 | 
        
           |  |  | 32 |   | 
        
           |  |  | 33 |     /**
 | 
        
           |  |  | 34 |      * Méthode appelée pour ajouter un élément.
 | 
        
           |  |  | 35 |      */
 | 
        
           |  |  | 36 |     public function ajouterCotisation() {
 | 
        
           |  |  | 37 |   | 
        
           |  |  | 38 |     	$params = $_POST;
 | 
        
           |  |  | 39 |   | 
        
           |  |  | 40 |     	$elements_requis = array('id_cotisant','date_cotisation', 'montant_cotisation', 'mode_cotisation');
 | 
        
           |  |  | 41 |     	$erreurs = array();
 | 
        
           |  |  | 42 |   | 
        
           |  |  | 43 |     	foreach($elements_requis as $requis) {
 | 
        
           |  |  | 44 |     		if(!isset($params[$requis])) {
 | 
        
           |  |  | 45 |     			//$erreurs[$requis] = 'erreur ';
 | 
        
           |  |  | 46 |     		}
 | 
        
           |  |  | 47 |     	}
 | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 |     	if(!empty($erreurs)) {
 | 
        
           |  |  | 50 |     		$this->envoyer($erreurs);
 | 
        
           |  |  | 51 |     	}
 | 
        
           |  |  | 52 |   | 
        
           | 513 | aurelien | 53 |     	$annuaire_modele = $this->getModele('AnnuaireModele');
 | 
        
           |  |  | 54 |     	$params['infos_utilisateur'] = $annuaire_modele->obtenirInfosUtilisateurParId($elements_requis['id_cotisant']);
 | 
        
           |  |  | 55 |   | 
        
           | 296 | aurelien | 56 |     	$params['date_cotisation'] = $this->formaterVersDateMysql($params['date_cotisation']);
 | 
        
           |  |  | 57 |   | 
        
           |  |  | 58 |     	$cotisation_modele = new CotisationModele();
 | 
        
           |  |  | 59 |     	$ajout_cotisation = $cotisation_modele->ajouterCotisation($params);
 | 
        
           |  |  | 60 |   | 
        
           |  |  | 61 | 		if(!$ajout_cotisation) {
 | 
        
           |  |  | 62 |     		$retour['erreurs'] = 'erreur d\'insertion';
 | 
        
           |  |  | 63 |     	}
 | 
        
           |  |  | 64 |   | 
        
           |  |  | 65 |     	$retour['id_utilisateur'] = $params['id_cotisant'];
 | 
        
           |  |  | 66 |   | 
        
           |  |  | 67 |     	return $this->afficherInformationsCotisationPourInscrit($retour);
 | 
        
           |  |  | 68 |   | 
        
           |  |  | 69 |     }
 | 
        
           |  |  | 70 |   | 
        
           |  |  | 71 |     /**
 | 
        
           |  |  | 72 |      * Méthode appelée pour mettre à jour une cotisation
 | 
        
           |  |  | 73 |      */
 | 
        
           |  |  | 74 |     public function mettreAJourCotisation()    {
 | 
        
           |  |  | 75 |   | 
        
           |  |  | 76 |     	$params = $_POST;
 | 
        
           |  |  | 77 |   | 
        
           |  |  | 78 |     	$id_cotisation = $params['id_cotisation'];
 | 
        
           |  |  | 79 |   | 
        
           |  |  | 80 |     	$elements_requis = array('id_cotisation','id_cotisant','date_cotisation', 'montant_cotisation', 'mode_cotisation');
 | 
        
           |  |  | 81 |     	$erreurs = array();
 | 
        
           |  |  | 82 |   | 
        
           |  |  | 83 |     	foreach($elements_requis as $requis) {
 | 
        
           |  |  | 84 |     		if(!isset($params[$requis])) {
 | 
        
           |  |  | 85 |     			//$erreurs[$requis] = 'erreur ';
 | 
        
           |  |  | 86 |     		}
 | 
        
           |  |  | 87 |     	}
 | 
        
           |  |  | 88 |   | 
        
           |  |  | 89 |     	if(!empty($erreurs)) {
 | 
        
           |  |  | 90 |     		$this->envoyer($erreurs);
 | 
        
           |  |  | 91 |     	}
 | 
        
           |  |  | 92 |   | 
        
           |  |  | 93 |     	$params['date_cotisation'] = $this->formaterVersDateMysql($params['date_cotisation']);
 | 
        
           |  |  | 94 |   | 
        
           |  |  | 95 |     	$cotisation_modele = new CotisationModele();
 | 
        
           |  |  | 96 |     	$modification_cotisation = $cotisation_modele->mettreAJourCotisation($id_cotisation, $params);
 | 
        
           |  |  | 97 |   | 
        
           |  |  | 98 | 		if(!$modification_cotisation) {
 | 
        
           |  |  | 99 |     		$retour['erreurs'] = 'erreur d\'insertion';
 | 
        
           |  |  | 100 |     	}
 | 
        
           |  |  | 101 |   | 
        
           |  |  | 102 |     	$retour['id_utilisateur'] = $params['id_cotisant'];
 | 
        
           |  |  | 103 |   | 
        
           |  |  | 104 |     	return $this->afficherInformationsCotisationPourInscrit($retour);
 | 
        
           |  |  | 105 |     }
 | 
        
           |  |  | 106 |   | 
        
           |  |  | 107 |     /**
 | 
        
           |  |  | 108 |      * Méthode appelée pour supprimer un élément
 | 
        
           |  |  | 109 |      */
 | 
        
           |  |  | 110 |     public function supprimerCotisation() {
 | 
        
           |  |  | 111 |   | 
        
           |  |  | 112 |     	$id_cotisation = $_GET['id_cotisation'];
 | 
        
           |  |  | 113 |   | 
        
           |  |  | 114 |     	$cotisation_modele = new CotisationModele();
 | 
        
           |  |  | 115 |     	$suppression_cotisation = $cotisation_modele->supprimerCotisation($id_cotisation);
 | 
        
           |  |  | 116 |   | 
        
           |  |  | 117 |     	if(!$suppression_cotisation) {
 | 
        
           |  |  | 118 |     		// TODO: comment gère t'on les erreurs ?
 | 
        
           |  |  | 119 |     	}
 | 
        
           |  |  | 120 |   | 
        
           |  |  | 121 |     	$param['id_utilisateur'] = $_GET['id_utilisateur'];
 | 
        
           |  |  | 122 |   | 
        
           |  |  | 123 |     	return $this->afficherInformationsCotisationPourInscrit($param);
 | 
        
           |  |  | 124 |   | 
        
           |  |  | 125 |     }
 | 
        
           |  |  | 126 |   | 
        
           |  |  | 127 |      /**
 | 
        
           |  |  | 128 |      *
 | 
        
           |  |  | 129 | 	 * Affiche un tableau récapitulant les informations de l'historique des cotisations pour un membre donné
 | 
        
           |  |  | 130 |      */
 | 
        
           |  |  | 131 |     private function afficherInformationsCotisationPourInscrit($param) {
 | 
        
           |  |  | 132 |   | 
        
           |  |  | 133 |     	$id_inscrit = $param['id_utilisateur'];
 | 
        
           |  |  | 134 |   | 
        
           |  |  | 135 |     	if(!Registre::getInstance()->get('est_admin')) {
 | 
        
           |  |  | 136 |     		$id_inscrit = Registre::getInstance()->get('identification_id');
 | 
        
           |  |  | 137 |     	}
 | 
        
           |  |  | 138 |   | 
        
           |  |  | 139 |     	$donnees['cotisations'] = $this->obtenirInformationsCotisationPourInscrit($param);
 | 
        
           |  |  | 140 |   | 
        
           | 513 | aurelien | 141 |     	$donnees['infos_utilisateur'] = $this->getInformationsUtilisateur($id_inscrit);
 | 
        
           |  |  | 142 |   | 
        
           | 296 | aurelien | 143 |     	$donnees['url_formulaire_ajout_cotisation'] = $this->getUrlFormulaireAjoutCotisation($id_inscrit);
 | 
        
           |  |  | 144 |   | 
        
           |  |  | 145 |     	if(isset($param['message'])) {
 | 
        
           |  |  | 146 |     		$donnees['message'] = $param['message'];
 | 
        
           |  |  | 147 |     	}
 | 
        
           |  |  | 148 |   | 
        
           |  |  | 149 |     	if(Registre::getInstance()->get('est_admin')) {
 | 
        
           |  |  | 150 |     		$squelette = 'liste_cotisations_admin';
 | 
        
           |  |  | 151 |     	} else {
 | 
        
           |  |  | 152 |     		$squelette = 'liste_cotisations_inscrit';
 | 
        
           |  |  | 153 |     	}
 | 
        
           |  |  | 154 |   | 
        
           |  |  | 155 |     	$liste_cotisations_html = $this->renvoyerSquelette($squelette, $donnees);
 | 
        
           |  |  | 156 |   | 
        
           |  |  | 157 |     	return $liste_cotisations_html;
 | 
        
           |  |  | 158 |     }
 | 
        
           |  |  | 159 |   | 
        
           |  |  | 160 |     /**
 | 
        
           |  |  | 161 |      *
 | 
        
           |  |  | 162 | 	 *  Renvoie les informations de cotisation pour un membre donné
 | 
        
           |  |  | 163 |      */
 | 
        
           |  |  | 164 | 	private function obtenirInformationsCotisationPourInscrit($param) {
 | 
        
           |  |  | 165 |   | 
        
           |  |  | 166 | 		$id_inscrit = $param['id_utilisateur'];
 | 
        
           |  |  | 167 |   | 
        
           |  |  | 168 | 		if(!Registre::getInstance()->get('est_admin')) {
 | 
        
           |  |  | 169 |     		$id_inscrit = Registre::getInstance()->get('identification_id');
 | 
        
           |  |  | 170 |     	}
 | 
        
           |  |  | 171 |   | 
        
           |  |  | 172 | 		$cotisation_modele = new CotisationModele();
 | 
        
           |  |  | 173 | 		$infos_cotisation_inscrit = $cotisation_modele->obtenirInformationsCotisationsPourInscrit($id_inscrit);
 | 
        
           |  |  | 174 |   | 
        
           |  |  | 175 |     	$infos_cotisation_inscrit_formatees = array();
 | 
        
           |  |  | 176 |   | 
        
           |  |  | 177 |     	foreach($infos_cotisation_inscrit as $cotisation_inscrit) {
 | 
        
           |  |  | 178 |     		$infos_cotisation_inscrit_formatees[] = $this->formaterInformationsCotisationPourEnvoi($cotisation_inscrit);
 | 
        
           |  |  | 179 |     	}
 | 
        
           |  |  | 180 |   | 
        
           |  |  | 181 |     	return $infos_cotisation_inscrit_formatees;
 | 
        
           |  |  | 182 | 	}
 | 
        
           |  |  | 183 |   | 
        
           |  |  | 184 |   | 
        
           |  |  | 185 | 	private function afficherFormulaireAjoutCotisation($param) {
 | 
        
           |  |  | 186 |   | 
        
           |  |  | 187 | 		$donnees['id_cotisant'] = $param['id_cotisant'];
 | 
        
           |  |  | 188 |   | 
        
           |  |  | 189 |     	$donnees['cotisations'] = $this->obtenirInformationsCotisationPourInscrit($param);
 | 
        
           |  |  | 190 |   | 
        
           |  |  | 191 |     	$cotisation_modele = new CotisationModele();
 | 
        
           |  |  | 192 |     	$donnees['modes_cotisation'] = $cotisation_modele->obtenirListeModesCotisation();
 | 
        
           |  |  | 193 |   | 
        
           |  |  | 194 |     	$donnees['url_liste_cotisations'] = $this->getUrlVoirListeCotisations();
 | 
        
           |  |  | 195 |   | 
        
           |  |  | 196 |     	$donnees['url_ajout_cotisation'] = $this->getUrlAjoutCotisation();
 | 
        
           |  |  | 197 |   | 
        
           |  |  | 198 |     	$donnees['url_retour'] = $this->urlService();
 | 
        
           |  |  | 199 |   | 
        
           | 513 | aurelien | 200 |     	$donnees['infos_utilisateur'] = $this->getInformationsUtilisateur($donnees['id_cotisant']);
 | 
        
           |  |  | 201 |   | 
        
           | 296 | aurelien | 202 |     	$liste_cotisations_html = $this->renvoyerSquelette('formulaire_ajout_cotisation', $donnees);
 | 
        
           |  |  | 203 |   | 
        
           |  |  | 204 |     	return $liste_cotisations_html;
 | 
        
           |  |  | 205 |     }
 | 
        
           |  |  | 206 |   | 
        
           |  |  | 207 |     private function afficherFormulaireModificationCotisation() {
 | 
        
           |  |  | 208 |   | 
        
           |  |  | 209 |     	$param = $_GET;
 | 
        
           |  |  | 210 |   | 
        
           |  |  | 211 |     	$donnees['id_utilisateur'] = $param['id_utilisateur'];
 | 
        
           |  |  | 212 |     	$donnees['id_cotisation_a_modifer'] = $param['id_cotisation'];
 | 
        
           |  |  | 213 |   | 
        
           |  |  | 214 |     	$donnees['cotisations'] = $this->obtenirInformationsCotisationPourInscrit($param);
 | 
        
           |  |  | 215 |   | 
        
           |  |  | 216 |     	$cotisation_modele = new CotisationModele();
 | 
        
           |  |  | 217 |     	$donnees['modes_cotisation'] = $cotisation_modele->obtenirListeModesCotisation();
 | 
        
           |  |  | 218 |   | 
        
           |  |  | 219 |     	$donnees['url_liste_cotisations'] = $this->getUrlVoirListeCotisations();
 | 
        
           |  |  | 220 |   | 
        
           |  |  | 221 |     	$donnees['url_modification_cotisation'] = $this->getUrlModificationCotisation($donnees['id_cotisation_a_modifer']);
 | 
        
           |  |  | 222 |   | 
        
           |  |  | 223 |     	$donnees['url_retour'] = $this->urlService();
 | 
        
           |  |  | 224 |   | 
        
           | 513 | aurelien | 225 |     	$donnees['infos_utilisateur'] = $this->getInformationsUtilisateur($donnees['id_utilisateur']);
 | 
        
           |  |  | 226 |   | 
        
           | 296 | aurelien | 227 |     	$liste_cotisations_html = $this->renvoyerSquelette('formulaire_modification_cotisation', $donnees);
 | 
        
           |  |  | 228 |   | 
        
           |  |  | 229 |     	return $liste_cotisations_html;
 | 
        
           |  |  | 230 |     }
 | 
        
           |  |  | 231 |   | 
        
           | 513 | aurelien | 232 |     private function getInformationsUtilisateur($id_utilisateur) {
 | 
        
           |  |  | 233 |     	$id_annuaire = !empty($_GET['id_annuaire']) ? $_GET['id_annuaire'] : Config::get('annuaire_defaut');
 | 
        
           |  |  | 234 |     	$annuaire_modele = $this->getModele('AnnuaireModele');
 | 
        
           |  |  | 235 |     	return $annuaire_modele->obtenirInfosUtilisateurParId($id_annuaire, $id_utilisateur);
 | 
        
           |  |  | 236 |     }
 | 
        
           |  |  | 237 |   | 
        
           | 296 | aurelien | 238 |     // +---------------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 239 |     // METHODES D'ACCES A LA BASE DE DONNEES
 | 
        
           |  |  | 240 |   | 
        
           |  |  | 241 |     private function getInformationsHistoriqueCotisation() {
 | 
        
           |  |  | 242 |   | 
        
           |  |  | 243 |     	$requete_infos_historique_cotisation = 'SELECT * FROM annuaire_COTISATION';
 | 
        
           |  |  | 244 |   | 
        
           |  |  | 245 |     	$infos_historique_cotisation = $this->executerRequete($requete_infos_historique_cotisation);
 | 
        
           |  |  | 246 |   | 
        
           |  |  | 247 |     	$infos_historique_cotisation_formatees = array();
 | 
        
           |  |  | 248 |   | 
        
           |  |  | 249 |     	foreach($infos_historique_cotisation as $cotisation) {
 | 
        
           |  |  | 250 |     		$infos_historique_cotisation_formatees[] = $this->formaterInformationsCotisationPourEnvoi($cotisation);
 | 
        
           |  |  | 251 |     	}
 | 
        
           |  |  | 252 |   | 
        
           |  |  | 253 |     	return $infos_historique_cotisation_formatees;
 | 
        
           |  |  | 254 |     }
 | 
        
           | 329 | aurelien | 255 |   | 
        
           |  |  | 256 |     private function obtenirNumeroRecuCotisation($param) {
 | 
        
           |  |  | 257 |   | 
        
           | 296 | aurelien | 258 |     	$id_cotisation = $param['id_cotisation'];
 | 
        
           |  |  | 259 |     	$id_utilisateur = $param['id_utilisateur'];
 | 
        
           |  |  | 260 |   | 
        
           |  |  | 261 | 		if(!Registre::getInstance()->get('est_admin')) {
 | 
        
           |  |  | 262 |     		$id_utilisateur = Registre::getInstance()->get('identification_id');
 | 
        
           |  |  | 263 |     	}
 | 
        
           |  |  | 264 |   | 
        
           |  |  | 265 |     	$id_annuaire = Config::get('annuaire_defaut');
 | 
        
           |  |  | 266 |   | 
        
           |  |  | 267 |     	if(isset($_GET['id_annuaire'])) {
 | 
        
           |  |  | 268 |     		$id_annuaire = $_GET['id_annuaire'];
 | 
        
           |  |  | 269 |     	}
 | 
        
           |  |  | 270 |   | 
        
           |  |  | 271 |     	$utilisateur = $this->obtenirValeursUtilisateur($id_annuaire, $id_utilisateur);
 | 
        
           |  |  | 272 |   | 
        
           |  |  | 273 | 	    if(!isset($id_cotisation)) {
 | 
        
           |  |  | 274 |     		return;
 | 
        
           |  |  | 275 |     	}
 | 
        
           |  |  | 276 |   | 
        
           |  |  | 277 |     	$cotisation_modele = new CotisationModele();
 | 
        
           |  |  | 278 |     	$infos_cotisation = $cotisation_modele->obtenirInformationsPourIdCotisation($id_cotisation, $id_utilisateur);
 | 
        
           |  |  | 279 |   | 
        
           |  |  | 280 |     	if(empty($infos_cotisation)) {
 | 
        
           |  |  | 281 |     		return;
 | 
        
           |  |  | 282 |     	}
 | 
        
           |  |  | 283 |   | 
        
           |  |  | 284 |     	$infos_cotisation_formatees = $this->formaterInformationsCotisationPourEnvoi($infos_cotisation);
 | 
        
           | 329 | aurelien | 285 |   | 
        
           | 296 | aurelien | 286 | 	    if(!$this->recuEstGenere($infos_cotisation_formatees)) {
 | 
        
           |  |  | 287 |   | 
        
           |  |  | 288 |     		$numero_nouveau_recu = $this->calculerNouvelOrdreRecuPourCotisation($infos_cotisation_formatees);
 | 
        
           |  |  | 289 |     		$infos_cotisation_formatees['recu_envoye'] = $numero_nouveau_recu;
 | 
        
           | 329 | aurelien | 290 |     		$this->mettreAJourNumeroRecu($infos_cotisation_formatees['id_cotisation'],$numero_nouveau_recu);
 | 
        
           | 296 | aurelien | 291 |   | 
        
           | 329 | aurelien | 292 | 	    }
 | 
        
           |  |  | 293 |   | 
        
           |  |  | 294 | 	    return $infos_cotisation_formatees;
 | 
        
           | 296 | aurelien | 295 |     }
 | 
        
           |  |  | 296 |   | 
        
           | 329 | aurelien | 297 |     private function initialiserInformationsAnnuaireUtilisateur($param) {
 | 
        
           | 296 | aurelien | 298 |   | 
        
           |  |  | 299 |     	$id_cotisation = $param['id_cotisation'];
 | 
        
           |  |  | 300 |     	$id_utilisateur = $param['id_utilisateur'];
 | 
        
           |  |  | 301 |   | 
        
           | 329 | aurelien | 302 | 		if(!Registre::getInstance()->get('est_admin')) {
 | 
        
           |  |  | 303 |     		$param['id_utilisateur'] = Registre::getInstance()->get('identification_id');
 | 
        
           | 296 | aurelien | 304 |     	}
 | 
        
           |  |  | 305 |   | 
        
           |  |  | 306 |     	$id_annuaire = Config::get('annuaire_defaut');
 | 
        
           |  |  | 307 |   | 
        
           |  |  | 308 |     	if(isset($_GET['id_annuaire'])) {
 | 
        
           | 329 | aurelien | 309 |     		$param['id_annuaire'] = $_GET['id_annuaire'];
 | 
        
           | 296 | aurelien | 310 |     	}
 | 
        
           |  |  | 311 |   | 
        
           | 329 | aurelien | 312 |     	$param['utilisateur'] = $this->obtenirValeursUtilisateur($id_annuaire, $id_utilisateur);
 | 
        
           | 296 | aurelien | 313 |   | 
        
           | 329 | aurelien | 314 |     	return $param;
 | 
        
           |  |  | 315 |     }
 | 
        
           |  |  | 316 |   | 
        
           |  |  | 317 | 	private function envoyerRecuCotisation($param) {
 | 
        
           |  |  | 318 |   | 
        
           |  |  | 319 | 		$param = $this->initialiserInformationsAnnuaireUtilisateur($param);
 | 
        
           |  |  | 320 |   | 
        
           |  |  | 321 | 		$infos_cotisation_formatees = $this->obtenirNumeroRecuCotisation($param);
 | 
        
           |  |  | 322 |   | 
        
           |  |  | 323 | 		if(!$this->recuEstEnvoye($infos_cotisation_formatees)) {
 | 
        
           |  |  | 324 | 	    	$infos_cotisation_formatees['date_envoi_recu'] = $this->mettreAJourDateEnvoiRecuPourCotisation($infos_cotisation_formatees);
 | 
        
           |  |  | 325 | 	    }
 | 
        
           |  |  | 326 |   | 
        
           |  |  | 327 |     	$recu = new Recu();
 | 
        
           |  |  | 328 |     	$recu_pdf = $recu->renvoyerRecuPdf($param['utilisateur'], $infos_cotisation_formatees);
 | 
        
           |  |  | 329 |   | 
        
           |  |  | 330 |     	$messagerie = new MessageControleur();
 | 
        
           |  |  | 331 |     	$donnees['url_voir_recu'] = $this->getUrlTelechargementRecuPourMail($param['id_cotisation']);
 | 
        
           |  |  | 332 |     	$contenu_message = $this->renvoyerSquelette('message_recu_cotisation', $donnees);
 | 
        
           |  |  | 333 |     	$envoi = $messagerie->envoyerMailAvecPieceJointe(Config::get('adresse_mail_cotisation'), $param['utilisateur']['mail']['amv_valeur'], 'Recu pour votre don à tela botanica', $contenu_message, $recu_pdf, 'Recu.pdf', 'application/pdf');
 | 
        
           |  |  | 334 |   | 
        
           |  |  | 335 |     	$param['message'] = 'Votre reçu a bien été envoyé à l\'adresse '.$param['utilisateur']['mail']['amv_valeur'];
 | 
        
           |  |  | 336 |   | 
        
           |  |  | 337 |     	return $this->afficherInformationsCotisationPourInscrit($param);
 | 
        
           |  |  | 338 |     }
 | 
        
           |  |  | 339 |   | 
        
           |  |  | 340 |     private function voirRecuCotisation($param) {
 | 
        
           |  |  | 341 |   | 
        
           |  |  | 342 | 		$param = $this->initialiserInformationsAnnuaireUtilisateur($param);
 | 
        
           |  |  | 343 |   | 
        
           |  |  | 344 | 	    if(!isset($param['id_cotisation'])) {
 | 
        
           | 296 | aurelien | 345 |     		return;
 | 
        
           |  |  | 346 |     	}
 | 
        
           |  |  | 347 |   | 
        
           |  |  | 348 |     	$cotisation_modele = new CotisationModele();
 | 
        
           | 329 | aurelien | 349 |     	$infos_cotisation = $cotisation_modele->obtenirInformationsPourIdCotisation($param['id_cotisation'], $param['id_utilisateur']);
 | 
        
           | 296 | aurelien | 350 |   | 
        
           |  |  | 351 |     	if(empty($infos_cotisation)) {
 | 
        
           |  |  | 352 |     		return;
 | 
        
           |  |  | 353 |     	}
 | 
        
           |  |  | 354 |   | 
        
           | 329 | aurelien | 355 |     	$infos_cotisation_formatees = $this->formaterInformationsCotisationPourEnvoi($infos_cotisation);
 | 
        
           |  |  | 356 |     	$infos_cotisation_formatees = $this->obtenirNumeroRecuCotisation($param);
 | 
        
           |  |  | 357 |   | 
        
           |  |  | 358 |     	// tant que le recu n'est pas envoyé sa date est celle du jour courant
 | 
        
           |  |  | 359 |     	if(!$this->recuEstEnvoye($infos_cotisation_formatees)) {
 | 
        
           |  |  | 360 |     		$infos_cotisation_formatees['date_envoi_recu'] = date('d/m/Y');
 | 
        
           | 296 | aurelien | 361 |     	}
 | 
        
           |  |  | 362 |   | 
        
           |  |  | 363 |     	$recu = new Recu();
 | 
        
           |  |  | 364 |   | 
        
           | 329 | aurelien | 365 |     	$recu->afficherRecuPdf($param['utilisateur'], $infos_cotisation_formatees);
 | 
        
           | 296 | aurelien | 366 |   | 
        
           |  |  | 367 |     	return true;
 | 
        
           |  |  | 368 |     }
 | 
        
           |  |  | 369 |   | 
        
           |  |  | 370 |     private function recuEstGenere($cotisation) {
 | 
        
           |  |  | 371 |   | 
        
           |  |  | 372 |     	if($cotisation['recu_envoye'] != null && $cotisation['recu_envoye'] != 0) {
 | 
        
           |  |  | 373 |     		return true;
 | 
        
           |  |  | 374 |     	}
 | 
        
           |  |  | 375 |   | 
        
           |  |  | 376 |     	return false;
 | 
        
           |  |  | 377 |     }
 | 
        
           |  |  | 378 |   | 
        
           |  |  | 379 | 	private function recuEstEnvoye($cotisation) {
 | 
        
           |  |  | 380 |   | 
        
           |  |  | 381 |     	if($cotisation['date_envoi_recu'] != null && $cotisation['date_envoi_recu'] != 0) {
 | 
        
           |  |  | 382 |     		return true;
 | 
        
           |  |  | 383 |     	}
 | 
        
           |  |  | 384 |   | 
        
           |  |  | 385 |     	return false;
 | 
        
           |  |  | 386 |     }
 | 
        
           |  |  | 387 |   | 
        
           | 336 | aurelien | 388 |     private function calculerNouvelOrdreRecuPourCotisation($cotisation) {
 | 
        
           | 296 | aurelien | 389 |   | 
        
           |  |  | 390 |     	$cotisation_modele = new CotisationModele();
 | 
        
           |  |  | 391 |   | 
        
           | 336 | aurelien | 392 |     	$annee_recu = $cotisation['annee_cotisation'];
 | 
        
           |  |  | 393 |     	$numero_ordre = $cotisation_modele->calculerNouvelOrdreRecuEtIncrementer($annee_recu);
 | 
        
           |  |  | 394 |   | 
        
           | 296 | aurelien | 395 |     	return $numero_ordre;
 | 
        
           |  |  | 396 |     }
 | 
        
           |  |  | 397 |   | 
        
           |  |  | 398 |     private function mettreAJourDateEnvoiRecuPourCotisation($cotisation) {
 | 
        
           |  |  | 399 |   | 
        
           |  |  | 400 |     	$cotisation_modele = new CotisationModele();
 | 
        
           |  |  | 401 |     	$cotisation_modele->mettreAJourDateEnvoiRecu($cotisation['id_cotisation']);
 | 
        
           |  |  | 402 |   | 
        
           | 329 | aurelien | 403 |     	$date_envoi_recu = $this->genererDateCouranteFormatAnnuaire();
 | 
        
           | 296 | aurelien | 404 |   | 
        
           | 329 | aurelien | 405 |     	return $date_envoi_recu;
 | 
        
           | 296 | aurelien | 406 |     }
 | 
        
           |  |  | 407 |   | 
        
           |  |  | 408 | 	private function mettreAJourNumeroRecu($id_cotisation, $numero_recu) {
 | 
        
           |  |  | 409 |   | 
        
           |  |  | 410 |     	$cotisation_modele = new CotisationModele();
 | 
        
           | 329 | aurelien | 411 |     	$maj_cotisation_num_recu = $cotisation_modele->mettreAJourNumeroRecu($id_cotisation, $numero_recu);
 | 
        
           | 296 | aurelien | 412 |   | 
        
           | 329 | aurelien | 413 |     	return $maj_cotisation_num_recu;
 | 
        
           | 296 | aurelien | 414 |     }
 | 
        
           |  |  | 415 |   | 
        
           |  |  | 416 |     private function formaterInformationsCotisationPourEnvoi($cotisation) {
 | 
        
           |  |  | 417 |   | 
        
           |  |  | 418 |     	$cotisation_modele = new CotisationModele();
 | 
        
           |  |  | 419 |   | 
        
           |  |  | 420 |     	$cotisation_champs_formates = array(
 | 
        
           |  |  | 421 | 		    	'id_cotisation' => $cotisation['IC_ID'],
 | 
        
           |  |  | 422 | 		    	'id_inscrit' => $cotisation['IC_ANNU_ID'],
 | 
        
           | 329 | aurelien | 423 |     			'annee_cotisation' => $this->formaterAnneeDateCotisationMySql($cotisation['IC_DATE']),
 | 
        
           | 296 | aurelien | 424 | 				'date_cotisation' => $this->formaterDateMysqlVersDateAnnuaire($cotisation['IC_DATE']),
 | 
        
           |  |  | 425 |     			'montant_cotisation' => $cotisation['IC_MONTANT'],
 | 
        
           |  |  | 426 | 				'mode_cotisation' => $cotisation_modele->obtenirModeCotisationParId($cotisation['IC_MC_ID']),
 | 
        
           |  |  | 427 | 				'id_mode_cotisation' => $cotisation['IC_MC_ID'],
 | 
        
           |  |  | 428 | 				'recu_envoye' => $cotisation['IC_RECU'],
 | 
        
           |  |  | 429 |     			'date_envoi_recu' => $this->formaterDateMysqlVersDateCotisation($cotisation['IC_DATE_ENVOIE_RECU']),
 | 
        
           |  |  | 430 |     			'url_voir_recu' => $this->getUrlVoirRecuCotisation($cotisation['IC_ID']),
 | 
        
           |  |  | 431 |     	    	'url_envoyer_recu' => $this->getUrlEnvoiRecuCotisation($cotisation['IC_ID']),
 | 
        
           |  |  | 432 |     			'url_formulaire_modification' => $this->getUrlFormulaireModificationCotisation($cotisation['IC_ID']),
 | 
        
           |  |  | 433 |     			'url_suppression' => $this->getUrlSuppressionCotisation($cotisation['IC_ID'])
 | 
        
           |  |  | 434 | 		    );
 | 
        
           |  |  | 435 |   | 
        
           |  |  | 436 | 		return $cotisation_champs_formates;
 | 
        
           |  |  | 437 |     }
 | 
        
           |  |  | 438 |   | 
        
           |  |  | 439 |     private function renvoyerSquelette($squelette, $donnees) {
 | 
        
           |  |  | 440 |   | 
        
           |  |  | 441 |     	$chemin_squelette = Config::get('chemin_appli').'composants'.DS.ANNUAIRE_PLUGIN.DS.'squelettes'.DS.$squelette.'.tpl.html';
 | 
        
           |  |  | 442 |   | 
        
           |  |  | 443 |     	$sortie = SquelettePhp::analyser($chemin_squelette, $donnees);
 | 
        
           |  |  | 444 |     	//$squelette_dossier = .'squelettes'.DS;
 | 
        
           |  |  | 445 |     	return $sortie;
 | 
        
           |  |  | 446 |     }
 | 
        
           |  |  | 447 |   | 
        
           |  |  | 448 | 	private function urlService($params = array()) {
 | 
        
           |  |  | 449 |   | 
        
           |  |  | 450 |     	$url_service = new Url(Url::getDemande()->getUrl());
 | 
        
           |  |  | 451 |   | 
        
           |  |  | 452 |     	$variables_requetes = $url_service->getVariablesRequete();
 | 
        
           |  |  | 453 |   | 
        
           |  |  | 454 |     	$variables_plugins = array(Config::get('plugin_variable_action'), 'id_cotisation', 'id_cotisant');
 | 
        
           |  |  | 455 |   | 
        
           |  |  | 456 |     	foreach($params as $cle => $valeur) {
 | 
        
           |  |  | 457 |     		$variables_requetes[$cle] = $valeur;
 | 
        
           |  |  | 458 |     	}
 | 
        
           |  |  | 459 |   | 
        
           |  |  | 460 |     	$url_service->setVariablesRequete($variables_requetes);
 | 
        
           |  |  | 461 |   | 
        
           |  |  | 462 |     	return $url_service->getUrl();
 | 
        
           |  |  | 463 |     }
 | 
        
           |  |  | 464 |   | 
        
           |  |  | 465 | 	private function getUrlVoirListeCotisations() {
 | 
        
           |  |  | 466 |   | 
        
           |  |  | 467 | 		$params = array('action_cotisation' => 'afficherInformationsCotisationPourInscrit');
 | 
        
           |  |  | 468 |   | 
        
           |  |  | 469 |     	return $this->urlService($params);
 | 
        
           |  |  | 470 |     }
 | 
        
           |  |  | 471 |   | 
        
           |  |  | 472 | 	private function getUrlVoirRecuCotisation($id_cotisation) {
 | 
        
           |  |  | 473 |   | 
        
           |  |  | 474 | 		$params = array('action_cotisation' => 'voirRecuCotisation',
 | 
        
           |  |  | 475 | 						'id_cotisation' => $id_cotisation);
 | 
        
           |  |  | 476 |   | 
        
           |  |  | 477 |     	return $this->urlService($params);
 | 
        
           |  |  | 478 |     }
 | 
        
           |  |  | 479 |   | 
        
           |  |  | 480 |     private function getUrlTelechargementRecuPourMail($id_cotisation) {
 | 
        
           |  |  | 481 |     	return Config::get('base_url_telechargement').'?m=annuaire_afficher_page&page=cotisations&id_annuaire=1&action_cotisation=voirRecuCotisation&id_cotisation='.$id_cotisation;
 | 
        
           |  |  | 482 |     }
 | 
        
           |  |  | 483 |   | 
        
           |  |  | 484 | 	private function getUrlEnvoiRecuCotisation($id_cotisation) {
 | 
        
           |  |  | 485 |   | 
        
           |  |  | 486 | 		$params = array('action_cotisation' => 'envoyerRecuCotisation',
 | 
        
           |  |  | 487 | 						'id_cotisation' => $id_cotisation);
 | 
        
           |  |  | 488 |   | 
        
           |  |  | 489 |     	return $this->urlService($params);
 | 
        
           |  |  | 490 |     }
 | 
        
           |  |  | 491 |   | 
        
           |  |  | 492 |     private function getUrlFormulaireAjoutCotisation($id_cotisant) {
 | 
        
           |  |  | 493 |   | 
        
           |  |  | 494 |     	$params = array('action_cotisation' => 'afficherFormulaireAjoutCotisation',
 | 
        
           |  |  | 495 | 						'id_cotisant' => $id_cotisant);
 | 
        
           |  |  | 496 |   | 
        
           |  |  | 497 |     	return $this->urlService($params);
 | 
        
           |  |  | 498 |     }
 | 
        
           |  |  | 499 |   | 
        
           |  |  | 500 | 	private function getUrlAjoutCotisation() {
 | 
        
           |  |  | 501 |   | 
        
           |  |  | 502 |     	$params = array('action_cotisation' => 'ajouterCotisation');
 | 
        
           |  |  | 503 |   | 
        
           |  |  | 504 |     	return $this->urlService($params);
 | 
        
           |  |  | 505 |     }
 | 
        
           |  |  | 506 |   | 
        
           |  |  | 507 |     private function getUrlFormulaireModificationCotisation($id_cotisation) {
 | 
        
           |  |  | 508 |   | 
        
           |  |  | 509 |     	$params = array('action_cotisation' => 'afficherFormulaireModificationCotisation',
 | 
        
           |  |  | 510 | 						'id_cotisation' => $id_cotisation);
 | 
        
           |  |  | 511 |   | 
        
           |  |  | 512 |     	return $this->urlService($params);
 | 
        
           |  |  | 513 |     }
 | 
        
           |  |  | 514 |   | 
        
           |  |  | 515 |    	private function getUrlModificationCotisation($id_cotisation) {
 | 
        
           |  |  | 516 |   | 
        
           |  |  | 517 |    		$params = array('action_cotisation' => 'mettreAjourCotisation',
 | 
        
           |  |  | 518 | 					'id_cotisation' => $id_cotisation);
 | 
        
           |  |  | 519 |   | 
        
           |  |  | 520 |    		return $this->urlService($params);
 | 
        
           |  |  | 521 |    	}
 | 
        
           |  |  | 522 |   | 
        
           |  |  | 523 | 	private function getUrlSuppressionCotisation($id_cotisation) {
 | 
        
           |  |  | 524 |   | 
        
           |  |  | 525 | 		$params = array('action_cotisation' => 'supprimerCotisation',
 | 
        
           |  |  | 526 | 					'id_cotisation' => $id_cotisation);
 | 
        
           |  |  | 527 |   | 
        
           |  |  | 528 |     	return $this->urlService($params);
 | 
        
           |  |  | 529 |     }
 | 
        
           |  |  | 530 |   | 
        
           |  |  | 531 |     private function controleAccesAdmin($fonction) {
 | 
        
           |  |  | 532 |   | 
        
           |  |  | 533 |     	$fonction_admins = array(
 | 
        
           |  |  | 534 |     		'ajouterCotisation',
 | 
        
           |  |  | 535 |     		'mettreAJourCotisation',
 | 
        
           |  |  | 536 |     		'supprimerCotisation',
 | 
        
           |  |  | 537 |     		'afficherFormulaireAjoutCotisation',
 | 
        
           |  |  | 538 |     		'envoyerRecuCotisation'
 | 
        
           |  |  | 539 |     	);
 | 
        
           |  |  | 540 |   | 
        
           |  |  | 541 |     	if(in_array($fonction, $fonction_admins) && !Registre::getInstance()->get('est_admin')) {
 | 
        
           |  |  | 542 |     		return false;
 | 
        
           |  |  | 543 |     	}
 | 
        
           |  |  | 544 |   | 
        
           |  |  | 545 |     	return true;
 | 
        
           |  |  | 546 |     }
 | 
        
           |  |  | 547 |   | 
        
           | 329 | aurelien | 548 |     private function formaterAnneeDateCotisationMySql($date_cotisation) {
 | 
        
           |  |  | 549 |   | 
        
           |  |  | 550 |     	$annee_cotisation = '0';
 | 
        
           |  |  | 551 |   | 
        
           |  |  | 552 |     	if($date_cotisation != '0') {
 | 
        
           |  |  | 553 |     		$annee_cotisation = date('Y',strtotime($date_cotisation));
 | 
        
           |  |  | 554 |     	}
 | 
        
           |  |  | 555 |   | 
        
           |  |  | 556 |     	return $annee_cotisation;
 | 
        
           |  |  | 557 |     }
 | 
        
           |  |  | 558 |   | 
        
           | 296 | aurelien | 559 |     private function formaterDateMysqlVersDateCotisation($date) {
 | 
        
           |  |  | 560 |     	if($date == '0000-00-00') {
 | 
        
           |  |  | 561 |     		return 0;
 | 
        
           |  |  | 562 |     	}
 | 
        
           |  |  | 563 |     	return $this->formaterDateMysqlVersDateAnnuaire($date);
 | 
        
           |  |  | 564 |     }
 | 
        
           |  |  | 565 | }
 | 
        
           |  |  | 566 | ?>
 |