Browse Source

commit 24/07/2025-2

28062025_02
andrymodeste 4 months ago
parent
commit
a52749c415
  1. 3
      android/app/build.gradle.kts
  2. 1
      ios/build/ios/XCBuildData/PIFCache/workspace/WORKSPACE@v11_hash=(null)_subobjects=b2e12b7ce127ba825ffc2656889f5368-json
  3. 89
      lib/Components/AddClient.dart
  4. 73
      lib/Components/QrScan.dart
  5. 302
      lib/Views/demande_sortie_personnelle_page.dart
  6. 1442
      lib/Views/historique.dart

3
android/app/build.gradle.kts

@ -8,7 +8,8 @@ plugins {
android {
namespace = "com.example.my_app"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
ndkVersion = "26.3.11579264"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11

1
ios/build/ios/XCBuildData/PIFCache/workspace/WORKSPACE@v11_hash=(null)_subobjects=b2e12b7ce127ba825ffc2656889f5368-json

@ -0,0 +1 @@
{"guid":"dc4b70c03e8043e50e38f2068887b1d4","name":"Pods","path":"/Users/rabarisonmimistephanethannio/Documents/DEV/guycom_finale/ios/Pods/Pods.xcodeproj/project.xcworkspace","projects":["PROJECT@v11_mod=7e9f9a517e1b730b3eb5b9aa5a52f2df_hash=bfdfe7dc352907fc980b868725387e98plugins=1OJSG6M1FOV3XYQCBH7Z29RZ0FPR9XDE1"]}

89
lib/Components/AddClient.dart

@ -4,22 +4,21 @@ import 'package:youmazgestion/Models/client.dart';
import '../Services/stock_managementDatabase.dart';
class ClientFormController extends GetxController {
final _formKey = GlobalKey<FormState>();
// Controllers pour les champs
final _nomController = TextEditingController();
final _prenomController = TextEditingController();
final _emailController = TextEditingController();
final _telephoneController = TextEditingController();
final _adresseController = TextEditingController();
// Variables observables pour la recherche
var suggestedClients = <Client>[].obs;
var isSearching = false.obs;
var selectedClient = Rxn<Client>();
@override
void onClose() {
_nomController.dispose();
@ -29,14 +28,14 @@ class ClientFormController extends GetxController {
_adresseController.dispose();
super.onClose();
}
// Méthode pour rechercher les clients existants
Future<void> searchClients(String query) async {
if (query.length < 2) {
suggestedClients.clear();
return;
}
isSearching.value = true;
try {
final clients = await AppDatabase.instance.suggestClients(query);
@ -48,7 +47,7 @@ class ClientFormController extends GetxController {
isSearching.value = false;
}
}
// Méthode pour remplir automatiquement le formulaire
void fillFormWithClient(Client client) {
selectedClient.value = client;
@ -59,7 +58,7 @@ class ClientFormController extends GetxController {
_adresseController.text = client.adresse ?? '';
suggestedClients.clear();
}
// Méthode pour vider le formulaire
void clearForm() {
selectedClient.value = null;
@ -70,14 +69,14 @@ class ClientFormController extends GetxController {
_adresseController.clear();
suggestedClients.clear();
}
// Méthode pour valider et soumettre
Future<void> submitForm() async {
if (!_formKey.currentState!.validate()) return;
try {
Client clientToUse;
if (selectedClient.value != null) {
// Utiliser le client existant
clientToUse = selectedClient.value!;
@ -88,17 +87,18 @@ class ClientFormController extends GetxController {
prenom: _prenomController.text.trim(),
email: _emailController.text.trim(),
telephone: _telephoneController.text.trim(),
adresse: _adresseController.text.trim().isEmpty ? null : _adresseController.text.trim(),
adresse: _adresseController.text.trim().isEmpty
? null
: _adresseController.text.trim(),
dateCreation: DateTime.now(),
);
clientToUse = await AppDatabase.instance.createOrGetClient(newClient);
}
// Procéder avec la commande
Get.back();
_submitOrderWithClient(clientToUse);
} catch (e) {
Get.snackbar(
'Erreur',
@ -108,7 +108,7 @@ class ClientFormController extends GetxController {
);
}
}
void _submitOrderWithClient(Client client) {
// Votre logique existante pour soumettre la commande
// avec le client fourni
@ -116,9 +116,10 @@ class ClientFormController extends GetxController {
}
// Widget pour le formulaire avec auto-completion
// ignore: unused_element
void _showClientFormDialog() {
final controller = Get.put(ClientFormController());
Get.dialog(
AlertDialog(
title: Row(
@ -155,7 +156,7 @@ void _showClientFormDialog() {
// Section de recherche rapide
_buildSearchSection(controller),
const SizedBox(height: 16),
// Indicateur client sélectionné
Obx(() {
if (controller.selectedClient.value != null) {
@ -168,7 +169,8 @@ void _showClientFormDialog() {
),
child: Row(
children: [
Icon(Icons.check_circle, color: Colors.green.shade600),
Icon(Icons.check_circle,
color: Colors.green.shade600),
const SizedBox(width: 8),
Expanded(
child: Text(
@ -186,12 +188,13 @@ void _showClientFormDialog() {
return const SizedBox.shrink();
}),
const SizedBox(height: 12),
// Champs du formulaire
_buildTextFormField(
controller: controller._nomController,
label: 'Nom',
validator: (value) => value?.isEmpty ?? true ? 'Veuillez entrer un nom' : null,
validator: (value) =>
value?.isEmpty ?? true ? 'Veuillez entrer un nom' : null,
onChanged: (value) {
if (controller.selectedClient.value != null) {
controller.selectedClient.value = null;
@ -199,11 +202,13 @@ void _showClientFormDialog() {
},
),
const SizedBox(height: 12),
_buildTextFormField(
controller: controller._prenomController,
label: 'Prénom',
validator: (value) => value?.isEmpty ?? true ? 'Veuillez entrer un prénom' : null,
validator: (value) => value?.isEmpty ?? true
? 'Veuillez entrer un prénom'
: null,
onChanged: (value) {
if (controller.selectedClient.value != null) {
controller.selectedClient.value = null;
@ -211,14 +216,16 @@ void _showClientFormDialog() {
},
),
const SizedBox(height: 12),
_buildTextFormField(
controller: controller._emailController,
label: 'Email',
keyboardType: TextInputType.emailAddress,
validator: (value) {
if (value?.isEmpty ?? true) return 'Veuillez entrer un email';
if (!RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$').hasMatch(value!)) {
// if (value?.isEmpty ?? true) return 'Veuillez entrer un email';
if (value?.isEmpty ?? true) return null;
if (!RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$')
.hasMatch(value!)) {
return 'Email invalide';
}
return null;
@ -232,12 +239,14 @@ void _showClientFormDialog() {
},
),
const SizedBox(height: 12),
_buildTextFormField(
controller: controller._telephoneController,
label: 'Téléphone',
keyboardType: TextInputType.phone,
validator: (value) => value?.isEmpty ?? true ? 'Veuillez entrer un téléphone' : null,
validator: (value) => value?.isEmpty ?? true
? 'Veuillez entrer un téléphone'
: null,
onChanged: (value) {
if (controller.selectedClient.value != null) {
controller.selectedClient.value = null;
@ -247,12 +256,14 @@ void _showClientFormDialog() {
},
),
const SizedBox(height: 12),
_buildTextFormField(
controller: controller._adresseController,
label: 'Adresse',
maxLines: 2,
validator: (value) => value?.isEmpty ?? true ? 'Veuillez entrer une adresse' : null,
validator: (value) => value?.isEmpty ?? true
? 'Veuillez entrer une adresse'
: null,
onChanged: (value) {
if (controller.selectedClient.value != null) {
controller.selectedClient.value = null;
@ -260,9 +271,9 @@ void _showClientFormDialog() {
},
),
const SizedBox(height: 12),
_buildCommercialDropdown(),
// Liste des suggestions
Obx(() {
if (controller.isSearching.value) {
@ -271,11 +282,11 @@ void _showClientFormDialog() {
child: Center(child: CircularProgressIndicator()),
);
}
if (controller.suggestedClients.isEmpty) {
return const SizedBox.shrink();
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -288,8 +299,9 @@ void _showClientFormDialog() {
),
),
const SizedBox(height: 8),
...controller.suggestedClients.map((client) =>
_buildClientSuggestionTile(client, controller),
...controller.suggestedClients.map(
(client) =>
_buildClientSuggestionTile(client, controller),
),
],
);
@ -349,7 +361,8 @@ Widget _buildSearchSection(ClientFormController controller) {
}
// Widget pour afficher une suggestion de client
Widget _buildClientSuggestionTile(Client client, ClientFormController controller) {
Widget _buildClientSuggestionTile(
Client client, ClientFormController controller) {
return Card(
margin: const EdgeInsets.only(bottom: 8),
child: ListTile(
@ -414,4 +427,4 @@ Widget _buildTextFormField({
Widget _buildCommercialDropdown() {
// Votre implémentation existante
return Container(); // Remplacez par votre code existant
}
}

73
lib/Components/QrScan.dart

@ -25,13 +25,14 @@ class _ScanQRPageState extends State<ScanQRPage> {
}
void _initializeController() {
if (!isMobile) {
setState(() {
_hasError = true;
_errorMessage = "Le scanner QR n'est pas disponible sur cette plateforme.";
});
return;
}
if (!isMobile) {
setState(() {
_hasError = true;
_errorMessage =
"Le scanner QR n'est pas disponible sur cette plateforme.";
});
return;
}
try {
cameraController = MobileScannerController(
detectionSpeed: DetectionSpeed.noDuplicates,
@ -61,22 +62,25 @@ class _ScanQRPageState extends State<ScanQRPage> {
return Scaffold(
appBar: AppBar(
title: const Text('Scanner QR Code'),
actions: _hasError ? [] : [
if (cameraController != null) ...[
IconButton(
color: Colors.white,
icon: const Icon(Icons.flash_on, color: Colors.white),
iconSize: 32.0,
onPressed: () => cameraController!.toggleTorch(),
),
IconButton(
color: Colors.white,
icon: const Icon(Icons.flip_camera_ios, color: Colors.white),
iconSize: 32.0,
onPressed: () => cameraController!.switchCamera(),
),
],
],
actions: _hasError
? []
: [
if (cameraController != null) ...[
IconButton(
color: Colors.white,
icon: const Icon(Icons.flash_on, color: Colors.white),
iconSize: 32.0,
onPressed: () => cameraController!.toggleTorch(),
),
IconButton(
color: Colors.white,
icon:
const Icon(Icons.flip_camera_ios, color: Colors.white),
iconSize: 32.0,
onPressed: () => cameraController!.switchCamera(),
),
],
],
),
body: _hasError ? _buildErrorWidget() : _buildScannerWidget(),
);
@ -150,7 +154,8 @@ class _ScanQRPageState extends State<ScanQRPage> {
children: [
const Icon(Icons.error, size: 64, color: Colors.red),
const SizedBox(height: 16),
Text('Erreur: ${error.errorDetails?.message ?? 'Erreur inconnue'}'),
Text(
'Erreur: ${error.errorDetails?.message ?? 'Erreur inconnue'}'),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () => _initializeController(),
@ -236,19 +241,25 @@ class QrScannerOverlay extends CustomPainter {
..style = PaintingStyle.stroke;
// Coins du scanner
_drawCorner(canvas, borderPaint, areaLeft, areaTop, borderLength, true, true);
_drawCorner(canvas, borderPaint, areaLeft + areaSize, areaTop, borderLength, false, true);
_drawCorner(canvas, borderPaint, areaLeft, areaTop + areaSize, borderLength, true, false);
_drawCorner(canvas, borderPaint, areaLeft + areaSize, areaTop + areaSize, borderLength, false, false);
_drawCorner(
canvas, borderPaint, areaLeft, areaTop, borderLength, true, true);
_drawCorner(canvas, borderPaint, areaLeft + areaSize, areaTop, borderLength,
false, true);
_drawCorner(canvas, borderPaint, areaLeft, areaTop + areaSize, borderLength,
true, false);
_drawCorner(canvas, borderPaint, areaLeft + areaSize, areaTop + areaSize,
borderLength, false, false);
}
void _drawCorner(Canvas canvas, Paint paint, double x, double y, double length, bool isLeft, bool isTop) {
void _drawCorner(Canvas canvas, Paint paint, double x, double y,
double length, bool isLeft, bool isTop) {
final double horizontalStart = isLeft ? x : x - length;
final double horizontalEnd = isLeft ? x + length : x;
final double verticalStart = isTop ? y : y - length;
final double verticalEnd = isTop ? y + length : y;
canvas.drawLine(Offset(horizontalStart, y), Offset(horizontalEnd, y), paint);
canvas.drawLine(
Offset(horizontalStart, y), Offset(horizontalEnd, y), paint);
canvas.drawLine(Offset(x, verticalStart), Offset(x, verticalEnd), paint);
}
@ -256,4 +267,4 @@ class QrScannerOverlay extends CustomPainter {
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return false;
}
}
}

302
lib/Views/demande_sortie_personnelle_page.dart

@ -5,31 +5,33 @@ import 'package:youmazgestion/Components/appDrawer.dart';
import 'package:youmazgestion/Services/stock_managementDatabase.dart';
import 'package:youmazgestion/controller/userController.dart';
import '../Models/produit.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
class DemandeSortiePersonnellePage extends StatefulWidget {
const DemandeSortiePersonnellePage({super.key});
@override
_DemandeSortiePersonnellePageState createState() => _DemandeSortiePersonnellePageState();
_DemandeSortiePersonnellePageState createState() =>
_DemandeSortiePersonnellePageState();
}
class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnellePage>
with TickerProviderStateMixin {
class _DemandeSortiePersonnellePageState
extends State<DemandeSortiePersonnellePage> with TickerProviderStateMixin {
final AppDatabase _database = AppDatabase.instance;
final UserController _userController = Get.find<UserController>();
final _formKey = GlobalKey<FormState>();
final _quantiteController = TextEditingController(text: '1');
final _motifController = TextEditingController();
final _notesController = TextEditingController();
final _searchController = TextEditingController();
Product? _selectedProduct;
List<Product> _products = [];
List<Product> _filteredProducts = [];
bool _isLoading = false;
bool _isSearching = false;
late AnimationController _animationController;
late Animation<double> _fadeAnimation;
late Animation<Offset> _slideAnimation;
@ -44,14 +46,66 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
_fadeAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(parent: _animationController, curve: Curves.easeInOut),
);
_slideAnimation = Tween<Offset>(begin: const Offset(0, 0.3), end: Offset.zero).animate(
_slideAnimation =
Tween<Offset>(begin: const Offset(0, 0.3), end: Offset.zero).animate(
CurvedAnimation(parent: _animationController, curve: Curves.easeOutCubic),
);
_loadProducts();
_searchController.addListener(_filterProducts);
}
void _scanQrOrBarcode() async {
// Open the mobile scanner as a modal widget
await showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Container(
width: double.maxFinite,
height: 400, // Adjust according to your needs
child: MobileScanner(
onDetect: (barcodeCapture) {
String scanResult = barcodeCapture.rawValue ?? '';
Navigator.of(context).pop(); // Close dialog after scanning
if (scanResult.isEmpty) return;
setState(() {
_searchController.text = scanResult; // Show scanned text
});
// Assume IMEI is always 15 digits, adjust if necessary
Product? found;
if (scanResult.length == 15 &&
int.tryParse(scanResult) != null) {
found =
_products.firstWhereOrNull((p) => p.imei == scanResult);
} else {
found = _products
.firstWhereOrNull((p) => p.reference == scanResult);
}
if (found != null) {
setState(() {
_selectedProduct = found;
_filteredProducts = [found!];
});
} else {
_showErrorSnackbar('Aucun produit trouvé avec ce code.');
setState(() {
_filteredProducts = [];
_selectedProduct = null;
});
}
},
),
),
);
},
);
}
void _filterProducts() {
final query = _searchController.text.toLowerCase();
setState(() {
@ -62,7 +116,7 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
_isSearching = true;
_filteredProducts = _products.where((product) {
return product.name.toLowerCase().contains(query) ||
(product.reference?.toLowerCase().contains(query) ?? false);
(product.reference?.toLowerCase().contains(query) ?? false);
}).toList();
}
});
@ -91,14 +145,15 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
}
final quantite = int.tryParse(_quantiteController.text) ?? 0;
if (quantite <= 0) {
_showErrorSnackbar('La quantité doit être supérieure à 0');
return;
}
if ((_selectedProduct!.stock ?? 0) < quantite) {
_showErrorSnackbar('Stock insuffisant (disponible: ${_selectedProduct!.stock})');
_showErrorSnackbar(
'Stock insuffisant (disponible: ${_selectedProduct!.stock})');
return;
}
@ -114,11 +169,16 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
adminId: _userController.userId,
quantite: quantite,
motif: _motifController.text.trim(),
pointDeVenteId: _userController.pointDeVenteId > 0 ? _userController.pointDeVenteId : null,
notes: _notesController.text.trim().isNotEmpty ? _notesController.text.trim() : null,
pointDeVenteId: _userController.pointDeVenteId > 0
? _userController.pointDeVenteId
: null,
notes: _notesController.text.trim().isNotEmpty
? _notesController.text.trim()
: null,
);
_showSuccessSnackbar('Votre demande de sortie personnelle a été soumise pour approbation');
_showSuccessSnackbar(
'Votre demande de sortie personnelle a été soumise pour approbation');
// Réinitialiser le formulaire avec animation
_resetForm();
@ -144,55 +204,58 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
Future<bool> _showConfirmationDialog() async {
return await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
title: Row(
children: [
Icon(Icons.help_outline, color: Colors.orange.shade700),
const SizedBox(width: 8),
const Text('Confirmer la demande'),
],
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('Êtes-vous sûr de vouloir soumettre cette demande ?'),
const SizedBox(height: 16),
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.grey.shade50,
borderRadius: BorderRadius.circular(8),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Produit: ${_selectedProduct?.name}'),
Text('Quantité: ${_quantiteController.text}'),
Text('Motif: ${_motifController.text}'),
],
),
context: context,
builder: (context) => AlertDialog(
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
title: Row(
children: [
Icon(Icons.help_outline, color: Colors.orange.shade700),
const SizedBox(width: 8),
const Text('Confirmer la demande'),
],
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text('Annuler'),
),
ElevatedButton(
onPressed: () => Navigator.of(context).pop(true),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.orange.shade700,
foregroundColor: Colors.white,
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Êtes-vous sûr de vouloir soumettre cette demande ?'),
const SizedBox(height: 16),
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.grey.shade50,
borderRadius: BorderRadius.circular(8),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Produit: ${_selectedProduct?.name}'),
Text('Quantité: ${_quantiteController.text}'),
Text('Motif: ${_motifController.text}'),
],
),
),
],
),
child: const Text('Confirmer'),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text('Annuler'),
),
ElevatedButton(
onPressed: () => Navigator.of(context).pop(true),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.orange.shade700,
foregroundColor: Colors.white,
),
child: const Text('Confirmer'),
),
],
),
],
),
) ?? false;
) ??
false;
}
void _showSuccessSnackbar(String message) {
@ -203,7 +266,9 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
children: [
Icon(Icons.check_circle, color: Colors.white),
const SizedBox(width: 8),
const Text('Succès', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
const Text('Succès',
style:
TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
],
),
messageText: Text(message, style: const TextStyle(color: Colors.white)),
@ -224,7 +289,9 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
children: [
Icon(Icons.error, color: Colors.white),
const SizedBox(width: 8),
const Text('Erreur', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
const Text('Erreur',
style:
TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
],
),
messageText: Text(message, style: const TextStyle(color: Colors.white)),
@ -325,33 +392,27 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
),
),
const SizedBox(height: 12),
// Barre de recherche
Container(
decoration: BoxDecoration(
color: Colors.grey.shade50,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey.shade300),
),
child: TextField(
controller: _searchController,
decoration: InputDecoration(
hintText: 'Rechercher un produit...',
prefixIcon: Icon(Icons.search, color: Colors.grey.shade600),
suffixIcon: _isSearching
? IconButton(
icon: Icon(Icons.clear, color: Colors.grey.shade600),
onPressed: () {
_searchController.clear();
FocusScope.of(context).unfocus();
},
)
: null,
border: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
Row(
children: [
Expanded(
child: TextField(
controller: _searchController,
decoration: InputDecoration(
hintText: 'Rechercher un produit...',
prefixIcon: Icon(Icons.search, color: Colors.grey.shade600),
),
),
),
),
IconButton(
icon: Icon(Icons.qr_code_scanner, color: Colors.blue),
onPressed: _scanQrOrBarcode,
tooltip: 'Scanner QR ou code-barres',
),
],
),
const SizedBox(height: 12),
// Liste des produits
@ -366,10 +427,13 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.search_off, size: 48, color: Colors.grey.shade400),
Icon(Icons.search_off,
size: 48, color: Colors.grey.shade400),
const SizedBox(height: 8),
Text(
_isSearching ? 'Aucun produit trouvé' : 'Aucun produit disponible',
_isSearching
? 'Aucun produit trouvé'
: 'Aucun produit disponible',
style: TextStyle(color: Colors.grey.shade600),
),
],
@ -380,15 +444,20 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
itemBuilder: (context, index) {
final product = _filteredProducts[index];
final isSelected = _selectedProduct?.id == product.id;
return AnimatedContainer(
duration: const Duration(milliseconds: 200),
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
margin: const EdgeInsets.symmetric(
horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: isSelected ? Colors.orange.shade50 : Colors.transparent,
color: isSelected
? Colors.orange.shade50
: Colors.transparent,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: isSelected ? Colors.orange.shade300 : Colors.transparent,
color: isSelected
? Colors.orange.shade300
: Colors.transparent,
width: 2,
),
),
@ -397,30 +466,41 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
width: 48,
height: 48,
decoration: BoxDecoration(
color: isSelected ? Colors.orange.shade100 : Colors.grey.shade100,
color: isSelected
? Colors.orange.shade100
: Colors.grey.shade100,
borderRadius: BorderRadius.circular(8),
),
child: Icon(
Icons.inventory,
color: isSelected ? Colors.orange.shade700 : Colors.grey.shade600,
color: isSelected
? Colors.orange.shade700
: Colors.grey.shade600,
),
),
title: Text(
product.name,
style: TextStyle(
fontWeight: isSelected ? FontWeight.bold : FontWeight.w500,
color: isSelected ? Colors.orange.shade800 : Colors.grey.shade800,
fontWeight:
isSelected ? FontWeight.bold : FontWeight.w500,
color: isSelected
? Colors.orange.shade800
: Colors.grey.shade800,
),
),
subtitle: Text(
'Stock: ${product.stock} • Réf: ${product.reference ?? 'N/A'}',
style: TextStyle(
color: isSelected ? Colors.orange.shade600 : Colors.grey.shade600,
color: isSelected
? Colors.orange.shade600
: Colors.grey.shade600,
),
),
trailing: isSelected
? Icon(Icons.check_circle, color: Colors.orange.shade700)
: Icon(Icons.radio_button_unchecked, color: Colors.grey.shade400),
? Icon(Icons.check_circle,
color: Colors.orange.shade700)
: Icon(Icons.radio_button_unchecked,
color: Colors.grey.shade400),
onTap: () {
setState(() {
_selectedProduct = product;
@ -445,7 +525,8 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
keyboardType: TextInputType.number,
icon: Icons.format_list_numbered,
suffix: _selectedProduct != null
? Text('max: ${_selectedProduct!.stock}', style: TextStyle(color: Colors.grey.shade600))
? Text('max: ${_selectedProduct!.stock}',
style: TextStyle(color: Colors.grey.shade600))
: null,
validator: (value) {
if (value == null || value.isEmpty) {
@ -455,7 +536,8 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
if (quantite == null || quantite <= 0) {
return 'Quantité invalide';
}
if (_selectedProduct != null && quantite > (_selectedProduct!.stock ?? 0)) {
if (_selectedProduct != null &&
quantite > (_selectedProduct!.stock ?? 0)) {
return 'Quantité supérieure au stock disponible';
}
return null;
@ -538,7 +620,8 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
),
filled: true,
fillColor: Colors.grey.shade50,
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
contentPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
),
),
],
@ -571,10 +654,13 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
],
),
const SizedBox(height: 12),
_buildInfoRow(Icons.account_circle, 'Demandeur', _userController.name),
_buildInfoRow(
Icons.account_circle, 'Demandeur', _userController.name),
if (_userController.pointDeVenteId > 0)
_buildInfoRow(Icons.store, 'Point de vente', _userController.pointDeVenteDesignation),
_buildInfoRow(Icons.calendar_today, 'Date', DateTime.now().toLocal().toString().split(' ')[0]),
_buildInfoRow(Icons.store, 'Point de vente',
_userController.pointDeVenteDesignation),
_buildInfoRow(Icons.calendar_today, 'Date',
DateTime.now().toLocal().toString().split(' ')[0]),
],
),
);
@ -721,4 +807,8 @@ class _DemandeSortiePersonnellePageState extends State<DemandeSortiePersonnelleP
_searchController.dispose();
super.dispose();
}
}
}
extension on BarcodeCapture {
get rawValue => null;
}

1442
lib/Views/historique.dart

File diff suppressed because it is too large
Loading…
Cancel
Save