public function bestellingDoorvoeren($arrBestelRegel, $datum, $prijs, $KlantID) { // Voert een bestelling door naar DB $albestelddiedag = bestellingService::alBesteldDieDag($datum, $KlantID); if (!$albestelddiedag) { $BestelID = BestellingDAO::createBestelling($KlantID, $datum, $arrBestelRegel, $prijs); foreach ($arrBestelRegel as $regel) { $Aantal = $regel->aantal; if ($Aantal) { $ProductID = $regel->productID; $product = productService::getProductFromId($ProductID); $productPrijs = $product->prijs; $Prijs = $Aantal * $productPrijs; BestelRegelDAO::createBestelRegel($BestelID, $ProductID, $Aantal, $Prijs); $Aantal = 0; } } unset($_SESSION['bestelregelarray']); return TRUE; } if ($albestelddiedag) { return FALSE; } }
<?php session_start(); require_once './Business/bestellingService.php'; //aanmaken lijst bestellingen $bestellingservice = new bestellingService(); $bestellingLijst = $bestellingservice->getBestelling($_SESSION['user']); if (!isset($_SESSION['user'])) { header('location: loginController.php'); } if (isset($_GET['verwijder'])) { var_dump($_GET); $bestellingservice = new bestellingService(); $verwijder = $bestellingservice->verwijderBestelling($_GET["verwijder"]); header('location: accountOverzichtController.php'); } if (isset($_GET['action']) && $_GET['action'] == "logout") { unset($_SESSION["user"]); header('location: indexController.php'); } include_once './Presentation/accountOverzicht.php';
<?php if (isset($_GET['verwijder'])) { bestellingService::verwijderBestelling($_GET['verwijder']); } ?> <div class="wrapper clearfix"> <div class="txtC"> <h1>Besteloverzicht</h1> </div> <div class="wrapper clearfix txtC"> <?php $nextdatum = ""; $arrBestellingen = bestellingService::getAllBestellingen(); foreach ($arrBestellingen as $bestelling) { $klantID = $bestelling->KlantID; $klant = klantService::getKlantFromId($klantID); $dbDatum = $bestelling->Besteldatum; $datum = date('d-m-Y', strtotime($dbDatum)); $BestelID = $bestelling->BestelID; $klantnaam = $klant->Naam . " " . $klant->VNaam; if ($nextdatum == "") { print $datum . "<hr/>"; } else { if ($nextdatum != $dbDatum) { print "<hr/>" . $datum . "<hr/>"; } } print "<div class='innercontainer txtL'> "; print "<dl><dt>Bestelling voor " . $klantnaam . " op " . $datum . "</dt>"; $totPrijs = $bestelling->Prijs;
//info ophalen over product aan de hand van productID $productservice = new productService(); $prijs = $productservice->getPrijsEnNaam($_SESSION['winkelmandje']); //afrekenenen moet true zijn if (isset($_GET['betalen']) && ($_GET['betalen'] = true)) { //de klant moet toelating hebben om te bestellen $klantService = new KlantService(); $status = $klantService->checkStatus($_SESSION['user']); if ($status = false) { header('location: afrekenController.php?error=verboden'); exit(0); } //als de klant toestemming heeft word er gekeken naar de datum, als deze hoger is dan vandaag dan word er gesubmit naar de databank. if ($_POST['bestellingsdatum'] > strtotime('now') && $_POST['bestellingsdatum'] < strtotime('+3 day')) { $bestellinglijnService = new bestellingLijnService(); $bestellingService = new bestellingService(); //resultaat ophalen of er een bestelling bestaat of niet. //Werkt in realiteit niet omdat de datum uit de databank komt met minuten en seconden en die waarmee vergeleken word //is de gekozen datum met het uur + minuten van de bestelling. Want het is bv: now +1 day. $datumArray = $bestellingService->getDatum($_SESSION['user']); $alEenBestelling = in_array($_POST['bestellingsdatum'], $datumArray); //als er geen rijen terug komen voor die user op die datum dan mag er besteld worden if ($alEenBestelling == FALSE) { $bestellingService->insertBestelling($_SESSION['user'], $_POST['bestellingsdatum']); //alle lijnen afloopen van het order for ($i = 0; $i < count($_SESSION['winkelmandje']); $i++) { $bestellinglijnService->insertLijnen($_SESSION['winkelmandje'][$i]['BestellingsID'], $_SESSION['winkelmandje'][$i]['productID'], $_SESSION['winkelmandje'][$i]['hoeveelheid']); } //als er toestemming is, als de datum juist is, als er nog geen bestelling is voor die datum, als de bestelling en de bestellingslijnen in de databank zitten //dan mag er bevestigd worden en de sessie unsetten. unset($_SESSION['winkelmandje']);
<?php if (isset($_GET['verwijder'])) { bestellingService::verwijderBestelling($_GET['verwijder']); } ?> <div class="wrapper clearfix"> <div class="txtC"> <h1>Besteloverzicht</h1> </div> <div class="wrapper clearfix txtC"> <?php $arrBestellingen = bestellingService::getBestellingFromKlantId($klantID); foreach ($arrBestellingen as $bestelling) { print "<div class='innercontainer txtL'> "; $dbDatum = $bestelling->Besteldatum; $datum = date('d-m-Y', strtotime($dbDatum)); $BestelID = $bestelling->BestelID; print "<dl><dt>Bestelling voor " . $datum . "</dt>"; $arrBestelRegel = bestelRegelService::getBestelRegelsFromId($BestelID); $totprijs = 0; foreach ($arrBestelRegel as $regel) { $productID = $regel->productID; $aantal = $regel->aantal; $product = productService::getProductFromId($productID); $productPrijs = $product->prijs; $prijs = $aantal * $productPrijs; if ($aantal) { print "<dd>" . $aantal . " x " . $product->product . " <strong>€ " . $productPrijs . "</strong> = € " . $prijs . "</dd>"; } $totprijs += $prijs;