Browse Source

commit de 28072025_02

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

20
lib/Services/stock_managementDatabase.dart

@ -3163,26 +3163,32 @@ Future<double> getValeurTotaleStock() async {
return []; return [];
} }
} }
Future<List<Map<String, dynamic>>> getHistoriqueSortiesPersonnelles({
Future<List<Map<String, dynamic>>> getHistoriqueSortiesPersonnelles({
int? adminId, int? adminId,
String? statut, String? statut,
int? pointDeVenteId,
int limit = 50, int limit = 50,
}) async { }) async {
final db = await database; final db = await database;
try { try {
String whereClause = ''; String whereClause = '';
List<dynamic> params = []; 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) { if (adminId != null) {
whereClause = 'WHERE sp.admin_id = ?'; whereClause += (whereClause.isEmpty ? 'WHERE' : ' AND') + ' sp.admin_id = ?';
params.add(adminId); params.add(adminId);
} }
if (statut != null) { if (statut != null) {
whereClause += whereClause += (whereClause.isEmpty ? 'WHERE' : ' AND') + ' sp.statut = ?';
(whereClause.isEmpty ? 'WHERE' : ' AND') + ' sp.statut = ?';
params.add(statut); params.add(statut);
} }
@ -3210,7 +3216,7 @@ Future<double> getValeurTotaleStock() async {
print('Erreur récupération historique sorties: $e'); print('Erreur récupération historique sorties: $e');
return []; return [];
} }
} }
Future<Map<String, dynamic>> getStatistiquesSortiesPersonnelles() async { Future<Map<String, dynamic>> getStatistiquesSortiesPersonnelles() async {
final db = await database; final db = await database;

12
lib/Views/HandleProduct.dart

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

54
lib/Views/commandManagement.dart

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

2
lib/Views/historique.dart

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

4
lib/Views/historique_sorties_personnelles_page.dart

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

4
lib/config/DatabaseConfig.dart

@ -5,13 +5,13 @@ import 'dart:async';
class DatabaseConfig { class DatabaseConfig {
// Local MySQL settings // 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 localUsername = 'guycom';
static const String? localPassword = '3iV59wjRdbuXAPR'; static const String? localPassword = '3iV59wjRdbuXAPR';
static const String localDatabase = 'guycom'; static const String localDatabase = 'guycom';
// Production (public) MySQL settings // 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 prodUsername = 'guycom';
static const String prodPassword = '3iV59wjRdbuXAPR'; static const String prodPassword = '3iV59wjRdbuXAPR';
static const String prodDatabase = 'guycom'; static const String prodDatabase = 'guycom';

48
pubspec.lock

@ -57,6 +57,46 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.2" 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: characters:
dependency: transitive dependency: transitive
description: description:
@ -1053,6 +1093,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.4" 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: string_scanner:
dependency: transitive dependency: transitive
description: description:

1
pubspec.yaml

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

Loading…
Cancel
Save