2019-09-26 23:40:22 +02:00
|
|
|
<?php
|
2019-11-19 23:09:14 +01:00
|
|
|
session_start();
|
2019-11-09 23:23:19 +01:00
|
|
|
ini_set('display_errors', 0);
|
2019-11-21 12:57:32 +01:00
|
|
|
include '../../config/config.php';
|
2019-11-09 23:23:19 +01:00
|
|
|
$antenne_slug = $_GET['antenne_slug'];
|
2019-11-21 16:37:05 +01:00
|
|
|
$nom_connecte = $_SESSION['user'];
|
2019-11-20 21:59:17 +01:00
|
|
|
$bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password);
|
2019-09-26 23:40:22 +02:00
|
|
|
|
2019-11-09 23:23:19 +01:00
|
|
|
// Affichage des intitulés de colonnes
|
|
|
|
$data = '<table class="table table-bordered table-striped">
|
|
|
|
<tr style="color: black;">
|
|
|
|
<th>No.</th>
|
|
|
|
<th>Bien/service recherché</th>
|
|
|
|
<th>Photo</th>
|
|
|
|
<th>Acheteur</th>
|
|
|
|
<th>Clé publique</th>
|
|
|
|
<th>Quantité</th>
|
|
|
|
<th>Prix en Ğ1</th>';
|
2019-10-26 01:42:50 +02:00
|
|
|
|
2019-11-09 23:23:19 +01:00
|
|
|
$params["antenne_slug"] = $antenne_slug;
|
|
|
|
$requete = "SELECT souhaits.*, users.username, users.pubkey
|
2019-11-25 20:17:45 +01:00
|
|
|
FROM souhaits
|
|
|
|
LEFT JOIN antennes
|
|
|
|
ON antennes.id = souhaits.antenne_id
|
|
|
|
LEFT JOIN users
|
|
|
|
ON users.id = souhaits.user_id
|
2019-11-09 23:23:19 +01:00
|
|
|
WHERE antennes.slug = :antenne_slug";
|
|
|
|
$stmt = $bdd->prepare($requete);
|
|
|
|
$stmt2 = $bdd->prepare($requete);
|
|
|
|
$stmt->execute($params);
|
|
|
|
$stmt2->execute($params);
|
|
|
|
$count = $stmt->rowCount();
|
|
|
|
$affich_actions = false;
|
|
|
|
while ($row2 = $stmt2->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
if ($row2['username'] == $nom_connecte) {
|
|
|
|
$affich_actions = true;
|
2019-10-26 01:42:50 +02:00
|
|
|
}
|
2019-11-09 23:23:19 +01:00
|
|
|
}
|
|
|
|
if ($affich_actions) {
|
|
|
|
$data .= '<th colspan="2" style="text-align: center;">Actions</th>';
|
|
|
|
$data .= '</tr>';
|
|
|
|
} else {
|
2019-10-26 01:42:50 +02:00
|
|
|
$data .= '</tr>';
|
|
|
|
}
|
2019-11-09 23:23:19 +01:00
|
|
|
if ($count > 0)
|
|
|
|
{
|
|
|
|
$number = 1;
|
|
|
|
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
$data .= "<tr style='background:lightblue;color:black;'>
|
|
|
|
<td>$number</td>";
|
|
|
|
$prix = $row['prix'];
|
|
|
|
$vendeur = $row['username'];
|
|
|
|
$produit = $row['name'];
|
|
|
|
$pubkey = $row['pubkey'];
|
|
|
|
$vendeur_format = "<a target=\"_blank\" href=\"https://g1.duniter.fr/#/app/wot/$pubkey/\">$vendeur</a>";
|
|
|
|
$pubkeyShort = substr($pubkey, 0, 8);
|
|
|
|
$data .= '<td>'.$produit.'</td>';
|
2019-11-25 20:17:45 +01:00
|
|
|
$imagep = '../uploads/recherches/'.$antenne_slug.'/'.$row['image'].'';
|
|
|
|
if (file_exists($imagep) && $row['image']) {
|
|
|
|
$data .= '<td><img src="/uploads/recherches/'.$antenne_slug.'/'.$row['image'].'" width="100" height="100" /></td>';
|
|
|
|
} else {
|
|
|
|
$data .= '<td><img src="/uploads/default.png" width="50" height="50" /></td>';
|
|
|
|
}
|
2019-11-09 23:23:19 +01:00
|
|
|
$data .= '<td>'.$vendeur_format.'</td>';
|
|
|
|
$data .= '<td>'.$pubkeyShort.'...</td>';
|
|
|
|
$data .= '<td>'.$row['quantite'].'</td>';
|
|
|
|
$data .= '<td>'.$prix.'</td>';
|
2019-11-19 23:09:14 +01:00
|
|
|
if ($row['username'] == $nom_connecte ) {
|
2019-11-09 23:23:19 +01:00
|
|
|
$data .= '<td>';
|
|
|
|
$data .= '<button onclick="GetRecherchesDetails(\'';
|
|
|
|
$data .= $row['id'];
|
|
|
|
$data .= "'";
|
|
|
|
$data .= ',';
|
|
|
|
$data .= "'$antenne_slug'";
|
|
|
|
$data .= ",'";
|
|
|
|
$data .= $row['image'];
|
|
|
|
$data .= "'";
|
|
|
|
$data .= ')" class=\'btn btn-primary\'';
|
|
|
|
$data .= '>Modifier';
|
|
|
|
$data .= '</button>';
|
|
|
|
$data .= '</td><td>';
|
|
|
|
$data .= '<button onclick="DeleteRecherches(\'';
|
|
|
|
$data .= $row['id'];
|
|
|
|
$data .= "'";
|
|
|
|
$data .= ',';
|
|
|
|
$data .= "'$antenne_slug'";
|
|
|
|
$data .= ",'";
|
|
|
|
$data .= $row['image'];
|
|
|
|
$data .= "'";
|
|
|
|
$data .= ')" class=\'btn btn-danger\'';
|
|
|
|
$data .= '>Supprimer</button>';
|
|
|
|
$data .= '</td>';
|
|
|
|
} else {
|
|
|
|
if ($affich_actions) {
|
|
|
|
$data .= '<td></td><td></td>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$data .= '</tr>';
|
|
|
|
$number++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Il n'y a pas encore de biens/services recherchés saisis
|
|
|
|
$data .= "<tr style='background-color:lightblue;text-align:left;color:black;'><td colspan='10'>Aucun enregistrement saisi</td></tr>";
|
|
|
|
}
|
|
|
|
$data .= '</table>';
|
|
|
|
echo $data;
|
2019-09-26 23:40:22 +02:00
|
|
|
?>
|