Skip to content

Commit 26eca22

Browse files
feat: gestione registrazione danni automezzi
1 parent 6a49e49 commit 26eca22

7 files changed

Lines changed: 289 additions & 10 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
include_once __DIR__.'/../../core.php';
22+
23+
switch (post('op')) {
24+
// Aggiunta danno
25+
case 'adddanno':
26+
$descrizione = post('descrizione');
27+
$data = post('data');
28+
$luogo = post('luogo');
29+
30+
$dbo->insert('an_automezzi_danni', [
31+
'idsede' => $id_record,
32+
'descrizione' => $descrizione,
33+
'data' => $data,
34+
'luogo' => $luogo
35+
]);
36+
37+
flash()->info(tr('Danno aggiunto correttamente!'));
38+
39+
break;
40+
41+
// Modifica danno
42+
case 'editdanno':
43+
$iddanno = post('iddanno');
44+
$descrizione = post('descrizione');
45+
$data = post('data');
46+
$luogo = post('luogo');
47+
48+
$dbo->update('an_automezzi_danni', [
49+
'descrizione' => $descrizione,
50+
'data' => $data,
51+
'luogo' => $luogo
52+
], [
53+
'id' => $iddanno,
54+
]);
55+
56+
flash()->info(tr('Danno modificato correttamente!'));
57+
58+
break;
59+
60+
// Eliminazione scadenza
61+
case 'deldanno':
62+
$idscadenza = post('id');
63+
64+
$dbo->query('DELETE FROM an_automezzi_danni WHERE id = '.prepare($idscadenza));
65+
66+
flash()->info(tr('Scadenza eliminata correttamente!'));
67+
68+
break;
69+
}

