201 lines
8.8 KiB
PHP
Executable File
201 lines
8.8 KiB
PHP
Executable File
<?php
|
|
require_once 'Framework/Controleur.php';
|
|
require_once 'Modele/Gestionconfiee.php';
|
|
require_once 'Modele/Police.php';
|
|
require_once 'Modele/Menuvueutilisateur.php';
|
|
require_once 'Modele/Tarifsactes.php';
|
|
require_once 'Modele/Periodicite.php';
|
|
require_once 'Modele/Pmodepaiement.php';
|
|
require_once 'Modele/Ouinon.php';
|
|
|
|
|
|
class ControleurFichegcassureur extends Controleur {
|
|
private $menuvue;
|
|
private $gc;
|
|
private $police;
|
|
private $tarif;
|
|
private $periodicite;
|
|
private $modepaiement;
|
|
private $encaissementExigeOuinon;
|
|
|
|
public function __construct() {
|
|
$this->menuvue = new Menuvueutilisateur();
|
|
$this->menuvue->getMenuVue("Fichegcassureur");
|
|
|
|
$this->gc = new Gestionconfiee();
|
|
$this->police = new Police();
|
|
$this->tarif = new Tarifsactes();
|
|
$this->periodicite = new Periodicite();
|
|
$this->modepaiement = (new Pmodepaiement())->getListe();
|
|
|
|
$this->encaissementExigeOuinon = (new Ouinon())->getListe();
|
|
|
|
$_SESSION['modeDevis'] = "0";
|
|
}
|
|
|
|
public function index() {
|
|
$idGc = $this->requete->getParametreFormulaire("id");
|
|
|
|
$gc = $this->gc->getGcAssureurId($idGc);
|
|
|
|
$_SESSION['codeGcAssureur_C'] = $gc['codeGcAssureur'];
|
|
$_SESSION['nomGcAssureur_C'] = $gc['libelle'] ;
|
|
$_SESSION['idGcAssureur_C'] = $idGc ;
|
|
|
|
$_SESSION['logoGarant'] = isset($_SESSION['logoGarant']) ?? "";
|
|
|
|
$codeGcAssureur = $_SESSION['codeGcAssureur_C'];
|
|
|
|
$message = "";
|
|
$nouveau_fichier = "Rien";
|
|
|
|
if(!empty($_POST))
|
|
{
|
|
define('TARGET', $_SESSION['dossierSociete'].'/Tarifs/Img/garants/'); // Repertoire cible
|
|
define('MAX_SIZE', 100000); // Taille max en octets du fichier
|
|
define('WIDTH_MAX', 800); // Largeur max de l'image en pixels
|
|
define('HEIGHT_MAX', 800); // Hauteur max de l'image en pixels
|
|
|
|
$tabExt = array('jpg','png','jpeg'); // Extensions autorisees
|
|
$infosImg = array();
|
|
|
|
$extension = '';
|
|
$nomImage = '';
|
|
|
|
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 !';
|
|
}
|
|
}
|
|
|
|
if(!empty($_FILES['fichier_image_a_uploader']['name']))
|
|
{
|
|
if(!empty($_FILES['fichier_image_a_uploader']['tmp_name']))
|
|
{
|
|
$extension = pathinfo($_FILES['fichier_image_a_uploader']['name'], PATHINFO_EXTENSION);
|
|
|
|
if(in_array(strtolower($extension),$tabExt))
|
|
{
|
|
$infosImg = getimagesize($_FILES['fichier_image_a_uploader']['tmp_name']);
|
|
|
|
if($infosImg[2] >= 1 && $infosImg[2] <= 14)
|
|
{
|
|
if(isset($_FILES['fichier_image_a_uploader']['error'])
|
|
&& UPLOAD_ERR_OK === $_FILES['fichier_image_a_uploader']['error'])
|
|
{
|
|
$rand = rand(1,1000000);
|
|
$nomImageTemp = "logo_".$_SESSION['codeGcAssureur_C'].$extension;
|
|
|
|
if(move_uploaded_file($_FILES['fichier_image_a_uploader']['tmp_name'], TARGET.$nomImageTemp))
|
|
{
|
|
$src = TARGET.$nomImageTemp;
|
|
$rand = rand(1,1000000);
|
|
$nomImage = "logo_".$_SESSION['codeGcAssureur_C'].'.jpg';
|
|
|
|
$imgtype = image_type_to_mime_type($infosImg[2]);
|
|
|
|
switch ($imgtype) {
|
|
case 'image/jpeg':
|
|
$source_image = imagecreatefromjpeg($src);
|
|
break;
|
|
case 'image/jpg':
|
|
$source_image = imagecreatefromjpeg($src);
|
|
break;
|
|
case 'image/png':
|
|
$source_image = imagecreatefrompng($src);
|
|
break;
|
|
}
|
|
|
|
$width = imagesx($source_image);
|
|
$desired_width = $width;
|
|
if($desired_width > $_SESSION['largeurPhoto'])
|
|
{
|
|
$desired_width = $_SESSION['largeurPhoto'];
|
|
}
|
|
|
|
$height = imagesy($source_image);
|
|
|
|
$desired_height = floor($height * ($desired_width / $width));
|
|
|
|
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);
|
|
|
|
imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
|
|
|
|
imagejpeg($virtual_image, TARGET.$nomImage, -1);
|
|
|
|
$nouveau_fichier = $nomImage;
|
|
$message = 'Chargement réussi !';
|
|
$this->gc->changerlogo($codeGcAssureur, $nomImage);
|
|
|
|
$_SESSION['logoGarant'] = $nomImage;
|
|
|
|
unlink(TARGET.$nomImageTemp);
|
|
}
|
|
else
|
|
{
|
|
$message = 'Problème lors du chargement !';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$message = 'Une erreur interne a empêché le chargement';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$message = 'Le fichier à charger n\'est pas une image !';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$message = 'L\'extension du fichier est incorrecte !';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$message = 'Revoir votre fichier image!';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$message = 'Veuillez sélectionner un fichier SVP !';
|
|
}
|
|
} //
|
|
|
|
|
|
|
|
$polices = $this->police->getPolicesDuGarant($codeGcAssureur);
|
|
|
|
$codeTypeTarifActe = "TGAR";
|
|
|
|
$tarifActe = $this->tarif->getTarifActeByType($codeTypeTarifActe);
|
|
|
|
$periodicites = $this->periodicite->getPeriodiciteFactureGarant();
|
|
|
|
$gc = $this->gc->getGcAssureurId($idGc);
|
|
|
|
$periodicitesappelfond = $this->periodicite->getPeriodiciteFactureGarant();
|
|
|
|
$periodicitesappelcotisation = $this->periodicite->getPeriodiciteFactureGarant();
|
|
$periodicitesfactsinistre = $this->periodicite->getPeriodiciteFactureGarant();
|
|
$periodicitesfactDeficit = $this->periodicite->getPeriodiciteFactureGarant();
|
|
|
|
$conventions = $this->periodicite->getTypeConvention();
|
|
|
|
$assiettefonds = $this->gc->getListeAssiettes();
|
|
$assiettehonoraire = $this->gc->getListeAssiettes();
|
|
|
|
$sourcefonds = $this->gc->getListeSourceFondGarant();
|
|
$sourcehonoraire = $this->gc->getListeSourceFondGarant();
|
|
|
|
$this->genererVue(array('gc' => $gc, 'polices' => $polices, 'tarifActe' => $tarifActe,
|
|
'periodicites' => $periodicites,'periodicitesfactsinistre' => $periodicitesfactsinistre,
|
|
'periodicitesappelfond' => $periodicitesappelfond, 'periodicitesappelcotisation' => $periodicitesappelcotisation,
|
|
'periodicitesfactDeficit' => $periodicitesfactDeficit, 'conventions' => $conventions,'modepaiement' => $this->modepaiement,
|
|
'sourcefonds' => $sourcefonds, 'sourcehonoraire' => $sourcehonoraire, 'assiettefonds' => $assiettefonds,
|
|
'assiettehonoraire' => $assiettehonoraire, 'encaissementExigeOuinon' => $this->encaissementExigeOuinon,
|
|
'message' => $message, 'nouveau_fichier' => $nouveau_fichier,));
|
|
}
|
|
} |