openstamanager/modules/interventi/edit.php

443 lines
19 KiB
PHP
Raw Normal View History

<?php
include_once __DIR__.'/../../core.php';
unset($_SESSION['superselect']['idanagrafica']);
unset($_SESSION['superselect']['idsede_partenza']);
unset($_SESSION['superselect']['idsede_destinazione']);
2018-07-18 15:20:10 +02:00
$_SESSION['superselect']['idanagrafica'] = $record['idanagrafica'];
$_SESSION['superselect']['idsede_partenza'] = $record['idsede_partenza'];
$_SESSION['superselect']['idsede_partenza'];
$_SESSION['superselect']['idsede_destinazione'] = $record['idsede_destinazione'];
2018-02-23 16:04:50 +01:00
?><form action="" method="post" id="edit-form">
<input type="hidden" name="op" value="update">
<input type="hidden" name="backto" value="record-edit">
2018-02-18 19:53:23 +01:00
<input type="hidden" name="id_record" value="<?php echo $id_record; ?>">
<!-- DATI CLIENTE -->
<div class="panel panel-primary">
<div class="panel-heading">
2018-02-18 19:53:23 +01:00
<h3 class="panel-title"><?php echo tr('Dati cliente'); ?></h3>
</div>
<div class="panel-body">
<!-- RIGA 1 -->
<div class="row">
<div class="col-md-3">
<?php
2018-07-18 15:20:10 +02:00
echo Modules::link('Anagrafiche', $record['idanagrafica'], null, null, 'class="pull-right"');
?>
2018-07-18 15:20:10 +02:00
{[ "type": "select", "label": "<?php echo tr('Cliente'); ?>", "name": "idanagrafica", "required": 1, "values": "query=SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione='Cliente' AND deleted_at IS NULL ORDER BY ragione_sociale", "value": "$idanagrafica$", "ajax-source": "clienti", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
</div>
<div class="col-md-3">
{[ "type": "select", "label": "<?php echo tr('Sede destinazione'); ?>", "name": "idsede_destinazione","value": "$idsede_destinazione$", "ajax-source": "sedi", "placeholder": "Sede legale", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
</div>
<div class="col-md-3">
<?php
2018-07-18 15:20:10 +02:00
echo Modules::link('Anagrafiche', $record['idclientefinale'], null, null, 'class="pull-right"');
?>
2018-07-18 15:20:10 +02:00
{[ "type": "select", "label": "<?php echo tr('Per conto di'); ?>", "name": "idclientefinale", "value": "$idclientefinale$", "ajax-source": "clienti", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
</div>
<div class="col-md-3">
2018-07-18 15:20:10 +02:00
{[ "type": "select", "label": "<?php echo tr('Referente'); ?>", "name": "idreferente", "value": "$idreferente$", "ajax-source": "referenti", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
</div>
</div>
<!-- RIGA 2 -->
<div class="row">
<div class="col-md-6">
<?php
if (!empty($record['idpreventivo'])) {
echo '
2018-07-18 15:20:10 +02:00
'.Modules::link('Preventivi', $record['idpreventivo'], null, null, 'class="pull-right"');
}
?>
2018-07-18 15:20:10 +02:00
{[ "type": "select", "label": "<?php echo tr('Preventivo'); ?>", "name": "idpreventivo", "value": "$idpreventivo$", "ajax-source": "preventivi", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
</div>
<div class="col-md-6">
<?php
$idcontratto_riga = $dbo->fetchOne('SELECT id FROM co_promemoria WHERE idintervento='.prepare($id_record))['id'];
if (!empty($record['idcontratto'])) {
echo '
2018-12-03 18:06:39 +01:00
'.Modules::link('Contratti', $record['idcontratto'], null, null, 'class="pull-right"');
}
?>
{[ "type": "select", "label": "<?php echo tr('Contratto'); ?>", "name": "idcontratto", "value": "<?php echo $record['id_contratto']; ?>", "ajax-source": "contratti", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
2018-02-18 19:53:23 +01:00
<input type='hidden' name='idcontratto_riga' value='<?php echo $idcontratto_riga; ?>'>
</div>
</div>
</div>
</div>
<!-- DATI INTERVENTO -->
<div class="panel panel-primary">
<div class="panel-heading">
2018-02-18 19:53:23 +01:00
<h3 class="panel-title"><?php echo tr('Dati intervento'); ?></h3>
</div>
<div class="panel-body">
<!-- RIGA 3 -->
<div class="row">
<div class="col-md-3">
2018-07-18 15:20:10 +02:00
{[ "type": "span", "label": "<?php echo tr('Numero'); ?>", "name": "codice", "value": "$codice$", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
</div>
<div class="col-md-3">
2019-02-27 13:04:05 +01:00
{[ "type": "timestamp", "label": "<?php echo tr('Data/ora richiesta'); ?>", "name": "data_richiesta", "required": 1, "value": "$data_richiesta$", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
</div>
<div class="col-md-3">
{[ "type": "timestamp", "label": "<?php echo tr('Data/ora scadenza'); ?>", "name": "data_scadenza", "required": 0, "value": "$data_scadenza$", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
</div>
2018-02-20 17:57:16 +01:00
2018-02-15 12:22:21 +01:00
<div class="col-md-3">
2018-11-21 00:06:56 +01:00
{[ "type": "select", "label": "<?php echo tr('Zona'); ?>", "name": "idzona", "values": "query=SELECT id, CONCAT_WS( ' - ', nome, descrizione) AS descrizione FROM an_zone ORDER BY nome", "value": "$idzona$" , "placeholder": "<?php echo tr('Nessuna zona'); ?>", "extra": "readonly", "help":"<?php echo 'La zona viene definita automaticamente in base al cliente selezionato'; ?>." ]}
2018-02-15 12:22:21 +01:00
</div>
2018-02-20 17:57:16 +01:00
</div>
<!-- RIGA 4 -->
<div class="row">
<div class="col-md-4">
2018-07-18 15:20:10 +02:00
{[ "type": "select", "label": "<?php echo tr('Tipo attività'); ?>", "name": "idtipointervento", "required": 1, "values": "query=SELECT idtipointervento AS id, descrizione FROM in_tipiintervento", "value": "$idtipointervento$", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
</div>
<div class="col-md-4">
{[ "type": "select", "label": "<?php echo tr('Stato'); ?>", "name": "idstatointervento", "required": 1, "values": "query=SELECT idstatointervento AS id, descrizione, colore AS _bgcolor_ FROM in_statiintervento WHERE deleted_at IS NULL", "value": "$idstatointervento$" ]}
</div>
</div>
<!-- RIGA 5 -->
<div class="row">
<div class="col-md-12">
2018-07-18 15:20:10 +02:00
{[ "type": "textarea", "label": "<?php echo tr('Richiesta'); ?>", "name": "richiesta", "required": 1, "class": "autosize", "value": "$richiesta$", "extra": "rows='5'", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
</div>
<div class="col-md-12">
2018-09-07 17:43:52 +02:00
{[ "type": "ckeditor", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "class": "autosize", "value": "$descrizione$", "extra": "rows='10'", "readonly": "<?php echo $record['flag_completato']; ?>" ]}
</div>
<div class="col-md-12">
{[ "type": "textarea", "label": "<?php echo tr('Note interne'); ?>", "name": "informazioniaggiuntive", "class": "autosize", "value": "$informazioniaggiuntive$", "extra": "rows='5'" ]}
</div>
</div>
</div>
</div>
2018-11-09 12:45:22 +01:00
<?php
2019-01-10 18:41:25 +01:00
// Visualizzo solo se l'anagrafica cliente è un ente pubblico
if (!empty($record['idcontratto'])) {
$contratto = $dbo->fetchOne('SELECT num_item,codice_cig,codice_cup,id_documento_fe FROM co_contratti WHERE id = '.prepare($record['idcontratto']));
2019-01-10 18:41:25 +01:00
$record['id_documento_fe'] = $contratto['id_documento_fe'];
$record['codice_cup'] = $contratto['codice_cup'];
$record['codice_cig'] = $contratto['codice_cig'];
$record['num_item'] = $contratto['num_item'];
2019-01-10 18:41:25 +01:00
}
2018-11-09 12:45:22 +01:00
?>
<!-- Fatturazione Elettronica PA-->
2019-02-13 18:27:01 +01:00
<div class="panel panel-primary <?php echo ($record['tipo_anagrafica'] == 'Ente pubblico' || $record['tipo_anagrafica'] == 'Azienda') ? 'show' : 'hide'; ?>" >
2018-11-09 12:45:22 +01:00
<div class="panel-heading">
2019-01-10 18:41:25 +01:00
<h3 class="panel-title"><?php echo tr('Dati appalto'); ?>
<?php if (!empty($record['idcontratto'])) {
?>
2019-01-22 17:16:17 +01:00
<span class="tip" title="<?php echo tr('E\' possibile specificare i dati dell\'appalto solo se il cliente è di tipo \'Ente pubblico\' o \'Azienda\' e l\'attività non risulta già collegata ad un contratto.'); ?>" > <i class="fa fa-question-circle-o"></i></span>
2019-01-10 18:41:25 +01:00
</h3>
<?php
} ?>
2018-11-09 12:45:22 +01:00
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
{[ "type": "<?php echo !empty($record['idcontratto']) ? 'span' : 'text'; ?>", "label": "<?php echo tr('Identificatore Documento'); ?>", "name": "id_documento_fe", "required": 0, "help": "<?php echo tr('<span>Obbligatorio per valorizzare CIG/CUP. &Egrave; possible inserire: </span><ul><li>N. determina</li><li>RDO</li><li>Ordine MEPA</li></ul>'); ?>", "value": "<?php echo $record['id_documento_fe']; ?>", "maxlength": 20, "readonly": "<?php echo $record['flag_completato']; ?>", "extra": "" ]}
2018-11-09 12:45:22 +01:00
</div>
<div class="col-md-6">
{[ "type": "<?php echo !empty($record['idcontratto']) ? 'span' : 'text'; ?>", "label": "<?php echo tr('Numero Riga'); ?>", "name": "num_item", "required": 0, "value": "<?php echo $record['num_item']; ?>", "maxlength": 15, "readonly": "<?php echo $record['flag_completato']; ?>", "extra": "" ]}
</div>
</div>
<div class="row">
<div class="col-md-6">
2019-01-10 18:41:25 +01:00
{[ "type": "<?php echo !empty($record['idcontratto']) ? 'span' : 'text'; ?>", "label": "<?php echo tr('Codice CIG'); ?>", "name": "codice_cig", "required": 0, "value": "<?php echo $record['codice_cig']; ?>", "maxlength": 15, "readonly": "<?php echo $record['flag_completato']; ?>", "extra": "" ]}
2018-11-09 12:45:22 +01:00
</div>
<div class="col-md-6">
2019-01-10 18:41:25 +01:00
{[ "type": "<?php echo !empty($record['idcontratto']) ? 'span' : 'text'; ?>", "label": "<?php echo tr('Codice CUP'); ?>", "name": "codice_cup", "required": 0, "value": "<?php echo $record['codice_cup']; ?>", "maxlength": 15, "readonly": "<?php echo $record['flag_completato']; ?>", "extra": "" ]}
2018-11-09 12:45:22 +01:00
</div>
</div>
</div>
</div>
2019-01-10 18:41:25 +01:00
2018-11-09 12:45:22 +01:00
<!-- ORE LAVORO -->
<div class="panel panel-primary">
<div class="panel-heading">
2018-02-18 19:53:23 +01:00
<h3 class="panel-title"><?php echo tr('Ore di lavoro'); ?></h3>
</div>
<div class="panel-body">
<div class="pull-right">
2018-05-26 01:59:27 +02:00
<a class='btn btn-default btn-details' onclick="$('.extra').removeClass('hide'); $(this).addClass('hide'); $('#dontshowall_dettagli').removeClass('hide');" id='showall_dettagli'><i class='fa fa-square-o'></i> <?php echo tr('Visualizza dettaglio costi'); ?></a>
<a class='btn btn-info btn-details hide' onclick="$('.extra').addClass('hide'); $(this).addClass('hide'); $('#showall_dettagli').removeClass('hide');" id='dontshowall_dettagli'><i class='fa fa-check-square-o'></i> <?php echo tr('Visualizza dettaglio costi'); ?></a>
</div>
<div class="clearfix"></div>
<br>
<div class="row">
<div class="col-md-12" id="tecnici">
2018-06-23 15:41:32 +02:00
<?php
2018-06-26 14:30:26 +02:00
if (file_exists($docroot.'/modules/interventi/custom/ajax_tecnici.php')) {
?>
<script>$('#tecnici').load('<?php echo $rootdir; ?>/modules/interventi/custom/ajax_tecnici.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');</script>
2018-06-23 15:41:32 +02:00
<?php
2018-06-26 14:30:26 +02:00
} else {
?>
<script>$('#tecnici').load('<?php echo $rootdir; ?>/modules/interventi/ajax_tecnici.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');</script>
<?php
2018-06-26 14:30:26 +02:00
}
?>
</div>
</div>
</div>
</div>
<?php
// Conteggio numero articoli intervento per eventuale blocco della sede di partenza
$articoli = $dbo->fetchArray('SELECT mg_articoli_interventi.id FROM mg_articoli_interventi INNER JOIN in_interventi ON in_interventi.id=mg_articoli_interventi.idintervento WHERE in_interventi.id='.prepare($id_record));
?>
<!-- ARTICOLI -->
<div class="panel panel-primary">
<div class="panel-heading">
2018-02-18 19:53:23 +01:00
<h3 class="panel-title"><?php echo tr('Materiale utilizzato'); ?></h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-3">
{[ "type": "select", "label": "<?php echo tr('Partenza merce'); ?>", "name": "idsede_partenza", "ajax-source": "sedi_azienda", "value": "$idsede_partenza$", "readonly": "<?php echo ($record['flag_completato'] || sizeof($articoli)) ? 1 : 0; ?>" ]}
</div>
</div>
<div id="articoli">
2018-06-23 15:41:32 +02:00
<?php
2018-06-26 14:30:26 +02:00
if (file_exists($docroot.'/modules/interventi/custom/ajax_articoli.php')) {
include $docroot.'/modules/interventi/custom/ajax_articoli.php';
} else {
include $docroot.'/modules/interventi/ajax_articoli.php';
}
?>
</div>
2018-07-18 15:20:10 +02:00
<?php if (!$record['flag_completato']) {
2018-06-26 14:30:26 +02:00
?>
<button type="button" class="btn btn-primary" onclick="launch_modal( '<?php echo tr('Aggiungi articolo'); ?>', '<?php echo $rootdir; ?>/modules/interventi/add_articolo.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>&idriga=0', 1);"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi articolo'); ?>...</button>
<?php
2018-06-26 14:30:26 +02:00
} ?>
</div>
</div>
<!-- SPESE AGGIUNTIVE -->
<div class="panel panel-primary">
<div class="panel-heading">
2018-02-18 19:53:23 +01:00
<h3 class="panel-title"><?php echo tr('Altre spese'); ?></h3>
</div>
<div class="panel-body">
2019-03-29 12:46:17 +01:00
<?php
if (!$record['flag_completato']) {
echo '
<a class="btn btn-sm btn-primary" data-href="'.$structure->fileurl('add_righe.php').'?id_module='.$id_module.'&id_record='.$id_record.'&is_sconto" data-toggle="tooltip" data-title="'.tr('Aggiungi altre spese').'">
<i class="fa fa-plus"></i> '.tr('Altre spese').'...
</a>';
echo '
<a class="btn btn-sm btn-primary" data-href="'.$structure->fileurl('row-add.php').'?id_module='.$id_module.'&id_record='.$id_record.'&is_sconto" data-toggle="tooltip" data-title="'.tr('Aggiungi sconto/maggiorazione').'">
<i class="fa fa-plus"></i> '.tr('Sconto/maggiorazione').'
</a>';
}
?>
<div class="clearfix"></div>
<br>
<div id="righe">
2019-03-29 12:46:17 +01:00
<?php
include $structure->filepath('ajax_righe.php');
?>
</div>
</div>
</div>
<!-- COSTI TOTALI -->
<div class="panel panel-primary">
<div class="panel-heading">
2018-02-18 19:53:23 +01:00
<h3 class="panel-title"><?php echo tr('Costi totali'); ?></h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12" id="costi">
2018-06-23 15:41:32 +02:00
<?php
2018-06-26 14:30:26 +02:00
if (file_exists($docroot.'/modules/interventi/custom/ajax_costi.php')) {
?>
<script>$('#costi').load('<?php echo $rootdir; ?>/modules/interventi/custom/ajax_costi.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');</script>
2018-06-23 15:41:32 +02:00
<?php
2018-06-26 14:30:26 +02:00
} else {
?>
<script>$('#costi').load('<?php echo $rootdir; ?>/modules/interventi/ajax_costi.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');</script>
<?php
2018-06-26 14:30:26 +02:00
}
?>
</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$", <?php echo ($record['flag_completato']) ? '"readonly": 1' : '"readonly": 0'; ?> )}
<!-- EVENTUALE FIRMA GIA' EFFETTUATA -->
2018-11-21 00:21:09 +01:00
<div class="text-center row">
<div class="col-md-12" >
<?php
2018-11-30 16:10:15 +01:00
if ($record['firma_file'] == '') {
echo '
2018-11-21 00:21:09 +01:00
<div class="alert alert-warning"><i class="fa fa-warning"></i> '.tr('Questo intervento non è ancora stato firmato dal cliente').'.</div>';
2018-11-30 16:10:15 +01:00
} else {
echo '
2018-11-21 00:21:09 +01:00
<img src="'.$rootdir.'/files/interventi/'.$record['firma_file'].'" class="img-thumbnail"><div>&nbsp;</div>
<div class="col-md-6 col-md-offset-3 alert alert-success"><i class="fa fa-check"></i> '.tr('Firmato il _DATE_ alle _TIME_ da _PERSON_', [
2018-11-30 16:10:15 +01:00
'_DATE_' => Translator::dateToLocale($record['firma_data']),
'_TIME_' => Translator::timeToLocale($record['firma_data']),
'_PERSON_' => '<b>'.$record['firma_nome'].'</b>',
]).'</div>';
}
?>
2018-11-21 00:21:09 +01:00
</div>
</div>
<script>
$('#idanagrafica').change( function(){
session_set('superselect,idanagrafica', $(this).val(), 0);
$("#idsede").selectReset();
$("#idpreventivo").selectReset();
$("#idcontratto").selectReset();
2018-02-20 17:57:16 +01:00
2018-02-15 12:22:21 +01:00
if (($(this).val())) {
if (($(this).selectData().idzona)){
$('#idzona').val($(this).selectData().idzona).change();
2018-02-20 17:57:16 +01:00
2018-02-15 12:22:21 +01:00
}else{
$('#idzona').val('').change();
}
//session_set('superselect,idzona', $(this).selectData().idzona, 0);
}
2018-02-20 17:57:16 +01:00
});
$('#idpreventivo').change( function(){
if($('#idcontratto').val() && $(this).val()){
$('#idcontratto').val('').trigger('change');
}
});
$('#idcontratto').change( function(){
if($('#idpreventivo').val() && $(this).val()){
$('#idpreventivo').val('').trigger('change');
$('input[name=idcontratto_riga]').val('');
}
});
$('#matricola').change( function(){
session_set('superselect,marticola', $(this).val(), 0);
});
2018-02-20 17:57:16 +01:00
2018-02-15 12:22:21 +01:00
$('#idsede').change( function(){
if (($(this).val())) {
if (($(this).selectData().idzona)){
$('#idzona').val($(this).selectData().idzona).change();
}else{
$('#idzona').val('').change();
}
//session_set('superselect,idzona', $(this).selectData().idzona, 0);
}
});
$('#codice_cig, #codice_cup').bind("keyup change", function(e) {
if ($('#codice_cig').val() == '' && $('#codice_cup').val() == '' ){
$('#id_documento_fe').prop('required', false);
}else{
$('#id_documento_fe').prop('required', true);
}
});
2018-02-20 17:57:16 +01:00
</script>
2018-09-28 16:17:10 +02:00
{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )}
<?php
2018-09-05 10:05:23 +02:00
// Collegamenti diretti
2018-07-04 12:57:53 +02:00
// Fatture collegate a questo intervento
2018-09-05 10:05:23 +02:00
$elementi = $dbo->fetchArray('SELECT `co_documenti`.*, `co_tipidocumento`.`descrizione` AS tipo_documento, `co_tipidocumento`.`dir` FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`id` IN (SELECT `iddocumento` FROM `co_righe_documenti` WHERE `idintervento` = '.prepare($id_record).') ORDER BY `data`');
2017-11-16 18:55:03 +01:00
2018-09-05 10:05:23 +02:00
if (!empty($elementi)) {
echo '
2018-09-05 10:05:23 +02:00
<div class="box box-warning collapsable collapsed-box">
<div class="box-header with-border">
<h3 class="box-title"><i class="fa fa-warning"></i> '.tr('Documenti collegati: _NUM_', [
2018-09-19 09:57:30 +02:00
'_NUM_' => count($elementi),
2018-09-05 10:05:23 +02:00
]).'</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i></button>
</div>
</div>
<div class="box-body">
<ul>';
foreach ($elementi as $fattura) {
$descrizione = tr('_DOC_ num. _NUM_ del _DATE_', [
'_DOC_' => $fattura['tipo_documento'],
'_NUM_' => !empty($fattura['numero_esterno']) ? $fattura['numero_esterno'] : $fattura['numero'],
'_DATE_' => Translator::dateToLocale($fattura['data']),
]);
$modulo = ($fattura['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto';
$id = $fattura['id'];
echo '
2018-09-05 10:05:23 +02:00
<li>'.Modules::link($modulo, $id, $descrizione).'</li>';
}
echo '
</ul>
2018-09-05 10:05:23 +02:00
</div>
</div>';
}
if (!empty($elementi)) {
echo '
<div class="alert alert-error">
'.tr('Eliminando questo documento si potrebbero verificare problemi nelle altre sezioni del gestionale').'.
</div>';
}
?>
<a class="btn btn-danger ask" data-backto="record-list">
2018-02-18 19:53:23 +01:00
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
</a>