plugins/automezzi_danni/edit.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
include_once __DIR__.'/../../core.php';
4+
5+
use Models\Plugin;
6+
7+
$plugin = Plugin::find($id_plugin);
8+
9+
?>
10+
<div class="row">
11+
<div class="col-md-12">
12+
<!-- DANNI -->
13+
<div class="card card-primary">
14+
<div class="card-header">
15+
<h3 class="card-title"><?php echo tr('Danni'); ?></h3>
16+
</div>
17+
18+
<div class="card-body">
19+
<div class="row">
20+
<div class="col-md-12">
21+
<?php
22+
include $plugin->filepath('row-list-danni.php');
23+
?>
24+
25+
<div class="pull-left">
26+
<a class="btn btn-sm btn-primary" data-href="<?php echo $plugin->fileurl('modals/manage_danno.php'); ?>?id_module=<?php echo $id_module; ?>&id_plugin=<?php echo $id_plugin; ?>&id=<?php echo $id_record; ?>" data-card-widget="modal" data-title="<?php echo tr('Aggiungi danno'); ?>"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi danno'); ?></a>
27+
</div>
28+
<div class="clearfix"></div>
29+
</div>
30+
</div>
31+
</div>
32+
</div>
33+
</div>
34+
</div>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
include_once __DIR__.'/../../../core.php';
22+
23+
$idautomezzo = get('id');
24+
$iddanno = get('iddanno');
25+
26+
// Recupero dati danno se in modifica
27+
if (!empty($iddanno)) {
28+
$record = $dbo->fetchOne('SELECT * FROM an_automezzi_danni WHERE id = '.prepare($iddanno));
29+
$title = tr('Modifica');
30+
$button_icon = 'edit';
31+
} else {
32+
$record = [];
33+
$title = tr('Aggiungi');
34+
$button_icon = 'plus';
35+
}
36+
37+
echo '
38+
<form action="" method="post" id="form-danno">
39+
<input type="hidden" name="backto" value="record-edit">
40+
<input type="hidden" name="op" value="'.(!empty($iddanno) ? 'editdanno' : 'adddanno').'">
41+
<input type="hidden" name="id_module" value="'.$id_module.'">
42+
<input type="hidden" name="id_record" value="'.$idautomezzo.'">
43+
<input type="hidden" name="id_plugin" value="'.$id_plugin.'">
44+
<input type="hidden" name="iddanno" value="'.$iddanno.'">
45+
46+
<div class="row">
47+
<div class="col-md-4">
48+
{[ "type": "date", "label": "'.tr('Data').'", "name": "data", "required": 1, "value": "'.($record['data'] ?? '').'" ]}
49+
</div>
50+
<div class="col-md-8">
51+
{[ "type": "text", "label": "'.tr('Luogo').'", "name": "luogo", "required": 1, "value": "'.($record['dove'] ?? '').'" ]}
52+
</div>
53+
</div>
54+
55+
<div class="row">
56+
<div class="col-md-12">
57+
{[ "type": "text", "label": "'.tr('Descrizione').'", "name": "descrizione", "required": 1, "value": "'.($record['descrizione'] ?? '').'" ]}
58+
</div>
59+
</div>
60+
61+
<div class="row">
62+
<div class="col-md-12 text-right">
63+
<button type="submit" class="btn btn-primary"><i class="fa fa-'.$button_icon.'"></i> '.$title.'</button>
64+
</div>
65+
</div>
66+
</form>';
67+
68+
if ($record['id']) {
69+
echo '
70+
<hr>
71+
{( "name": "filelist_and_upload", "id_module": "'.$id_module.'", "id_record": "'.$iddanno.'", "id_plugin": "'.$id_plugin.'" )}';
72+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
include_once __DIR__.'/../../core.php';
22+
23+
// Recupero i danni per questo automezzo
24+
$danni = $dbo->fetchArray('
25+
SELECT
26+
m.*
27+
FROM
28+
an_automezzi_danni m
29+
WHERE
30+
m.idsede = '.prepare($id_record).'
31+
ORDER BY
32+
m.data DESC
33+
');
34+
35+
echo '
36+
<table class="table table-striped table-hover table-sm">
37+
<thead>
38+
<tr>
39+
<th width="15%" class="text-center">'.tr('Data').'</th>
40+
<th width="25%">'.tr('Luogo').'</th>
41+
<th>'.tr('Descrizione').'</th>
42+
<th width="12%" class="text-center">'.tr('Azioni').'</th>
43+
</tr>
44+
</thead>
45+
<tbody>';
46+
47+
if (!empty($danni)) {
48+
$disabled = $user->gruppo == 'Tecnici' ? 'disabled' : '';
49+
foreach ($danni as $danno) {
50+
$n_file = $dbo->fetchNum('SELECT * FROM zz_files WHERE id_record='.$danno['id'].' AND id_plugin='.$id_plugin);
51+
echo '
52+
<tr>
53+
<td class="text-center">'.Translator::dateToLocale($danno['data']).'</td>
54+
<td>'.$danno['luogo'].'</td>
55+
<td>'.$danno['descrizione'].'</td>
56+
<td class="text-center">
57+
<button class="btn btn-xs btn-warning" data-href="'.$plugin->fileurl('modals/manage_danno.php').'?id_module='.$id_module.'&id_plugin='.$id_plugin.'&id='.$id_record.'&iddanno='.$danno['id'].'" data-card-widget="modal" data-title="'.tr('Modifica danno').'" '.$disabled.'>
58+
<i class="fa fa-edit"></i>
59+
</button>
60+
<button class="btn btn-xs btn-danger ask" data-backto="record-edit" data-op="deldanno" data-id="'.$danno['id'].'" data-id_plugin="'.$id_plugin.'" '.$disabled.'>
61+
<i class="fa fa-trash"></i>
62+
</button>
63+
</td>
64+
</tr>';
65+
}
66+
} else {
67+
echo '
68+
<tr>
69+
<td colspan="6" class="text-center">
70+
<i class="fa fa-info-circle"></i> '.tr('Nessun danno registrato').'
71+
</td>
72+
</tr>';
73+
}
74+
75+
echo '
76+
</tbody>
77+
</table>';

plugins/automezzi_manutenzioni/modals/manage_manutenzione.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@
6666
<button type="submit" class="btn btn-primary"><i class="fa fa-'.$button_icon.'"></i> '.$title.'</button>
6767
</div>
6868
</div>
69-
</form>
70-
<hr>
71-
{( "name": "filelist_and_upload", "id_module": "'.$id_module.'", "id_record": "'.$idmanutenzione.'", "id_plugin": "'.$id_plugin.'" )}';
69+
</form>';
70+
71+
if ($record['id']) {
72+
echo '
73+
<hr>
74+
{( "name": "filelist_and_upload", "id_module": "'.$id_module.'", "id_record": "'.$idmanutenzione.'", "id_plugin": "'.$id_plugin.'" )}';
75+
}
7276

7377
// Recupero elenco descrizioni già utilizzate per l'autocompletamento
7478
$descrizioni = $dbo->fetchArray('SELECT DISTINCT(BINARY `descrizione`) AS `descrizione` FROM `an_automezzi_scadenze` WHERE `is_manutenzione` = 1 AND `descrizione` IS NOT NULL AND `descrizione` != "" ORDER BY `descrizione`');

plugins/automezzi_scadenze/modals/manage_scadenza.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,17 @@
7575
<button type="submit" class="btn btn-primary"><i class="fa fa-'.$button_icon.'"></i> '.$title.'</button>
7676
</div>
7777
</div>
78-
</form>
79-
<hr>
80-
{( "name": "filelist_and_upload", "id_module": "'.$id_module.'", "id_record": "'.$idscadenza.'", "id_plugin": "'.$id_plugin.'" )}
78+
</form>';
8179

80+
if ($record['id']) {
81+
echo '
82+
<hr>
83+
{( "name": "filelist_and_upload", "id_module": "'.$id_module.'", "id_record": "'.$idscadenza.'", "id_plugin": "'.$id_plugin.'" )}';
84+
}
85+
86+
echo '
8287
<script>
83-
$(document).ready(function() {
84-
init();
85-
});
88+
$(document).ready(function() {
89+
init();
90+
});
8691
</script>';

update/2_10.sql

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,4 +484,22 @@ INSERT INTO `zz_settings_lang` (`id_lang`, `id_record`, `title`, `help`) VALUES
484484
(1, (SELECT MAX(`id`) FROM `zz_settings`), 'Identificativo software', 'Codice identificativo del software utilizzato per la LIPE (es. codice fiscale del produttore del software). Se vuoto, il campo viene omesso nel file XML.'),
485485
(2, (SELECT MAX(`id`)-2 FROM `zz_settings`), 'Tax ID of declarant', 'Tax ID of declarant for LIPE (Periodic VAT Settlement). If empty, the company''s default tax ID is used.'),
486486
(2, (SELECT MAX(`id`)-1 FROM `zz_settings`), 'Tax ID of intermediary', 'Tax ID of intermediary for LIPE.'),
487-
(2, (SELECT MAX(`id`) FROM `zz_settings`), 'Software identifier', 'Software identifier code for LIPE (e.g., tax ID of software producer). If empty, the field is omitted from the XML file.');
487+
(2, (SELECT MAX(`id`) FROM `zz_settings`), 'Software identifier', 'Software identifier code for LIPE (e.g., tax ID of software producer). If empty, the field is omitted from the XML file.');
488+
489+
-- Nuovo plugin Danni automezzi
490+
INSERT INTO `zz_plugins` (`name`, `idmodule_from`, `idmodule_to`, `position`, `script`, `enabled`, `default`, `order`, `compatibility`, `version`, `options`, `directory`, `help`) VALUES ('Danni', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Automezzi'), (SELECT `id` FROM `zz_modules` WHERE `name` = 'Automezzi'), 'tab', '', '1', '0', '0', '2.*', '2.10', 'custom', 'automezzi_danni', '');
491+
INSERT INTO `zz_plugins_lang` (`id_lang`, `id_record`, `title`)
492+
VALUES
493+
(1, (SELECT MAX(`id`) FROM `zz_plugins`), 'Danni'),
494+
(2, (SELECT MAX(`id`) FROM `zz_plugins`), 'Damages');
495+
496+
-- Creazione tabella per danni automezzi
497+
CREATE TABLE IF NOT EXISTS `an_automezzi_danni` (
498+
`id` INT NOT NULL AUTO_INCREMENT,
499+
`idsede` INT NOT NULL,
500+
`descrizione` VARCHAR(255) NOT NULL,
501+
`data` DATE NOT NULL,
502+
`luogo` VARCHAR(255) NOT NULL,
503+
PRIMARY KEY (`id`),
504+
INDEX(`idsede`)
505+
);

0 commit comments

Comments
 (0)