Remise des popups de mise à jour et création des biens/services(produits)
parent
a0fd572948
commit
9cc2d4ca16
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
$host = '';
|
||||
$username = '';
|
||||
$password = '';
|
||||
$database_name = '';
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
$host = 'localhost';
|
||||
$username = 'guser';
|
||||
$password = 'kptgT81U7nzYWHBdQ9';
|
||||
$database_name = 'gmarche';
|
|
@ -15,11 +15,10 @@ use Framework\Twig\{
|
|||
|
||||
return [
|
||||
'env' => \DI\env('ENV', 'production'),
|
||||
/*'env' => \DI\env('ENV', 'development'),*/
|
||||
'database.host' => 'localhost',
|
||||
'database.username' => 'root',
|
||||
'database.host' => '',
|
||||
'database.username' => '',
|
||||
'database.password' => '',
|
||||
'database.name' => 'gmarche',
|
||||
'database.name' => '',
|
||||
'views.path' => dirname(__DIR__) . '/views',
|
||||
'twig.extensions' => [
|
||||
\DI\get(RouterTwigExtension::class),
|
||||
|
@ -50,4 +49,4 @@ return [
|
|||
'mail.to' => 'admin@gmarche-testmail.com',
|
||||
'mail.from' => 'no-reply@admin.fr',
|
||||
Swift_Mailer::class => \DI\factory(\Framework\SwiftMailerFactory::class)
|
||||
];
|
||||
];
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
if(isset($_POST['produit']) && isset($_POST['vendeur']) && isset($_POST['cle_pub']))
|
||||
{
|
||||
// include Database connection file
|
||||
include("db_connection.php");
|
||||
|
||||
// get values
|
||||
$produit = $_POST['produit'];
|
||||
$vendeur = $_POST['vendeur'];
|
||||
$cle_pub = $_POST['cle_pub'];
|
||||
$prix = $_POST['prix'];
|
||||
|
||||
$query = "INSERT INTO produits(produit, vendeur, cle_pub, prix) VALUES('$produit', '$vendeur', '$cle_pub', $prix)";
|
||||
if (!$result = mysqli_query($db,$query)) {
|
||||
exit(mysqli_connect_error());
|
||||
}
|
||||
echo "1 enregistrement ajouté !";
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
if(isset($_POST['produit_r']) && isset($_POST['vendeur_r']) && isset($_POST['cle_pub_r']))
|
||||
{
|
||||
// include Database connection file
|
||||
include("db_connection.php");
|
||||
|
||||
// get values
|
||||
$produit_r = $_POST['produit_r'];
|
||||
$vendeur_r = $_POST['vendeur_r'];
|
||||
$cle_pub_r = $_POST['cle_pub_r'];
|
||||
$prix_r = $_POST['prix_r'];
|
||||
|
||||
$query = "INSERT INTO recherches(produit, vendeur, cle_pub, prix) VALUES('$produit_r', '$vendeur_r', '$cle_pub_r', $prix_r)";
|
||||
//echo "Query = ".$query."////";
|
||||
//exit;
|
||||
if (!$result = mysqli_query($db,$query)) {
|
||||
exit(mysqli_connect_error());
|
||||
}
|
||||
echo "1 enregistrement ajouté !";
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
include '..\..\config\conf.php';
|
||||
|
||||
if($_POST['id'] !== null)
|
||||
{
|
||||
// Connexion à la base de données
|
||||
$bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password);
|
||||
|
||||
$params['product_id'] = $_POST['id'];
|
||||
|
||||
// Suppression du bien/service
|
||||
$requete = "DELETE FROM products WHERE id = :product_id";
|
||||
|
||||
$stmt = $bdd->prepare($requete);
|
||||
$stmt->execute($params);
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
// check request
|
||||
if(isset($_POST['id_r']) && isset($_POST['id_r']) != "")
|
||||
{
|
||||
// include Database connection file
|
||||
include("db_connection.php");
|
||||
|
||||
// get user id
|
||||
$id_r = $_POST['id_r'];
|
||||
|
||||
// delete User
|
||||
$query = "DELETE FROM recherches WHERE id = '$id_r'";
|
||||
if (!$result = mysqli_query($db,$query)) {
|
||||
exit(mysqli_connect_error());
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
include '..\..\config\conf.php';
|
||||
|
||||
try {
|
||||
|
||||
$bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password);
|
||||
if (isset($_POST['id']) && isset($_POST['id']) != "") {
|
||||
|
||||
$product_id = $_POST['id'];
|
||||
|
||||
// Get Product Details
|
||||
$params["product_id"] = $product_id;
|
||||
|
||||
$requete = "SELECT products.*, users.username
|
||||
FROM products
|
||||
LEFT JOIN users
|
||||
ON users.id = products.user_id
|
||||
WHERE products.id = :product_id";
|
||||
$query = $bdd->prepare($requete);
|
||||
$query->execute($params);
|
||||
$results = array();
|
||||
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
$results = $row;
|
||||
};
|
||||
echo json_encode($results);
|
||||
} else {
|
||||
$response['status'] = 200;
|
||||
$response['message'] = "Invalid Request!";
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo "Erreur : " . $e->getMessage() . "<br/>";
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
// include Database connection file
|
||||
include("db_connection.php");
|
||||
|
||||
// check request
|
||||
if(isset($_POST['id_r']) && isset($_POST['id_r']) != "")
|
||||
{
|
||||
// get Recherches ID
|
||||
$id_r = $_POST['id_r'];
|
||||
|
||||
// Get Recherches Details
|
||||
$query = "SELECT * FROM recherches WHERE id = '$id_r'";
|
||||
if (!$result = mysqli_query($db,$query)) {
|
||||
exit(mysqli_connect_error());
|
||||
}
|
||||
$response = array();
|
||||
if(mysqli_num_rows($result) > 0) {
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$response = $row;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$response['status'] = 200;
|
||||
$response['message'] = "Data not found!";
|
||||
}
|
||||
// display JSON data
|
||||
echo json_encode($response);
|
||||
}
|
||||
else
|
||||
{
|
||||
$response['status'] = 200;
|
||||
$response['message'] = "Invalid Request!";
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
ini_set('display_errors', 0);
|
||||
include '..\..\config\conf.php';
|
||||
$antenne_slug = $_GET['antenne_slug'];
|
||||
|
||||
if ($bdd === null ) {
|
||||
$bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password);
|
||||
}
|
||||
// Design initial table header
|
||||
$data = '<table class="table table-bordered table-striped">
|
||||
<tr style="color: black;">
|
||||
<th>No.</th>
|
||||
<th>Bien / service</th>
|
||||
<th>Vendeur</th>
|
||||
<th>Clé publique</th>
|
||||
<th>Quantité</th>
|
||||
<th>Prix en junes</th>
|
||||
<th colspan="2" style="text-align: center;">Actions</th>
|
||||
</tr>';
|
||||
|
||||
$params["antenne_slug"] = $antenne_slug;
|
||||
$requete = "SELECT products.*, users.username
|
||||
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);
|
||||
$stmt->execute($params);
|
||||
$count = $stmt->rowCount();
|
||||
|
||||
if ($count > 0)
|
||||
{
|
||||
$number = 1;
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
$data .= "<tr style='background:lightblue;color:black;'>
|
||||
<td>$number</td>";
|
||||
|
||||
$data .= '<td>'.$row['name'].'</td>';
|
||||
$data .= '<td>'.$row['username'].'</td>';
|
||||
$data .= '<td>'.$row['cle_pub'].'</td>';
|
||||
$data .= '<td>'.$row['quantite'].'</td>';
|
||||
$data .= '<td>'.$row['prix'].'</td>';
|
||||
$data .= '<td>';
|
||||
$data .= '<button onclick="GetProduitsDetails(\'';
|
||||
$data .= $row['id'];
|
||||
$data .= "'";
|
||||
$data .= ',';
|
||||
$data .= "'$antenne_slug'";
|
||||
$data .= ')" class=\'btn btn-primary\'';
|
||||
$data .= '>Mettre à jour';
|
||||
$data .= '</button>';
|
||||
$data .= '</td><td>';
|
||||
$data .= '<button onclick="DeleteProduits(\'';
|
||||
$data .= $row['id'];
|
||||
$data .= "'";
|
||||
$data .= ',';
|
||||
$data .= "'$antenne_slug'";
|
||||
$data .= ')" class=\'btn btn-danger\'';
|
||||
$data .= '>Supprimer</button>';
|
||||
$data .= '</td>';
|
||||
$data .= '</tr>';
|
||||
|
||||
$number++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Il n'y a pas encore de biens/services saisis
|
||||
$data .= "<tr style='color:white;'><td colspan='6'>Pas d'enregistrement</td></tr>";
|
||||
}
|
||||
|
||||
$data .= '</table>';
|
||||
|
||||
echo $data;
|
||||
?>
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
// include Database connection file
|
||||
include("db_connection.php");
|
||||
|
||||
// Design initial table header
|
||||
$data = '<table class="table table-bordered table-striped">
|
||||
<tr style="color: black;">
|
||||
<th>No.</th>
|
||||
<th>Bien ou service recherché</th>
|
||||
<th>Acheteur</th>
|
||||
<th>Clé publique</th>
|
||||
<th>Prix en junes</th>
|
||||
<th>Mise à jour</th>
|
||||
<th>Suppression</th>
|
||||
</tr>';
|
||||
|
||||
$query = "SELECT * FROM recherches";
|
||||
|
||||
if (!$result = mysqli_query($db,$query)) {
|
||||
exit(mysqli_connect_error());
|
||||
}
|
||||
|
||||
// if query results contains rows then fetch those rows
|
||||
if(mysqli_num_rows($result) > 0)
|
||||
{
|
||||
$number = 1;
|
||||
while($row = mysqli_fetch_assoc($result))
|
||||
{
|
||||
$data .= '<tr style="background:lightblue;color:black;">
|
||||
<td>'.$number.'</td>
|
||||
<td>'.$row['produit'].'</td>
|
||||
<td>'.$row['vendeur'].'</td>
|
||||
<td>'.$row['cle_pub'].'</td>
|
||||
<td>'.$row['prix'].'</td>
|
||||
<td>
|
||||
<button onclick="GetRecherchesDetails('.$row['id'].')" class="btn btn-warning">Mettre à jour</button>
|
||||
</td>
|
||||
<td>
|
||||
<button onclick="DeleteRecherches('.$row['id'].')" class="btn btn-danger">Supprimer</button>
|
||||
</td>
|
||||
</tr>';
|
||||
$number++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// records now found
|
||||
$data .= "<tr style='color:white;'><td colspan='6'>Pas d'enregistrement</td></tr>";
|
||||
}
|
||||
|
||||
$data .= '</table>';
|
||||
|
||||
echo $data;
|
||||
?>
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
include '..\..\config\conf.php';
|
||||
|
||||
$bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password);
|
||||
// check request
|
||||
if(isset($_POST))
|
||||
{
|
||||
// get values
|
||||
|
||||
$params["id"] = $_POST['id'];
|
||||
$name = $_POST['produit'];
|
||||
$quantite = $_POST['quantite'];
|
||||
$prix = $_POST['prix'];
|
||||
// Update Products details
|
||||
|
||||
$requete = "UPDATE products SET name = '$name', quantite = '$quantite', prix = $prix WHERE id = :id";
|
||||
$query = $bdd->prepare($requete);
|
||||
$query->execute($params);
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
// include Database connection file
|
||||
include("db_connection.php");
|
||||
|
||||
// check request
|
||||
if(isset($_POST))
|
||||
{
|
||||
// get values
|
||||
$id_r = $_POST['id_r'];
|
||||
$produit_r = $_POST['produit_r'];
|
||||
$vendeur_r = $_POST['vendeur_r'];
|
||||
$cle_pub_r = $_POST['cle_pub_r'];
|
||||
$prix_r = $_POST['prix_r'];
|
||||
// Updaste User details
|
||||
|
||||
$query = "UPDATE recherches SET produit = '$produit_r', vendeur = '$vendeur_r', cle_pub = '$cle_pub_r', prix = $prix_r WHERE id = '$id_r'";
|
||||
if (!$result = mysqli_query($db,$query)) {
|
||||
exit(mysqli_connect_error());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,195 @@
|
|||
// Add Record
|
||||
function addRecord() {
|
||||
// get values
|
||||
var produit = $("#produit").val();
|
||||
var vendeur = $("#vendeur").val();
|
||||
var cle_pub = $("#cle_pub").val();
|
||||
var prix = $("#prix").val();
|
||||
// Add record
|
||||
$.post("ajax/addRecord.php", {
|
||||
produit: produit,
|
||||
vendeur: vendeur,
|
||||
cle_pub: cle_pub,
|
||||
prix: prix
|
||||
}, function (data, status) {
|
||||
// close the popup
|
||||
$("#add_new_record_modal").modal("hide");
|
||||
|
||||
// read records again
|
||||
readRecords();
|
||||
|
||||
// clear fields from the popup
|
||||
$("#produit").val("");
|
||||
$("#vendeur").val("");
|
||||
$("#cle_pub").val("");
|
||||
$("#prix").val("");
|
||||
});
|
||||
}
|
||||
|
||||
function addRecord2() {
|
||||
// get values
|
||||
var produit_r = $("#produit_r").val();
|
||||
var vendeur_r = $("#vendeur_r").val();
|
||||
var cle_pub_r = $("#cle_pub_r").val();
|
||||
var prix_r = $("#prix_r").val();
|
||||
// Add record
|
||||
$.post("ajax/addRecord2.php", {
|
||||
produit_r: produit_r,
|
||||
vendeur_r: vendeur_r,
|
||||
cle_pub_r: cle_pub_r,
|
||||
prix_r: prix_r
|
||||
}, function (data, status) {
|
||||
// close the popup
|
||||
$("#add_new_record_modal2").modal("hide");
|
||||
|
||||
// read records again
|
||||
readRecords2();
|
||||
|
||||
// clear fields from the popup
|
||||
$("#produit_r").val("");
|
||||
$("#vendeur_r").val("");
|
||||
$("#cle_pub_r").val("");
|
||||
$("#prix_r").val("");
|
||||
});
|
||||
}
|
||||
|
||||
// READ records
|
||||
function readRecords(antenne_slug) {
|
||||
$.get("/ajax/readRecords.php", {
|
||||
antenne_slug: antenne_slug
|
||||
}, function (data, status) {
|
||||
$(".records_content").html(data);
|
||||
});
|
||||
}
|
||||
// READ records2
|
||||
function readRecords2() {
|
||||
$.get("ajax/readRecords2.php", {}, function (data, status) {
|
||||
$(".records_content2").html(data);
|
||||
});
|
||||
}
|
||||
|
||||
function DeleteProduits(id, antenne_slug) {
|
||||
$("#hidden_antenne_slug").val(antenne_slug);
|
||||
var conf = confirm("Etes-vous sûr(e) de vouloir supprimer ce bien ou service ?");
|
||||
if (conf == true) {
|
||||
$.post("/ajax/deleteProduits.php", {
|
||||
id: id
|
||||
},
|
||||
function (data, status) {
|
||||
// Rechargement de la liste Biens/services
|
||||
readRecords(antenne_slug);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
function DeleteRecherches(id) {
|
||||
var conf = confirm("Etes-vous sûr(e) de vouloir supprimer ce bien ou service ?");
|
||||
if (conf == true) {
|
||||
$.post("ajax/deleteRecherches.php", {
|
||||
id_r: id
|
||||
},
|
||||
function (data, status) {
|
||||
// reload Recherches by using readRecords2();
|
||||
readRecords2();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
function GetProduitsDetails(id, antenne_slug) {
|
||||
// Add Products ID to the hidden field for future usage
|
||||
$("#hidden_user_id").val(id);
|
||||
$("#hidden_antenne_slug").val(antenne_slug);
|
||||
$.post("/ajax/readProduitsDetails.php", {
|
||||
id: id
|
||||
},
|
||||
function (data, status) {
|
||||
|
||||
var produit = JSON.parse(data);
|
||||
// Assign existing values to the modal popup fields
|
||||
$("#update_produit").val(produit.name);
|
||||
$("#update_vendeur").val(produit.username);
|
||||
$("#update_quantite").val(produit.quantite);
|
||||
$("#update_prix").val(produit.prix);
|
||||
}
|
||||
);
|
||||
// Open modal popup
|
||||
$("#update_user_modal").modal("show");
|
||||
}
|
||||
function GetRecherchesDetails(id) {
|
||||
// Add Recherches ID to the hidden field for future usage
|
||||
$("#hidden_user_id_r").val(id);
|
||||
$.post("ajax/readRecherchesDetails.php", {
|
||||
id_r: id
|
||||
},
|
||||
function (data, status) {
|
||||
// PARSE json data
|
||||
var produit = JSON.parse(data);
|
||||
// Assign existing values to the modal popup fields
|
||||
$("#update_produit_r").val(produit.produit);
|
||||
$("#update_vendeur_r").val(produit.vendeur);
|
||||
$("#update_cle_pub_r").val(produit.cle_pub);
|
||||
$("#update_prix_r").val(produit.prix);
|
||||
}
|
||||
);
|
||||
// Open modal popup
|
||||
$("#update_user_modal2").modal("show");
|
||||
}
|
||||
function UpdateProduitsDetails() {
|
||||
// get values
|
||||
var produit = $("#update_produit").val();
|
||||
//var vendeur = $("#update_vendeur").val();
|
||||
var quantite = $("#update_quantite").val();
|
||||
var prix = $("#update_prix").val();
|
||||
// get hidden field value
|
||||
var id = $("#hidden_user_id").val();
|
||||
var antenne_slug = $("#hidden_antenne_slug").val();
|
||||
// Update the details by requesting to the server using ajax
|
||||
$.post("/ajax/updateProduitsDetails.php", {
|
||||
id: id,
|
||||
produit: produit,
|
||||
quantite: quantite,
|
||||
prix: prix
|
||||
},
|
||||
function (data, status) {
|
||||
// hide modal popup
|
||||
$("#update_user_modal").modal("hide");
|
||||
// reload Produits by using readRecords();
|
||||
readRecords(antenne_slug);
|
||||
}
|
||||
);
|
||||
}
|
||||
function UpdateRecherchesDetails() {
|
||||
// get values
|
||||
var produit = $("#update_produit_r").val();
|
||||
var vendeur = $("#update_vendeur_r").val();
|
||||
var cle_pub = $("#update_cle_pub_r").val();
|
||||
var prix = $("#update_prix_r").val();
|
||||
// get hidden field value
|
||||
var id = $("#hidden_user_id_r").val();
|
||||
|
||||
// Update the details by requesting to the server using ajax
|
||||
$.post("ajax/updateRecherchesDetails.php", {
|
||||
id_r: id,
|
||||
produit_r: produit,
|
||||
vendeur_r: vendeur,
|
||||
cle_pub_r: cle_pub,
|
||||
prix_r: prix
|
||||
},
|
||||
function (data, status) {
|
||||
// hide modal popup
|
||||
$("#update_user_modal2").modal("hide");
|
||||
// reload Recherches by using readRecords2();
|
||||
readRecords2();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
// On récupère le nom de l'antenne dans l'url pour afficher les biens/services de celle-ci
|
||||
var url = document.location.href;
|
||||
var antenne_slug = url.split('/')[5];
|
||||
|
||||
// READ records on page load
|
||||
readRecords(antenne_slug);
|
||||
//readRecords2();
|
||||
});
|
|
@ -49,11 +49,7 @@ class AntenneShowAction
|
|||
$slug = $request->getAttribute('slug');
|
||||
$page = $params['p'] ?? 1; // Si la page n'est pas définie, on l'initialise à 1
|
||||
$antennes = $this->antenneTable->findAllbyRegion($region_id)->paginate(10, $page);
|
||||
//echo "Antennes1=";
|
||||
//var_dump($this->antenneTable->findAllbyRegion($region_id));
|
||||
//echo "<br /><br /><br />Antennes=";
|
||||
//var_dump($antennes);
|
||||
//die();
|
||||
|
||||
$region=$this->regionTable->findBy('slug', $request->getAttribute('slug'));
|
||||
$antenne = 1;
|
||||
/*if ($region->slug !== $slug) {
|
||||
|
|
|
@ -42,24 +42,4 @@ class ProductTable extends Table
|
|||
->where("$field = $value" )
|
||||
->order('p.created_at DESC');
|
||||
}
|
||||
/* public function findPublic(): Query
|
||||
{
|
||||
return $this->makeQuery()
|
||||
->where('created_at < NOW()');
|
||||
}
|
||||
public function findPaginatedProduct(string $table, int $perPage, int $currentPage): Pagerfanta
|
||||
{
|
||||
$query = new PaginatedQuery(
|
||||
$this->pdo,
|
||||
"SELECT *
|
||||
FROM {$this->table}
|
||||
ORDER BY name ASC",
|
||||
"SELECT COUNT(id) FROM {$this->table}",
|
||||
$this->entity
|
||||
);
|
||||
return (new Pagerfanta($query))
|
||||
->setMaxPerPage($perPage)
|
||||
->setCurrentPage($currentPage);
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
{% extends 'layout.twig' %}
|
||||
{% block title "Ğ1-Marché - Produits" %}
|
||||
|
||||
|
@ -42,6 +43,7 @@
|
|||
padding-right: 2rem;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" src="/js/script.js"></script>
|
||||
<div id="la_page">
|
||||
<div class="label" style="background-color: white;">
|
||||
<h4>G-Marché de : {{ antenne_name }}</h4>
|
||||
|
@ -52,13 +54,95 @@
|
|||
</script>
|
||||
{% endif %}
|
||||
|
||||
<p class="text-right">
|
||||
<a href="{{ path(routePrefix ~ '.create',{region: explodeUrl()[2], slug: explodeUrl()[3], antenne: explodeUrl()[4]} )}}" class="btn btn-primary">
|
||||
Ajouter un produit
|
||||
</a>
|
||||
{{ items[name] }}
|
||||
</p>
|
||||
<table style="padding:0.15rem;" class="table-striped tableau">
|
||||
<div class="container">
|
||||
<div class="row" style="text-align: left;">
|
||||
<div class="col-md-12">
|
||||
<p class="text-right">
|
||||
<!--<a href="crochet crochet path(routePrefix ~ '.create',{region: explodeUrl()[2], slug: explodeUrl()[3], antenne: explodeUrl()[4]} )}}" class="btn btn-primary">-->
|
||||
<button style="color:black;" class="btn btn-success" data-toggle="modal" data-target="#add_new_record_modal">Ajouter un bien ou service à proposer
|
||||
</button>
|
||||
<!--</a>-->
|
||||
</p>
|
||||
<div class="records_content"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="add_new_record_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
<div class="modal-dialog" role="document" style="color: black;">
|
||||
<div class="modal-content" style="text-align: left;">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="myModalLabel">Ajouter une ligne</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="produit">Bien ou service</label>
|
||||
<input type="text" id="produit" placeholder="Bien ou service" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="vendeur">Vendeur</label>
|
||||
<input type="text" id="vendeur" placeholder="Vendeur" class="form-control"/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="cle_pub">Clé publique</label>
|
||||
<input type="text" id="cle_pub" placeholder="Clé publique" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group has-error has-feedback">
|
||||
<label for="prix">Prix en junes</label>
|
||||
<input type="number" id="prix" placeholder="prix" class="form-control"/>
|
||||
</div>
|
||||
<div class="alert alert-block alert-danger" style="display:none">
|
||||
<h4>Erreur !</h4>
|
||||
Vous devez entrer un nombre !
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
|
||||
<button type="button" class="btn btn-primary" onclick="addRecord()">Ajouter</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="update_user_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
<div class="modal-dialog" role="document" style="color: black;">
|
||||
<div class="modal-content" style="text-align: left;">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="myModalLabel">Mettre à jour</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="update_produit">Bien ou service</label>
|
||||
<input type="text" id="update_produit" placeholder="Bien ou service proposé" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="update_vendeur">Vendeur</label>
|
||||
<input type="input" disabled="disabled" id="update_vendeur" placeholder="Vendeur" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group has-error has-feedback">
|
||||
<label for="update_quantite">Quantité</label>
|
||||
<input type="text" id="update_quantite" placeholder="Quantité" class="form-control"/>
|
||||
</div>
|
||||
<div class="form-group has-error has-feedback">
|
||||
<label for="update_prix">Prix en junes</label>
|
||||
<input type="number" id="update_prix" placeholder="prix" class="form-control"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
|
||||
<button type="button" class="btn btn-primary" onclick="UpdateProduitsDetails()" >Sauvegarder</button>
|
||||
<input type="hidden" id="hidden_user_id">
|
||||
<input type="hidden" id="hidden_antenne_slug">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <table style="padding:0.15rem;" class="table-striped tableau">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:8rem;">Produit</th>
|
||||
|
@ -71,45 +155,9 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% set token_input = csrf_input %}
|
||||
<!--crochet% set token_input = csrf_input %crochet-->
|
||||
|
||||
{% for item in items %}
|
||||
<tr>
|
||||
<td>{{ item.name }}</td>
|
||||
<td class="colonne_image" style="width:80px;"> {% if item.image %}
|
||||
<img src="{{ item.thumb }}" alt="" style="width:100%; height:auto;">
|
||||
{% endif %}
|
||||
</td>
|
||||
<td> {{ item.username }}</td>
|
||||
<td class="align_droite"> {{ item.quantite }} </td>
|
||||
<td class="align_droite"> {{ item.prix }} </td>
|
||||
<td> {{ item.strUpdatedAt }} </td>
|
||||
<td>
|
||||
{% if current_user().id == item.userId %}
|
||||
<a href="{{ path('product.admin.edit', {id: item.id, region: explodeUrl()[2], slug: explodeUrl()[3], antenne: explodeUrl()[4]}) }}" class="btn btn-primary">Editer</a>
|
||||
{% else %}
|
||||
<button class="btn btn-disabled">Acheter</button>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if current_user().id == item.userId %}
|
||||
<form style="display: inline;height:50px;" action="{{ path(routePrefix ~ '.delete', {id: item.id, region: explodeUrl()[2], slug: explodeUrl()[3], antenne: explodeUrl()[4]}) }}" method="POST" onsubmit="return confirm('Êtes-vous sûr ?')">
|
||||
<input type="hidden" name="_method" value="DELETE">
|
||||
<button class="btn btn-danger" style="position:relative;top:43px;">Supprimer</button>
|
||||
{{ field('antenne_id', explodeUrl()[4], "", {type: 'hidden'}) }}
|
||||
{{ field('produit_name', item.name, "", {type: 'hidden'}) }}
|
||||
{{ token_input | raw }}
|
||||
</form>
|
||||
{% else %}
|
||||
<button class="btn btn-disabled">Supprimer</button><!-- On ne peut supprimer les produits des autres -->
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{ paginate(items, routePrefix ~ '.index', {id: item.id, region: explodeUrl()[2], slug: explodeUrl()[3], antenne: explodeUrl()[4]}) }}
|
||||
<!-- paginate(items, routePrefix ~ '.index', {id: item.id, region: explodeUrl()[2], slug: explodeUrl()[3], antenne: explodeUrl()[4]}) -->
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -58,13 +58,8 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- if flash('error')
|
||||
<div class="alert alert-danger">
|
||||
flash('error')
|
||||
</div>
|
||||
endif -->
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
|
||||
|
||||
<!--<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>-->
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
|
||||
{% block body %}{% endblock %}
|
||||
|
||||
</div><!-- /.container -->
|
||||
|
|
Loading…
Reference in New Issue