Browse Source

commit de 28072025_02

28062025_02
andrymodeste 4 months ago
parent
commit
f41fc922a6
  1. 88
      lib/Services/stock_managementDatabase.dart
  2. 12
      lib/Views/HandleProduct.dart
  3. 54
      lib/Views/commandManagement.dart
  4. 2
      lib/Views/historique.dart
  5. 6
      lib/Views/historique_sorties_personnelles_page.dart
  6. 4
      lib/config/DatabaseConfig.dart
  7. 48
      pubspec.lock
  8. 1
      pubspec.yaml

88
lib/Services/stock_managementDatabase.dart

@ -3163,54 +3163,60 @@ Future<double> getValeurTotaleStock() async {
return [];
}
}
Future<List<Map<String, dynamic>>> getHistoriqueSortiesPersonnelles({
int? adminId,
String? statut,
int? pointDeVenteId,
int limit = 50,
}) async {
final db = await database;
Future<List<Map<String, dynamic>>> getHistoriqueSortiesPersonnelles({
int? adminId,
String? statut,
int limit = 50,
}) async {
final db = await database;
try {
String whereClause = '';
List<dynamic> params = [];
try {
String whereClause = '';
List<dynamic> params = [];
// Filtre par point de vente seulement si pointDeVenteId n'est pas null
// (null signifie que l'utilisateur a pointDeVenteId = 0 et peut tout voir)
if (pointDeVenteId != null) {
whereClause = 'WHERE sp.point_de_vente_id = ?';
params.add(pointDeVenteId);
}
if (adminId != null) {
whereClause = 'WHERE sp.admin_id = ?';
params.add(adminId);
}
if (adminId != null) {
whereClause += (whereClause.isEmpty ? 'WHERE' : ' AND') + ' sp.admin_id = ?';
params.add(adminId);
}
if (statut != null) {
whereClause +=
(whereClause.isEmpty ? 'WHERE' : ' AND') + ' sp.statut = ?';
params.add(statut);
}
if (statut != null) {
whereClause += (whereClause.isEmpty ? 'WHERE' : ' AND') + ' sp.statut = ?';
params.add(statut);
}
final result = await db.query('''
SELECT sp.*,
p.name as produit_nom,
p.reference as produit_reference,
u_admin.name as admin_nom,
u_admin.lastname as admin_nom_famille,
u_approb.name as approbateur_nom,
u_approb.lastname as approbateur_nom_famille,
pv.nom as point_vente_nom
FROM sorties_stock_personnelles sp
JOIN products p ON sp.produit_id = p.id
JOIN users u_admin ON sp.admin_id = u_admin.id
LEFT JOIN users u_approb ON sp.approbateur_id = u_approb.id
LEFT JOIN points_de_vente pv ON sp.point_de_vente_id = pv.id
$whereClause
ORDER BY sp.date_sortie DESC
LIMIT ?
''', [...params, limit]);
final result = await db.query('''
SELECT sp.*,
p.name as produit_nom,
p.reference as produit_reference,
u_admin.name as admin_nom,
u_admin.lastname as admin_nom_famille,
u_approb.name as approbateur_nom,
u_approb.lastname as approbateur_nom_famille,
pv.nom as point_vente_nom
FROM sorties_stock_personnelles sp
JOIN products p ON sp.produit_id = p.id
JOIN users u_admin ON sp.admin_id = u_admin.id
LEFT JOIN users u_approb ON sp.approbateur_id = u_approb.id
LEFT JOIN points_de_vente pv ON sp.point_de_vente_id = pv.id
$whereClause
ORDER BY sp.date_sortie DESC
LIMIT ?
''', [...params, limit]);
return result.map((row) => row.fields).toList();
} catch (e) {
print('Erreur récupération historique sorties: $e');
return [];
}
return result.map((row) => row.fields).toList();
} catch (e) {
print('Erreur récupération historique sorties: $e');
return [];
}
}
Future<Map<String, dynamic>> getStatistiquesSortiesPersonnelles() async {
final db = await database;

12
lib/Views/HandleProduct.dart

@ -1507,7 +1507,13 @@ Future<void> _showDemandeTransfertDialog(Product product) async {
// Valeurs par défaut
normalizedData['description'] = ''; // Description toujours vide
normalizedData['stock'] = 1; // Stock toujours à 1
if (mapping.containsKey('stock')) {
final stockValue = _cleanValue(_getColumnValue(row, mapping, 'stock'));
final stock = int.tryParse(stockValue ?? '0') ?? 1;
normalizedData['stock'] = stock > 0 ? stock : 1;
} else {
normalizedData['stock'] = 1; // Valeur par défaut
}
// Validation des données obligatoires
if (normalizedData['name'] == null || normalizedData['price'] == null) {
@ -1567,6 +1573,9 @@ Future<void> _showDemandeTransfertDialog(Product product) async {
} else if (header == 'PRIX' || header == 'PRICE') {
columnMapping['price'] = i;
print('→ Mappé vers price');
} else if (header == 'STOCK' || header == 'QUANTITY' || header == 'QTE') {
columnMapping['stock'] = i;
print('→ Mappé vers stock');
} else if (header == 'BOUTIQUE' ||
header.contains('POINT DE VENTE') ||
header == 'MAGASIN') {
@ -2175,6 +2184,7 @@ Future<void> _showDemandeTransfertDialog(Product product) async {
'RAM', // ram
'INTERNE', // memoire_interne
'IMEI', // imei
'STOCK'
'PRIX', // price
'BOUTIQUE', // point_de_vente
];

54
lib/Views/commandManagement.dart

@ -636,7 +636,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
children: [
if (detail.estCadeau) ...[
pw.Text(
'${detail.prixUnitaire.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixUnitaire)}',
style: pw.TextStyle(
fontSize: 8,
decoration: pw.TextDecoration.lineThrough,
@ -655,7 +655,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
),
] else if (detail.aRemise) ...[
pw.Text(
'${detail.prixUnitaire.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixUnitaire)}',
style: pw.TextStyle(
fontSize: 8,
decoration: pw.TextDecoration.lineThrough,
@ -664,7 +664,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
)
),
pw.Text(
'${(detail.prixFinal / detail.quantite).toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixFinal / detail.quantite)}',
style: pw.TextStyle(
fontSize: 10,
color: PdfColors.orange700,
@ -709,7 +709,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
),
] else if (detail.aRemise) ...[
pw.Text(
'${detail.sousTotal.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.sousTotal)}',
style: pw.TextStyle(
fontSize: 8,
decoration: pw.TextDecoration.lineThrough,
@ -718,7 +718,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
)
),
pw.Text(
'${detail.prixFinal.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixFinal)}',
style: pw.TextStyle(
fontSize: 10,
fontWeight: pw.FontWeight.bold,
@ -727,7 +727,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
),
] else
pw.Text(
'${detail.prixFinal.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixFinal)}',
style: smallTextStyle
),
],
@ -759,7 +759,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
children: [
pw.Text('SOUS-TOTAL:', style: smallTextStyle),
pw.SizedBox(width: 10),
pw.Text('${sousTotal.toStringAsFixed(0)}', style: smallTextStyle),
pw.Text('${NumberFormat('#,##0', 'fr_FR').format(sousTotal)}', style: smallTextStyle),
],
),
pw.SizedBox(height: 2),
@ -771,7 +771,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
children: [
pw.Text('REMISES:', style: pw.TextStyle(color: PdfColors.orange, fontSize: 10, font: regularFont)),
pw.SizedBox(width: 10),
pw.Text('-${totalRemises.toStringAsFixed(0)}', style: pw.TextStyle(color: PdfColors.orange, fontSize: 10, font: regularFont)),
pw.Text('-${NumberFormat('#,##0', 'fr_FR').format(totalRemises)}', style: pw.TextStyle(color: PdfColors.orange, fontSize: 10, font: regularFont)),
],
),
pw.SizedBox(height: 2),
@ -783,7 +783,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
children: [
pw.Text('CADEAUX ($nombreCadeaux):', style: pw.TextStyle(color: PdfColors.green700, fontSize: 10, font: regularFont)),
pw.SizedBox(width: 10),
pw.Text('-${totalCadeaux.toStringAsFixed(0)}', style: pw.TextStyle(color: PdfColors.green700, fontSize: 10, font: regularFont)),
pw.Text('-${NumberFormat('#,##0', 'fr_FR').format(totalCadeaux)}', style: pw.TextStyle(color: PdfColors.green700, fontSize: 10, font: regularFont)),
],
),
pw.SizedBox(height: 2),
@ -1197,7 +1197,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
pw.Container(
width: 180, height: 1, color: PdfColors.black),
pw.SizedBox(height: 4),
pw.Text('${client?.nom} \n ${client?.prenom}',
pw.Text('${client?.nom} ${client?.prenom}',
style: boldTextStyle),
pw.SizedBox(height: 4),
pw.Text(client?.telephone ?? 'Non spécifié',
@ -1357,7 +1357,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
children: [
if (detail.estCadeau) ...[
pw.Text(
'${detail.prixUnitaire.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixUnitaire)}',
style: pw.TextStyle(
fontSize: 7,
decoration: pw.TextDecoration.lineThrough,
@ -1373,19 +1373,19 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
detail.prixUnitaire !=
detail.sousTotal / detail.quantite) ...[
pw.Text(
'${detail.prixUnitaire.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixUnitaire)}',
style: pw.TextStyle(
fontSize: 7,
decoration: pw.TextDecoration.lineThrough,
color: PdfColors.grey600,
)),
pw.Text(
'${(detail.prixFinal / detail.quantite).toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixFinal / detail.quantite)}',
style: pw.TextStyle(
fontSize: 9, color: PdfColors.orange)),
] else
pw.Text(
'${detail.prixUnitaire.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixUnitaire)}',
style: normalTextStyle),
],
),
@ -1419,7 +1419,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
children: [
if (detail.estCadeau) ...[
pw.Text(
'${detail.sousTotal.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.sousTotal)}',
style: pw.TextStyle(
fontSize: 7,
decoration: pw.TextDecoration.lineThrough,
@ -1434,20 +1434,20 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
] else if (detail.aRemise &&
detail.sousTotal != detail.prixFinal) ...[
pw.Text(
'${detail.sousTotal.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.sousTotal)}',
style: pw.TextStyle(
fontSize: 7,
decoration: pw.TextDecoration.lineThrough,
color: PdfColors.grey600,
)),
pw.Text(
'${detail.prixFinal.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixFinal)}',
style: pw.TextStyle(
fontSize: 9,
fontWeight: pw.FontWeight.bold)),
] else
pw.Text(
'${detail.prixFinal.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixFinal)}',
style: normalTextStyle),
],
),
@ -1475,7 +1475,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
pw.SizedBox(width: 20),
pw.Container(
width: 80,
child: pw.Text('${sousTotal.toStringAsFixed(0)}',
child: pw.Text('${NumberFormat('#,##0', 'fr_FR').format(sousTotal)}',
style: normalTextStyle,
textAlign: pw.TextAlign.right),
),
@ -1494,7 +1494,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
pw.Container(
width: 80,
child: pw.Text(
'-${totalRemises.toStringAsFixed(0)}',
'-${NumberFormat('#,##0', 'fr_FR').format(totalRemises)}',
style: pw.TextStyle(
color: PdfColors.orange,
fontWeight: pw.FontWeight.bold,
@ -1516,7 +1516,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
pw.Container(
width: 80,
child: pw.Text(
'-${totalCadeaux.toStringAsFixed(0)}',
'-${NumberFormat('#,##0', 'fr_FR').format(totalCadeaux)}',
style: pw.TextStyle(
color: PdfColors.green700,
fontWeight: pw.FontWeight.bold,
@ -1543,7 +1543,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
pw.Container(
width: 80,
child: pw.Text(
'${commande.montantTotal.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(commande.montantTotal)}',
style: boldTextStyle,
textAlign: pw.TextAlign.right),
),
@ -2103,7 +2103,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
children: [
if (detail.estCadeau) ...[
pw.Text(
'${detail.prixUnitaire.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixUnitaire)}',
style: pw.TextStyle(
fontSize: 6,
decoration: pw.TextDecoration.lineThrough,
@ -2119,18 +2119,18 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
detail.prixUnitaire !=
detail.prixFinal / detail.quantite) ...[
pw.Text(
'${detail.prixUnitaire.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixUnitaire)}',
style: pw.TextStyle(
fontSize: 6,
decoration: pw.TextDecoration.lineThrough,
color: PdfColors.grey600,
)),
pw.Text(
'${(detail.prixFinal / detail.quantite).toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixFinal / detail.quantite)}',
style: const pw.TextStyle(fontSize: 7)),
] else
pw.Text(
'${detail.prixUnitaire.toStringAsFixed(0)}',
'${NumberFormat('#,##0', 'fr_FR').format(detail.prixUnitaire)}',
style: const pw.TextStyle(fontSize: 7)),
],
),
@ -2857,7 +2857,7 @@ class _GestionCommandesPageState extends State<GestionCommandesPage> {
),
const SizedBox(width: 2),
Text(
'-${totalRemises.toStringAsFixed(0)}',
'-${NumberFormat('#,##0', 'fr_FR').format(totalRemises)}',
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.bold,

2
lib/Views/historique.dart

@ -556,7 +556,7 @@ class _HistoriquePageState extends State<HistoriquePage> {
.format(commande.dateCommande),
Icons.calendar_today),
_buildDetailRow(
'PV', '${_selectedPointDeVente} ', Icons.person),
'PV', '${commande.pointDeVenteDesign} ', Icons.person),
Row(
children: [
Icon(Icons.assignment,

6
lib/Views/historique_sorties_personnelles_page.dart

@ -31,9 +31,10 @@ class _HistoriqueSortiesPersonnellesPageState extends State<HistoriqueSortiesPer
Future<void> _loadHistorique() async {
setState(() => _isLoading = true);
try {
final historique = await _database.getHistoriqueSortiesPersonnelles(
final historique = await _database.getHistoriqueSortiesPersonnelles(
adminId: _afficherSeulementMesDemandes ? _userController.userId : null,
statut: _filtreStatut,
pointDeVenteId: _userController.pointDeVenteId == 0 ? null : _userController.pointDeVenteId, // Si pointDeVenteId = 0, ne pas filtrer
limit: 100,
);
setState(() {
@ -150,8 +151,9 @@ class _HistoriqueSortiesPersonnellesPageState extends State<HistoriqueSortiesPer
Icon(Icons.history, size: 64, color: Colors.grey),
SizedBox(height: 16),
Text(
'Aucun historique trouvé',
'Aucun historique trouvé pour ce point de vente',
style: TextStyle(fontSize: 18, color: Colors.grey),
textAlign: TextAlign.center,
),
],
),

4
lib/config/DatabaseConfig.dart

@ -5,13 +5,13 @@ import 'dart:async';
class DatabaseConfig {
// Local MySQL settings
static const String localHost = '102.17.52.31';
static const String localHost = '192.168.88.73';
static const String localUsername = 'guycom';
static const String? localPassword = '3iV59wjRdbuXAPR';
static const String localDatabase = 'guycom';
// Production (public) MySQL settings
static const String prodHost = '102.17.52.31';
static const String prodHost = '185.70.105.157';
static const String prodUsername = 'guycom';
static const String prodPassword = '3iV59wjRdbuXAPR';
static const String prodDatabase = 'guycom';

48
pubspec.lock

@ -57,6 +57,46 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.2"
camera:
dependency: "direct main"
description:
name: camera
sha256: dfa8fc5a1adaeb95e7a54d86a5bd56f4bb0e035515354c8ac6d262e35cec2ec8
url: "https://pub.dev"
source: hosted
version: "0.10.6"
camera_android:
dependency: transitive
description:
name: camera_android
sha256: "4f40d053a67e99029b5be7f00ef8047b63edb65ccc4e2546b84d47e302c6bf62"
url: "https://pub.dev"
source: hosted
version: "0.10.10+4"
camera_avfoundation:
dependency: transitive
description:
name: camera_avfoundation
sha256: cabc6cbdeadca9cbcac178110c9d5e87bde5c646c3b8c9c4c2747fc500a12432
url: "https://pub.dev"
source: hosted
version: "0.9.20+5"
camera_platform_interface:
dependency: transitive
description:
name: camera_platform_interface
sha256: "2f757024a48696ff4814a789b0bd90f5660c0fb25f393ab4564fb483327930e2"
url: "https://pub.dev"
source: hosted
version: "2.10.0"
camera_web:
dependency: transitive
description:
name: camera_web
sha256: "595f28c89d1fb62d77c73c633193755b781c6d2e0ebcd8dc25b763b514e6ba8f"
url: "https://pub.dev"
source: hosted
version: "0.3.5"
characters:
dependency: transitive
description:
@ -1053,6 +1093,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
stream_transform:
dependency: transitive
description:
name: stream_transform
sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871
url: "https://pub.dev"
source: hosted
version: "2.1.1"
string_scanner:
dependency: transitive
description:

1
pubspec.yaml

@ -68,6 +68,7 @@ dependencies:
numbers_to_letters: ^1.0.0
qr_code_scanner_plus: ^2.0.10+1
window_manager: ^0.3.7
camera: ^0.10.5+9

Loading…
Cancel
Save