require_once 'Modele/Modele.php';
class AccueilModele extends Modele
{
private $libelle_ville;
private $code_postal;
private $ville_and_code_postal;
public function __construct()
{
$this->libelle_ville = array();
$this->code_postal = array();
}
public function doQuery()
{
$sql_bien = 'SELECT DISTINCT libelle_ville AS ville, code_postal AS code_postal FROM Bien_immobilier WHERE vendu = :vendu ORDER BY libelle_ville';
$this->array_sql[':vendu'] = 0;
//$liste_ville = $this->executerRequete($sql_ville);
$liste_ville_bien = $this->executerRequete($sql_bien, $this->array_sql);
$this->code_postal = array();
$this->libelle_ville = array();
while ($ville = $liste_ville_bien->fetch()) {
$ville_downcase = strtolower($ville['ville']);
if (strstr($ville_downcase, "min") || strstr($ville_downcase, "1/2") || strstr($ville_downcase, "km") || strstr($ville_downcase, "mn")
|| strstr($ville_downcase, "mpin") || strstr($ville_downcase, "mi") || strstr($ville_downcase, "proche")
) {
;// a bdd est degue bonne chance au prochain!!!! //Code commente car trop long a s'executer sinon
$sql_ville = 'SELECT DISTINCT Ville.libelle_ville, Ville.code_postal FROM Ville WHERE Ville.libelle_ville LIKE "%' . $ville_downcase . '%" ';
//echo $sql_ville ;
$name_ville = $this->executerRequete($sql_ville);
($test = $name_ville->fetch());
// echo $test['libelle_ville'];
if (!empty($test['code_postal'])) {
array_push($this->code_postal, $test['code_postal']);
} else {
array_push($this->code_postal, "");
}
array_push($this->libelle_ville, $test['libelle_ville']);
} else {
if (!empty($ville['code_postal'])) {
array_push($this->code_postal, $ville['code_postal']);
} else {
array_push($this->code_postal, "");
}
array_push($this->libelle_ville, $ville['ville']);
}
}
// $this->ville_and_code_postal = $liste_ville_bien;
}
/**
* @return mixed
*/
public function getVilleAndCodePostal()
{
return $this->ville_and_code_postal;
}
/**
* @return array
*/
public function getCodePostal()
{
return $this->code_postal;
}
/**
* @return array
*/
public function getLibelleVille()
{
return $this->libelle_ville;
}
}
?>
require_once 'Vue/Vue.php';
require_once 'Modele/BienAfficherUnBien.php';
require_once 'Modele/AccueilModele.php';
require_once 'Form/MyForm.php';
require_once 'Form/VerifForm.php';
require_once 'constantes.php';
class ControlleurRecommanderAmi
{
private $id;
private $Bien;
private $confirmation;
private $array_form = array();
private $Liste_ville;
private $My_form;
public function __construct($id)
{
$this->id = $id;
$this->Bien = new BienAfficherUnBien($id);
$this->array_form = VerifForm::initArrayForm($this->array_form);
$this->array_form = VerifForm::readForm($this->array_form);
$this->array_form = VerifForm::verifForms($this->array_form);
VerifForm::saveForm($this->array_form);
$this->My_form = new MyForm();
$this->My_form->createForm1($this->array_form);
$this->Liste_ville = new AccueilModele();
}
public function form()
{
$this->Bien->doQuery();
$this->Liste_ville->doQuery();
if (isset($_POST['nom']) && isset($_POST['mail']) && isset($_POST['mailD']) && isset($_POST['sujet']) && isset($_POST['message'])
&& $_POST['nom'] != '' && $_POST['mail'] != '' && $_POST['mailD'] != '' && $_POST['sujet'] && $_POST['message']) {
$mailD = $_POST['mailD'];
$name = $_POST['nom'];
$mail = $_POST['mail'];
$message = '
Bien immobilier
'
. $_POST['message'] . $name . '
' . $mail .
'
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
//$headers .= "To: <'.$mailD.'>" . "\r\n";
//$headers .= 'From:' .$name. ' <'.$mail.'>' . "\r\n";
$this->confirmation = "Votre message a ete envoye";
if (mail($_POST['mailD'], $_POST['sujet'], $message, $headers) == FALSE)
$this->confirmation = "Il y a eu une erreur lors de l'envoie du mail, veuillez reasseyer";
} else {
$this->confirmation = "Veuillez remplir le formulaire";
}
$vue = new Vue("RecommanderAmi");
$vue->generer(array('bien' => $this->Bien->getBien(), 'confirmation' => $this->confirmation, 'listeVille' => $this->Liste_ville->getLibelleVille(),
'listeCodePostal' => $this->Liste_ville->getCodePostal(),
'form' => $this->My_form->getForm1()));
}
}
error_reporting(E_ALL);
ini_set('display_errors', 'on');
require_once 'Vue/Vue.php';
require_once 'Modele/BienAfficherUnBien.php';
require_once 'Form/MyForm.php';
require_once 'Form/VerifForm.php';
require_once 'constantes.php';
class ControlleurNousContacter
{
private $id;
private $array_form;
private $Bien;
private $confirmation;
public function __construct($id)
{
$this->id = $id;
$this->Bien = new BienAfficherUnBien($id);
$this->array_form = VerifForm::initArrayForm($this->array_form);
$this->array_form = VerifForm::readForm($this->array_form);
$this->array_form = VerifForm::verifForms($this->array_form);
VerifForm::saveForm($this->array_form);
$this->My_form = new MyForm();
$this->My_form->createForm1($this->array_form);
$this->Liste_ville = new AccueilModele();
}
public function contact()
{
$this->Bien->doQuery();
$this->Liste_ville->doQuery();
$this->Bien = $this->Bien->getBien();
$this->confirmation = "Veuillez remplir le formulaire";
if (isset($_POST['nom']) && isset($_POST['tel']) && isset($_POST['mail']) && isset($_POST['sujet']) && isset($_POST['message'])
&& $_POST['nom'] != '' && $_POST['tel'] != '' && $_POST['mail'] != '' && $_POST['sujet'] != '' && $_POST['message'] != '') {
$nom = "Nom: " . $_POST['nom'];
$tel = "Numero de telephone: " . $_POST['tel'];
$mail = "Adresse mail: " . $_POST['mail'];
$sujet = $_POST['sujet'];
$message = '
Bien immobilier
' . $_POST['message'] . '
' .
$nom . '
' .
$tel . '
' .
$mail . '
' .
'
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
if (mail($this->Bien['adresse_mail'], $sujet, $message, $headers) == FALSE) {
$this->confirmation = "Il y a eu une erreur lors de l'envoie du mail veuillez recommencer";
} else {
$this->confirmation = "Votre message a ete envoye";
}
}
$vue = new Vue("NousContacter");
$vue->generer(array('bien' => $this->Bien, 'listeVille' => $this->Liste_ville->getLibelleVille(),
'listeCodePostal' => $this->Liste_ville->getCodePostal(), 'form' => $this->My_form->getForm1(),
'confirmation' => $this->confirmation));
}
}
ob_start();
error_reporting(E_ALL);
ini_set('display_errors', 1);
include('include/html2pdf_v4.03/html2pdf.class.php');
require_once 'Modele/BienAfficherUnBien.php';
class ControlleurBienPdf
{
private $id;
private $Bien;
private $style = '';
private $html = '';
public function __construct($id)
{
$this->id = $id;
$this->Bien = new BienAfficherUnBien($id);
$this->Bien->doQuery();
$this->setStyle();
}
public function buildPdf()
{
$this->setHtml();
$pdf = new html2pdf('P', 'A4', 'fr');
$pdf->WriteHTML($this->html);
$pdf->Output('testHTML.pdf');
}
public function gwDpeImage($consommation, $emission) {
define ('GW_DPE_IMG_PATH', 'gw_dpe/img/');
define ('GW_DPE_POLICE_PATH', 'gw_dpe/police/');
if (!empty($consommation) && !empty($emission)) {
$dst = array(
'conso' => 168, 'emis' => 381,
'a' => 14, 'b' => 38,
'c' => 61, 'd' => 84,
'e' => 108, 'f' => 131,
'g' => 154
);
$conso = $this->getConsommation($consommation);
$emis = $this->getEmission($emission);
$picture = imagecreate(100, 100);
$fond = imagecreatefrompng(GW_DPE_IMG_PATH.'fond-pdf.png');
$white = imagecolorallocate($fond, 255, 255, 255);
$value = imagecreatefrompng(GW_DPE_IMG_PATH.'value.png');
$largeur = imagesx($value);
$hauteur = imagesy($value);
imagecopy($fond, $value, $dst['conso'], $dst[$conso], 0, 0, $largeur, $hauteur);
imagecopy($fond, $value, $dst['emis'], $dst[$emis], 0, 0, $largeur, $hauteur);
imagefttext($fond, 10, 0, $dst['conso'] + 7, $dst[$conso] + 14, $white, GW_DPE_POLICE_PATH . 'verdanab.ttf', $consommation);
imagefttext($fond, 10, 0, $dst['emis'] + 7, $dst[$emis] + 14, $white, GW_DPE_POLICE_PATH . 'verdanab.ttf', $emission);
ob_end_clean();
imagepng($fond, GW_DPE_IMG_PATH.'pdf.png');
return GW_DPE_IMG_PATH.'pdf.jpg';
}
}
public function getConsommation($value) {
if ($value <= 50)
return 'a';
elseif ($value > 50 && $value <= 90)
return 'b';
elseif ($value > 90 && $value <= 150)
return 'c';
elseif ($value > 150 && $value <= 230)
return 'd';
elseif ($value > 230 && $value <= 330)
return 'e';
elseif ($value > 330 && $value <= 450)
return 'f';
return 'g';
}
public function getEmission($value) {
if ($value <= 5)
return 'a';
elseif ($value > 5 && $value <= 10)
return 'b';
elseif ($value > 10 && $value <= 20)
return 'c';
elseif ($value > 20 && $value <= 35)
return 'd';
elseif ($value > 35 && $value <= 55)
return 'e';
elseif ($value > 55 && $value <= 80)
return 'f';
return 'g';
}
private function setHtml()
{
$bien = $this->Bien->getBien();
$perf = $this->gwDpeImage($bien['gw_conso'], $bien['gw_emis']);
echo $perf;
$img = "http://www.easyannonce.com/img_users/" . $bien['photo_1'];
$file_headers = @get_headers($img);
($file_headers[0] == 'HTTP/1.1 404 Not Found' || $bien['photo_1'] == '') ? $img = "http://trouvetontoit.com/mvc/design/img/image-non-dispo.jpg" : $img = $img;
$size = getimagesize($img);
$largeur_src = $size[0];
$hauteur_src = $size[1];
$logo = 'http://www.immobilier-aquitain.fr/design/img/logo.png';
$this->html = '
';
if ($bien['vendu'] == 0) {
$dispo = 'indispo';
} else {
$dispo = 'dispo';
}
$this->html .=
'
' . $bien['libelle_categorie_bien'] . " " . $bien['nb_pieces_bien'] . " piece(s)" . $bien['surface_habitable'] . 'm2
' . $bien['libelle_ville'] . " (" . $bien['code_postal'] . ')
' . $bien['prix_bien'] . 'euros ' . $dispo . 'nible
';
$this->html .=
'
' . ucwords($bien['libelle_categorie_bien']) . '- Dossier ' . $bien['numero_bien'] . ' |
Libelle |
' . $bien['libelle_ville'] . ' |
Nb pieces |
' . $bien['nb_pieces_bien'] . ' |
Surface habitable (m²) |
' . $bien['surface_habitable'] . ' |
Prestige |
' . $bien['prestige'] . ' |
Adresse du bien |
' . $bien['adresse'] . ' |
Prix |
' . $bien['prix_bien'] . '€/mois CC |
';
$this->html .=
'
Descriptif |
' . stripcslashes(nl2br($bien['descriptif_bien'])) . ' |
';
$this->html .=
'
Infos comp |
Nb chambres |
' . $bien['nombre_chambres'] . ' |
Nb salles de bain |
' . $bien['nombre_salles_de_bain'] . ' |
Etage |
' . $bien['numero_etage'] . ' |
interphone |
' . $bien['interphone'] . ' |
Parking |
' . $bien['parking'] . ' |
Garage |
' . $bien['garage'] . ' |
Taxe d\'habitation |
' . $bien['taxes_habitation'] . ' |
Taxe fonçière |
' . $bien['taxes_foncieres'] . '€ |
Charges mensuelles |
' . $bien['charges_locatives'] . '€ |
Dépot de garantie |
' . $bien['depot_garantie'] . '€ |
Année de construction |
' . $bien['annee_construction'] . ' |
Neuf |
' . $bien['est_neuf'] . ' |
Surface terrain (m²) |
' . $bien['surface_terrain'] . ' |
Energie Chauffage |
' . $bien['moyen_chauffage'] . ' |
';
$this->html .= '
Mandat |
N° dossier |
' . $bien['numero_bien'] . ' |
Etat |
' . $dispo . 'nible |
Créé le |
' . date('d/m/Y') . ' |
MAJ |
' . date('d/m/Y') . ' |
Agence |
Contact |
' . $bien['adresse_mail'] . '
|
';
//colonne droite pdf
$imgBien1 = $img;
$this->html .= '
';
$this->html .= '
Diagnostic de performance énergétique |
Consommation énergétiques (en énergie primaire)
|
Émissions de gaz à effet de serre (GES)
|
Pour le chauffage, la production d\'eau chaude sanitaire et le refroidissement
|
' . $bien['gw_conso'] . ' kWh ep/m².an
|
' . $bien['gw_emis'] . ' kg éqco2/m².an
|
|
' .$bien['gw_conso'].'
' . $bien['gw_emis']. '
';
$this->html .= '
';
}
private function setStyle()
{
$this->style = '
';
}
/*
*/
}