Example #1
0
?>
<br /></td></tr>
			<tr><td>Vestigingsplaats:</td><td> <?php 
echo $bedrijf->getProperty('Vestigingsplaats');
?>
<br /></td></tr>
			<tr><td>Email:</td><td> <?php 
echo $bedrijf->getProperty('Email');
?>
<br /></td></tr>
		</dd>

		<?php 
if ($_SESSION['GroepID'] == 2) {
    $groothandel = Gebruiker::get($gebruiker->getProperty('Aanmaker'));
    $bedrijf = Bedrijf::get($groothandel->getProperty('BedrijfID'));
    ?>
			</table>
			<dt style=" background-color: green; color:white">Leverancier gegevens</dt>
			<dd>
				<table style=" margin-top: 10px">
				<tr><td>Bedrijfsnaam:</td><td> <?php 
    echo $bedrijf->getProperty('Bedrijfsnaam');
    ?>
<br /></td></tr>
				<tr><td>Adres:</td><td>
				<?php 
    echo $bedrijf->getProperty('Straat') . ' ' . $bedrijf->getProperty('Huisnummer') . $bedrijf->getProperty('HuisnummerToevoeging');
    ?>
				<br /></td></tr>
				<tr><td>Postcode:</td><td> <?php 
					</div>

					<table class="list">
						<tr>
							<th>#</th>
							<th>Groothandel</th>
							<th>Productlijst</th>
						</tr>

						<tr>
							<td><?php 
            echo $gebruiker_productlijst->getProperty('Gebruiker_ProductlijstID');
            ?>
</td>
							<td><?php 
            echo Bedrijf::get(Gebruiker::get($gebruiker_productlijst->getProperty('GebruikerID'))->getProperty('BedrijfID'))->getProperty('Bedrijfsnaam');
            ?>
</td>
							<td><?php 
            echo Productlijst::get($gebruiker_productlijst->getProperty('ProductlijstID'))->getProperty('Naam');
            ?>
</td>
						</tr>
					</table>

					<form name="frmDelete" method="POST">
						<input type="submit" name="submit" class="button" value="Ontkoppelen" />
					</form><br />
		<?php 
        } else {
            ?>
            $eind = $treshhold + $itemsLastPage - 1;
        }
        if (!empty($items)) {
            ?>
		<div id="accordion">
		<?php 
            for ($i = $start; $i <= $eind; $i++) {
                ?>
				<h3>
					<?php 
                echo '<strong>' . $items[$i]['Titel'] . '</strong> - ' . substr($items[$i]['Datum'], 0, 10);
                ?>
				</h3>
				<div>
					<strong>Door:</strong> <?php 
                echo Bedrijf::get($gebruiker->getProperty('BedrijfID'))->getProperty('Bedrijfsnaam');
                ?>
					<p>
						<?php 
                echo $items[$i]['Bericht'];
                $sth = $db->prepare("SELECT * FROM bestelling WHERE Datum = '" . $items[$i]['Datum'] . "' AND GebruikerID =" . $items[$i]['AuteurID'] . "");
                $sth->bindParam(":bestellingid", $_GET['id']);
                $sth->bindParam(":productid", $value["ProductID"]);
                $sth->execute();
                $result2 = $sth->fetch(PDO::FETCH_ASSOC);
                echo "<br/><a href='index.php?c=bestelling&p=single&id=" . $result2['BestellingID'] . "'>(zie bestelling)</a>";
                ?>
					</p>
				</div>
			<?php 
            }
		<table width="100%" cellpadding="0" cellspacing="0" border="0" class="display" id="table">
			<thead>
				<tr>
					<th>#</th>
					<th>Naam</th>
					<th>Vestigingsplaats</th>
					<th>Postcode</th>
					<th>Huisnummer</th>
					<th>Selecteer</th>
				</tr>
			</thead>
			<tbody>
				<?php 
    foreach ($gebruikers as $gebruiker) {
        if ($gebruiker->getProperty('GroepID') == 3) {
            $bedrijf = Bedrijf::get($gebruiker->getProperty('BedrijfID'));
            echo "<tr style='text-align: center'>";
            echo '<td>' . $gebruiker->getProperty('GebruikerID') . '</td>';
            echo '<td>' . $bedrijf->getProperty('Bedrijfsnaam') . '</td>';
            echo '<td>' . $bedrijf->getProperty('Vestigingsplaats') . '</td>';
            echo '<td>' . $bedrijf->getProperty('Postcode') . '</td>';
            echo '<td>' . $bedrijf->getProperty('Huisnummer') . '</td>';
            echo '<td><input type="checkbox" name="' . $gebruiker->getProperty('GebruikerID') . '" value="' . $gebruiker->getProperty('GebruikerID') . '" /></td>';
            echo "</tr>";
        }
    }
    ?>
			</tbody>
		</table>

		<table class="list">
<a href="index.php?c=groothandel&p=list" class="button">Lijstweergave</a>
<a href="index.php?c=groothandel&p=add" class="button">Groothandel aanmaken</a><br />
<?php 
if (!defined('isIncluded') || $_SESSION['GroepID'] != 4) {
    header('location: index.php');
}
if (isset($_POST['submit'])) {
    if (!empty($_POST['iptGebEmail']) && !empty($_POST['iptGebStraat']) && !empty($_POST['iptGebHuisnummer']) && !empty($_POST['iptGebPostcode']) && !empty($_POST['iptGebWoonplaats']) && !empty($_POST['iptGebTelefoon']) && !empty($_POST['iptBedBedrijfsnaam']) && !empty($_POST['iptBedStraat']) && !empty($_POST['iptBedHuisnummer']) && !empty($_POST['iptBedPostcode']) && !empty($_POST['iptBedVestigingsplaats']) && !Gebruiker::emailAlreadyExists($_POST['iptGebEmail'])) {
        $properties_values = array('Bedrijfsnaam' => $_POST['iptBedBedrijfsnaam'], 'Straat' => $_POST['iptBedStraat'], 'Huisnummer' => $_POST['iptBedHuisnummer'], 'HuisnummerToevoeging' => $_POST['iptBedHuisnummerToevoeging'], 'Postcode' => $_POST['iptBedPostcode'], 'Vestigingsplaats' => $_POST['iptBedVestigingsplaats'], 'Email' => $_POST['iptBedEmail']);
        Bedrijf::create($properties_values);
        global $db;
        $stmt = $db->query("SELECT MAX(BedrijfID) FROM bedrijf");
        $stmt->execute();
        $res = $stmt->fetch(PDO::FETCH_ASSOC);
        $bedrijfId = $res['MAX(BedrijfID)'];
        $randPass = getUniqueCode(15);
        mailPassword($_POST['iptGebEmail'], $randPass);
        $properties_values = array('Email' => $_POST['iptGebEmail'], 'Wachtwoord' => encrypt($randPass), 'GroepID' => 3, 'BedrijfID' => $bedrijfId, 'Voornaam' => $_POST['iptGebVoornaam'], 'Tussenvoegsel' => $_POST['iptGebTussenvoegsel'], 'Achternaam' => $_POST['iptGebAchternaam'], 'Straat' => $_POST['iptGebStraat'], 'Huisnummer' => $_POST['iptGebHuisnummer'], 'HuisnummerToevoeging' => $_POST['iptGebHuisnummerToevoeging'], 'Postcode' => $_POST['iptGebPostcode'], 'Woonplaats' => $_POST['iptGebWoonplaats'], 'Telefoon' => $_POST['iptGebTelefoon'], 'Aanmaker' => $_SESSION['GebruikerID']);
        Gebruiker::create($properties_values);
        echo '<br /><div class="notification_ok">De groothandel is succesvol aangemaakt.</div>';
    } else {
        if (Gebruiker::emailAlreadyExists($_POST['iptGebEmail'])) {
            echo '<br /><div class="notification_error">Dit e-mailadres is al in gebruik.</div>';
        } else {
            echo '<br /><div class="notification_error">De groothandel kon niet worden aangemaakt.</div>';
        }
    }
} else {
    ?>
	<div id="form">
		<form name="groothandelAdd" method="post">
		<th>Budget</th></tr>';
?>
	</tbody>
</table>
<br /><br />

<table cellpadding="0" cellspacing="0" border="0" class="display" id="table2">
	<thead>
		<th>Bedrijfsnr</th>
		<th>Bedrijfsnaam</th>
		<th>Budget</th>
	</thead>

	<tbody>
		<?php 
$bedrijven = Bedrijf::getAll();
foreach ($bedrijven as $bedrijf) {
    $gebruikers = Gebruiker::getAll();
    foreach ($gebruikers as $gebruiker) {
        if ($gebruiker->getProperty('BedrijfID') == $bedrijf->getProperty('BedrijfID') && $gebruiker->getProperty('GroepID') == 2) {
            ?>
							<tr>
								<td><?php 
            echo $bedrijf->getProperty('BedrijfID');
            ?>
</td>
								<td><?php 
            echo $bedrijf->getProperty('Bedrijfsnaam');
            ?>
</td>
								<td><?php 
                ?>
</td>
						<td><?php 
                echo $nieuwsitem->getProperty('Titel');
                ?>
</td>
						<td><?php 
                echo substr($nieuwsitem->getProperty('Bericht'), 0, 25);
                ?>
...</td>
						<td><?php 
                echo $nieuwsitem->getProperty('Datum');
                ?>
</td>
						<td><?php 
                echo Bedrijf::get(Gebruiker::get($nieuwsitem->getProperty('OntvangerID'))->getProperty('BedrijfID'))->getProperty('Bedrijfsnaam');
                ?>
</td>
						<td>
							<a href='index.php?c=nieuwsitem&p=delete&id=<?php 
                echo $nieuwsitem->getProperty('NieuwsitemID');
                ?>
'><img src='tpl/img/delete-icon.png' alt='verwijderen' title="verwijderen"/></a>
							<a href='index.php?c=nieuwsitem&p=edit&id=<?php 
                echo $nieuwsitem->getProperty('NieuwsitemID');
                ?>
'><img src='tpl/img/edit-icon.png' alt='wijzigen' title="wijzigen"/></a>
							<a href='index.php?c=nieuwsitem&p=single&id=<?php 
                echo $nieuwsitem->getProperty('NieuwsitemID');
                ?>
'><img src='tpl/img/view-icon.png' alt='bekijken' title="bekijken"/></a>
            ?>
...</td>
								<td><?php 
            echo $nieuwsitem->getProperty('Datum');
            ?>
</td>
								<?php 
            $auteur = Gebruiker::get($nieuwsitem->getProperty('AuteurID'));
            $ontvanger = Gebruiker::get($nieuwsitem->getProperty('OntvangerID'));
            ?>
								<td><?php 
            Bedrijf::get($auteur->getProperty('BedrijfID'))->getProperty('Bedrijfsnaam');
            ?>
</td>
								<td><?php 
            Bedrijf::get($ontvanger->getProperty('BedrijfID'))->getProperty('Bedrijfsnaam');
            ?>
</td>
							</tr>
						</tbody>
					</table>
					<br /><br />

					<form name="frmDelete" method="POST">
						<input type="submit" name="submit" class="button" value="Verwijderen" />
					</form><br />
		<?php 
        } else {
            ?>
			<div class="notification_info">U heeft nog geen nieuwsitems aangemaakt.</div>
		<?php 
						<div class="notification_warning">Alle velden zijn verplicht!</div>
					</div>

					<div id="fields">
						<label>Titel</label><input class="textbox" type="text" name="iptTitel" value="" /><br />
						<label>Bericht</label><textarea name="iptBericht" rows="5" cols="25"></textarea><br />
						<?php 
        if ($_SESSION['GroepID'] == 3 || $_SESSION['GroepID'] == 4) {
            ?>
							<label>Ontvanger</label>
							<select name="iptOntvanger" class="selectbox">
								<?php 
            $gebruikers = Gebruiker::getAll();
            foreach ($gebruikers as $gebruiker) {
                if ($gebruiker->getProperty('GroepID') == $_SESSION['GroepID'] - 1 && ($gebruiker->getProperty('Aanmaker') == $_SESSION['GebruikerID'] || $gebruiker->getProperty('BedrijfID') == $_SESSION['BedrijfID'])) {
                    echo '<option value="' . $gebruiker->getProperty('GebruikerID') . '">' . Bedrijf::get($gebruiker->getProperty('BedrijfID'))->getProperty('Bedrijfsnaam') . '</option>';
                }
            }
            ?>
							</select><br />
							<?php 
        }
        ?>
						<input type="submit" name="submit" value="Verzenden" />
					</div>
				</fieldset>
			</form>
		</div>
		<?php 
    } else {
        header('location: index.php');
					<th>Geexporteerd</th>
					<th>Bekijk bestelling</th>
				</tr>
			</thead>

			<tbody>
				<?php 
    global $db;
    $sth = $db->prepare("SELECT bestelling.* FROM bestelling WHERE :GebruikerID IN (SELECT Aanmaker FROM gebruiker WHERE GebruikerID IN\r\n\t\t\t\t\t(SELECT Aanmaker FROM gebruiker WHERE GebruikerID IN\r\n\t\t\t\t\t(SELECT GebruikerID FROM bestelling)))");
    $sth->bindParam(":GebruikerID", $_SESSION['GebruikerID']);
    $sth->execute();
    $result = $sth->FetchAll(PDO::FETCH_ASSOC);
    if (!empty($result)) {
        foreach ($result as $key => $value) {
            $gebruiker = Gebruiker::get($value["GebruikerID"]);
            $bedrijf = Bedrijf::get($gebruiker->getProperty("BedrijfID"));
            $bedrijf = $bedrijf->getProperty("Bedrijfsnaam");
            ?>
						<tr style="text-align: center">
							<td style="width: 85px"><?php 
            echo $gebruiker->getProperty("Personeelsnummer") . "-" . $value["BestellingID"];
            ?>
</td>
							<td><?php 
            echo $value["Datum"];
            ?>
</td>
							<td><?php 
            echo $bedrijf;
            ?>
</td>