2017-08-04 16:28:16 +02:00
< ? 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 />.
*/
2017-08-04 16:28:16 +02:00
include_once __DIR__ . '/../../core.php' ;
2019-07-24 12:42:45 +02:00
$block_edit = $record [ 'is_completato' ];
2021-03-08 14:17:59 +01:00
if ( strtotime ( $record [ 'data_conclusione' ]) < strtotime ( $record [ 'data_accettazione' ]) ){
echo '
< div class = " alert alert-warning " >< a class = " clickable " onclick = " $ ( \ '.alert \ ').hide(); " >< i class = " fa fa-times " ></ i ></ a > '.tr(' Attenzione ! La data di accettazione supera la data di conclusione del contratto . verificare tali informazioni . ').' </ div > ' ;
}
2020-02-17 18:43:49 +01:00
?>
2018-02-23 16:04:50 +01:00
< form action = " " method = " post " id = " edit-form " >
2017-08-04 16:28:16 +02:00
< 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 = " id_record " value = " <?php echo $id_record ; ?> " >
2017-08-04 16:28:16 +02:00
<!-- DATI INTESTAZIONE -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2018-02-18 19:53:23 +01:00
< h3 class = " panel-title " >< ? php echo tr ( 'Intestazione' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " >
< div class = " row " >
2019-07-24 12:42:45 +02:00
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Numero'); ?> " , " name " : " numero " , " required " : 1 , " class " : " text-center " , " value " : " $numero $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
2019-07-24 12:42:45 +02:00
< div class = " col-md-3 " >
{[ " type " : " date " , " label " : " <?php echo tr('Data bozza'); ?> " , " name " : " data_bozza " , " value " : " $data_bozza $ " ]}
</ div >
2017-08-04 16:28:16 +02:00
2019-07-24 12:42:45 +02:00
< div class = " col-md-2 " >
2021-03-08 14:17:59 +01:00
{[ " type " : " date " , " label " : " <?php echo tr('Data accettazione'); ?> " , " name " : " data_accettazione " , " value " : " $data_accettazione $ " , " max-date " : " $data_conclusione $ " ]}
2019-07-24 12:42:45 +02:00
</ div >
2018-11-09 11:34:27 +01:00
2019-07-24 12:42:45 +02:00
< div class = " col-md-2 " >
2020-12-01 16:52:51 +01:00
{[ " type " : " date " , " label " : " <?php echo tr('Data conclusione'); ?> " , " name " : " data_conclusione " , " value " : " $data_conclusione $ " , " disabled " : " <?php echo $contratto->isDataConclusioneAutomatica () ? '1 " , " help " : " '.tr('La Data di conclusione è calcolata in automatico in base al valore del campo Validità contratto, se definita') : '0'; ?> " ]}
2019-07-24 12:42:45 +02:00
</ div >
2018-11-09 11:34:27 +01:00
2019-07-24 12:42:45 +02:00
< div class = " col-md-2 " >
{[ " type " : " date " , " label " : " <?php echo tr('Data rifiuto'); ?> " , " name " : " data_rifiuto " , " value " : " $data_rifiuto $ " ]}
</ div >
</ div >
2018-11-09 11:34:27 +01:00
2018-11-07 16:40:48 +01:00
< div class = " row " >
2019-07-24 12:42:45 +02:00
< div class = " col-md-3 " >
< ? php
echo Modules :: link ( 'Anagrafiche' , $record [ 'idanagrafica' ], null , null , 'class="pull-right"' );
?>
2018-11-09 11:34:27 +01:00
2019-07-24 12:42:45 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Cliente'); ?> " , " name " : " idanagrafica " , " id " : " idanagrafica_c " , " required " : 1 , " value " : " $idanagrafica $ " , " ajax-source " : " clienti " ]}
</ div >
2018-11-07 16:40:48 +01:00
2020-07-31 14:25:50 +02:00
< ? php
echo '
2019-07-24 12:42:45 +02:00
< div class = " col-md-3 " >
2020-07-31 14:25:50 +02:00
{[ " type " : " select " , " label " : " '.tr('Sede').' " , " name " : " idsede " , " value " : " $idsede $ " , " ajax-source " : " sedi " , " select-options " : { " idanagrafica " : '.$record[' idanagrafica '].' }, " placeholder " : " Sede legale " ]}
2020-07-31 16:13:24 +02:00
</ div >
2018-11-09 11:34:27 +01:00
2018-11-07 16:40:48 +01:00
< div class = " col-md-3 " >
2020-07-31 16:13:24 +02:00
'.Plugins::link(' Referenti ', $record[' idanagrafica '], null, null, ' class = " pull-right " ').'
{[ " type " : " select " , " label " : " '.tr('Referente').' " , " name " : " idreferente " , " value " : " $idreferente $ " , " ajax-source " : " referenti " , " select-options " : { " idanagrafica " : '.$record[' idanagrafica '].' } ]}
2018-11-07 16:40:48 +01:00
</ div >
2018-11-09 11:34:27 +01:00
2020-07-31 16:13:24 +02:00
< div class = " col-md-3 " > ' ;
2018-07-18 15:20:10 +02:00
if ( $record [ 'idagente' ] != 0 ) {
echo Modules :: link ( 'Anagrafiche' , $record [ 'idagente' ], null , null , 'class="pull-right"' );
2018-02-04 17:26:25 +01:00
}
2018-01-15 20:28:36 +01:00
?>
2018-07-17 08:05:19 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Agente'); ?> " , " name " : " idagente " , " 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='Agente' AND deleted_at IS NULL ORDER BY ragione_sociale " , " value " : " $idagente $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
2018-11-09 11:34:27 +01:00
2018-04-13 17:55:20 +02:00
</ div >
2017-08-04 16:28:16 +02:00
2019-07-24 12:42:45 +02:00
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Nome'); ?> " , " name " : " nome " , " required " : 1 , " value " : " $nome $ " ]}
</ div >
< div class = " col-md-3 " >
{[ " type " : " select " , " label " : " <?php echo tr('Pagamento'); ?> " , " name " : " idpagamento " , " values " : " query=SELECT id, descrizione FROM co_pagamenti GROUP BY descrizione ORDER BY descrizione " , " value " : " $idpagamento $ " ]}
</ div >
< div class = " col-md-3 " >
{[ " type " : " select " , " label " : " <?php echo tr('Stato'); ?> " , " name " : " idstato " , " required " : 1 , " values " : " query=SELECT id, descrizione FROM co_staticontratti " , " value " : " $idstato $ " , " class " : " unblockable " ]}
</ div >
</ div >
2018-04-13 17:55:20 +02:00
< div class = " row " >
2018-11-09 11:34:27 +01:00
2019-04-08 18:50:28 +02:00
< div class = " col-md-3 " >
2020-12-01 16:52:51 +01:00
{[ " type " : " number " , " label " : " <?php echo tr('Validità contratto'); ?> " , " name " : " validita " , " decimals " : " 0 " , " value " : " $validita $ " , " icon-after " : " choice|period|<?php echo $record['tipo_validita'] ; ?> " , " help " : " <?php echo tr('Il campo Validità contratto viene utilizzato per il calcolo della Data di conclusione del contratto'); ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
2018-11-09 11:34:27 +01:00
2021-02-18 09:57:35 +01:00
< div class = " col-md-9 " >
2020-07-31 16:20:31 +02:00
{[ " type " : " select " , " multiple " : " 1 " , " label " : " <?php echo tr('Impianti'); ?> " , " name " : " matricolaimpianto[] " , " values " : " query=SELECT idanagrafica, id AS id, IF(nome = '', matricola, CONCAT(matricola, ' - ', nome)) AS descrizione FROM my_impianti WHERE idanagrafica=' $idanagrafica $ ' ORDER BY descrizione " , " value " : " $idimpianti $ " , " icon-after " : " add|<?php echo Modules::get('Impianti')['id']; ?>|||<?php echo (empty( $block_edit )) ? '' : 'disabled'; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
2020-12-01 16:52:51 +01:00
2017-09-11 11:28:39 +02:00
</ div >
2017-08-04 16:28:16 +02:00
< div class = " row " >
< div class = " col-md-12 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " textarea " , " label " : " <?php echo tr('Esclusioni'); ?> " , " name " : " esclusioni " , " class " : " autosize " , " value " : " $esclusioni $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-12 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " textarea " , " label " : " <?php echo tr('Descrizione'); ?> " , " name " : " descrizione " , " class " : " autosize " , " value " : " $descrizione $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
</ div >
2019-10-14 19:13:11 +02:00
< ? php
2019-10-18 15:28:44 +02:00
if ( ! empty ( $record [ 'id_documento_fe' ]) || ! empty ( $record [ 'num_item' ]) || ! empty ( $record [ 'codice_cig' ]) || ! empty ( $record [ 'codice_cup' ])) {
2019-10-14 19:13:11 +02:00
$collapsed = 'in' ;
2019-10-18 15:28:44 +02:00
} else {
2019-10-14 19:13:11 +02:00
$collapsed = '' ;
}
?>
<!-- Fatturazione Elettronica PA -->
< div class = " panel-group " >
< div class = " panel panel-primary <?php echo ( $record['tipo_anagrafica'] == 'Ente pubblico' || $record['tipo_anagrafica'] == 'Azienda') ? 'show' : 'hide'; ?> " >
< div class = " panel-heading " >
< h4 class = " panel-title " >
< ? php echo tr ( 'Dati appalto' ); ?>
2020-02-17 13:18:25 +01:00
< div class = " box-tools pull-right " >
< a data - toggle = " collapse " href = " #dati_appalto " >< i class = " fa fa-plus " style = 'color:white;margin-top:2px;' ></ i ></ a >
2019-10-14 19:13:11 +02:00
</ div >
</ h4 >
</ div >
2019-10-18 15:28:44 +02:00
< div id = " dati_appalto " class = " panel-collapse collapse <?php echo $collapsed ; ?> " >
2019-10-14 19:13:11 +02:00
< div class = " panel-body " >
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Identificatore Documento'); ?> " , " name " : " id_documento_fe " , " required " : 0 , " help " : " <?php echo tr('<span>Obbligatorio per valorizzare CIG/CUP. È possible inserire: </span><ul><li>N. determina</li><li>RDO</li><li>Ordine MEPA</li></ul>'); ?> " , " value " : " $id_documento_fe $ " , " maxlength " : 20 ]}
</ div >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Numero Riga'); ?> " , " name " : " num_item " , " required " : 0 , " value " : " $num_item $ " , " maxlength " : 15 ]}
</ div >
</ div >
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Codice CIG'); ?> " , " name " : " codice_cig " , " required " : 0 , " value " : " $codice_cig $ " , " maxlength " : 15 ]}
</ div >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Codice CUP'); ?> " , " name " : " codice_cup " , " required " : 0 , " value " : " $codice_cup $ " , " maxlength " : 15 ]}
</ div >
</ div >
</ div >
2018-11-09 12:45:22 +01:00
</ div >
</ div >
</ div >
2017-08-04 16:28:16 +02:00
<!-- COSTI -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2017-09-04 12:02:29 +02:00
< h3 class = " panel-title " >< ? php echo tr ( 'Costi unitari' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " >
< div class = " row " >
< div class = " col-md-12 col-lg-12 " >
< ? php
$idtipiintervento = [ '-1' ];
2019-07-08 12:24:59 +02:00
// Loop fra i tipi di attività e i relativi costi del tipo intervento
$rs = $dbo -> fetchArray ( 'SELECT co_contratti_tipiintervento.*, in_tipiintervento.descrizione FROM co_contratti_tipiintervento INNER JOIN in_tipiintervento ON in_tipiintervento.idtipointervento = co_contratti_tipiintervento.idtipointervento WHERE idcontratto=' . prepare ( $id_record ) . ' AND (co_contratti_tipiintervento.costo_ore != in_tipiintervento.costo_orario OR co_contratti_tipiintervento.costo_km != in_tipiintervento.costo_km OR co_contratti_tipiintervento.costo_dirittochiamata != in_tipiintervento.costo_diritto_chiamata) ORDER BY in_tipiintervento.descrizione' );
2017-08-04 16:28:16 +02:00
2019-07-08 12:24:59 +02:00
if ( ! empty ( $rs )) {
2017-08-04 16:28:16 +02:00
echo '
< table class = " table table-striped table-condensed table-bordered " >
< tr >
2017-09-04 12:02:29 +02:00
< th width = " 300 " > '.tr(' Tipo attività ').' </ th >
2017-08-04 16:28:16 +02:00
2019-06-14 15:39:40 +02:00
< th > '.tr(' Addebito orario ').' < span class = " tip " title = " '.tr('Addebito al cliente').' " >< i class = " fa fa-question-circle-o " ></ i ></ span ></ th >
< th > '.tr(' Addebito km ').' < span class = " tip " title = " '.tr('Addebito al cliente').' " >< i class = " fa fa-question-circle-o " ></ i ></ span ></ th >
< th > '.tr(' Addebito diritto ch . ').' < span class = " tip " title = " '.tr('Addebito al cliente').' " >< i class = " fa fa-question-circle-o " ></ i ></ span ></ th >
2020-02-17 13:18:25 +01:00
2019-06-14 15:39:40 +02:00
< th width = " 40 " ></ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
for ( $i = 0 ; $i < sizeof ( $rs ); ++ $i ) {
echo '
< tr >
< td > '.$rs[$i][' descrizione '].' </ td >
< td >
{[ " type " : " number " , " name " : " costo_ore['. $rs[$i] ['idtipointervento'].'] " , " value " : " '. $rs[$i] ['costo_ore'].' " ]}
</ td >
< td >
{[ " type " : " number " , " name " : " costo_km['. $rs[$i] ['idtipointervento'].'] " , " value " : " '. $rs[$i] ['costo_km'].' " ]}
</ td >
< td >
{[ " type " : " number " , " name " : " costo_dirittochiamata['. $rs[$i] ['idtipointervento'].'] " , " value " : " '. $rs[$i] ['costo_dirittochiamata'].' " ]}
</ td >
2019-06-14 15:39:40 +02:00
< td >
2020-09-23 17:53:19 +02:00
< button type = " button " class = " btn btn-warning " data - toggle = " tooltip " title = " Importa valori da tariffe standard " onclick = " if( confirm( \ 'Importare i valori dalle tariffe standard? \ ') ) { $ .post( \ ''.base_path().'/modules/contratti/actions.php \ ', { op: \ 'import \ ', idcontratto: \ ''. $id_record .' \ ', idtipointervento: \ ''. $rs[$i] ['idtipointervento'].' \ ' }, function(data) { location.href= \ ''.base_path().'/editor.php?id_module='. $id_module .'&id_record='. $id_record .' \ '; } ); } " >
2019-07-08 12:24:59 +02:00
< i class = " fa fa-download " ></ i >
</ button >
2019-06-14 15:39:40 +02:00
</ td >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
$idtipiintervento [] = prepare ( $rs [ $i ][ 'idtipointervento' ]);
}
echo '
</ table > ' ;
}
echo '
2019-07-08 12:24:59 +02:00
< button type = " button " onclick = " $ (this).next().toggleClass( \ 'hide \ '); " class = " btn btn-info btn-sm " >< i class = " fa fa-th-list " ></ i > '.tr(' Mostra tipi di attività non modificati ').' </ button >
2017-08-04 16:28:16 +02:00
< div class = " hide " > ' ;
//Loop fra i tipi di attività e i relativi costi del tipo intervento (quelli a 0)
2019-07-08 12:24:59 +02:00
$rs = $dbo -> fetchArray ( 'SELECT * FROM co_contratti_tipiintervento INNER JOIN in_tipiintervento ON in_tipiintervento.idtipointervento = co_contratti_tipiintervento.idtipointervento WHERE co_contratti_tipiintervento.idtipointervento NOT IN(' . implode ( ',' , $idtipiintervento ) . ') AND idcontratto=' . prepare ( $id_record ) . ' ORDER BY descrizione' );
2017-08-04 16:28:16 +02:00
2019-07-08 12:24:59 +02:00
if ( ! empty ( $rs )) {
2017-08-04 16:28:16 +02:00
echo '
2018-11-13 14:51:19 +01:00
< div class = " clearfix " >& nbsp ; </ div >
< table class = " table table-striped table-condensed table-bordered " >
2017-08-04 16:28:16 +02:00
< tr >
2017-09-04 12:02:29 +02:00
< th width = " 300 " > '.tr(' Tipo attività ').' </ th >
2017-08-04 16:28:16 +02:00
2019-06-13 18:05:19 +02:00
< th > '.tr(' Addebito orario ').' < span class = " tip " title = " '.tr('Addebito al cliente').' " >< i class = " fa fa-question-circle-o " ></ i ></ span ></ th >
< th > '.tr(' Addebito km ').' < span class = " tip " title = " '.tr('Addebito al cliente').' " >< i class = " fa fa-question-circle-o " ></ i ></ span ></ th >
< th > '.tr(' Addebito diritto ch . ').' < span class = " tip " title = " '.tr('Addebito al cliente').' " >< i class = " fa fa-question-circle-o " ></ i ></ span ></ th >
2017-08-04 16:28:16 +02:00
2019-06-14 15:39:40 +02:00
< th width = " 40 " ></ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
for ( $i = 0 ; $i < sizeof ( $rs ); ++ $i ) {
echo '
< tr >
< td > '.$rs[$i][' descrizione '].' </ td >
< td >
{[ " type " : " number " , " name " : " costo_ore['. $rs[$i] ['idtipointervento'].'] " , " value " : " '. $rs[$i] ['costo_orario'].' " ]}
</ td >
< td >
{[ " type " : " number " , " name " : " costo_km['. $rs[$i] ['idtipointervento'].'] " , " value " : " '. $rs[$i] ['costo_km'].' " ]}
</ td >
< td >
{[ " type " : " number " , " name " : " costo_dirittochiamata['. $rs[$i] ['idtipointervento'].'] " , " value " : " '. $rs[$i] ['costo_diritto_chiamata'].' " ]}
</ td >
2019-06-14 15:39:40 +02:00
< td >
2020-09-23 17:53:19 +02:00
< button type = " button " class = " btn btn-warning " data - toggle = " tooltip " title = " Importa valori da tariffe standard " onclick = " if( confirm( \ 'Importare i valori dalle tariffe standard? \ ') ) { $ .post( \ ''.base_path().'/modules/contratti/actions.php \ ', { op: \ 'import \ ', idcontratto: \ ''. $id_record .' \ ', idtipointervento: \ ''. $rs[$i] ['idtipointervento'].' \ ' }, function(data) { location.href= \ ''.base_path().'/editor.php?id_module='. $id_module .'&id_record='. $id_record .' \ '; } ); } " >
2019-06-14 15:39:40 +02:00
< i class = " fa fa-download " ></ i >
</ button >
</ td >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
}
echo '
</ table > ' ;
}
2020-08-03 12:08:52 +02:00
echo '
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
</ div >
</ div >
</ form >
<!-- RIGHE -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2020-08-03 12:08:52 +02:00
< h3 class = " panel-title " > '.tr(' Righe ').' </ h3 >
2017-08-04 16:28:16 +02:00
</ div >
2020-08-03 12:08:52 +02:00
< div class = " panel-body " > ' ;
2019-07-24 12:42:45 +02:00
if ( ! $block_edit ) {
2019-03-29 12:46:17 +01:00
echo '
2020-08-26 14:28:56 +02:00
< button type = " button " class = " btn btn-sm btn-primary tip " title = " '.tr('Aggiungi articolo').' " onclick = " gestioneArticolo(this) " >
2019-03-29 12:46:17 +01:00
< i class = " fa fa-plus " ></ i > '.tr(' Articolo ').'
2020-08-03 12:08:52 +02:00
</ button > ' ;
2019-03-29 12:46:17 +01:00
2020-07-20 14:40:11 +02:00
echo '
2020-08-26 14:28:56 +02:00
< button type = " button " class = " btn btn-sm btn-primary tip " title = " '.tr('Aggiungi articoli tramite barcode').' " onclick = " gestioneBarcode(this) " >
2020-07-20 14:40:11 +02:00
< i class = " fa fa-plus " ></ i > '.tr(' Barcode ').'
2020-08-03 12:08:52 +02:00
</ button > ' ;
2020-07-20 14:40:11 +02:00
2019-03-29 12:46:17 +01:00
echo '
2020-08-26 14:28:56 +02:00
< button type = " button " class = " btn btn-sm btn-primary tip " title = " '.tr('Aggiungi riga').' " onclick = " gestioneRiga(this) " >
2019-03-29 12:46:17 +01:00
< i class = " fa fa-plus " ></ i > '.tr(' Riga ').'
2020-08-03 12:08:52 +02:00
</ button > ' ;
2018-02-19 10:52:42 +01:00
2019-03-29 12:46:17 +01:00
echo '
2020-08-26 14:28:56 +02:00
< button type = " button " class = " btn btn-sm btn-primary tip " title = " '.tr('Aggiungi descrizione').' " onclick = " gestioneDescrizione(this) " >
2019-03-29 12:46:17 +01:00
< i class = " fa fa-plus " ></ i > '.tr(' Descrizione ').'
2020-08-03 12:08:52 +02:00
</ button > ' ;
2018-02-19 10:52:42 +01:00
2019-03-29 12:46:17 +01:00
echo '
2020-08-26 14:28:56 +02:00
< button type = " button " class = " btn btn-sm btn-primary tip " title = " '.tr('Aggiungi sconto/maggiorazione').' " onclick = " gestioneSconto(this) " >
2019-03-29 12:46:17 +01:00
< i class = " fa fa-plus " ></ i > '.tr(' Sconto / maggiorazione ').'
2020-08-03 12:08:52 +02:00
</ button > ' ;
2017-08-04 16:28:16 +02:00
}
2020-08-03 12:08:52 +02:00
echo '
2017-08-04 16:28:16 +02:00
< div class = " clearfix " ></ div >
< br >
< div class = " row " >
2020-09-14 10:49:23 +02:00
< div class = " col-md-12 " id = " righe " ></ div >
</ div >
2017-08-04 16:28:16 +02:00
</ div >
</ div >
2018-11-13 14:51:19 +01:00
{( " name " : " filelist_and_upload " , " id_module " : " $id_module $ " , " id_record " : " $id_record $ " )}
{( " name " : " log_email " , " id_module " : " $id_module $ " , " id_record " : " $id_record $ " )}
2017-09-04 11:53:30 +02:00
< script type = " text/javascript " >
2020-08-03 12:08:52 +02:00
function gestioneArticolo ( button ) {
gestioneRiga ( button , " is_articolo " );
}
function gestioneBarcode ( button ) {
gestioneRiga ( button , " is_barcode " );
}
function gestioneSconto ( button ) {
gestioneRiga ( button , " is_sconto " );
}
function gestioneDescrizione ( button ) {
gestioneRiga ( button , " is_descrizione " );
}
async function gestioneRiga ( button , options ) {
// Salvataggio via AJAX
let valid = await salvaForm ( button , $ ( " #edit-form " ));
// Apertura modal
if ( valid ) {
// Lettura titolo e chiusura tooltip
let title = $ ( button ) . tooltipster ( " content " );
$ ( button ) . tooltipster ( " close " )
// Apertura modal
options = options ? options : " is_riga " ;
openModal ( title , " '. $structure->fileurl ('row-add.php').'?id_module='. $id_module .'&id_record='. $id_record .'& " + options );
}
}
2020-09-14 10:49:23 +02:00
/**
* Funzione dedicata al caricamento dinamico via AJAX delle righe del documento .
*/
function caricaRighe () {
let container = $ ( " #righe " );
localLoading ( container , true );
2020-09-14 11:06:35 +02:00
return $ . get ( " '. $structure->fileurl ('row-list.php').'?id_module='. $id_module .'&id_record='. $id_record .' " , function ( data ) {
container . html ( data );
2020-09-14 10:49:23 +02:00
localLoading ( container , false );
});
}
$ ( document ) . ready ( function () {
caricaRighe ();
});
2020-08-03 12:08:52 +02:00
$ ( document ) . ready ( function () {
$ ( " #data_accettazione " ) . on ( " dp.change " , function () {
if ( $ ( this ) . val ()){
$ ( " #data_rifiuto " ) . attr ( " disabled " , true );
} else {
$ ( " #data_rifiuto " ) . attr ( " disabled " , false );
}
2017-09-04 11:53:30 +02:00
});
2018-05-11 14:48:46 +02:00
2020-08-03 12:08:52 +02:00
$ ( " #data_rifiuto " ) . on ( " dp.change " , function () {
if ( $ ( this ) . val ()){
$ ( " #data_accettazione " ) . attr ( " disabled " , true );
} else {
$ ( " #data_accettazione " ) . attr ( " disabled " , false );
}
});
2018-04-13 17:55:20 +02:00
2020-08-03 12:08:52 +02:00
$ ( " #data_accettazione " ) . trigger ( " dp.change " );
$ ( " #data_rifiuto " ) . trigger ( " dp.change " );
});
2020-02-17 13:18:25 +01:00
2020-08-03 12:08:52 +02:00
$ ( " #idanagrafica_c " ) . change ( function () {
updateSelectOption ( " idanagrafica " , $ ( this ) . val ());
session_set ( " superselect,idanagrafica " , $ ( this ) . val (), 0 );
2020-02-17 13:18:25 +01:00
2020-08-03 12:08:52 +02:00
$ ( " #idsede " ) . selectReset ();
});
2020-02-17 13:18:25 +01:00
2020-08-03 12:08:52 +02:00
$ ( " #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 );
}
});
</ script > ' ;
2017-09-04 11:53:30 +02:00
2018-09-05 10:05:23 +02:00
// Collegamenti diretti
2019-11-14 18:37:42 +01:00
// Fatture o interventi collegati a questo contratto
$elementi = $dbo -> fetchArray ( 'SELECT 0 AS `codice`, `co_documenti`.`id` AS `id`, `co_documenti`.`numero` AS `numero`, `co_documenti`.`numero_esterno` AS `numero_esterno`, `co_documenti`.`data`, `co_tipidocumento`.`descrizione` AS `tipo_documento`, `co_tipidocumento`.`dir` AS `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 `idcontratto` = ' . prepare ( $id_record ) . ')' . '
UNION
SELECT `in_interventi` . `codice` AS `codice` , `in_interventi` . `id` AS `id` , 0 AS `numero` , 0 AS `numero_esterno` , `in_interventi` . `data_richiesta` AS `data` , 0 AS `tipo_documento` , 0 AS `dir` FROM `in_interventi` WHERE `in_interventi` . `id_contratto` = '.prepare($id_record).' ORDER BY `data` ' );
2018-09-05 10:05:23 +02:00
if ( ! empty ( $elementi )) {
2017-09-14 10:27:49 +02:00
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 > ' ;
2019-11-15 15:11:20 +01:00
2019-11-14 18:37:42 +01:00
// Elenco attività o contratti collegati
foreach ( $elementi as $riga ) {
2019-11-15 15:11:20 +01:00
if ( ! empty ( $riga [ 'dir' ])) {
2019-11-14 18:37:42 +01:00
$descrizione = tr ( '_DOC_ num. _NUM_ del _DATE_' , [
'_DOC_' => $riga [ 'tipo_documento' ],
'_NUM_' => ! empty ( $riga [ 'numero_esterno' ]) ? $riga [ 'numero_esterno' ] : $riga [ 'numero' ],
'_DATE_' => Translator :: dateToLocale ( $riga [ 'data' ]),
]);
2017-09-14 10:27:49 +02:00
2019-11-14 18:37:42 +01:00
$modulo = ( $riga [ 'dir' ] == 'entrata' ) ? 'Fatture di vendita' : 'Fatture di acquisto' ;
$id = $riga [ 'id' ];
echo '
< li > '.Modules::link($modulo, $id, $descrizione).' </ li > ' ;
2019-11-15 15:11:20 +01:00
} else {
2019-11-14 18:37:42 +01:00
$descrizione = tr ( 'Intervento num. _NUM_ del _DATE_' , [
2019-11-15 15:11:20 +01:00
'_NUM_' => $riga [ 'codice' ],
2019-11-14 18:37:42 +01:00
'_DATE_' => Translator :: dateToLocale ( $riga [ 'data' ]),
]);
$modulo = 'Interventi' ;
$id = $riga [ 'id' ];
echo '
< li > '.Modules::link($modulo, $id, $descrizione).' </ li > ' ;
}
2017-09-14 10:27:49 +02:00
}
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 > ' ;
2019-11-15 15:11:20 +01:00
} else {
?>
2017-11-16 14:27:43 +01:00
< a class = " btn btn-danger ask " data - backto = " record-list " >
< i class = " fa fa-trash " ></ i > < ? php echo tr ( 'Elimina' ); ?>
2018-01-15 20:28:36 +01:00
</ a >
2019-11-14 18:37:42 +01:00
< ? php
2019-11-15 15:11:20 +01:00
}
2020-04-01 16:42:32 +02:00
2020-12-01 16:52:51 +01:00
echo '
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
$ ( " #rinnovabile " ) . click ( function () {
if ( $ ( this ) . is ( " :checked " )){
input ( " giorni_preavviso_rinnovo " ) . enable ();
input ( " rinnovo_automatico " ) . enable ();
} else {
input ( " giorni_preavviso_rinnovo " ) . disable ();
input ( " rinnovo_automatico " ) . disable ();
}
});
2021-03-08 14:17:59 +01:00
$ ( " #data_conclusione " ) . on ( " dp.change " , function ( e ) {
let data_accettazione = $ ( " #data_accettazione " );
data_accettazione . data ( " DateTimePicker " ) . maxDate ( e . date );
if ( data_accettazione . data ( " DateTimePicker " ) . date () > e . date ){
data_accettazione . data ( " DateTimePicker " ) . date ( e . date );
}
});
2020-04-01 16:42:32 +02:00
});
2020-12-01 16:52:51 +01:00
</ script > ' ;
?>