prestation/Controleur/ControleurOptique.php
2025-12-01 18:54:33 +00:00

219 lines
7.4 KiB
PHP

<?php
require_once 'Framework/Controleur.php';
require_once 'Modele/Menuvueutilisateur.php';
require_once 'Modele/Optique_temp.php';
require_once 'Modele/Detailoptique.php';
require_once 'Modele/Detailtarifoptique.php';
require_once 'Modele/Bonpec.php';
require_once 'Modele/Prescription.php';
require_once 'Modele/Ouinon.php';
require_once 'Modele/Medecin.php';
require_once 'Modele/Detailtarifacte.php';
require_once 'Modele/Garantiesbaremepriseencharge.php';
require_once 'Modele/Ged.php';
require_once 'Modele/Feuillemaladie.php';
class ControleurOptique extends Controleur {
private $menuvue;
private $optique;
private $detailoptique;
private $acte;
private $bonpec;
private $prescription;
private $oui_non;
private $medecin;
private $detail;
private $garantie;
private $ged;
private $feuille;
public function __construct() {
$this->menuvue = new Menuvueutilisateur();
$this->menuvue->getMenuVue('Optique');
$this->optique = new Optique_temp();
$this->detailoptique = new Detailoptique();
$this->acte = new Detailtarifoptique();
$this->bonpec = new Bonpec();
$this->oui_non = new Ouinon();
$this->prescription = new Prescription();
$this->detail = new Detailtarifacte();
$this->medecin = new Medecin();
$this->garantie = new Garantiesbaremepriseencharge();
$this->ged = new Ged();
$this->feuille = new Feuillemaladie();
$codePrestataire = $_SESSION['p_codePrestataire_C'];
}
public function index($msgErreur=null)
{
$contestation = $this->feuille->getContestationFeuille();
if($contestation == "1"){
$this->rediriger("Feuillemaladie");
}
$message = "";
$nouveau_fichier = "Rien";
if(!empty($_POST))
{
define('TARGET', $_SESSION['p_cheminGed']); // Repertoire cible
define('MAX_SIZE', 10000000); // Taille max en octets du fichier
// Tableaux de donnees
// ".avi", ".bmp", ".doc", ".docx", ".gif", ".jpeg", "jpg", "jpe", ".mkv", ".mp3", ".pdf", ".png", ".pps", ".xls", ".xlsx", ".wav"
// $tabExt = array('jpg','png','jpeg'); // Extensions autorisees
$tabExt = array("avi", "bmp", "doc", "docx", "gif", "jpeg", "jpg", "jpe", "mkv", "mp3", "mp4", "pdf", "png", "pps", "xls", "xlsx", "wav"); // Extensions autorisees
// Variables
$extension = '';
if( !is_dir(TARGET) )
{
if( !mkdir(TARGET, 0755) )
{
$message = 'Erreur : le répertoire cible ne peut-être créé ! Vérifiez que vous diposiez des droits suffisants pour le faire ou créez le manuellement !';
}
}
// On verifie si le champ est rempli
if( !empty($_FILES['fichier_upload']['name']) )
{
// Recuperation de l'extension du fichier
$extension = pathinfo($_FILES['fichier_upload']['name'], PATHINFO_EXTENSION);
// On verifie l'extension du fichier
if(in_array(strtolower($extension), $tabExt))
{
$message = $_FILES['fichier_upload']['size'];
// On verifie les dimensions et taille du fichier
if($_FILES['fichier_upload']['size'] <= MAX_SIZE)
{
$taille = $_FILES['fichier_upload']['size'];
// Parcours du tableau d'erreurs
if(isset($_FILES['fichier_upload']['error']) && UPLOAD_ERR_OK === $_FILES['fichier_upload']['error'])
{
// 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))
{
$message = 'Chargé avec succès / Uploaded successfully';
// on va envoyer dans la base de données
$this->ged->enregistrergedprescriptionoptique($nomOrigine, $nouveau_fichier, $taille);
}
else
{
// Sinon on affiche une erreur systeme
$message = 'Problème lors du chargement !';
}
}
else
{
$message = 'Une erreur interne a empêché le chargement';
}
}
else
{
$message .= $_FILES['fichier_upload']['size']." Erreur dans les dimensions du fichier !";
// $message = 'Erreur dans les dimensions du fichier !';
}
}
else
{
// Sinon on affiche une erreur pour l'extension
$message = 'Extension du fichier est incorrecte !';
}
}
else
{
// Sinon on affiche une erreur pour le champ vide
$message = 'Veuillez sélectionner un fichier SVP! / Please select a file!';
}
// fin upload
}
$msgErreurGed = $message;
$codePrestataire = $_SESSION['p_codePrestataire_C'];
$codeTypeBon = "OPTQ";
$nbBonsOrd = $this->bonpec->getNbBonPrestataireDisponible($codePrestataire, $codeTypeBon);
$codeGestionBon = $this->bonpec->getCodeGestionBon($codeTypeBon);
$typeGestionbon = $this->bonpec->getGestionBon($codeGestionBon);
$codeGarantie = "OPT";
$numeroFeuilleMaladie = $_SESSION['p_numeroFeuilleMaladie_C'];
$this->optique->initoptique_cso();
$optique = $this->optique->getoptiquetemp();
$idBeneficiaire = $_SESSION['p_idBeneficiaire_C'];
//$acte = $this->acte->getverrespossiblesprescription();
$datePrestation = $this->prescription->getDateSurvenance($numeroFeuilleMaladie);
//$tm = $this->detail->ticketModerateurCollege($idBeneficiaire, $datePrestation);
$tm = $this->detail->ticketModerateurDefinitif($codeGarantie, "", $datePrestation);
$tauxCouverture = (100-$tm)."%";
$detailoptiques = $this->detailoptique->getdetailoptiquefeuille();
$nbVerres_0 = count($detailoptiques);
$doubleFoyer = $this->oui_non->getListe();
$progressif = $this->oui_non->getListe();
$teinteA = $this->oui_non->getListe();
$teinteAB = $this->oui_non->getListe();
$teinteB = $this->oui_non->getListe();
$teinteC = $this->oui_non->getListe();
$photogray = $this->oui_non->getListe();
$antireflet = $this->oui_non->getListe();
$photochromique = $this->oui_non->getListe();
$antiUV = $this->oui_non->getListe();
$transition = $this->oui_non->getListe();
$antiBuee = $this->oui_non->getListe();
$filtreBleu = $this->oui_non->getListe();
$statut = $this->garantie->getstatutgarantie($idBeneficiaire, $codeGarantie);
$motif = $this->garantie->getlibellemotifdepassement($statut);
$medecins = $this->medecin->getpraticiensprestataire($codePrestataire);
unset($_FILES['fichier_upload']);
$geds = $this->ged->getgedoptique();
$this->genererVue(array('optique' => $optique, 'detailoptiques' => $detailoptiques, /*'acte' => $acte,*/ 'nbVerres_0' => $nbVerres_0,
'nbBonsOrd' => $nbBonsOrd, 'codeGestionBon' => $codeGestionBon, 'typeGestionbon' => $typeGestionbon, 'tauxCouverture' => $tauxCouverture,
'doubleFoyer' => $doubleFoyer, 'progressif' => $progressif, 'teinteA' => $teinteA, 'teinteAB' => $teinteAB, 'teinteB' => $teinteB,
'teinteC' => $teinteC, 'photogray' => $photogray, 'antireflet' => $antireflet, 'photochromique' => $photochromique,'medecins' => $medecins,
'antiUV' => $antiUV, 'transition' => $transition, 'antiBuee' => $antiBuee, 'filtreBleu' => $filtreBleu, /*'bool' => $bool, 'dateFin' => $dateFin*/
'statut' => $statut, 'motif' => $motif, 'geds' => $geds, 'msgErreurGed' => $msgErreurGed));
}
}