public static function sendConfirmationMail(Commande $command) { $message = "Votre commande a bien été validée.<br/>"; $message .= "Numéro de confirmation : " . $command->getConfirmation() . "<br/><br/>"; $message .= "Adresse de livraison : " . $command->getAddress()->getAddress() . "<br/><br/>"; $message .= "Date prévue de la livraison : " . $command->getDateTime() . "<br/><br/>"; $message .= "Items : <br/><br/>"; foreach ($command->getItems() as $item) { $message .= "- " . $item->getName() . "<br/>"; $message .= " Prix : " . $item->getPrice() . "<br/>"; $message .= " Quantité : " . $item->quantity . "<br/>"; $message .= " Sous-Total : " . $item->quantity * $item->getPrice() . "<br/>"; } $message .= "Total : " . $command->getPrice() . "<br/><br/>"; $message .= "Adresse : " . $command->getAddress()->getAddress() . "<br/>"; $objet = "Confirmation de votre commande"; $destinataire = $command->getClient()->getMail(); $mail = new PHPMailer(); $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = '******'; $mail->Password = '******'; $mail->SMTPSecure = 'ssl'; $mail->Port = 465; $mail->From = '*****@*****.**'; $mail->FromName = 'LOG 210'; $mail->addAddress('*****@*****.**', 'Camille Hougron'); $mail->addReplyTo('*****@*****.**', 'LOG 210'); $mail->WordWrap = 50; $mail->isHTML(true); $mail->Subject = $objet; $mail->Body = $message; if (!$mail->send()) { exit; } }
private function addCommande() { $commandes = Commande::getBy(array()); $mail = true; while (count($commandes) <= 5) { $commande = new Commande(); $restaurant = Restaurant::getOneBy(array('name' => 'Ma Queue Mickey')); $item = ItemMenu::getOneBy(array('name' => 'Burger')); $address = Address::getOneBy(array('address' => '18 Rue des Roses')); $commande->setItem($item, 2); $commande->setStatus(Commande::COMMAND_STATUS_PAYED); $commande->setDatetime('12/12/12 12:12'); $commande->createConfirmationCode(); $commande->setAddress($address); $client = Client::getOneBy(array('_mail' => "*****@*****.**")); $commande->setClient($client); $commande->save(); $restaurant->save(); $commandes = Commande::getBy(array()); } }
public function gererCommande($id = 0) { $restaurateur = Restaurateur::getOneBy(array('_id' => new \MongoId(Session::getUser()->getId()))); //If we are not connected as a Restaurateur, send to the login page if (!Session::isConnected() || Session::getUser()->getType() != USER_RESTAURATEUR) { return Redirect::to('/restaurateur/login'); } //If no restaurant is specified, display the list if ($id == 0) { $commandes = Commande::getByRestaurateur($restaurateur); return View::render("restaurateur/gestionCommande.php", array('commandes' => $commandes)); } $commande = Commande::getOneBy(array('_id' => new \MongoId($id))); if ($commande->getStatus() < Commande::COMMAND_STATUS_PREPARING) { $commande->setStatus(Commande::COMMAND_STATUS_PREPARING); $commande->save(); } if (Form::exists('finir_commande_form')) { $commande->setStatus(commande::COMMAND_STATUS_READY); $commande->save(); $commandes = Commande::getByRestaurateur($restaurateur); return View::render("restaurateur/gestionCommande.php", array('commandes' => $commandes)); } return View::render("restaurateur/prepareCommande.php", array('commande' => $commande)); }
public function cancelCommand($commandId) { //If User is not logged in if (!Session::isConnected() || Session::getUser()->getType() != USER_CLIENT) { Session::addFlashMessage("Non connecté", "error", "Veuillez vous connecter avant de continuer."); Redirect::to('/restaurant'); } //If it doesn't exist, return to the list $command = Commande::getOneBy(array('_id' => new \MongoId($commandId))); if (!$command) { Redirect::to('/restaurant'); } $command->delete(); return Redirect::to('/restaurant'); }
public function mesCommandes() { //If we are not connected as a livreur, send to the login page if (!Session::isConnected() || Session::getUser()->getType() != USER_LIVREUR) { Session::disconnect(); return Redirect::to('/livreur/login'); } $commandes = Commande::getBy(array('_livreur' => Session::getUser()->getId())); return View::render("livreur/mesCommandes.php", array('commandes' => $commandes)); }