| Current Path : /home/happyrenas/old/happy-r.fr/transfere_pro/administration/templates/admin2/ |
Linux webd005.cluster105.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 |
| Current File : /home/happyrenas/old/happy-r.fr/transfere_pro/administration/templates/admin2/reservation_ajout.php |
<?
session_start();
include("config.php");
$page="mesreservations";
?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="fr" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8"/>
<title>HAPPY RENTALS ADMINISTRATION</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta content="" name="description"/>
<meta content="" name="author"/>
<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css">
<link href="../../assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="../../assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css">
<link href="../../assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="../../assets/global/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css">
<link href="../../assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css"/>
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN PAGE LEVEL STYLES -->
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/clockface/css/clockface.css"/>
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/bootstrap-datepicker/css/datepicker3.css"/>
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/bootstrap-timepicker/css/bootstrap-timepicker.min.css"/>
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/bootstrap-colorpicker/css/colorpicker.css"/>
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/bootstrap-daterangepicker/daterangepicker-bs3.css"/>
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css"/>
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/bootstrap-fileinput/bootstrap-fileinput.css"/>
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css"/>
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/jquery-tags-input/jquery.tagsinput.css"/>
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/bootstrap-markdown/css/bootstrap-markdown.min.css">
<link rel="stylesheet" type="text/css" href="../../assets/global/plugins/typeahead/typeahead.css">
<!-- END PAGE LEVEL STYLES -->
<!-- BEGIN THEME STYLES -->
<link href="../../assets/global/css/components.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/global/css/plugins.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/admin/layout2/css/layout.css" rel="stylesheet" type="text/css"/>
<link id="style_color" href="../../assets/admin/layout2/css/themes/default.css" rel="stylesheet" type="text/css"/>
<link href="../../assets/admin/layout2/css/custom.css" rel="stylesheet" type="text/css"/>
<!-- END THEME STYLES -->
<link rel="shortcut icon" href="favicon.ico"/>
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<!-- DOC: Apply "page-header-fixed-mobile" and "page-footer-fixed-mobile" class to body element to force fixed header or footer in mobile devices -->
<!-- DOC: Apply "page-sidebar-closed" class to the body and "page-sidebar-menu-closed" class to the sidebar menu element to hide the sidebar by default -->
<!-- DOC: Apply "page-sidebar-hide" class to the body to make the sidebar completely hidden on toggle -->
<!-- DOC: Apply "page-sidebar-closed-hide-logo" class to the body element to make the logo hidden on sidebar toggle -->
<!-- DOC: Apply "page-sidebar-hide" class to body element to completely hide the sidebar on sidebar toggle -->
<!-- DOC: Apply "page-sidebar-fixed" class to have fixed sidebar -->
<!-- DOC: Apply "page-footer-fixed" class to the body element to have fixed footer -->
<!-- DOC: Apply "page-sidebar-reversed" class to put the sidebar on the right side -->
<!-- DOC: Apply "page-full-width" class to the body element to have full width page without the sidebar menu -->
<body class="page-boxed page-header-fixed page-sidebar-closed-hide-logo page-container-bg-solid page-sidebar-closed-hide-logo">
<!-- BEGIN HEADER -->
<?include("header_top.php");?>
<!-- END HEADER -->
<div class="clearfix">
</div>
<!-- BEGIN CONTAINER -->
<div class="container">
<div class="page-container">
<!-- BEGIN SIDEBAR -->
<div class="page-sidebar-wrapper">
<!-- DOC: Set data-auto-scroll="false" to disable the sidebar from auto scrolling/focusing -->
<!-- DOC: Change data-auto-speed="200" to adjust the sub menu slide up/down speed -->
<div class="page-sidebar navbar-collapse collapse">
<?include("header_left.php");?>
</div>
</div>
<!-- END SIDEBAR -->
<!-- BEGIN CONTENT -->
<div class="page-content-wrapper">
<div class="page-content">
<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
<div class="modal fade" id="portlet-config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
<!-- BEGIN PAGE HEADER-->
<h3 class="page-title">
Envoyer un contrat <small>Formulaire d'envoi d'un nouveeau contrat</small>
</h3>
<div class="page-bar">
<ul class="page-breadcrumb">
<li>
<i class="fa fa-home"></i>
<a href="index.php">Accueil</a>
<i class="fa fa-angle-right"></i>
</li>
<li>
<a href="#">Ajouter un contrat</a>
</li>
</ul>
</div>
<!-- END PAGE HEADER-->
<!-- BEGIN PAGE CONTENT-->
<!--PHILIPPE-->
<?
/*
http://www.vijayjoshi.org/2011/09/07/php-get-intersecting-dates-between-2-date-ranges/
*/
// INSERTION
if ($_POST['mail']!='')
{
$mail = $db->escape($_POST['mail']);
$date1 = $db->escape($_POST['date1']);
$date2 = $db->escape($_POST['date2']);
$tarif = $db->escape($_POST['tarif']);
$id_logement = $db->escape($_POST['id_logement']);
$statut = 1;
$id_proprietaire = $_SESSION['proprietaire_id'];
$date1 = date("Y-m-d", strtotime($date1));
$date2 = date("Y-m-d", strtotime($date2));
$date_demande=date("Y-m-d");
// GESTION ERREUR : SI DATE DEBUT POSTERIEURE A LA DATE FIN
$erreur="";
if ($date1>$date2) {$erreur=1;$texte_message="La date de début est postérieure à la date de fin";}
// SI DATES DE RESERVATION DEJA RESERVEES
$b1 = $db->escape($_POST['date1']);
$b2 = $db->escape($_POST['date2']);
$myquery = "SELECT date1,date2 from reservation where id_logement=$id_logement";
$site_calls = $db->get_results($myquery);
if (!empty($site_calls))
{
foreach ( $site_calls as $call )
{
$a1=$call->date1;
$a2=$call->date2;
// DATE 1 JOUR
if ($a2==$date2 && $a1==$date1)
{
$texte_message = "";
$erreur=2;
}
// DATE PLUSIEURS JOURS
$intersection = getIntersection($a1,$a2,$b1,$b2);
if($intersection === false)
{
}
else
{
$texte_message = "Réservation active du ".date('d-M-Y', $intersection['start'])." au ".date('d-M-Y', $intersection['end']);
$erreur=2;
}
//echo $a1." => ".$a2;
//echo "<br>";
}
}
//echo "<b>" . $date1." => ".$date2;
if ($erreur)
{
$type_message="danger";
$titre_message="Erreur";
echo "
<div class='portlet-body'>
<div class='note note-$type_message'>
<h4 class='block'>$titre_message</h4>
<p>$texte_message</p>
</div>
</div>
";
}
else
{
$requete="INSERT INTO reservation(
id_proprietaire,
id_logement,
mail,
date1,
date2,
tarif,
is_remboursement,
date_demande,
statut
)
VALUES(
'$id_proprietaire',
'$id_logement',
'$mail',
'$date1',
'$date2',
'$tarif',
'1',
'$date_demande',
'$statut' )";
//echo $requete;
$db->query($requete);
$type_message="success";
$titre_message="Mise à jour effectuée";
$texte_message="L'ajout est validé";
echo "
<div class='portlet-body'>
<div class='note note-$type_message'>
<h4 class='block'>$titre_message</h4>
<p>$texte_message</p>
</div>
</div>
";
// ENVOI DU MAIL
$myquery = "SELECT * from logement where id=".$id_logement;
$lelogement = $db->get_row($myquery);
$nom_logement=$lelogement->label;
$nom_logement=utf8_decode($nom_logement);
$myquery = "SELECT * from proprietaire where id=".$lelogement->id_proprietaire;
$leproprietaire = $db->get_row($myquery);
$mail_proprietaire=$leproprietaire->mail;
$myquery = "SELECT id from reservation where id_logement=".$id_logement." ORDER by ID DESC";
$reservation_maxi = $db->get_row($myquery);
//echo $myquery;
$lien=$nom_de_domaine."/administration/templates/admin2/contrat.php?reservation_id=".$reservation_maxi->id;
$fiche=$nom_de_domaine."/administration/templates/admin2/fiche.php?logement_id=".$id_logement;
$signature = $_SESSION['proprietaire_prenom']." ".$_SESSION['proprietaire_nom'];
include('mailing_template.php');
require('includes/class.phpmailer.php');
require('includes/class.smtp.php');
$objet="Votre contrat de location ".$nom_logement." du ".date("j-m-Y", strtotime($date1))." au ".date("j-m-Y", strtotime($date2));
$from=$nom_du_mail;
$to_1=$mail; //mail du client
$to_2=$nom_du_mail; //défini dans config.php
$reply=$nom_du_mail;
$mail = new PHPmailer();
$mail->IsHTML(true);
$mail->From=$from;
$mail->AddAddress($to_1);
$mail->AddBCC("resa@happy-r.fr");
$mail->AddBCC($mail_proprietaire);
$mail->AddReplyTo($reply);
$mail->Subject=$objet;
$mail->Body=$message;
$dir="../../assets/global/plugins/jquery-file-upload/server/php/files/".$id_proprietaire."/".$id_logement."/";
$lister_exec = lister($dir);
if (!empty($lister_exec))
{
foreach ($lister_exec as $key)
{
foreach ($key as $v2)
{
//echo $dir.$v2."<br>";
$mail->AddAttachment($dir.$v2);
}
}
}
$cgv="../../assets/global/plugins/jquery-file-upload/server/php/files/cgv.pdf";
$cgu="../../assets/global/plugins/jquery-file-upload/server/php/files/cgu.pdf";
$mail->AddAttachment($cgv);
$mail->AddAttachment($cgu);
if(!$mail->Send())
{echo $mail->ErrorInfo;}
else{echo '';}
unset($mail);
}
}
?>
<div class="row">
<div class="col-md-12">
<div class="portlet box blue-hoki">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-cogs"></i>Contrat
</div>
<div class="tools">
<a href="javascript:;" onclick='location.reload(true); return false;' class="reload">
</a>
</div>
</div>
<div class="portlet-body form">
<!-- BEGIN FORM-->
<form method="post" action="reservation_ajout.php" class="form-horizontal form-row-seperated">
<div class="form-body">
<div class="form-group">
<label class="control-label col-md-3">Mail client</label>
<div class="col-md-9">
<input required value="<?echo $mail;?>" type="email" name="mail" placeholder="Adresse mail de votre client" maxlength="100" class="form-control"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3">Réservation entre le </label>
<div class="col-md-4">
<div class="input-group input-large date-picker input-daterange" data-date="10/11/2012" data-date-format="dd-mm-yyyy">
<input id="date1" required value="<?if ($date1) {echo date("j-m-Y", strtotime($date1));}?>" type="text" class="form-control" name="date1">
<span class="input-group-addon">
et </span>
<input id="date2" required value="<?if ($date2) {echo date("j-m-Y", strtotime($date2));}?>" type="text" class="form-control" name="date2">
</div>
<!-- /input-group -->
<span class="help-block">
Selectionner la période souhaitée </span>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3">Tarif convenu</label>
<div class="col-md-3">
<input required value="<?echo $tarif;?>" type="numeric" name="tarif" placeholder="Tarif convenu" maxlength="100" class="form-control"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3">Logement : </label>
<div class="col-md-9">
<select name="id_logement" class="form-control select2_category">
<?
$ordre="id desc";
$id_proprietaire = $_SESSION['proprietaire_id'];
if ($_GET['order']=='label') {$ordre="label";}
$myquery = "SELECT * from logement where 1 AND id_proprietaire=$id_proprietaire order by ".$ordre;
if ($_SESSION['statut']==10) {$myquery = "SELECT * from logement where 1 order by ".$ordre;}
$site_calls = $db->get_results($myquery);
$num = $db->num_rows;
?>
<?
if (!empty($site_calls))
{
foreach ( $site_calls as $call )
{
$logement_existence=1;
?>
<option <?if ($call->id==$_GET[logement_id]) {echo "selected ";}?> value="<?echo $call->id;?>"><?echo $call->label;?></option>
<?
}
}
?>
</select>
</div>
</div>
<?if ($logement_existence)
{
?>
<div class="form-group">
<div class="col-md-offset-3 col-md-9">
<button type="submit" class="btn green"><i class="fa fa-pencil"></i> Valider</button>
</div>
</div>
<?}?>
</div>
</form>
<!-- END FORM-->
</div>
</div>
<!-- END EXTRAS PORTLET-->
</div>
</div>
<?
if (!$logement_existence)
{
$type_message="warning";
$titre_message="<b>Information importante</b>";
$texte_message="Vous devez d\abord ajouter des logements.";
echo "
<div class='portlet-body'>
<div class='note note-$type_message'>
<h4 class='block'>$titre_message</h4>
<p>$texte_message</p>
</div>
</div>
";}?>
<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$(function() {
$('#date1').change(function(){
var $date1 = $('#date1').val();
var $datepicker = $( "#date2" );
$datepicker.datepicker();
$datepicker.datepicker('setDate', $date1);
});
});
});//]]>
</script>
<!-- END PAGE CONTENT-->
</div>
</div>
<!-- END CONTENT -->
<!-- BEGIN QUICK SIDEBAR -->
<!--Cooming Soon...-->
<!-- END QUICK SIDEBAR -->
</div>
<!-- END CONTAINER -->
<!-- BEGIN FOOTER -->
<div class="page-footer">
<div class="page-footer-inner">
2014 © Metronic by keenthemes.
</div>
<div class="scroll-to-top">
<i class="icon-arrow-up"></i>
</div>
</div>
<!-- END FOOTER -->
</div>
<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- BEGIN CORE PLUGINS -->
<!--[if lt IE 9]>
<script src="../../assets/global/plugins/respond.min.js"></script>
<script src="../../assets/global/plugins/excanvas.min.js"></script>
<![endif]-->
<script src="../../assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/jquery-migrate.min.js" type="text/javascript"></script>
<!-- IMPORTANT! Load jquery-ui-1.10.3.custom.min.js before bootstrap.min.js to fix bootstrap tooltip conflict with jquery ui tooltip -->
<script src="../../assets/global/plugins/jquery-ui/jquery-ui-1.10.3.custom.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/jquery.cokie.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
<script src="../../assets/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js" type="text/javascript"></script>
<!-- END CORE PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script type="text/javascript" src="../../assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="../../assets/global/plugins/bootstrap-timepicker/js/bootstrap-timepicker.min.js"></script>
<script type="text/javascript" src="../../assets/global/plugins/clockface/js/clockface.js"></script>
<script type="text/javascript" src="../../assets/global/plugins/bootstrap-daterangepicker/moment.min.js"></script>
<script type="text/javascript" src="../../assets/global/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
<script type="text/javascript" src="../../assets/global/plugins/bootstrap-colorpicker/js/bootstrap-colorpicker.js"></script>
<script type="text/javascript" src="../../assets/global/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="../../assets/global/scripts/metronic.js" type="text/javascript"></script>
<script src="../../assets/admin/layout2/scripts/layout.js" type="text/javascript"></script>
<script src="../../assets/admin/layout2/scripts/demo.js" type="text/javascript"></script>
<script src="../../assets/admin/pages/scripts/components-pickers.js"></script>
<!-- END PAGE LEVEL SCRIPTS -->
<script>
jQuery(document).ready(function() {
// initiate layout and plugins
Metronic.init(); // init metronic core components
Layout.init(); // init current layout
Demo.init(); // init demo features
ComponentsPickers.init();
});
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>