menuvue = new Menuvueutilisateur(); $this->menuvue->getMenuVue('Creerbeneficiaire'); $this->beneficiaire = new Beneficiaire(); $this->naturepiece = (new Naturepiece())->getListe(); $this->sexe = (new Sexe())->getListe(); $this->groupesanguin = (new Groupesanguin())->getListe(); $this->adherent = new Adherent(); $this->lienparente = (new Lienparente())->getListeDependant(); $this->avenant = (new Avenant())->getListeEnCours($_SESSION['idPolice_C']); $this->ouinonprorata = (new Ouinon())->getListe(); $this->beneficiaire_temp = new Beneficiaire_temp(); $this->tarif = new Tarifsactes(); $this->police = new Police(); $this->ouinonvip = (new Ouinon())->getListe(); $this->ouinonconserver = (new Ouinon())->getListe(); $this->produit = new Produit(); // $this->qrcode = new Qrcodemodele(); } public function index() { $idPolice = $_SESSION['idPolice_C']; $idAdherent = $_SESSION['idAdherent_C']; $user = $_SESSION['login']; $this->police->getContextePoliceId($idPolice); $police = $this->police->getPoliceId($idPolice); $adherent = $this->adherent->getContexteAdherentId($idAdherent); $idCollege = $_SESSION['idCollege_C']; $fraisCarte = $this->beneficiaire_temp->get_frais_carte_college($idCollege); $nomGarant = $this->police->getNomGarant($police['codeGcAssureur']); $_SESSION['nomGcAssureur_C'] = $nomGarant; $prorata = "1"; $dateEntree = $_SESSION['dateAvenant_C']; if ($dateEntree=="0000-00-00" || is_null($dateEntree)){ $dateEntree = $this->beneficiaire_temp->getdateentreeadherent($idAdherent); } $beneficiaire_temp = $this->beneficiaire_temp->getBeneficiaire_temp($idAdherent, $dateEntree, $user, $prorata, $fraisCarte); //$adherent = $this->adherent->getContexteAdherentId($idAdherent); $codeTypeTarifActe = "TBEN"; $tarifActe = $this->tarif->getTarifActeByType($codeTypeTarifActe); $codeModeCalculPrime= $this->beneficiaire_temp->getModeCalculPrime($idAdherent); $typeremboursement = $this->produit->getlisteTypeRemboursement(); $this->genererVue(array('adherent' => $adherent, 'naturepiece' => $this->naturepiece, 'sexe' => $this->sexe, 'groupesanguin' => $this->groupesanguin, 'lienparente' => $this->lienparente, 'avenant' => $this->avenant, 'ouinonprorata' => $this->ouinonprorata, 'beneficiaire_temp' => $beneficiaire_temp, 'fraisCarte' => $fraisCarte, 'tarifActe' => $tarifActe, 'codeModeCalculPrime' => $codeModeCalculPrime, 'ouinonvip' => $this->ouinonvip, 'ouinonconserver' => $this->ouinonconserver, 'police' => $police, 'typeremboursement' => $typeremboursement)); } public function ajouter() { $idAdherent = $this->requete->getParametreFormulaire("idAdherent"); $numeroAdherent = $this->requete->getParametreFormulaire("numeroAdherent"); $nomBeneficiaire = strtoupper($this->requete->getParametreFormulaire("nomBeneficiaire")); $prenomsBeneficiaire = strtoupper($this->requete->getParametreFormulaire("prenomsBeneficiaire")); $codeLienParente = $this->requete->getParametreFormulaire("codeLienParente"); $codeNaturePiece = $this->requete->getParametreFormulaire("codeNaturePiece"); $numeroPiece = strtoupper($this->requete->getParametreFormulaire("numeroPiece")); if($codeLienParente == "C"){ $sexe = $this->requete->getParametreFormulaire("sexeConjoint"); }else{ $sexe = $this->requete->getParametreFormulaire("sexe"); } $codeGroupeSanguin = $this->requete->getParametreFormulaire("codeGroupeSanguin"); $dateNaissance = $this->requete->getParametreDate("dateNaissance"); $telephonePortable = $this->requete->getParametreFormulaire("telephonePortable"); $dateEntree = $this->requete->getParametreDate("dateEntree"); $user = $this->requete->getSession()->getAttribut('login'); $idAvenant = $this->requete->getParametreFormulaire("idAvenant"); $dateCre = date("Y-m-d"); $fraisCarte = $this->requete->getParametreFormulaire("fraisCarte","numerique"); $numeroCmu = strtoupper($this->requete->getParametreFormulaire("numeroCmu")); $numeroMatricule = strtoupper($this->requete->getParametreFormulaire("numeroMatricule")); $prorata = $this->requete->getParametreFormulaire("prorata"); //Ajouté par sorel le 27-05-2023 $codeTarifActe = $this->requete->getParametreFormulaire("codeTarifActe"); //ajouter par sorel 19-06-2023 $dateSouscription = $this->requete->getParametreFormulaire("dateSouscription"); if($dateSouscription == ""){ $dateSouscription=null; }else{ $dateSouscription = $this->requete->getParametreDate("dateSouscription"); } $vip = $this->requete->getParametreFormulaire("vip"); $seuilRdBeneficiaire = $this->requete->getParametreFormulaire("seuilRdBeneficiaire"); $numeroBs = $this->requete->getParametreFormulaire("numeroBs"); $ancienNumeroAssure = $this->requete->getParametreFormulaire("ancienNumeroAssure"); $conserverAncienNumeroAssure = $this->requete->getParametreFormulaire("conserverAncienNumeroAssure"); $codeTypeRemboursement = $this->requete->getParametreFormulaire("codeTypeRemboursement"); $dernierNumeroBeneficiaire = $this->beneficiaire->getDenierNumeroBeneficiaire($idAdherent); $dernierNumeroBeneficiaire++; //var_dump($dernierNumeroBeneficiaire);die(); $numeroBeneficiaire = $numeroAdherent . $dernierNumeroBeneficiaire; //$lienPhoto = $numeroBeneficiaire.".jpg"; $idBeneficiaire = $this->beneficiaire->ajouter($idAdherent, $numeroBeneficiaire, $nomBeneficiaire, $prenomsBeneficiaire, $codeLienParente, $codeNaturePiece, $numeroPiece, $sexe, $codeGroupeSanguin, $dateNaissance, $telephonePortable, $dateEntree, $dateCre, $user, $idAvenant, $fraisCarte, $numeroCmu, $numeroMatricule, $prorata, $codeTarifActe, $dateSouscription, $vip, $seuilRdBeneficiaire, $numeroBs, $ancienNumeroAssure, $conserverAncienNumeroAssure, $codeTypeRemboursement); $matricule = $this->beneficiaire->getMatriculeBeneficiaire($idBeneficiaire); if (!empty($matricule)){ // $success = $this->genererEtStockerQRCodeFichier($matricule); } $this->beneficiaire->setDenierNumeroBeneficiaire($idAdherent, $dernierNumeroBeneficiaire); // On va calculuer la prime $_SESSION['idAdherent_C'] = $idAdherent; $_SESSION['idBeneficiaire_C'] = $idBeneficiaire; // On actualise le contexte : NbAdh et NbAss $idPolice = $_SESSION['idPolice_C']; $this->beneficiaire->getNbassure($idPolice); //var_dump($idBeneficiaire);die(); $this->rediriger("Ficheadherent/".$idAdherent); } function genererEtStockerQRCodeFichier($matricule) { /* $cheminDossier = $_SESSION['dossierSociete'].'/qrcodes/'; try { // 1. Validation du matricule if (empty($matricule) || !preg_match('/^[A-Z0-9_-]+$/i', $matricule)) { throw new Exception("Matricule invalide"); } // 2. Gestion du dossier $cheminDossier = rtrim($cheminDossier, '/') . '/'; if (!file_exists($cheminDossier)) { if (!mkdir($cheminDossier, 0777, true)) { throw new Exception("Impossible de créer le dossier QR"); } } if (!is_writable($cheminDossier)) { throw new Exception("Dossier non accessible en écriture"); } // 3. Suppression ancien QR code $ancienChemin = $this->qrcode->getAncienChemin($matricule); if ($ancienChemin) { $ancienFichier = $cheminDossier . $ancienChemin; if (file_exists($ancienFichier) && !unlink($ancienFichier)) { error_log("Avertissement: Impossible de supprimer l'ancien QR"); } } // 4. Génération avec endroid/qr-code //$nomFichier = 'qr_' . preg_replace('/[^A-Z0-9]/i', '_', $matricule) . '_' . time() . '.png'; $nomFichier = $matricule.'.png'; $cheminComplet = $cheminDossier . $nomFichier; // Création du QR Code $qrCode = QrCode::create($matricule) ->setSize(150) ->setMargin(5) ->setForegroundColor(new Color(0, 0, 0)) // Noir ->setBackgroundColor(new Color(255, 255, 255)) // Blanc ->setErrorCorrectionLevel(ErrorCorrectionLevel::High); // Création du writer $writer = new PngWriter(); $result = $writer->write($qrCode); // Sauvegarde du fichier $result->saveToFile($cheminComplet); // 5. Vérification fichier généré if (!file_exists($cheminComplet)) { throw new Exception("Échec de la génération du fichier"); } $this->qrcode->majBeneficiaireQr($nomFichier, $matricule); return true; } catch (Exception $e) { error_log("Erreur QR Code: " . $e->getMessage()); return false; } */ } }