openstamanager/modules/impianti/edit.php

220 lines
9.1 KiB
PHP
Raw Normal View History

<?php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright (C) DevCode s.r.l.
2020-09-07 15:04:06 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
2024-03-05 16:01:45 +01:00
use Models\Module;
2024-04-18 17:44:05 +02:00
$id_modulo_categorie_impianti = (new Module())->getByField('title', 'Categorie Impianti', Models\Locale::getPredefined()->id);
2024-04-23 09:56:36 +02:00
$id_modulo_marca_impianti = (new Module())->getByField('title', 'Marche Impianti', Models\Locale::getPredefined()->id);
2018-07-10 16:39:02 +02:00
$img = null;
2018-07-18 15:20:10 +02:00
if (!empty($record['immagine'])) {
$fileinfo = Uploads::fileInfo($record['immagine']);
2018-07-10 16:39:02 +02:00
2018-07-13 16:19:44 +02:00
$default_img = '/'.Uploads::getDirectory($id_module).'/'.$fileinfo['filename'].'_thumb600.'.$fileinfo['extension'];
2018-07-10 16:39:02 +02:00
$img = file_exists(base_dir().$default_img) ? base_path().$default_img : base_path().'/'.Uploads::getDirectory($id_module).'/'.$record['immagine'];
2018-07-10 16:39:02 +02:00
}
2018-02-23 16:04:50 +01:00
?><form action="" method="post" id="edit-form" enctype="multipart/form-data">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="update">
2018-02-18 19:53:23 +01:00
<input type="hidden" name="matricola" value="<?php echo $id_record; ?>">
<!-- DATI ANAGRAFICI -->
2024-05-16 18:02:50 +02:00
<div class="card card-primary">
2024-05-17 12:11:00 +02:00
<div class="card-header">
2024-05-16 18:02:50 +02:00
<h3 class="card-title"><?php echo tr('Dati impianto'); ?></h3>
</div>
2024-05-16 18:02:50 +02:00
<div class="card-body">
<div class="row">
<div class="col-md-3">
2018-07-10 16:39:02 +02:00
{[ "type": "image", "label": "<?php echo tr('Immagine'); ?>", "name": "immagine", "class": "img-thumbnail", "value": "<?php echo $img; ?>" ]}
</div>
<div class="col-md-9">
<div class="row">
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Matricola'); ?>", "name": "matricola", "required": 1, "class": "text-center", "maxlength": 25, "value": "$matricola$", "validation": "matricola" ]}
</div>
2019-07-23 12:13:58 +02:00
<div class="col-md-6">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": 1, "value": "$nome$" ]}
</div>
<div class="col-md-2">
{[ "type": "date", "label": "<?php echo tr('Data installazione'); ?>", "name": "data", "value": "$data$" ]}
</div>
<div class="clearfix"></div>
<div class="col-md-4">
2024-04-23 09:56:36 +02:00
<?php echo Modules::link('Anagrafiche', $record['idanagrafica'], null, null, 'class="pull-right"'); ?>
2018-11-29 14:46:31 +01:00
{[ "type": "select", "label": "<?php echo tr('Cliente'); ?>", "name": "idanagrafica", "required": 1, "value": "$idanagrafica$", "extra": "", "ajax-source": "clienti" ]}
</div>
<?php
2024-04-23 09:56:36 +02:00
echo '
<div class="col-md-4">
{[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "value": "$idsede$", "required": "1", "ajax-source": "sedi", "select-options": '.json_encode(['idanagrafica' => $record['idanagrafica']]).', "placeholder": "'.tr('Sede legale').'" ]}
</div>';
2024-04-23 09:56:36 +02:00
?>
<div class="col-md-4">
2023-11-08 10:58:11 +01:00
{[ "type": "select", "label": "<?php echo tr('Tecnico predefinito'); ?>", "name": "idtecnico", "ajax-source": "tecnici", "value": "$idtecnico$" ]}
</div>
</div>
2023-11-08 10:58:11 +01:00
<div class ="row">
<div class="col-md-4">
{[ "type": "select", "label": "<?php echo tr('Marca'); ?>", "name": "id_marca", "value": "$id_marca$", "ajax-source": "marca", "icon-after": "add|<?php echo $id_modulo_marca_impianti; ?>" ]}
</div>
<div class="col-md-4">
{[ "type": "select", "label": "<?php echo tr('Modello'); ?>", "name": "id_modello", "value": "$id_modello$","ajax-source": "modello", "select-options": <?php echo json_encode(['id_marca' => $record['id_marca']]); ?>, "icon-after": "add|<?php echo $id_modulo_marca_impianti; ?>|id_original=<?php echo $record['id_marca']; ?>" ]}
</div>
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Proprietario'); ?>", "name": "proprietario", "value": "$proprietario$" ]}
</div>
</div>
<div class="row">
<div class="col-md-6">
<?php echo (!empty($record['id_categoria'])) ?
2024-01-15 15:30:45 +01:00
Modules::link('Categorie impianti', $record['id_categoria'], null, null, 'class="pull-right"') : ''; ?>
2024-03-05 16:01:45 +01:00
{[ "type": "select", "label": "<?php echo tr('Categoria'); ?>", "name": "id_categoria", "required": 0, "value": "$id_categoria$", "ajax-source": "categorie_imp", "icon-after": "add|<?php echo $id_modulo_categorie_impianti; ?>" ]}
</div>
2019-07-23 12:13:58 +02:00
<div class="col-md-6">
2024-03-05 16:01:45 +01:00
{[ "type": "select", "label": "<?php echo tr('Sottocategoria'); ?>", "name": "id_sottocategoria", "value": "$id_sottocategoria$", "ajax-source": "sottocategorie_imp", "select-options": <?php echo json_encode(['id_categoria' => $record['id_categoria']]); ?>, "icon-after": "add|<?php echo $id_modulo_categorie_impianti; ?>|id_original=<?php echo $record['id_categoria']; ?>" ]}
2018-10-18 19:36:19 +02:00
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
2023-11-15 14:10:33 +01:00
{[ "type": "textarea", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "value": "$descrizione$" ]}
</div>
</div>
<div class="row">
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Ubicazione'); ?>", "name": "ubicazione", "value": "$ubicazione$" ]}
</div>
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Palazzo'); ?>", "name": "palazzo", "value": "$palazzo$" ]}
</div>
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Scala'); ?>", "name": "scala", "value": "$scala$" ]}
</div>
</div>
<div class="row">
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Piano'); ?>", "name": "piano", "value": "$piano$" ]}
</div>
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Interno'); ?>", "name": "interno", "value": "$interno$" ]}
</div>
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Occupante'); ?>", "name": "occupante", "value": "$occupante$" ]}
</div>
</div>
</div>
</div>
</form>
2018-09-28 16:17:10 +02:00
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$" )}
2018-02-04 17:31:33 +01:00
<?php
$elementi = $dbo->fetchArray('SELECT `in_interventi`.`id`, `codice` AS numero, `data_richiesta` AS data, "Intervento" AS tipo_documento FROM `in_interventi` INNER JOIN `my_impianti_interventi` ON `in_interventi`.`id`=`my_impianti_interventi`.`idintervento` WHERE `my_impianti_interventi`.`idimpianto` = '.prepare($id_record).'
UNION
SELECT `co_contratti`.`id`, `numero` AS numero, `data_bozza` AS data, "Contratto" AS tipo_documento FROM `co_contratti` INNER JOIN `my_impianti_contratti` ON `co_contratti`.`id`=`my_impianti_contratti`.`idcontratto` WHERE `my_impianti_contratti`.`idimpianto` = '.prepare($id_record));
$class = '';
if (!empty($elementi)) {
echo '
2024-05-16 18:02:50 +02:00
<div class="card card-warning collapsable collapsed-card">
<div class="card-header with-border">
<h3 class="card-title"><i class="fa fa-warning"></i> '.tr('Documenti collegati: _NUM_', [
2024-03-22 15:52:24 +01:00
'_NUM_' => count($elementi),
]).'</h3>
2024-05-16 18:02:50 +02:00
<div class="card-tools pull-right">
2024-05-23 17:51:21 +02:00
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fa fa-plus"></i></button>
</div>
</div>
2024-05-16 18:02:50 +02:00
<div class="card-body">
<ul>';
foreach ($elementi as $elemento) {
$descrizione = tr('_DOC_ num. _NUM_ del _DATE_', [
'_DOC_' => $elemento['tipo_documento'],
'_NUM_' => $elemento['numero'],
'_DATE_' => Translator::dateToLocale($elemento['data']),
]);
2023-08-04 14:54:28 +02:00
if ($elemento['tipo_documento'] == 'Intervento') {
$modulo = 'Interventi';
} else {
$modulo = 'Contratti';
}
$id = $elemento['id'];
echo '
<li>'.Modules::link($modulo, $id, $descrizione).'</li>';
}
2023-08-04 14:54:28 +02:00
$class = 'disabled';
echo '
</ul>
</div>
</div>';
}
echo '
<a class="btn btn-danger ask '.$class.'" data-backto="record-list">
<i class="fa fa-trash"></i> '.tr('Elimina').'
</a>';
?>
<script type="text/javascript">
$(document).ready(function() {
$('#idanagrafica').change(function() {
updateSelectOption("idanagrafica", $(this).val());
session_set('superselect,idanagrafica', $(this).val(), 0);
var value = !$(this).val();
2018-08-11 15:49:46 +02:00
$("#idsede").prop("disabled", value)
.selectReset();
});
$("#id_categoria").on("change", function() {
updateSelectOption("id_categoria", $(this).val());
$("#id_sottocategoria").val(null).trigger("change");
});
$("#id_marca").on("change", function() {
updateSelectOption("id_marca", $(this).val());
$("#id_modello").val(null).trigger("change");
});
});
2018-08-11 15:49:46 +02:00
</script>