Skip to content

Commit

Permalink
Aggiunta: gestione categorie ATA in avvisi
Browse files Browse the repository at this point in the history
  • Loading branch information
trinko committed Jan 28, 2025
1 parent 3e04b14 commit 8e5e1c1
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Entity/Avviso.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Avviso implements Stringable {
private ?array $allegati = [];

/**
* @var array|null $destinatariAta Indica il personale ATA destinatario dell'avviso [D=DSGA, A=personale ATA]
* @var array|null $destinatariAta Indica il personale ATA destinatario dell'avviso [D=DSGA, A=tutto il personale ATA, M=amministrativi, T=tecnici, C=collaboratori scolastici]
*/
#[ORM\Column(name: 'destinatari_ata', type: Types::SIMPLE_ARRAY, nullable: true)]
private ?array $destinatariAta = [];
Expand Down
3 changes: 2 additions & 1 deletion src/Form/AvvisoType.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void {
'label_attr' => ['class' => 'gs-checkbox-inline gs-mr-5 gs-pr-5'],
'required' => true])
->add('destinatariAta', ChoiceType::class, ['label' => 'label.destinatari_ATA',
'choices' => ['label.dsga' => 'D', 'label.ata' => 'A'],
'choices' => ['label.dsga' => 'D', 'label.ata' => 'A', 'label.ata_amministrativi' => 'M',
'label.ata_tecnici' => 'T', 'label.ata_collaboratori' => 'C'],
'placeholder' => false,
'expanded' => true,
'multiple' => true,
Expand Down
33 changes: 32 additions & 1 deletion src/Repository/AtaRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getIdDsga() {
*
* @return array Lista di ID degli utenti ATA
*/
public function getIdAta($sedi) {
public function getIdAta($sedi): array {
$ata = $this->createQueryBuilder('a')
->select('a.id')
->where('a.abilitato=:abilitato')
Expand All @@ -80,6 +80,37 @@ public function getIdAta($sedi) {
return array_column($ata, 'id');
}

/**
* Restituisce gli utenti ATA per le sedi indicate, in base alle categorie scelte
*
* @param array $categorie Categorie personale ATA
* @param array $sedi Sedi di servizio (lista ID di Sede)
*
* @return array Lista di ID degli utenti ATA
*/
public function getIdCategorieAta($categorie, $sedi): array {
// imposta categorie ammesse
$cat = [];
foreach ($categorie as $c) {
if ($c == 'M') {
// codifica differente
$cat[] = 'A';
} elseif ($c == 'T' || $c == 'C') {
$cat[] = $c;
}
}
// legge utenti
$ata = $this->createQueryBuilder('a')
->select('a.id')
->where('a.abilitato=1 AND a.tipo IN (:categorie) AND (a.sede IS NULL OR a.sede IN (:sedi))')
->setParameter('categorie', $cat)
->setParameter('sedi', $sedi)
->getQuery()
->getArrayResult();
// restituisce la lista degli ID
return array_column($ata, 'id');
}

/**
* Restituisce la lista dei rappresentanti del personale ATA secondo i criteri indicati
*
Expand Down
8 changes: 6 additions & 2 deletions src/Util/BachecaUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function azioneAvviso($azione, DateTime $data, Docente $docente, Avviso $
} elseif ($azione == 'delete') {
// azione di cancellazione
if ($avviso) {
// esiste annotazione
// esiste avviso
if ($docente->getId() == $avviso->getDocente()->getId()) {
// stesso docente: ok
return true;
Expand Down Expand Up @@ -554,8 +554,12 @@ public function destinatariAvviso(Avviso $avviso) {
}
// ata
if (in_array('A', $avviso->getDestinatariAta())) {
// aggiunge ATA
// aggiunge tutto il personale ATA
$utenti = array_merge($utenti, $this->em->getRepository(Ata::class)->getIdAta($sedi));
} else if (in_array('M', $avviso->getDestinatariAta()) || in_array('T', $avviso->getDestinatariAta()) ||
in_array('C', $avviso->getDestinatariAta())) {
// aggiunge categorie ATA
$utenti = array_merge($utenti, $this->em->getRepository(Ata::class)->getIdCategorieAta($avviso->getDestinatariAta(), $sedi));
}
// RSPP
if (in_array('S', $avviso->getDestinatariSpeciali())) {
Expand Down
4 changes: 4 additions & 0 deletions src/Util/RegistroUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ public function azioneAnnotazione(string $azione, DateTime $data, Docente $docen
// stesso docente: ok
return true;
}
if (in_array('ROLE_STAFF', $annotazione->getDocente()->getRoles()) && in_array('ROLE_STAFF', $docente->getRoles())) {
// docente è dello staff come anche chi ha scritto avviso: ok
return true;
}
}
}
// non consentito
Expand Down
8 changes: 7 additions & 1 deletion templates/bacheca/avvisi.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@
{% if 'S' in a.avviso.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_S'|trans }}</span>{% endif %}
{% if 'P' in a.avviso.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_P'|trans }}</span>{% endif %}
{% if 'D' in a.avviso.destinatariAta %}<span class="gs-mr-2">DSGA</span>{% endif %}
{% if 'A' in a.avviso.destinatariAta %}<span class="gs-mr-2">ATA</span>{% endif %}
{% if 'A' in a.avviso.destinatariAta %}
<span class="gs-mr-2">ATA</span>
{% else %}
{% if 'M' in a.avviso.destinatariAta %}<span class="gs-mr-2">Amministrativi</span>{% endif %}
{% if 'T' in a.avviso.destinatariAta %}<span class="gs-mr-2">Tecnici</span>{% endif %}
{% if 'C' in a.avviso.destinatariAta %}<span class="gs-mr-2">Coll.scolast.</span>{% endif %}
{% endif %}
{% if 'S' in a.avviso.destinatariSpeciali %}<span class="gs-mr-2">RSPP</span>{% endif %}
</small>
</td>
Expand Down
8 changes: 7 additions & 1 deletion templates/bacheca/avvisi_ata.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@
{% if 'S' in a.avviso.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_S'|trans }}</span>{% endif %}
{% if 'P' in a.avviso.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_P'|trans }}</span>{% endif %}
{% if 'D' in a.avviso.destinatariAta %}<span class="gs-mr-2">DSGA</span>{% endif %}
{% if 'A' in a.avviso.destinatariAta %}<span class="gs-mr-2">ATA</span>{% endif %}
{% if 'A' in a.avviso.destinatariAta %}
<span class="gs-mr-2">ATA</span>
{% else %}
{% if 'M' in a.avviso.destinatariAta %}<span class="gs-mr-2">Amministrativi</span>{% endif %}
{% if 'T' in a.avviso.destinatariAta %}<span class="gs-mr-2">Tecnici</span>{% endif %}
{% if 'C' in a.avviso.destinatariAta %}<span class="gs-mr-2">Coll.scolast.</span>{% endif %}
{% endif %}
{% if 'S' in a.avviso.destinatariSpeciali %}<span class="gs-mr-2">RSPP</span>{% endif %}
</small>
</td>
Expand Down
8 changes: 7 additions & 1 deletion templates/bacheca/avvisi_genitori.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@
{% if 'S' in a.avviso.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_S'|trans }}</span>{% endif %}
{% if 'P' in a.avviso.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_P'|trans }}</span>{% endif %}
{% if 'D' in a.avviso.destinatariAta %}<span class="gs-mr-2">DSGA</span>{% endif %}
{% if 'A' in a.avviso.destinatariAta %}<span class="gs-mr-2">ATA</span>{% endif %}
{% if 'A' in a.avviso.destinatariAta %}
<span class="gs-mr-2">ATA</span>
{% else %}
{% if 'M' in a.avviso.destinatariAta %}<span class="gs-mr-2">Amministrativi</span>{% endif %}
{% if 'T' in a.avviso.destinatariAta %}<span class="gs-mr-2">Tecnici</span>{% endif %}
{% if 'C' in a.avviso.destinatariAta %}<span class="gs-mr-2">Coll.scolast.</span>{% endif %}
{% endif %}
{% if 'S' in a.avviso.destinatariSpeciali %}<span class="gs-mr-2">RSPP</span>{% endif %}
</small>
</td>
Expand Down
8 changes: 7 additions & 1 deletion templates/bacheca/scheda_avviso.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@
{% if 'S' in dati.avviso.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_S'|trans }}</span>{% endif %}
{% if 'P' in dati.avviso.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_P'|trans }}</span>{% endif %}
{% if 'D' in dati.avviso.destinatariAta %}<span class="gs-mr-2">DSGA</span>{% endif %}
{% if 'A' in dati.avviso.destinatariAta %}<span class="gs-mr-2">ATA</span>{% endif %}
{% if 'A' in dati.avviso.destinatariAta %}
<span class="gs-mr-2">ATA</span>
{% else %}
{% if 'M' in dati.avviso.destinatariAta %}<span class="gs-mr-2">Amministrativi</span>{% endif %}
{% if 'T' in dati.avviso.destinatariAta %}<span class="gs-mr-2">Tecnici</span>{% endif %}
{% if 'C' in dati.avviso.destinatariAta %}<span class="gs-mr-2">Coll.scolast.</span>{% endif %}
{% endif %}
{% if 'S' in dati.avviso.destinatariSpeciali %}<span class="gs-mr-2">RSPP</span>{% endif %}
</div>
{% if dati.classi|length > 0 %}
Expand Down
8 changes: 7 additions & 1 deletion templates/ruolo_staff/avvisi.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
{% if 'S' in a.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_S'|trans }}</span>{% endif %}
{% if 'P' in a.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_P'|trans }}</span>{% endif %}
{% if 'D' in a.destinatariAta %}<span class="gs-mr-2">DSGA</span>{% endif %}
{% if 'A' in a.destinatariAta %}<span class="gs-mr-2">ATA</span>{% endif %}
{% if 'A' in a.destinatariAta %}
<span class="gs-mr-2">ATA</span>
{% else %}
{% if 'M' in a.destinatariAta %}<span class="gs-mr-2">Amministrativi</span>{% endif %}
{% if 'T' in a.destinatariAta %}<span class="gs-mr-2">Tecnici</span>{% endif %}
{% if 'C' in a.destinatariAta %}<span class="gs-mr-2">Coll.scolast.</span>{% endif %}
{% endif %}
{% if 'S' in a.destinatariSpeciali %}<span class="gs-mr-2">RSPP</span>{% endif %}
</small>
</td>
Expand Down
8 changes: 7 additions & 1 deletion templates/ruolo_staff/avvisi_archivio.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@
{% if 'S' in a.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_S'|trans }}</span>{% endif %}
{% if 'P' in a.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_P'|trans }}</span>{% endif %}
{% if 'D' in a.destinatariAta %}<span class="gs-mr-2">DSGA</span>{% endif %}
{% if 'A' in a.destinatariAta %}<span class="gs-mr-2">ATA</span>{% endif %}
{% if 'A' in a.destinatariAta %}
<span class="gs-mr-2">ATA</span>
{% else %}
{% if 'M' in a.destinatariAta %}<span class="gs-mr-2">Amministrativi</span>{% endif %}
{% if 'T' in a.destinatariAta %}<span class="gs-mr-2">Tecnici</span>{% endif %}
{% if 'C' in a.destinatariAta %}<span class="gs-mr-2">Coll.scolast.</span>{% endif %}
{% endif %}
{% if 'S' in a.destinatariSpeciali %}<span class="gs-mr-2">RSPP</span>{% endif %}
</small>
</td>
Expand Down
15 changes: 15 additions & 0 deletions templates/ruolo_staff/avvisi_edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,21 @@ $(document).ready(function() {
$("#avviso_filtroTipo").val(old);
$("#gs-modal-alunni").modal('hide');
});
$("input[name='avviso[destinatariAta][]']").change(function() {
if ($(this).val() == 'A') {
if ($(this).is(":checked")) {
$("input[name='avviso[destinatariAta][]'][value='M']").prop("checked", true).parent().addClass('active');
$("input[name='avviso[destinatariAta][]'][value='T']").prop("checked", true).parent().addClass('active');
$("input[name='avviso[destinatariAta][]'][value='C']").prop("checked", true).parent().addClass('active');
} else {
$("input[name='avviso[destinatariAta][]'][value='M']").prop("checked", false).parent().removeClass('active');
$("input[name='avviso[destinatariAta][]'][value='T']").prop("checked", false).parent().removeClass('active');
$("input[name='avviso[destinatariAta][]'][value='C']").prop("checked", false).parent().removeClass('active');
}
} else if ($(this).val() != 'D') {
$("input[name='avviso[destinatariAta][]'][value='A']").prop("checked", false).parent().removeClass('active');
}
});
$(document).on('keypress','.modal', function(e){
return event.keyCode != 13;
});
Expand Down
8 changes: 7 additions & 1 deletion templates/ruolo_staff/scheda_avviso.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@
{% if 'S' in dati.avviso.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_S'|trans }}</span>{% endif %}
{% if 'P' in dati.avviso.destinatari %}<span class="gs-mr-2">{{ 'label.rappresentanti_P'|trans }}</span>{% endif %}
{% if 'D' in dati.avviso.destinatariAta %}<span class="gs-mr-2">DSGA</span>{% endif %}
{% if 'A' in dati.avviso.destinatariAta %}<span class="gs-mr-2">ATA</span>{% endif %}
{% if 'A' in dati.avviso.destinatariAta %}
<span class="gs-mr-2">ATA</span>
{% else %}
{% if 'M' in dati.avviso.destinatariAta %}<span class="gs-mr-2">Amministrativi</span>{% endif %}
{% if 'T' in dati.avviso.destinatariAta %}<span class="gs-mr-2">Tecnici</span>{% endif %}
{% if 'C' in dati.avviso.destinatariAta %}<span class="gs-mr-2">Coll.scolast.</span>{% endif %}
{% endif %}
{% if 'S' in dati.avviso.destinatariSpeciali %}<span class="gs-mr-2">RSPP</span>{% endif %}
</div>
{% if dati.classi|length > 0 %}
Expand Down
3 changes: 3 additions & 0 deletions translations/messages+intl-icu.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ label.ata_tipo_T: Tecnico
label.ata_tipo_U: Autista
label.ata_tipo: Mansioni
label.ata: ATA
label.ata_amministrativi: Amministrativi
label.ata_tecnici: Tecnici
label.ata_collaboratori: Collaboratori scolastici
label.attivita_sostegno: Attività del sostegno
label.attivita: Attività
label.autore: Autore
Expand Down

0 comments on commit 8e5e1c1

Please sign in to comment.