++ fix prioritario display and add link sent toggle

This commit is contained in:
2026-04-13 15:40:35 +00:00
parent 0553d4ef74
commit 6a65087449
10 changed files with 459 additions and 108 deletions

View File

@@ -19,6 +19,7 @@ class Assegnazione extends Model
'counted_in_campaign',
'campaign_id',
'pdf_access_code',
'link_sent',
'note',
'created_by',
'returned_by',
@@ -30,6 +31,7 @@ class Assegnazione extends Model
'assigned_at' => 'date',
'returned_at' => 'date',
'counted_in_campaign' => 'boolean',
'link_sent' => 'boolean',
];
}
@@ -117,6 +119,11 @@ class Assegnazione extends Model
return route('assignments.pdf.short', ['code' => $this->ensurePdfAccessCode()]);
}
public function markLinkSent(): void
{
$this->forceFill(['link_sent' => true])->saveQuietly();
}
// ─── Scopes ─────────────────────────────────────────────────
public function scopeAperte($query)

View File

@@ -72,19 +72,19 @@ class Campagna extends Model
/**
* Campaign coverage percentage.
* Numerator: assignments counted for campaign
* Denominator: ALL assignments with assigned_at in campaign range (returned or not)
* Denominator: total active territories
*/
public function getPercentualePercorrenzaAttribute(): float
{
$totaleNelRange = $this->assegnazioniNelRange()->count();
$totaleAttivi = Territorio::where('attivo', true)->count();
if ($totaleNelRange === 0) {
if ($totaleAttivi === 0) {
return 0.0;
}
$conteggiate = $this->assegnazioniConteggiate()->count();
return round(($conteggiate / $totaleNelRange) * 100, 1);
return round(($conteggiate / $totaleAttivi) * 100, 1);
}
public function scopeCompletate($query)