<?php

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

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

ob_start();

$html = '<style>
body {font-family: sans-serif;
	font-size: 10pt;
}
h1 {
	font-size:13pt;
}
table.sequence {
	border-collapse:collapse;
	margin:auto;
	border:1px black solid;
}
table.sequence td.td_chap {
	padding-left:50px;
	color:black;
	text-align:left;
	font-weight:bold;
	background-color: white;
	border:1px black solid;
}
table.sequence td.left {
	font-style:italic;
	vertical-align: top;
	border:1px black solid;
}
table.sequence td.center {
	text-align: center;
	border:1px black solid;
}
table.sequence td {
	text-align:left;
	border:1px black solid;
	padding-bottom:3px;
	padding-top:3px;
}
</style>
'.$_SESSION['edit_fiche'];

ob_end_clean();

$mpdf->WriteHTML($html);
$mail_file_seqpdf = $mpdf->Output('Sequence_'.$_POST['seq_id'].'.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 = SEQUPDF.' - '.$_POST['seq_niv'].'e : '.$_POST['seq_nom'].'';
//Préparation du texte
$body = SEQUPDF.' n° '.$_POST['seq_id'].' '.PJ1.'. '.$_POST['seq_niv'].'e : '.$_POST['seq_nom'].'';
$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');
?>