1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| <?php
session_start();
if (!array_key_exists('id', $_SESSION)) {
header('Location: connexion.php');
} else {
require('shared.php');
$stmt = $bdd->prepare('SELECT * FROM utilisateurs WHERE id = :id');
$stmt->bindParam('id', $_SESSION['id'], PDO::PARAM_INT);
$stmt->execute();
$user = $stmt->fetch();
}
if ($bdd) {
$bdd = NULL;
}
?>
<!DOCTYPE html>
<head >
<title>Commande aux bases</title>
<meta charset="UTF-8">
<meta name="googlebot" content="noindex,nofollow"/>
<meta name="robots" content="noindex,nofollow"/>
<meta name="description" content="commande mail des bases">
<meta name="keywords" content="HTML,CSS,XML,JavaScript">
<meta name="author" content="jerome" >
<link href="./images/style.css" rel="stylesheet" media="all" type="text/css">
</head>
<body>
<div id="conteneur">
<div id="header">
<nav>
<ul id="menu">
<li><a href="cde.php">Commande</a></li>
<li><a href="deconnexion.php">Déconnexion</a></li>
</ul>
<p id="session">
<?php echo '<br> Bienvenu(e) ', htmlspecialchars($user['login'], ENT_NOQUOTES);
echo ' de ',$_SESSION['base'];
?>
</p>
<p></p>
</nav><div id="session1">
<input type="button" value="Envoi Mail" onClick="javascript:document.location.href='mail.php'" />
</div>
</div>
<div id="contenu">
<?php
require('shared.php');
$sth=$bdd->prepare("SELECT choixbase, articles, designations, qte, casiers, qui, pourqui FROM envoi".$_SESSION['base'] . " WHERE choixbase = :choixbase AND datecde = CURDATE()");
$sth->execute(array(':choixbase'=>$_POST['submit']));
$data = '';
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
$data .= '<tr><td>'. $row['articles'] . '</td><td>' .$row['designations'] . ' </td><td> ' . $row['qte'] . '</td><td>' . $row['casiers'] . ' </td><td> ' . $row['qui'] . ' </td><td> ' . $row['pourqui']. '</td></tr>';
}
//echo $data ;
$date = date("d-m-Y");
require('./PHPMailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->CharSet = "UTF-8";
$mail->Host = '**********';
$mail->SMTPAuth = true;
$mail->Port = *******; // Par défaut
// Authentification
$mail->Username = "*************";
$mail->Password = "************";
// Expéditeur
$mail->SetFrom('magasin-'. $_SESSION['base'] .'@********.fr' , $_SESSION['base']);
// Destinataire
$mail->AddAddress('$_POST['submit'] .'@**********.fr', $_POST['submit']);
$mail->AddCC('**********');
// Objet
$mail->Subject = 'Commande de pièces à ' . $_POST['submit'] . ' pour '. $_SESSION['base'] .' du ' . $date ;
// Votre message
$mail->MsgHTML('Merci de nous faire passer les pièces suivantes :<br><br><table width:"300px" cellspacing="2px" cellpadding="2px;" rules="all" style="border:solid 1px black;"><th>Articles</th><th>Désignations</th><th>Qté</th><th>Casiers</th><th>Qui</th><th>Attribution</th>' . $data . '</table><br>' . $_POST['enplus'] . '<br><br>Merci');
// Envoi du mail avec gestion des erreurs
if(!$mail->Send()) {
echo 'Erreur : ' . $mail->ErrorInfo;
} else {
echo 'Message envoyé à '. $_POST['submit'];
}
?>
</div>
</div>
<div id="footer">Petit site de commandes entre bases. JGU</div>
</body>
</html> |
Partager