Skip to content

Commit c15ba01

Browse files
committed
feat: aggiunti header per moduli con accesso tramite token (anagrafiche e impianti)
1 parent 790ee1e commit c15ba01

3 files changed

Lines changed: 304 additions & 1 deletion

File tree

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?php
2+
3+
/*
4+
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
5+
* Copyright (C) DevCode s.r.l.
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
use Models\Module;
22+
use Models\Upload;
23+
use Modules\Anagrafiche\Anagrafica;
24+
25+
// Controllo che l'anagrafica sia disponibile
26+
if (empty($anagrafica)) {
27+
return;
28+
}
29+
30+
// Logo
31+
$logo_record = Upload::where('id_module', Module::where('name', 'Anagrafiche')->first()->id)
32+
->where('id_record', $anagrafica->idanagrafica)
33+
->where('name', 'Logo azienda')
34+
->first();
35+
36+
// Tipologie anagrafica
37+
$tipologie = $anagrafica->tipi->pluck('title')->toArray();
38+
$tipologie_string = !empty($tipologie) ? implode(', ', $tipologie) : tr('Nessuna tipologia');
39+
40+
// Sedi aggiuntive
41+
$sedi_aggiuntive = $anagrafica->sedi()->count();
42+
43+
// Referenti
44+
$referenti = $dbo->fetchArray('SELECT * FROM an_referenti WHERE idanagrafica = '.prepare($anagrafica->idanagrafica).' ORDER BY nome');
45+
46+
echo '
47+
<div class="row mb-4">
48+
<div class="col-md-12">
49+
<div class="card card-outline card-primary shadow">
50+
<div class="card-header">
51+
<h3 class="card-title"><i class="fa fa-vcard"></i> <span style="color: #000;">'.tr('Informazioni Anagrafica').'</span></h3>
52+
</div>
53+
<div class="card-body">
54+
<div class="row">
55+
<div class="col-md-10">
56+
<div class="row">
57+
<div class="col-md-6">
58+
<h4 class="mb-2"><b>'.$anagrafica->ragione_sociale.'</b></h4>
59+
60+
<p class="mb-2">
61+
'.(!empty($anagrafica->indirizzo) ? '<i class="fa fa-map-marker text-muted mr-1"></i> '.$anagrafica->indirizzo.(!empty($anagrafica->indirizzo2) ? ', '.$anagrafica->indirizzo2 : '').'<br>' : '').'
62+
'.(!empty($anagrafica->cap) || !empty($anagrafica->citta) ? '<i class="fa fa-map text-muted mr-1"></i> '.trim(($anagrafica->cap ?? '').' - '.($anagrafica->citta ?? '').' '.($anagrafica->provincia ?? ''), ' -()') : '').'
63+
</p>
64+
65+
<div class="mb-2">
66+
'.(!empty($anagrafica->codice) ? '<i class="fa fa-barcode mr-1"></i> '.$anagrafica->codice : '').'
67+
</div>
68+
</div>
69+
70+
<div class="col-md-6">
71+
<div class="mb-3">
72+
<h5 class="mb-2">
73+
<i class="fa fa-info-circle text-primary mr-1"></i>
74+
<strong>'.tr('Dati Fiscali').'</strong>
75+
</h5>
76+
<p class="text-muted mb-2">
77+
'.(!empty($anagrafica->piva) ? '<i class="fa fa-building text-muted mr-1"></i> <strong>'.tr('P.IVA').':</strong> '.$anagrafica->piva.'<br>' : '').'
78+
'.(!empty($anagrafica->codice_fiscale) ? '<i class="fa fa-id-card text-muted mr-1"></i> <strong>'.tr('C.F.').':</strong> '.$anagrafica->codice_fiscale : '').'
79+
</p>
80+
</div>
81+
82+
<div class="mt-2">
83+
'.(!empty($anagrafica->telefono) ? '<a class="btn btn-light btn-xs mr-1 mb-1" href="tel:'.$anagrafica->telefono.'" target="_blank"><i class="fa fa-phone text-primary"></i> '.$anagrafica->telefono.'</a>' : '').'
84+
'.(!empty($anagrafica->cellulare) ? '<a class="btn btn-light btn-xs mr-1 mb-1" href="tel:'.$anagrafica->cellulare.'" target="_blank"><i class="fa fa-mobile text-primary"></i> '.$anagrafica->cellulare.'</a>' : '').'
85+
'.(!empty($anagrafica->email) ? '<a class="btn btn-light btn-xs mr-1 mb-1" href="mailto:'.$anagrafica->email.'"><i class="fa fa-envelope text-primary"></i> '.$anagrafica->email.'</a>' : '').'
86+
'.(!empty($anagrafica->pec) ? '<a class="btn btn-light btn-xs mr-1 mb-1" href="mailto:'.$anagrafica->pec.'"><i class="fa fa-envelope-o text-primary"></i> PEC</a>' : '').'
87+
'.(!empty($anagrafica->sitoweb) ? '<a class="btn btn-light btn-xs mr-1 mb-1" href="'.(strpos($anagrafica->sitoweb, 'http') === 0 ? $anagrafica->sitoweb : 'http://'.$anagrafica->sitoweb).'" target="_blank"><i class="fa fa-globe text-primary"></i> '.tr('Sito web').'</a>' : '').'
88+
</div>';
89+
90+
// Mostra informazioni su sedi aggiuntive
91+
if ($sedi_aggiuntive > 0) {
92+
echo '
93+
<div class="mt-3">
94+
<div class="alert alert-info py-2 mb-2">
95+
<i class="fa fa-building-o mr-1"></i>
96+
<strong>'.tr('Sedi aggiuntive').':</strong> '.$sedi_aggiuntive.'
97+
</div>
98+
</div>';
99+
}
100+
101+
// Mostra referenti se presenti
102+
if (!empty($referenti)) {
103+
echo '
104+
<div class="mt-3">
105+
<h6><i class="fa fa-users text-muted mr-1"></i> <strong>'.tr('Referenti').':</strong></h6>';
106+
107+
foreach ($referenti as $referente) {
108+
echo '
109+
<div class="mb-2">
110+
<span class="text-muted"><i class="fa fa-user-o mr-1"></i> '.$referente['nome'].'</span>
111+
'.(!empty($referente['telefono']) ? '<a class="btn btn-light btn-xs ml-2" href="tel:'.$referente['telefono'].'" target="_blank"><i class="fa fa-phone text-primary"></i> '.$referente['telefono'].'</a>' : '').'
112+
'.(!empty($referente['email']) ? '<a class="btn btn-light btn-xs ml-1" href="mailto:'.$referente['email'].'"><i class="fa fa-envelope text-primary"></i> '.$referente['email'].'</a>' : '').'
113+
</div>';
114+
}
115+
116+
echo '
117+
</div>';
118+
}
119+
120+
echo '
121+
</div>
122+
</div>
123+
</div>
124+
</div>
125+
</div>
126+
</div>
127+
</div>
128+
</div>';

modules/impianti/shared_header.php

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
<?php
2+
3+
/*
4+
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
5+
* Copyright (C) DevCode s.r.l.
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
use Modules\Impianti\Impianto;
22+
23+
// Controllo che l'impianto sia disponibile
24+
if (empty($record)) {
25+
return;
26+
}
27+
28+
// Carico l'impianto con Eloquent per avere accesso alle relazioni
29+
$impianto = Impianto::find($id_record);
30+
if (empty($impianto)) {
31+
return;
32+
}
33+
34+
// Anagrafica cliente
35+
$anagrafica = $impianto->anagrafica;
36+
if (empty($anagrafica)) {
37+
return;
38+
}
39+
40+
// Sede
41+
$sede = null;
42+
if (!empty($record['idsede'])) {
43+
$sede = $dbo->fetchOne('SELECT * FROM an_sedi WHERE id = '.prepare($record['idsede']));
44+
} else {
45+
$sede = $anagrafica ? $anagrafica->toArray() : null;
46+
}
47+
48+
// Categoria e sottocategoria
49+
$categoria = null;
50+
$sottocategoria = null;
51+
if (!empty($record['id_categoria'])) {
52+
$categoria = $dbo->fetchOne('SELECT zz_categorie.*, zz_categorie_lang.title FROM zz_categorie LEFT JOIN zz_categorie_lang ON (zz_categorie.id = zz_categorie_lang.id_record AND zz_categorie_lang.id_lang = '.prepare(Models\Locale::getDefault()->id).') WHERE zz_categorie.id = '.prepare($record['id_categoria']));
53+
}
54+
if (!empty($record['id_sottocategoria'])) {
55+
$sottocategoria = $dbo->fetchOne('SELECT zz_categorie.*, zz_categorie_lang.title FROM zz_categorie LEFT JOIN zz_categorie_lang ON (zz_categorie.id = zz_categorie_lang.id_record AND zz_categorie_lang.id_lang = '.prepare(Models\Locale::getDefault()->id).') WHERE zz_categorie.id = '.prepare($record['id_sottocategoria']));
56+
}
57+
58+
// Marca e modello
59+
$marca = null;
60+
$modello = null;
61+
if (!empty($record['id_marca'])) {
62+
$marca = $dbo->fetchOne('SELECT * FROM zz_marche WHERE id = '.prepare($record['id_marca']).' AND deleted_at IS NULL');
63+
}
64+
if (!empty($record['id_modello'])) {
65+
$modello = $dbo->fetchOne('SELECT * FROM zz_marche WHERE id = '.prepare($record['id_modello']).' AND deleted_at IS NULL');
66+
}
67+
68+
echo '
69+
<div class="row mb-4">
70+
<div class="col-md-12">
71+
<div class="card card-outline card-primary shadow">
72+
<div class="card-header">
73+
<h3 class="card-title"><i class="fa fa-cogs"></i> <span style="color: #000;">'.tr('Informazioni Impianto').'</span></h3>
74+
</div>
75+
<div class="card-body">
76+
<div class="row">
77+
<div class="col-md-12">
78+
<div class="row">
79+
<div class="col-md-6">
80+
<h4 class="mb-2"><b><i class="fa fa-cog text-primary mr-1"></i> '.$record['nome'].'</b></h4>
81+
82+
<p class="mb-2">
83+
<span class="badge badge-secondary"><i class="fa fa-barcode mr-1"></i> '.$record['matricola'].'</span>
84+
'.(!empty($categoria['title']) ? '<span class="badge badge-info ml-1"><i class="fa fa-tag mr-1"></i> '.$categoria['title'].'</span>' : '').'
85+
'.(!empty($sottocategoria['title']) ? '<span class="badge badge-light ml-1">'.$sottocategoria['title'].'</span>' : '').'
86+
</p>
87+
88+
'.(!empty($record['descrizione']) ? '<p class="text-muted mb-2"><i class="fa fa-info-circle mr-1"></i> '.$record['descrizione'].'</p>' : '').'
89+
90+
<!-- Marca e Modello a sinistra -->';
91+
92+
// Informazioni tecniche
93+
if (!empty($marca['name']) || !empty($modello['name'])) {
94+
echo '<div class="mb-3">';
95+
if (!empty($marca['name'])) {
96+
echo '<h5 class="mb-1"><strong>'.tr('Marca').':</strong> '.$marca['name'].'</h5>';
97+
}
98+
if (!empty($modello['name'])) {
99+
echo '<h5 class="mb-1"><strong>'.tr('Modello').':</strong> '.$modello['name'].'</h5>';
100+
}
101+
echo '</div>';
102+
}
103+
104+
echo '
105+
</div>
106+
107+
<div class="col-md-6">';
108+
109+
// Data installazione - spostata sopra
110+
if (!empty($record['data'])) {
111+
echo '<div class="mb-3"><i class="fa fa-calendar text-muted mr-1"></i> <strong>'.tr('Installato il').':</strong> '.Translator::dateToLocale($record['data']).'</div>';
112+
}
113+
114+
echo '
115+
<!-- Cliente a destra -->
116+
<div class="mb-3">
117+
<h5 class="mb-2">
118+
<i class="fa fa-user text-primary mr-1"></i>
119+
<strong>'.$anagrafica->ragione_sociale.'</strong>
120+
</h5>
121+
</div>
122+
123+
<div class="mt-2">';
124+
125+
// Contatti sede/cliente
126+
if (!empty($sede['telefono']) || !empty($sede['email']) || !empty($anagrafica->telefono) || !empty($anagrafica->email)) {
127+
echo '<div class="mt-3">';
128+
if (!empty($sede['telefono'])) {
129+
echo '<a class="btn btn-light btn-xs mr-1 mb-1" href="tel:'.$sede['telefono'].'" target="_blank"><i class="fa fa-phone text-primary"></i> '.$sede['telefono'].'</a>';
130+
} elseif (!empty($anagrafica->telefono)) {
131+
echo '<a class="btn btn-light btn-xs mr-1 mb-1" href="tel:'.$anagrafica->telefono.'" target="_blank"><i class="fa fa-phone text-primary"></i> '.$anagrafica->telefono.'</a>';
132+
}
133+
134+
if (!empty($sede['email'])) {
135+
echo '<a class="btn btn-light btn-xs mr-1 mb-1" href="mailto:'.$sede['email'].'"><i class="fa fa-envelope text-primary"></i> '.$sede['email'].'</a>';
136+
} elseif (!empty($anagrafica->email)) {
137+
echo '<a class="btn btn-light btn-xs mr-1 mb-1" href="mailto:'.$anagrafica->email.'"><i class="fa fa-envelope text-primary"></i> '.$anagrafica->email.'</a>';
138+
}
139+
echo '</div>';
140+
}
141+
142+
echo '
143+
</div>
144+
</div>
145+
</div>
146+
</div>
147+
</div>
148+
</div>
149+
</div>
150+
</div>
151+
</div>';

shared_editor.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@
150150
'rwa' => tr('Gestione Allegati'),
151151
];
152152

153+
$permission_info = [
154+
'r' => tr('Hai accesso in sola lettura: puoi consultare tutte le informazioni e i dettagli presenti, ma non potrai apportare modifiche o salvare cambiamenti'),
155+
'rw' => tr('Hai accesso completo ai dati: puoi visualizzare tutte le informazioni e modificarle, salvando i cambiamenti quando necessario'),
156+
'ra' => tr('Hai accesso per caricare gli allegati: puoi caricare, consultare e scaricare tutti i documenti presenti'),
157+
'rwa' => tr('Hai accesso completo alla gestione documenti: puoi visualizzare, caricare, modificare ed eliminare allegati'),
158+
];
159+
153160
$pageTitle = tr($structure->getTranslation('title')).' - '.$permission_titles[$current_permission];
154161

155162
// Navbar custom prima di top.php
@@ -256,16 +263,33 @@
256263
<div class="col-md-12">
257264
258265
<!-- Titolo del modulo -->
259-
<div class="row">
266+
<div class="row mb-2">
260267
<div class="col-md-12">
261268
<h1>
262269
<i class="'.$structure['icon'].'"></i> '.$structure->getTranslation('title').'
263270
</h1>
264271
</div>
265272
</div>
266273
274+
<!-- Info in base al tipo di operazioni permesse -->
275+
<div class="row mb-2">
276+
<div class="col-md-12">
277+
<div class="alert alert-info">
278+
<i class="fa fa-info-circle"></i> '.$permission_info[$current_permission].'
279+
</div>
280+
</div>
281+
</div>
282+
267283
<div class="card">
268284
<div class="card-body">';
285+
286+
//Se abbiamo accesso solo agli allegati mostro un header informativo
287+
if ($current_permission == 'ra' || $current_permission == 'rwa') {
288+
// Includi l'header personalizzato se il modulo lo supporta e abbiamo i dati necessari
289+
if(file_exists(App::filepath('modules/'.$module['directory'].'|custom|', 'shared_header.php'))) {
290+
include_once App::filepath('modules/'.$module['directory'].'|custom|', 'shared_header.php');
291+
}
292+
}
269293

270294
if ($current_permission == 'rw' || $current_permission == 'r') {
271295
$path = $structure->getEditFile();

0 commit comments

Comments
 (0)