$req = $bdd->prepare('SELECT email FROM aide LEFT JOIN etudiant ON aide.numero_etudiant = etudiant.numero_etudiant WHERE aide.id_needhelp = :idannonce'); $req->execute(array('idannonce' => $_POST["idannonce"])) or die(print_r('2' . $bdd->errorInfo(), true)); $helper = $req->fetch(); $refus1 = new Template("../templates/mail.tpl"); $refus1->set("annonce", $demandeur["commentaire"]); $refus1->set("text", "Vous avez refuse l'aide pour l'annonce "); $refus1->set("url", "https://media.giphy.com/media/Hwq45iwTIUBGw/giphy.gif"); $mail_demandeur = new Helper_Mail(); $mail_demandeur->to($demandeur["email"])->sujet("Refus d'aide")->content($refus1->output())->send(); $refus2 = new Template("../templates/mail.tpl"); $refus2->set("annonce", $demandeur["commentaire"]); $refus2->set("text", "Un etudiant a refuse votre demande d'aide pour l'annonce "); $refus2->set("url", "http://www.reactiongifs.com/r/d9.gif"); $mail_helper = new Helper_Mail(); $mail_helper->to($helper["email"])->sujet("Refus d'aide")->content($refus2->output())->send(); $req = $bdd->prepare('UPDATE needhelp SET etat = 0 WHERE id = :idannonce '); $req->execute(array('idannonce' => $_POST["idannonce"])) or die('3' . print_r($bdd->errorInfo(), true)); $req = $bdd->prepare('DELETE FROM aide WHERE id_needhelp = :idannonce '); $req->execute(array('idannonce' => $_POST["idannonce"])) or die('4' . print_r($bdd->errorInfo(), true)); } else { echo "not ok lol"; }
} //On remet la demande d'aide à l'état d'origine $reqBis = $bdd->prepare('UPDATE needhelp SET etat=0 WHERE id IN(SELECT id_needhelp FROM aide WHERE etat=0 AND numero_etudiant= :iduser1)'); $reqBis->execute(array('iduser1' => $_POST["iduser"])) or die(print_r('3' . $bdd->errorInfo(), true)); $req = $bdd->prepare('DELETE FROM aide WHERE numero_etudiant = :iduser'); $req->execute(array('iduser' => $_POST["iduser"])) or die(print_r('4' . $bdd->errorInfo(), true)); //fin partie suppression proposeur aide //partie suppression demandes //On recupère les etudiants qui voulaient aider l'élève qui va être supprimer $reqBis = $bdd->prepare('SELECT numero_etudiant FROM aide WHERE etat=0 and id_needhelp in(SELECT id FROM needhelp WHERE etat=1 AND numero_etudiant= :iduser)'); $reqBis->execute(array('iduser' => $_POST["iduser"])) or die(print_r('6' . $bdd->errorInfo(), true)); $resultat = $reqBis->fetchAll(); //Ensuite on envoie un mail pour prévenir ces personnes foreach ($resultat as $r) { $req = $bdd2->prepare('SELECT email,nom,prenom FROM etudiant WHERE numero_etudiant= :iduser2'); $req->execute(array('iduser2' => $r['numero_etudiant'])) or die(print_r('7' . $bdd2->errorInfo(), true)); $resultatfind = $req->fetch(); // Envoi du mail $mail_demandeur = new Helper_Mail(); $mail_demandeur->to($resultatfind['email'])->sujet('Annulation echange')->content("Bonjour " . $resultatfind['prenom'] . " " . $resultatfind['nom'] . " .Malheuresement, nous avons banni un élève que vous souhaitiez aider :\n nous avons donc interrompu l'echange en cours.N'hésitez pas à aider d'autres personnes. Bonne journée !")->send(); } $req = $bdd->prepare('DELETE FROM aide WHERE id_needhelp IN(SELECT id from needhelp where numero_etudiant = :iduser)'); $req->execute(array('iduser' => $_POST["iduser"])) or die(print_r('8' . $bdd->errorInfo(), true)); $req = $bdd->prepare('DELETE FROM needhelp WHERE numero_etudiant = :iduser'); $req->execute(array('iduser' => $_POST["iduser"])) or die(print_r('9' . $bdd->errorInfo(), true)); //fin supression demandes $req = $bdd->prepare('DELETE FROM helper WHERE numero_etudiant = :iduser'); $req->execute(array('iduser' => $_POST["iduser"])) or die(print_r('5' . $bdd->errorInfo(), true)); $req = $bdd->prepare('DELETE FROM etudiant WHERE numero_etudiant = :iduser'); $req->execute(array('iduser' => $_POST["iduser"])) or die(print_r('10' . $bdd->errorInfo(), true)); }
$req = $bdd->prepare('SELECT email,prenom,nom, commentaire FROM needhelp LEFT JOIN etudiant ON needhelp.numero_etudiant = etudiant.numero_etudiant WHERE needhelp.id = :idannonce'); $req->execute(array('idannonce' => $_POST["idannonce"])) or die(print_r('1' . $bdd->errorInfo(), true)); $demandeur = $req->fetch(); // Mail helper $req = $bdd->prepare('SELECT email,nom,prenom FROM etudiant WHERE etudiant.numero_etudiant = :idetu'); $req->execute(array('idetu' => $_SESSION["login"])) or die(print_r('2' . $bdd->errorInfo(), true)); $helper = $req->fetch(); $mail_demandeur = new Helper_Mail(); $mail_demandeur->to($demandeur["email"])->sujet("Proposition d'aide")->content("L'etudiant " . $helper["prenom"] . " " . $helper["nom"] . " a repondu a votre demande d'aide : " . $demandeur["commentaire"] . ", merci de confirmer dans votre espace"); $mail_helper = new Helper_Mail(); $mail_helper->to($helper["email"])->sujet("Proposition d'aide")->content("Vous avez repondu a l'annonce : " . $demandeur["commentaire"] . ", merci d'attendre la confirmation de l'étudiant."); if ($mail_demandeur->send() && $mail_helper->send()) { $req = $bdd->prepare('UPDATE needhelp SET etat = 1 WHERE id = :idannonce '); $req->execute(array('idannonce' => $_POST["idannonce"])) or die('3' . print_r($bdd->errorInfo(), true)); $req = $bdd->prepare('INSERT INTO aide(numero_etudiant, id_needhelp) VALUES (:idetu, :idannonce) '); $req->execute(array('idetu' => $_SESSION["login"], 'idannonce' => $_POST["idannonce"])) or die(print_r('4' . $bdd->errorInfo(), true)); } else { echo "not ok lol"; } }
<?php session_start(); include 'Helper/Helper_Mail.php'; $texte = htmlspecialchars($_GET["contenuMail"]); if ($_GET["rep"] == 1 or $_GET["rep"] == 4) { //mail dejà envoyé header('Location:profile.php?rep=4'); } else { if ($texte != null) { // Envoi du mail $mail_demandeur = new Helper_Mail(); $mail_demandeur->to("*****@*****.**")->sujet("Demande/Question")->content("" . $texte)->send(); header('Location:profile.php?rep=1'); } else { if ($texte == null) { header('Location:profile.php?rep=2'); } else { header('Location:profile.php?rep=3'); } } }
$req = $bdd->prepare('SELECT email,nom,prenom, commentaire FROM needhelp LEFT JOIN etudiant ON needhelp.numero_etudiant = etudiant.numero_etudiant WHERE needhelp.id = :idannonce'); $req->execute(array('idannonce' => $_POST["idannonce"])) or die(print_r('1' . $bdd->errorInfo(), true)); $demandeur = $req->fetch(); // Mail helper $req = $bdd->prepare('SELECT email,nom,prenom FROM aide LEFT JOIN etudiant ON aide.numero_etudiant = etudiant.numero_etudiant WHERE aide.id_needhelp = :idannonce'); $req->execute(array('idannonce' => $_POST["idannonce"])) or die(print_r('2' . $bdd->errorInfo(), true)); $helper = $req->fetch(); // Suppression des annonces $req = $bdd->prepare('DELETE FROM aide WHERE id_needhelp = :idannonce '); $req->execute(array('idannonce' => $_POST["idannonce"])) or die(print_r('4' . $bdd->errorInfo(), true)); $req = $bdd->prepare('DELETE FROM needhelp WHERE id = :idannonce '); $req->execute(array('idannonce' => $_POST["idannonce"])) or die(print_r('3' . $bdd->errorInfo(), true)); // Envoi des mails $mail_demandeur = new Helper_Mail(); $mail_demandeur->to($demandeur["email"])->sujet("Acceptation d'aide")->content("Vous avez accepte l'aide de l'etudiant " . $helper["prenom"] . " " . $helper["nom"] . " pour l'annonce : " . $demandeur["commentaire"] . ". Merci de prendre contact avec cette personne à l'adresse suivante : " . $helper["email"])->send(); $mail_helper = new Helper_Mail(); $mail_helper->to($helper["email"])->sujet("Acceptation d'aide")->content("Votre aide a ete acceptée pour l'annonce : " . $demandeur["commentaire"] . " de " . $demandeur["prenom"] . " " . $demandeur["nom"] . " . Merci de prendre contact à l'adresse suivante : " . $demandeur["email"])->send(); } else { }