++ fix prioritario display and add link sent toggle
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user