requete pour retourner point de vente
This commit is contained in:
parent
5ad019d35e
commit
99d570bd3a
@ -806,12 +806,24 @@ class AppDatabase {
|
||||
|
||||
Future<List<Commande>> getCommandes() async {
|
||||
final db = await database;
|
||||
|
||||
final result = await db.query('''
|
||||
SELECT c.*, cl.nom as clientNom, cl.prenom as clientPrenom, cl.email as clientEmail
|
||||
SELECT
|
||||
c.*,
|
||||
cl.nom as clientNom,
|
||||
cl.prenom as clientPrenom,
|
||||
cl.email as clientEmail,
|
||||
u.nom as commandeurNom,
|
||||
u.prenom as commandeurPrenom,
|
||||
pdv.nom as pointDeVenteNom,
|
||||
pdv.id as pointDeVenteId
|
||||
FROM commandes c
|
||||
LEFT JOIN clients cl ON c.clientId = cl.id
|
||||
LEFT JOIN users u ON c.commandeurId = u.id
|
||||
LEFT JOIN points_de_vente pdv ON u.point_de_vente_id = pdv.id
|
||||
ORDER BY c.dateCommande DESC
|
||||
''');
|
||||
|
||||
return result.map((row) => Commande.fromMap(row.fields)).toList();
|
||||
}
|
||||
|
||||
@ -1464,7 +1476,8 @@ class AppDatabase {
|
||||
commandeMap['clientId'] = clientId;
|
||||
|
||||
final commandeFields = commandeMap.keys.join(', ');
|
||||
final commandePlaceholders = List.filled(commandeMap.length, '?').join(', ');
|
||||
final commandePlaceholders =
|
||||
List.filled(commandeMap.length, '?').join(', ');
|
||||
|
||||
final commandeResult = await db.query(
|
||||
'INSERT INTO commandes ($commandeFields) VALUES ($commandePlaceholders)',
|
||||
@ -1479,7 +1492,8 @@ class AppDatabase {
|
||||
detailMap['commandeId'] = commandeId;
|
||||
|
||||
final detailFields = detailMap.keys.join(', ');
|
||||
final detailPlaceholders = List.filled(detailMap.length, '?').join(', ');
|
||||
final detailPlaceholders =
|
||||
List.filled(detailMap.length, '?').join(', ');
|
||||
|
||||
await db.query(
|
||||
'INSERT INTO details_commandes ($detailFields) VALUES ($detailPlaceholders)',
|
||||
@ -1500,8 +1514,7 @@ class AppDatabase {
|
||||
print("Erreur lors de la création de la commande complète: $e");
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Méthode pour mettre à jour un détail de commande (utile pour modifier les remises)
|
||||
Future<int> updateDetailCommande(DetailCommande detail) async {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user