2019-09-26 23:40:22 +02:00
|
|
|
<?php
|
2019-11-09 23:23:19 +01:00
|
|
|
ini_set('display_errors', 0);
|
|
|
|
include '../../config/conf.php';
|
|
|
|
$antenne_slug = $_GET['antenne_slug'];
|
|
|
|
$nom_connecte = $_GET['nom_connecte'];
|
|
|
|
$bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password);
|
2019-11-04 23:26:02 +01: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</th>
|
|
|
|
<th>Photo</th>
|
|
|
|
<th>Vendeur</th>
|
|
|
|
<th>Clé publique</th>
|
|
|
|
<th>Quantité</th>
|
|
|
|
<th>Prix en junes</th>';
|
2019-09-26 23:40:22 +02:00
|
|
|
|
|
|
|
$params["antenne_slug"] = $antenne_slug;
|
2019-11-19 00:59:03 +01:00
|
|
|
$requete = "SELECT products.*, users.username, users.pubkey
|
2019-09-26 23:40:22 +02:00
|
|
|
FROM products
|
|
|
|
LEFT JOIN antennes
|
|
|
|
ON antennes.id = products.antenne_id
|
|
|
|
LEFT JOIN users
|
|
|
|
ON users.id = products.user_id
|
|
|
|
WHERE antennes.slug = :antenne_slug";
|
|
|
|
$stmt = $bdd->prepare($requete);
|
2019-11-04 23:26:02 +01:00
|
|
|
$stmt2 = $bdd->prepare($requete);
|
2019-09-26 23:40:22 +02:00
|
|
|
$stmt->execute($params);
|
2019-11-04 23:26:02 +01:00
|
|
|
$stmt2->execute($params);
|
2019-09-26 23:40:22 +02:00
|
|
|
$count = $stmt->rowCount();
|
2019-11-09 23:23:19 +01:00
|
|
|
$affich_actions = false;
|
2019-11-04 23:26:02 +01:00
|
|
|
while ($row2 = $stmt2->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
if ($row2['username'] == $nom_connecte) {
|
|
|
|
$affich_actions = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($affich_actions) {
|
|
|
|
$data .= '<th colspan="2" style="text-align: center;">Actions</th>';
|
|
|
|
$data .= '</tr>';
|
|
|
|
} else {
|
|
|
|
$data .= '</tr>';
|
|
|
|
}
|
2019-09-26 23:40:22 +02:00
|
|
|
if ($count > 0)
|
|
|
|
{
|
|
|
|
$number = 1;
|
|
|
|
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
|
|
|
|
|
|
$data .= "<tr style='background:lightblue;color:black;'>
|
2019-11-09 23:23:19 +01:00
|
|
|
<td>$number</td>";
|
2019-11-08 00:43:00 +01:00
|
|
|
$prix = $row['prix'];
|
|
|
|
$vendeur = $row['username'];
|
2019-11-19 00:59:03 +01:00
|
|
|
$status = $row['status'];
|
|
|
|
if ($status == "solde") {
|
2019-11-19 17:44:36 +01:00
|
|
|
$produit = "[Vendu] ";
|
2019-11-19 00:59:03 +01:00
|
|
|
} else {
|
|
|
|
$produit = "";
|
|
|
|
}
|
|
|
|
$produit .= $row['name'];
|
2019-11-08 00:43:00 +01:00
|
|
|
$pubkey = $row['pubkey'];
|
|
|
|
$pubkeyShort = substr($pubkey, 0, 8);
|
2019-11-08 01:25:31 +01:00
|
|
|
$vendeur_format = "<a target=\"_blank\" href=\"https://g1.duniter.fr/#/app/wot/$pubkey/\">$vendeur</a>";
|
2019-11-08 04:06:39 +01:00
|
|
|
$cle_pub_format = "<a target=\"_blank\" href=\"https://g1.duniter.fr/api/#/v1/payment/$pubkey?amount=$prix&name=$vendeur&comment=[Achat GMarche] : $produit&preferred_node=https://g1.librelois.fr&redirect_url=https://gmarche.monnaie-libre.fr\" title=$pubkey> $pubkeyShort... </a>";
|
2019-11-08 00:43:00 +01:00
|
|
|
$data .= '<td>'.$produit.'</td>';
|
2019-10-15 00:09:23 +02:00
|
|
|
$data .= '<td><img src="/uploads/products/'.$antenne_slug.'/'.$row['image'].'" width="100" height="100" /></td>';
|
2019-11-08 01:25:31 +01:00
|
|
|
$data .= '<td>'.$vendeur_format.'</td>';
|
|
|
|
$data .= '<td>'.$cle_pub_format.'</td>';
|
2019-09-26 23:40:22 +02:00
|
|
|
$data .= '<td>'.$row['quantite'].'</td>';
|
2019-11-08 00:43:00 +01:00
|
|
|
$data .= '<td>'.$prix.'</td>';
|
2019-11-09 23:23:19 +01:00
|
|
|
if ($row['username'] == $_GET['nom_connecte'] ) {
|
2019-11-04 23:26:02 +01:00
|
|
|
$data .= '<td>';
|
|
|
|
$data .= '<button onclick="GetProduitsDetails(\'';
|
|
|
|
$data .= $row['id'];
|
|
|
|
$data .= "'";
|
|
|
|
$data .= ',';
|
|
|
|
$data .= "'$antenne_slug'";
|
|
|
|
$data .= ",'";
|
|
|
|
$data .= $row['image'];
|
|
|
|
$data .= "'";
|
2019-09-28 02:20:10 +02:00
|
|
|
$data .= ')" class=\'btn btn-primary\'';
|
2019-11-04 23:26:02 +01:00
|
|
|
$data .= '>Modifier';
|
|
|
|
$data .= '</button>';
|
2019-11-09 23:23:19 +01:00
|
|
|
$data .= '</td><td>';
|
2019-11-04 23:26:02 +01:00
|
|
|
$data .= '<button onclick="DeleteProduits(\'';
|
|
|
|
$data .= $row['id'];
|
|
|
|
$data .= "'";
|
|
|
|
$data .= ',';
|
|
|
|
$data .= "'$antenne_slug'";
|
|
|
|
$data .= ",'";
|
|
|
|
$data .= $row['image'];
|
|
|
|
$data .= "'";
|
|
|
|
$data .= ')" class=\'btn btn-danger\'';
|
2019-11-09 23:23:19 +01:00
|
|
|
$data .= '>Supprimer</button>';
|
|
|
|
$data .= '</td>';
|
|
|
|
} else {
|
2019-11-04 23:26:02 +01:00
|
|
|
if ($affich_actions) {
|
|
|
|
$data .= '<td></td><td></td>';
|
|
|
|
}
|
2019-11-09 23:23:19 +01:00
|
|
|
}
|
2019-09-26 23:40:22 +02:00
|
|
|
$data .= '</tr>';
|
2019-11-09 23:23:19 +01:00
|
|
|
$number++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Il n'y a pas encore de biens/services saisis
|
|
|
|
$data .= "<tr style='background-color:lightblue;text-align:left;color:black;'><td colspan='10'>Aucun enregistrement saisi</td></tr>";
|
2019-09-26 23:40:22 +02:00
|
|
|
}
|
|
|
|
$data .= '</table>';
|
|
|
|
echo $data;
|
|
|
|
?>
|