a
This commit is contained in:
parent
15f3e158f7
commit
ea36cb7271
130
Controleur/ControleurImportassure.php
Normal file
130
Controleur/ControleurImportassure.php
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
<?php
|
||||
|
||||
require_once 'Framework/Controleur.php';
|
||||
require_once 'Modele/Police.php';
|
||||
require_once 'Modele/Beneficiaire.php';
|
||||
require_once 'Modele/Menuvueutilisateur.php';
|
||||
require_once 'Framework/Localisation.php';
|
||||
|
||||
class ControleurImportassure extends Controleur {
|
||||
private $police;
|
||||
private $beneficiaire;
|
||||
|
||||
public function __construct() {
|
||||
$this->menuvue = new Menuvueutilisateur();
|
||||
$this->menuvue->getMenuVue("Importassure");
|
||||
|
||||
$this->police = new Police();
|
||||
$this->beneficiaire = new Beneficiaire();
|
||||
}
|
||||
|
||||
public function index($msgErreur=null)
|
||||
{
|
||||
// DEBUT CHARGELENT FICHIER EXCEL A IMPORTER
|
||||
$message = "";
|
||||
|
||||
$nouveau_fichier = "Rien";
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
define('TARGET', 'Temp/import/'); // 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("xls", "xlsx"); // 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';
|
||||
$message = _('Chargé avec succès');
|
||||
|
||||
// on va envoyer dans la base de données
|
||||
|
||||
$this->beneficiaire->enregistrerparamimportassure($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
|
||||
}
|
||||
|
||||
$msgErreur = $message;
|
||||
|
||||
unset($_FILES['fichier_upload']);
|
||||
// FIN CHARGELENT FICHIER EXCEL A IMPORTER
|
||||
|
||||
$idPolice = $_SESSION['idPolice_C'];
|
||||
$this->police->getContextePoliceId($idPolice);
|
||||
$police = $this->police->getPoliceId($idPolice);
|
||||
|
||||
$fichierimport = $this->beneficiaire->getFichierImport();
|
||||
|
||||
$this->genererVue(array('police' => $police, 'msgErreur' => $msgErreur, 'fichierimport' => $fichierimport,
|
||||
'nouveau_fichier' => $nouveau_fichier));
|
||||
}
|
||||
|
||||
}
|
||||
136
Vue/Importassure/index.php
Normal file
136
Vue/Importassure/index.php
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
// $this->titre = "INTER-SANTE - Import assurés";
|
||||
?>
|
||||
|
||||
<div id="div_fichepolice">
|
||||
|
||||
<fieldset style='font-size:10pt;'>
|
||||
<legend> <?= _("Informations Police => Importation des assurés à partir d'un fichier Excel") ?> </legend>
|
||||
<table class="table table-responsive table-condensed" style='font-size:10pt;'>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td width="10%"> <?= _("Client") ?> </td>
|
||||
<td width="24%" ><INPUT style='font-size:10pt;' class="form-control" TYPE="text" id="nomClient" name="nomClient" value="<?= $_SESSION['nomClient_C'] ?>" readonly></td>
|
||||
|
||||
<td width="10%" align="center"> <?= _("No Police") ?> </td>
|
||||
<td width="24%"><INPUT style='font-size:10pt;' class="form-control" TYPE="text" id="numeroPolice" NAME="numeroPolice" value="<?= $this->nettoyer($police['numeroPolice']) ?>" readonly></td>
|
||||
|
||||
<td width="10%" align="center">Type</td>
|
||||
<td><INPUT style='font-size:10pt;' class="form-control" TYPE="text" id="typeContrat" NAME="typeContrat" value="<?= $this->nettoyer($police['typeContrat']) ?>" readonly></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <?= _("Courtier") ?> </td>
|
||||
<td><INPUT style='font-size:10pt;' class="form-control" TYPE="text" id="apporteurOld" NAME="apporteurOld" value="<?= $this->nettoyer($police['apporteur']) ?>" readonly></td>
|
||||
|
||||
<td align="center"> <?= _("Tx Comm(%)") ?> </td>
|
||||
<td><INPUT style='font-size:10pt;' class="form-control" TYPE="text" id="tauxCommissionOld" NAME="tauxCommissionOld" value="<?= $this->nettoyer($police['tauxCommission']) ?>" readonly></td>
|
||||
|
||||
<td align="center"> <?= _("Rachat TM") ?> </td>
|
||||
<td>
|
||||
<?php if ($police['rachatTm']=="1"): ?>
|
||||
<INPUT class="form-control" TYPE="text" id="rachattmOld" NAME="rachattmOld" value="<?= _("Oui") ?>" readonly>
|
||||
<?php else: ?>
|
||||
<INPUT class="form-control" TYPE="text" id="rachattmOld" NAME="rachattmOld" value="<?= _("Non") ?>" readonly>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <?= _("Etat") ?> </td>
|
||||
<td><INPUT style='font-size:10pt;' class="form-control" TYPE="text" id="etatPolice" NAME="etatPolice" value="<?= $this->nettoyer($police['etatPolice']) ?>" readonly></td>
|
||||
|
||||
<td align="center"> <?= _("Effet") ?> </td>
|
||||
<td><INPUT style='font-size:10pt;' class="form-control" id="dateEffet" NAME="dateEffet" TYPE="text" value="<?= dateLang($this->nettoyer($police['dateEffet'])) ?>" readonly></td>
|
||||
|
||||
<td align="center"> <?= _("Echéance") ?> </td>
|
||||
<td><INPUT style='font-size:10pt;' class="form-control" TYPE="text" id="dateEcheance" NAME="dateEcheance" value="<?= dateLang($this->nettoyer($police['dateEcheance'])) ?>" readonly></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <?= _("Dernier Avenant") ?> </td>
|
||||
<td><INPUT style='font-size:10pt;' class="form-control" TYPE="text" id="typeAvenant" NAME="typeAvenant" value="<?= $this->nettoyer($police['typeAvenant']) ?>" readonly></td>
|
||||
|
||||
<td align="center"> <?= _("No Avenant") ?> </td>
|
||||
<td><INPUT style='font-size:10pt;' class="form-control" TYPE="text" id="numeroAvenant" NAME="numeroAvenant" value="<?= $this->nettoyer($police['numeroAvenant']) ?>" readonly></td>
|
||||
|
||||
<td align="center"> <?= (isset($_SESSION['composanteprime']['Taxes'])) ? _($_SESSION['composanteprime']['Taxes']) : _("Taxes") ?> (%) </td>
|
||||
<td><INPUT style='font-size:10pt;' class="form-control" TYPE="text" id="tauxTaxe" NAME="tauxTaxe" value="<?= $this->nettoyer($police['tauxTaxe']) ?>" readonly></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<legend> Actions </legend>
|
||||
<table class="table table-responsive table-condensed" style='font-size:10pt;' >
|
||||
<tbody>
|
||||
<tr>
|
||||
<td> <button style='font-size:10pt;' type="button" class="form-control btn btn-primary" onclick="javascript:exporter_modele_assure();"> <?= _("1 => Obtenir Fichier Modèle") ?> </button> </td>
|
||||
|
||||
<td></td>
|
||||
|
||||
<td> <button style='font-size:10pt;' type="button" class="form-control btn btn-primary" onclick="javascript:charger_fichier_modele_assure();"> <?= _("2 => Charger Fichier Renseigné") ?> </button> </td>
|
||||
|
||||
<td>
|
||||
<?php if($fichierimport['etape2']=='1'): ?>
|
||||
<input id="etape2" NAME="etape2" style='width: 28px; height: 28px;' type="checkbox" checked value="<?php echo $fichierimport['etape2'] ; ?>" disabled >
|
||||
<?php else: ?>
|
||||
<input id="etape2" NAME="etape2" style='width: 28px; height: 28px;' type="checkbox" value="<?php echo $fichierimport['etape2'] ; ?>" disabled >
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
||||
<td></td>
|
||||
|
||||
<td> <button style='font-size:10pt;' type="button" class="form-control btn btn-primary" onclick="javascript:init_importer_modele_assure();"> <?= _("3 => Choisir Avenant") ?> </button> </td>
|
||||
|
||||
<td>
|
||||
<?php if($fichierimport['etape3']=='1'): ?>
|
||||
<input id="etape3" NAME="etape3" style='width: 28px; height: 28px;' type="checkbox" checked value="<?php echo $fichierimport['etape3'] ; ?>" disabled >
|
||||
<?php else: ?>
|
||||
<input id="etape3" NAME="etape3" style='width: 28px; height: 28px;' type="checkbox" value="<?php echo $fichierimport['etape3'] ; ?>" disabled >
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
||||
<td></td>
|
||||
|
||||
<td> <button style='font-size:10pt;' type="button" class="form-control btn btn-primary" onclick="javascript:traiter_lignes_importees();"> <?= _("4 => Traiter Importations") ?> </button> </td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="div_exporter_liste_assures">
|
||||
|
||||
</div>
|
||||
|
||||
<div id="div_form_upload" style="display: none">
|
||||
<form enctype="multipart/form-data" action="Importassure" method="post">
|
||||
<table class="table table-responsive table-condensed" style='font-size:10pt;'>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td> <?= _("Document") ?> </td>
|
||||
<td> <input style="font-size: 15px; height: 40px" class="form-control btn btn-info" name="fichier_upload" type="file" id="fichier_upload" /> </td>
|
||||
|
||||
<td> </td>
|
||||
<td> <input style='font-size:10pt;' class="form-control btn btn-primary" type="submit" name="submit" value="<?= _("Envoyer") ?>" /> </td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php if((isset($msgErreur)) && ($msgErreur>" ")) : ?>
|
||||
<INPUT style='font-size:14pt; color:green; text-align:center;' class="form-control" type="text" value="<?= $msgErreur ?>" readonly >
|
||||
<?php endif; ?>
|
||||
|
||||
<INPUT style='font-size:14pt; color:green; text-align:center;' class="form-control" type="text" value="<?= _('FICHIER A UTILISER').' => '.$this->nettoyer($fichierimport['nomOrigine']) ?>" readonly disabled >
|
||||
|
||||
<input class="sr-only" type="text" id="cheminFichier" name="cheminFichier" value="<?= $this->nettoyer($fichierimport['cheminFichier']) ?>">
|
||||
|
||||
<div id="div_erreur_excel" >
|
||||
<input class="sr-only" type="text" id="succes_impot_execl" name="succes_impot_execl" value="0">
|
||||
</div>
|
||||
Loading…
Reference in New Issue
Block a user