Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11c5352555 | ||
|
|
a0bdb9a535 |
No files matched your search
+61
-11
@@ -41,28 +41,78 @@ class DashboardTargetProgressState extends Equatable {
|
||||
);
|
||||
}
|
||||
|
||||
/// Avanzamento specifico del membro dello staff correntemente connesso
|
||||
TargetProgressModel? get currentStaffProgress {
|
||||
/// Avanzamento specifico del membro dello staff indicato o correntemente connesso
|
||||
TargetProgressModel? getStaffProgress([String? staffId]) {
|
||||
final curProgress = progress;
|
||||
final staffId = currentStaffId;
|
||||
if (curProgress == null || staffId == null) return null;
|
||||
return curProgress.staffProgress[staffId];
|
||||
final id = staffId ?? currentStaffId;
|
||||
if (curProgress == null || id == null) return null;
|
||||
return curProgress.staffProgress[id];
|
||||
}
|
||||
|
||||
/// True se lo staff connesso ha almeno un target individuale attivo impostato
|
||||
bool get hasStaffTargets {
|
||||
final sp = currentStaffProgress;
|
||||
/// True se lo staff connesso o specificato ha almeno un target individuale attivo impostato
|
||||
bool hasStaffTargets([String? staffId]) {
|
||||
final sp = getStaffProgress(staffId);
|
||||
if (sp == null) return false;
|
||||
return sp.categories.values.any((c) => c.hasTarget);
|
||||
}
|
||||
|
||||
/// Lista delle categorie con target attivo per l'addetto connesso
|
||||
List<CategoryProgress> get activeStaffCategories {
|
||||
final sp = currentStaffProgress;
|
||||
/// Lista delle categorie con target attivo per l'addetto indicato o connesso
|
||||
List<CategoryProgress> activeStaffCategories([String? staffId]) {
|
||||
final sp = getStaffProgress(staffId);
|
||||
if (sp == null) return const [];
|
||||
return sp.categories.values.where((c) => c.hasTarget).toList();
|
||||
}
|
||||
|
||||
/// Restituisce sempre l'avanzamento personalizzato per lo staff
|
||||
TargetProgressModel getEffectiveStaffProgress({
|
||||
required String? staffId,
|
||||
required String? staffName,
|
||||
}) {
|
||||
final sp = getStaffProgress(staffId);
|
||||
if (sp != null) {
|
||||
return sp;
|
||||
}
|
||||
|
||||
final curProgress = progress;
|
||||
if (curProgress == null) {
|
||||
return TargetProgressModel.empty();
|
||||
}
|
||||
|
||||
// Se l'addetto non è mappato nella lista (es. nuovo addetto senza operazioni),
|
||||
// creiamo una scheda personale con le categorie attive del negozio
|
||||
final staffCount = target?.individualTargets.length ?? 1;
|
||||
final divisor = staffCount > 0 ? staffCount : 1;
|
||||
|
||||
final userCategories = <String, CategoryProgress>{};
|
||||
for (final entry in curProgress.categories.entries) {
|
||||
final storeCat = entry.value;
|
||||
userCategories[entry.key] = CategoryProgress.calculate(
|
||||
key: storeCat.key,
|
||||
label: storeCat.label,
|
||||
actual: 0,
|
||||
s1: (storeCat.targetS1 / divisor).round(),
|
||||
s2: (storeCat.targetS2 / divisor).round(),
|
||||
elapsedDays: curProgress.elapsedWorkingDays,
|
||||
remainingDays: curProgress.remainingWorkingDays,
|
||||
totalDays: curProgress.totalWorkingDays,
|
||||
);
|
||||
}
|
||||
|
||||
return TargetProgressModel(
|
||||
targetId: curProgress.targetId,
|
||||
storeId: curProgress.storeId,
|
||||
staffId: staffId,
|
||||
staffName: staffName,
|
||||
totalWorkingDays: curProgress.totalWorkingDays,
|
||||
elapsedWorkingDays: curProgress.elapsedWorkingDays,
|
||||
remainingWorkingDays: curProgress.remainingWorkingDays,
|
||||
categories: userCategories,
|
||||
);
|
||||
}
|
||||
|
||||
/// Avanzamento specifico del membro dello staff correntemente connesso
|
||||
TargetProgressModel? get currentStaffProgress => getStaffProgress();
|
||||
|
||||
/// Lista delle categorie con target attivo per il negozio
|
||||
List<CategoryProgress> get activeStoreCategories {
|
||||
final curProgress = progress;
|
||||
|
||||
@@ -150,286 +150,325 @@ class DashboardTargetHeroCard extends StatelessWidget {
|
||||
final staffMember =
|
||||
context.watch<SessionCubit>().state.currentStaffMember;
|
||||
final staffName = staffMember?.name ?? 'Ospite';
|
||||
final staffId = staffMember?.id;
|
||||
|
||||
final hasStaffTargets = state.hasStaffTargets;
|
||||
final displayCategories = hasStaffTargets
|
||||
? state.activeStaffCategories
|
||||
: state.activeStoreCategories;
|
||||
final staffProgress = state.getEffectiveStaffProgress(
|
||||
staffId: staffId,
|
||||
staffName: staffName,
|
||||
);
|
||||
final displayCategories = staffProgress.categories.values
|
||||
.where((c) => c.hasTarget)
|
||||
.toList();
|
||||
|
||||
final remainingDays = progress.remainingWorkingDays;
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.primary.withValues(alpha: 0.25),
|
||||
width: 1.5,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: theme.colorScheme.primary.withValues(alpha: 0.06),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 6),
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final isCompact = constraints.maxWidth < 600;
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.primary.withValues(alpha: 0.25),
|
||||
width: 1.5,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: theme.colorScheme.primary.withValues(alpha: 0.06),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 6),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// ==========================================
|
||||
// 1. HEADER DELLA CARD (TITOLO & GIORNI)
|
||||
// ==========================================
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 18, 20, 14),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
theme.colorScheme.primary,
|
||||
theme.colorScheme.primary.withValues(alpha: 0.8),
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: theme.colorScheme.primary.withValues(alpha: 0.25),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.trending_up_rounded,
|
||||
color: Colors.white,
|
||||
size: 22,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// ==========================================
|
||||
// 1. HEADER DELLA CARD (TITOLO & GIORNI)
|
||||
// ==========================================
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
isCompact ? 14 : 20,
|
||||
isCompact ? 14 : 18,
|
||||
isCompact ? 14 : 20,
|
||||
isCompact ? 10 : 14,
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
hasStaffTargets
|
||||
? 'IL TUO RITMO PER OGGI'
|
||||
: 'RITMO GIORNALIERO NEGOZIO',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w800,
|
||||
letterSpacing: 0.8,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(isCompact ? 8 : 10),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
theme.colorScheme.primary,
|
||||
theme.colorScheme.primary.withValues(alpha: 0.8),
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: theme.colorScheme.primary
|
||||
.withValues(alpha: 0.25),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.primaryContainer
|
||||
.withValues(alpha: 0.35),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
remainingDays > 1
|
||||
? 'Mancano $remainingDays gg'
|
||||
: (remainingDays == 1
|
||||
? 'Ultimo giorno!'
|
||||
: 'Mese concluso'),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.primary,
|
||||
],
|
||||
),
|
||||
child: Icon(
|
||||
Icons.trending_up_rounded,
|
||||
color: Colors.white,
|
||||
size: isCompact ? 20 : 22,
|
||||
),
|
||||
),
|
||||
SizedBox(width: isCompact ? 10 : 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
'IL TUO RITMO PER OGGI',
|
||||
style: TextStyle(
|
||||
fontSize: isCompact ? 10.5 : 11,
|
||||
fontWeight: FontWeight.w800,
|
||||
letterSpacing: 0.6,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 7,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.primaryContainer
|
||||
.withValues(alpha: 0.35),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
remainingDays > 1
|
||||
? 'Mancano $remainingDays gg'
|
||||
: (remainingDays == 1
|
||||
? 'Ultimo giorno!'
|
||||
: 'Mese concluso'),
|
||||
style: TextStyle(
|
||||
fontSize: isCompact ? 10 : 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
staffMember != null
|
||||
? 'Cosa portare a casa oggi, $staffName'
|
||||
: 'Obiettivi personali per oggi',
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w900,
|
||||
fontSize: isCompact ? 15 : 17,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
hasStaffTargets
|
||||
? 'Cosa portare a casa oggi, $staffName'
|
||||
: 'Obiettivi di ${target.store?.name ?? "Negozio"} per oggi',
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w900,
|
||||
fontSize: 17,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
// Tasto rapido dettaglio
|
||||
if (isCompact)
|
||||
IconButton(
|
||||
onPressed: () => context.pushNamed(
|
||||
Routes.targetDetail,
|
||||
extra: target,
|
||||
),
|
||||
icon: const Icon(Icons.analytics_outlined),
|
||||
tooltip: 'Dettagli target',
|
||||
color: theme.colorScheme.primary,
|
||||
visualDensity: VisualDensity.compact,
|
||||
)
|
||||
else
|
||||
TextButton.icon(
|
||||
onPressed: () => context.pushNamed(
|
||||
Routes.targetDetail,
|
||||
extra: target,
|
||||
),
|
||||
icon: const Icon(Icons.analytics_outlined, size: 18),
|
||||
label: const Text('Dettagli'),
|
||||
style: TextButton.styleFrom(
|
||||
visualDensity: VisualDensity.compact,
|
||||
foregroundColor: theme.colorScheme.primary,
|
||||
textStyle: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Tasto rapido dettaglio
|
||||
TextButton.icon(
|
||||
onPressed: () => context.pushNamed(
|
||||
Routes.targetDetail,
|
||||
extra: target,
|
||||
),
|
||||
icon: const Icon(Icons.analytics_outlined, size: 18),
|
||||
label: const Text('Dettagli'),
|
||||
style: TextButton.styleFrom(
|
||||
visualDensity: VisualDensity.compact,
|
||||
foregroundColor: theme.colorScheme.primary,
|
||||
textStyle: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// ==========================================
|
||||
// 2. FOCUS METRICHE: MEDIE RICHIESTE PER OGGI
|
||||
// ==========================================
|
||||
if (displayCategories.isEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||
child: Text(
|
||||
'Nessun obiettivo attivo configurato per questo mese.',
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
fontSize: 13,
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final isWide = constraints.maxWidth > 700;
|
||||
|
||||
return GridView.builder(
|
||||
// ==========================================
|
||||
// 2. FOCUS METRICHE: MEDIE RICHIESTE PER OGGI
|
||||
// ==========================================
|
||||
if (displayCategories.isEmpty)
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||
child: Text(
|
||||
'Nessun obiettivo attivo configurato per questo mese.',
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: GridView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: displayCategories.length,
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: isWide ? 260 : 200,
|
||||
mainAxisExtent: 154,
|
||||
maxCrossAxisExtent:
|
||||
constraints.maxWidth > 700 ? 260 : 200,
|
||||
mainAxisExtent: 168,
|
||||
crossAxisSpacing: 10,
|
||||
mainAxisSpacing: 10,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final category = displayCategories[index];
|
||||
return _buildCategoryDailyPacingCard(theme, category);
|
||||
final storeCategory = progress.categories[category.key];
|
||||
return _buildCategoryDailyPacingCard(
|
||||
theme,
|
||||
category,
|
||||
storeCategory: storeCategory,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 14),
|
||||
const SizedBox(height: 14),
|
||||
|
||||
// ==========================================
|
||||
// 3. SEZIONE INFERIORE: RIEPILOGO NEGOZIO
|
||||
// ==========================================
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surfaceContainerHighest
|
||||
.withValues(alpha: 0.35),
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
bottom: Radius.circular(19),
|
||||
),
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: theme.dividerColor.withValues(alpha: 0.2),
|
||||
),
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.storefront_outlined,
|
||||
size: 18,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Negozio:',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: theme.colorScheme.primary,
|
||||
letterSpacing: 0.5,
|
||||
// ==========================================
|
||||
// 3. SEZIONE INFERIORE: RIEPILOGO NEGOZIO
|
||||
// ==========================================
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surfaceContainerHighest
|
||||
.withValues(alpha: 0.35),
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
bottom: Radius.circular(19),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
// Badge sintetici del negozio
|
||||
_buildMiniBadge(
|
||||
label: '${progress.countAchieved}/${progress.countTotalActive} Presi',
|
||||
color: const Color(0xFF15803D),
|
||||
bgColor: const Color(0xFFDCFCE7),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
_buildMiniBadge(
|
||||
label: '${progress.countInLineOnly} In linea',
|
||||
color: const Color(0xFF0D9488),
|
||||
bgColor: const Color(0xFFCCFBF1),
|
||||
),
|
||||
if (progress.countBehind > 0) ...[
|
||||
const SizedBox(width: 6),
|
||||
_buildMiniBadge(
|
||||
label: '${progress.countBehind} Sotto ritmo',
|
||||
color: const Color(0xFFDC2626),
|
||||
bgColor: const Color(0xFFFEE2E2),
|
||||
),
|
||||
],
|
||||
const Spacer(),
|
||||
InkWell(
|
||||
onTap: () => context.pushNamed(
|
||||
Routes.targetDetail,
|
||||
extra: target,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: theme.dividerColor.withValues(alpha: 0.2),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: isCompact ? 14 : 20,
|
||||
vertical: 10,
|
||||
),
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 10,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 6,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
'Apri analisi completa',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
Icons.arrow_forward_rounded,
|
||||
size: 14,
|
||||
Icons.storefront_outlined,
|
||||
size: 17,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
Text(
|
||||
'Negozio:',
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: theme.colorScheme.primary,
|
||||
letterSpacing: 0.5,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
// Badge sintetici del negozio
|
||||
_buildMiniBadge(
|
||||
label:
|
||||
'${progress.countAchieved}/${progress.countTotalActive} Presi',
|
||||
color: const Color(0xFF15803D),
|
||||
bgColor: const Color(0xFFDCFCE7),
|
||||
),
|
||||
_buildMiniBadge(
|
||||
label: '${progress.countInLineOnly} In linea',
|
||||
color: const Color(0xFF0D9488),
|
||||
bgColor: const Color(0xFFCCFBF1),
|
||||
),
|
||||
if (progress.countBehind > 0)
|
||||
_buildMiniBadge(
|
||||
label: '${progress.countBehind} Sotto ritmo',
|
||||
color: const Color(0xFFDC2626),
|
||||
bgColor: const Color(0xFFFEE2E2),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () => context.pushNamed(
|
||||
Routes.targetDetail,
|
||||
extra: target,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 4,
|
||||
vertical: 2,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Apri analisi completa',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
Icons.arrow_forward_rounded,
|
||||
size: 14,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCategoryDailyPacingCard(
|
||||
ThemeData theme,
|
||||
CategoryProgress category,
|
||||
) {
|
||||
CategoryProgress category, {
|
||||
CategoryProgress? storeCategory,
|
||||
}) {
|
||||
final pacingTheme = PacingTheme.of(category.status);
|
||||
final isAchieved = category.isAchieved;
|
||||
final hasS2 = category.targetS2 > 0;
|
||||
@@ -532,7 +571,7 @@ class DashboardTargetHeroCard extends StatelessWidget {
|
||||
)
|
||||
else
|
||||
Text(
|
||||
'Soglia minima centrata!',
|
||||
'Obiettivo personale centrato!',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -581,7 +620,7 @@ class DashboardTargetHeroCard extends StatelessWidget {
|
||||
)
|
||||
else
|
||||
Text(
|
||||
'per Minimo (${category.targetS1})',
|
||||
'Target: ${category.targetS1} pz',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -593,12 +632,12 @@ class DashboardTargetHeroCard extends StatelessWidget {
|
||||
|
||||
const Spacer(),
|
||||
|
||||
// Footer: Avanzamento e ritmo attuale
|
||||
// Footer: Avanzamento personale e ritmo
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Fatti: ${category.actualPieces} / ${category.targetS1}',
|
||||
'I tuoi: ${category.actualPieces} / ${category.targetS1}',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -627,6 +666,30 @@ class DashboardTargetHeroCard extends StatelessWidget {
|
||||
color: pacingTheme.primary,
|
||||
),
|
||||
),
|
||||
if (storeCategory != null && storeCategory.targetS1 > 0) ...[
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Negozio: ${storeCategory.actualPieces}/${storeCategory.targetS1}',
|
||||
style: TextStyle(
|
||||
fontSize: 9.5,
|
||||
color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.75),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'ritmo: ${storeCategory.actualDailyRate.toStringAsFixed(1)}/gg',
|
||||
style: TextStyle(
|
||||
fontSize: 9.5,
|
||||
color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.75),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -79,6 +79,12 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
}
|
||||
|
||||
void _startListeners() {
|
||||
final sessionState = context.read<SessionCubit>().state;
|
||||
context.read<DashboardTargetProgressCubit>().updateContext(
|
||||
newCompanyId: sessionState.company?.id,
|
||||
newStoreId: sessionState.currentStore?.id,
|
||||
newStaffId: sessionState.currentStaffMember?.id,
|
||||
);
|
||||
context.read<DashboardStoreOperationListCubit>().startListening();
|
||||
context.read<DashboardTaskListCubit>().startListening();
|
||||
context.read<DashboardStoreTicketListCubit>().startListening();
|
||||
|
||||
@@ -139,14 +139,39 @@ class TargetProgressService {
|
||||
|
||||
// 4. Costruzione avanzamento per singoli addetti
|
||||
final staffProgressMap = <String, TargetProgressModel>{};
|
||||
for (final it in target.individualTargets) {
|
||||
final individualTargetsList = target.individualTargets;
|
||||
|
||||
final bool hasExplicitIndividualTargets = individualTargetsList.any(
|
||||
(it) => it.metrics.totalLevel1 > 0 || it.metrics.totalLevel2 > 0,
|
||||
);
|
||||
|
||||
final int staffCount = individualTargetsList.isNotEmpty
|
||||
? individualTargetsList.length
|
||||
: (staffCounts.isNotEmpty ? staffCounts.length : 1);
|
||||
|
||||
for (final it in individualTargetsList) {
|
||||
final sId = it.staffId;
|
||||
final sCounts = staffCounts[sId] ?? {};
|
||||
final sCategories = <String, CategoryProgress>{};
|
||||
|
||||
for (final def in metricDefinitions) {
|
||||
final actual = sCounts[def.key] ?? 0;
|
||||
final targets = _extractTargetS1S2(it.metrics, def.key);
|
||||
({int s1, int s2}) targets;
|
||||
|
||||
if (hasExplicitIndividualTargets) {
|
||||
targets = _extractTargetS1S2(it.metrics, def.key);
|
||||
} else {
|
||||
// Se non sono stati assegnati target individuali, dividi equamente il target del negozio
|
||||
final storeTargets = _extractTargetS1S2(target.metrics, def.key);
|
||||
targets = (
|
||||
s1: staffCount > 0
|
||||
? (storeTargets.s1 / staffCount).round()
|
||||
: storeTargets.s1,
|
||||
s2: staffCount > 0
|
||||
? (storeTargets.s2 / staffCount).round()
|
||||
: storeTargets.s2,
|
||||
);
|
||||
}
|
||||
|
||||
sCategories[def.key] = CategoryProgress.calculate(
|
||||
key: def.key,
|
||||
@@ -172,6 +197,48 @@ class TargetProgressService {
|
||||
);
|
||||
}
|
||||
|
||||
// Se ci sono addetti con operazioni che non compaiono in individualTargets, creiamo la loro scheda
|
||||
for (final sId in staffCounts.keys) {
|
||||
if (!staffProgressMap.containsKey(sId)) {
|
||||
final sCounts = staffCounts[sId] ?? {};
|
||||
final sCategories = <String, CategoryProgress>{};
|
||||
|
||||
for (final def in metricDefinitions) {
|
||||
final actual = sCounts[def.key] ?? 0;
|
||||
final storeTargets = _extractTargetS1S2(target.metrics, def.key);
|
||||
final targets = (
|
||||
s1: staffCount > 0
|
||||
? (storeTargets.s1 / staffCount).round()
|
||||
: storeTargets.s1,
|
||||
s2: staffCount > 0
|
||||
? (storeTargets.s2 / staffCount).round()
|
||||
: storeTargets.s2,
|
||||
);
|
||||
|
||||
sCategories[def.key] = CategoryProgress.calculate(
|
||||
key: def.key,
|
||||
label: def.label,
|
||||
actual: actual,
|
||||
s1: targets.s1,
|
||||
s2: targets.s2,
|
||||
elapsedDays: days.elapsed,
|
||||
remainingDays: days.remaining,
|
||||
totalDays: days.total,
|
||||
);
|
||||
}
|
||||
|
||||
staffProgressMap[sId] = TargetProgressModel(
|
||||
targetId: target.id ?? '',
|
||||
storeId: target.storeId,
|
||||
staffId: sId,
|
||||
totalWorkingDays: days.total,
|
||||
elapsedWorkingDays: days.elapsed,
|
||||
remainingWorkingDays: days.remaining,
|
||||
categories: sCategories,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return TargetProgressModel(
|
||||
targetId: target.id ?? '',
|
||||
storeId: target.storeId,
|
||||
|
||||
@@ -179,6 +179,15 @@ class TargetProgressModel extends Equatable {
|
||||
this.staffProgress = const {},
|
||||
});
|
||||
|
||||
factory TargetProgressModel.empty() => const TargetProgressModel(
|
||||
targetId: '',
|
||||
totalWorkingDays: 0,
|
||||
elapsedWorkingDays: 0,
|
||||
remainingWorkingDays: 0,
|
||||
categories: {},
|
||||
staffProgress: {},
|
||||
);
|
||||
|
||||
/// Somma di tutti i pezzi realizzati finora
|
||||
int get totalActualPieces =>
|
||||
categories.values.fold(0, (sum, c) => sum + c.actualPieces);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
name: flux
|
||||
description: "Gestione attività negozio di telefonia"
|
||||
publish_to: 'none'
|
||||
version: 2.0.1+57
|
||||
version: 2.0.3+59
|
||||
|
||||
environment:
|
||||
sdk: ^3.11.3
|
||||
|
||||
Reference in new issue
Block a user