<?php

if(phpversion()>=8.0) {
	require_once './include/mpdf8/autoload.php';
}
else {
	require_once './include/mpdf/autoload.php';
}

$mpdf = new \Mpdf\Mpdf([
	'orientation' => 'L',
	'setAutoTopMargin' => 'pad'
]);

ob_start();

$html = '<style>
div.edt_grille, div.td, div.th {
	box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    border: 1px solid grey;
    font-family: Liberation Sans, Arial;
    text-align:center;
    margin:auto;
}
#edt_briques {
	position:fixed;
	height:90%;
	float:right;
	overflow:scroll;
	z-index:100;
}
.heure {
	width:60px;
}
.heure, .recept_open {
	display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
}
.recept_open {
	background-color:#eee;
}
.recept_close {
	background-color:#7D7777;
}
.txt_close {
	font-style:italic;
	font-size:1.8em;
	color:black;
	text-rotate:90;
}
.openmsg {
	display:block;
	text-align:center;
	font-size: 0.8em;
}
.cartclic {
	display:inline;
}
.cartouche {
	display:inline-block;
	/*padding:0px 1px 1px 1px;*/
	border:1px solid grey;
	width:120px;
	height:30px;
	text-align:center;
	line-height:12px;
	font-size: 0.8em;
	padding-left:10px;
	margin-top:10px;
}
.cartouche span {
	vertical-align:middle;
}
.cartouche .txtlibre_1 {
	padding-top:20px;
}
.cartouche .txtlibre_2 {
	padding-top:3px;
}
.cartedt {
	display:inline-block;
	/*padding:0px 1px 1px 1px;*/
	border:1px solid grey;
	width:120px;
	text-align:center;
	line-height:12px;
	font-size: 0.8em;
}
.cartedt span {
	vertical-align:middle;
}
.cartedt, .txtlibre_1 {
	margin-top:20px;
}
.cartedt, .txtlibre_2 {
	margin-top:9px;
	margin-left:7px;
}
.msg {
	font-family: Arial,Verdana;
	text-align:center;
	font-size:1.8em;
	color:black;
}
.tit {
	font-family: Arial,Verdana;
	text-align:center;
	font-size:1.8em;
	color:black;
}
.noprint {
	display:none;
}
.pdfmarg {
	padding-top:6px;
	padding-bottom:-6px;
}
.openmsgsped {
	line-height:5px;
	font-size:0.6em;
	padding-top:0px;
	padding-bottom:0px;
}
.brikspe1 {
	font-size:0.6em;
	line-height:5px;
	padding-top:-9px;
}
.brikspe2 {
	font-size:0.6em;
	line-height:5px;
	padding-top:-7px;
}
.fontsmall {
	font-size:0.5em;
}
</style>
<p class="tit" style="'.$_SESSION['edttitsize'].$_SESSION['edttitcolor'].'">'.$_SESSION['edt_tit'].'</p>'.$_SESSION['edt_tablepdf'].'<p class="msg" style="'.$_SESSION['edtbotmsgsize'].$_SESSION['edtbotmsgcolor'].'">'.$_SESSION['edt_msg'].'</p>';

ob_end_clean();

$mpdf->WriteHTML($html);
$mail_file_edtpdf = $mpdf->Output('EDT_S'.$_POST['week'].'.pdf', 'S');

//Préparation des adresses
$mails = array();
foreach($_POST['mail'] as $mail){
	if (preg_match("/@/i", $mail)) {
		array_push($mails, $mail);
	}
}
if (preg_match("/@/i", $_POST['mail1'])) { array_push($mails, $_POST['mail1']); }
if (preg_match("/@/i", $_POST['mail2'])) { array_push($mails, $_POST['mail2']); }
//Préparation de l'objet
$objet = EDT1.' '.$_SESSION['lieu'].' '.THISWEEK.' '.$_POST['week'].'';
//Préparation du texte
$body = EDT1.' '.$_SESSION['lieu'].' '.THISWEEK.' '.$_POST['week'].' '.PJ1.'.';
$email_exp = mysqli_fetch_assoc(mysqli_query($bdd,"SELECT login, mail FROM ".$prefix."_user WHERE id = '".$_SESSION['user_id']."'"));
$exp_mail = $email_exp['mail'];
$exp_login = $email_exp['login'];
//Envoi à partir des éléments précédents :
include('mailing_config.php');
?>