<?php
require_once __DIR__ . '/connection.php';
$product = 'SELECT * FROM product WHERE id = '.$prodId;
$currentUser = 1234;
$req = $dbConnect->query($product);
$req->bindParam(':CURRENT_USER', $currentUser, PDO::PARAM_INT);
$req->execute();
$prod = $req->fetch(PDO::FETCH_ASSOC);
?>
<div id="produits">
<div class="produit h-product" id="produit_<?php echo $prod['id'] ?>" align="center" style="margin-right:58%">
<form method="post" action="formular.php" autocomplete="off" name="<?php echo $prod['id'] ?>">
<input type="hidden" name="id" value="<?php echo $prod['id'] ?>">
<table border="0" cellpadding="0">
<tr>
<td style=" color:#FFFFFF ; background-color:#860000; width:0%; height:13px; border:3px solid #860000;">PRODUKT</td>
</tr>
<tr class="row9">
<td class="column0 style24 null style27" colspan="4" rowspan="8">
<img style=" z-index: 1; left: 40px; top: 10px; width: 220px; height: 220px;"
src="images/<?php echo $prod['path'] ?>"><input type="hidden" name="selected_photo"
value="<?php echo $prod['path'] ?>"></td>
<td class="column4 style10 s">a</td>
<td class="column5 style19 n" style="font-size:15px"><input type="text" name="a" size="6" maxlength="4" value="<?php echo $prod['a'] ?>"></td>
</tr>
<tr class="row10">
<td class="column4 style11 s">b</td>
<td class="column5 style20 n" style="font-size:15px"><input type="text" name="b" size="6" maxlength="4" value="<?php echo $prod['b'] ?>"></td>
</tr>
<tr class="row11">
<td class="column4 style11 s">c</td>
<td class="column5 style20 null" style="font-size:15px"><input type="text" name="c" size="6" maxlength="4" value="<?php echo $prod['c'] ?>">
</td>
</tr>
<tr class="row12">
<td class="column4 style11 s">d</td>
<td class="column5 style20 null" style="font-size:15px"><input type="text" name="d" size="6" maxlength="4" value="<?php echo $prod['d'] ?>">
</td>
</tr>
<tr class="row13">
<td class="column4 style11 s">e</td>
<td class="column5 style20 null" style="font-size:15px"><input type="text" name="e" size="6" maxlength="4" value="<?php echo $prod['e'] ?>">
</td>
</tr>
<tr class="row17" >
<td class="column0 style14 s" style="font-size:14px; text-align:center;font-weight:bold"><input type="reset" name="affacer_donnée" value="effacer"></td>
<td class="column1 style40 n style42" colspan="2"></td>
<td class="column3 style15 s" style="font-weight:bold">
<input type="checkbox" name="variant"> Ajouter une Variante </td>
<td class="column4 style40 n style41" colspan="2">
<input type="submit" name="save_product" value="Sauvegarder">
</td>
</tr>
</tbody>
</table>
</form>
</div>
<?php
// Variante
$variants = '
SELECT
id,
img_id,
user_id,
a,
b,
c,
d,
e
FROM
variants
JOIN users USING(user_id)
WHERE
user_id = :CURRENT_USER
OR user_id IN(
SELECT user_id
FROM users
WHERE ROLE = \'admin\');';
$req2 = $dbConnect->prepare($variants);
while ($variant = $req2->fetch(PDO::FETCH_ASSOC)) {
?>
<div class="produit" id="produit_<?php echo $variant['id'] ?>" align="center" style="margin-right:68%">
<form method="post" action="formular.php" name="<?php echo $variant['id'] ?>">
<input type="hidden" name="id" value="<?php echo $variant['id'] ?>">
<table border="0" cellpadding="0">
<td style=" color:#FFFFFF ; background-color:#004B27; width:0%; height:13px; border:3px solid #004B27;">VARIANTE</td>
<tr class="row9">
<td class="column0 style24 null style27" colspan="4" rowspan="8">
<img style=" z-index: 1; left: 40px; top: 10px; width: 220px; height: 220px;" src="images/<?php echo $prod['path'] ?>"><input type="hidden" name="selected_photo" value="<?php echo $prod['path'] ?>" ></td>
<td class="column4 style10 s">a</td>
<td class="column5 style19 n"style="font-size:15px"><input type="text" name="a" size="6" maxlength="4" value="<?php echo $variant['a'] ?>" ></td>
</tr>
<tr class="row10">
<td class="column4 style11 s">b</td>
<td class="column5 style20 n"style="font-size:15px"><input type="text" name="b" size="6" maxlength="4" value="<?php echo $variant['b'] ?>" ></td>
</tr>
<tr class="row11">
<td class="column4 style11 s">c</td>
<td class="column5 style20 null"style="font-size:15px"><input type="text" name="c" size="6" maxlength="4" value="<?php echo $variant['c'] ?>" ></td>
</tr>
<tr class="row12">
<td class="column4 style11 s">d</td>
<td class="column5 style20 null"style="font-size:15px"><input type="text" name="d" size="6" maxlength="4" value="<?php echo $variant['d'] ?>" ></td>
</tr>
<tr class="row13">
<td class="column4 style11 s">e</td>
<td class="column5 style20 null" style="font-size:15px"><input type="text" name="e" size="6" maxlength="4" value="<?php echo $variant['e'] ?>" ></td>
</tr>
<tr class="row17">
<td class="column0 style14 s" style="font-size:14px; text-align:center;font-weight:bold">
<input type="reset" name="daten_loeschen" value="Zurücksetzen">
</td>
<td class="column1 style40 n style42" colspan="2">
</td>
<td class="column3 style15 s">
</td>
<td class="column4 style40 n style41" colspan="2">
<input type="submit" name="save_variant" value="Speichern">
</td>
</tr>
</form>
<tr class="row17">
<td class="column0 style14 s"></td>
<td class="column1 style40 n style42" colspan="2">
<form method="post" action="delete_variant.php" name="delete_<?php echo $variant['id'] ?>">
<input type="hidden" name="id" value="<?php echo $variant['id'] ?>">
<input type="hidden" name="img_id" value="<?php echo $prod['id'] ?>">
<input type="hidden" name="img_path" value="<?php echo $prod['path'] ?>">
<input type="hidden" name="type" value="variant">
<input type="hidden" name="location" value="<?php echo $_SERVER['REQUEST_URI'] ?>">
<input type="hidden" name="user_id" value="<?php echo $_SESSION['user_id'] ?>">
<input type="hidden" name="sessionID" value="<?php echo $_SESSION['sessionID'] ?>">
<input type="hidden" name="time" value="<?php echo $_SESSION['time'] ?>">
<input type="submit" name="select_variant" value="Löschen" style="align:center">
</form>
</td>
<td class="column3 style15 s" style="font-size:14px; text-align:center;font-weight:bold">
<form method="post" action="drucker.php" name="<?php echo $variant['id'] ?>">
<input type="hidden" name="id" value="<?php echo $variant['id'] ?>">
<input type="hidden" name="img_id" value="<?php echo $prod['id'] ?>">
<input type="hidden" name="img_path" value="<?php echo $prod['path'] ?>">
<input type="hidden" name="type" value="variant">
<input type="hidden" name="location" value="<?php echo $_SERVER['REQUEST_URI'] ?>">
<input type="hidden" name="user_id" value="<?php echo $_SESSION['user_id'] ?>">
<input type="hidden" name="sessionID" value="<?php echo $_SESSION['sessionID'] ?>">
<input type="hidden" name="time" value="<?php echo $_SESSION['time'] ?>">
<input type="submit" name="select_variant" value="Auswählen" style="align:center">
</form>
</td>
<td class="column4 style40 n style41" colspan="2">
</td>
</tr>
</tbody>
</table>
</div>
<?php
}
?>