2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
2019-07-24 12:42:45 +02:00
$block_edit = $record [ 'is_completato' ];
2019-05-29 19:17:57 +02:00
unset ( $_SESSION [ 'superselect' ][ 'idsede_partenza' ]);
unset ( $_SESSION [ 'superselect' ][ 'idsede_destinazione' ]);
2017-08-04 16:28:16 +02:00
unset ( $_SESSION [ 'superselect' ][ 'idanagrafica' ]);
2018-07-18 15:20:10 +02:00
$_SESSION [ 'superselect' ][ 'idanagrafica' ] = $record [ 'idanagrafica' ];
2020-05-20 09:07:06 +02:00
$_SESSION [ 'superselect' ][ 'permetti_movimento_a_zero' ] = true ;
2017-08-04 16:28:16 +02:00
2020-04-01 17:17:26 +02:00
// Mostro un avviso se ci sono più revisioni del preventivo
2020-04-01 17:28:21 +02:00
if ( count ( $preventivo -> revisioni ) > 1 ) {
2020-04-01 17:17:26 +02:00
echo '
< div class = " alert alert-info " >
2020-07-07 17:32:03 +02:00
< i class = " fa fa-info-circle " ></ i >
2020-04-14 08:49:48 +02:00
'.tr(' Questo preventivo presenta _N_ revisioni ' ,
2020-04-01 17:17:26 +02:00
[
2020-04-14 08:49:48 +02:00
'_N_' => count ( $preventivo -> revisioni ),
2020-04-01 17:17:26 +02:00
]) . '
</ div >
' ;
}
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 " >
2019-07-24 12:42:45 +02: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 " >
2020-04-14 08:49:48 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Numero'); ?> " , " name " : " numero " , " required " : 1 , " class " : " text-center " , " value " : " $numero $ " , " icon-after " : " <?php echo (count( $preventivo->revisioni ) > 1) ? tr('rev.').' '. $preventivo->numero_revision : ''; ?> " ]}
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 >
< div class = " col-md-2 " >
{[ " type " : " date " , " label " : " <?php echo tr('Data accettazione'); ?> " , " name " : " data_accettazione " , " value " : " $data_accettazione $ " ]}
</ div >
< div class = " col-md-2 " >
2020-07-07 18:07:56 +02:00
{[ " type " : " date " , " label " : " <?php echo tr('Data conclusione'); ?> " , " name " : " data_conclusione " , " value " : " $data_conclusione $ " , " disabled " : " <?php echo $preventivo->isDataConclusioneAutomatica () ? '1 " , " help " : " '.tr('La Data di conclusione è calcolata in automatico in base al valore del campo Validità') : 0; ?> " ]}
2019-07-24 12:42:45 +02:00
</ div >
< div class = " col-md-2 " >
{[ " type " : " date " , " label " : " <?php echo tr('Data rifiuto'); ?> " , " name " : " data_rifiuto " , " value " : " $data_rifiuto $ " ]}
</ div >
2019-04-08 18:50:28 +02:00
</ div >
2019-11-29 18:21:31 +01:00
2019-04-08 18:50:28 +02: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"' );
?>
{[ " type " : " select " , " label " : " <?php echo tr('Cliente'); ?> " , " name " : " idanagrafica " , " required " : 1 , " value " : " $idanagrafica $ " , " ajax-source " : " clienti " ]}
</ div >
< div class = " col-md-3 " >
{[ " type " : " select " , " label " : " <?php echo tr('Sede'); ?> " , " name " : " idsede " , " value " : " $idsede $ " , " ajax-source " : " sedi " , " placeholder " : " Sede legale " ]}
</ div >
2019-04-08 18:50:28 +02:00
< div class = " col-md-3 " >
2019-07-05 10:47:45 +02:00
< ? php
2019-07-23 16:12:46 +02:00
if ( ! empty ( $record [ 'idreferente' ])) {
echo Plugins :: link ( 'Referenti' , $record [ 'idanagrafica' ], null , null , 'class="pull-right"' );
}
2019-07-05 10:47:45 +02:00
?>
2019-04-08 18:50:28 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Referente'); ?> " , " name " : " idreferente " , " value " : " $idreferente $ " , " ajax-source " : " referenti " ]}
</ div >
2019-11-29 18:21:31 +01:00
2017-08-04 16:28:16 +02:00
< div class = " col-md-3 " >
2018-01-15 20:28:36 +01:00
< ? php
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 >
</ div >
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_statipreventivi " , " value " : " $idstato $ " , " class " : " unblockable " ]}
</ div >
</ div >
2017-08-04 16:28:16 +02:00
< div class = " row " >
2019-04-08 18:50:28 +02:00
< div class = " col-md-3 " >
2020-07-07 18:07:56 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Validità offerta'); ?> " , " name " : " validita " , " decimals " : " 0 " , " value " : " $validita $ " , " icon-after " : " choice|period|<?php echo $record['tipo_validita'] ; ?> " , " help " : " <?php echo tr('Il campo Validità viene utilizzato in modo esclusivamente indicativo se impostato secondo l \ 'opzione manuale, mentre viene utilizzato per il calcolo della Data di conclusione del documento in caso alternativo'); ?> " ]}
2019-04-08 18:50:28 +02:00
</ div >
2019-11-29 18:21:31 +01:00
2017-08-04 16:28:16 +02:00
< div class = " col-md-3 " >
2019-04-08 18:50:28 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Tipo di attività'); ?> " , " name " : " idtipointervento " , " required " : 1 , " values " : " query=SELECT idtipointervento AS id, descrizione FROM in_tipiintervento ORDER BY descrizione " , " value " : " $idtipointervento $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
2019-04-08 18:50:28 +02:00
<!-- div class = " col-md-3 " >
{[ " type " : " select " , " label " : " <?php echo tr('Resa materiale'); ?> " , " name " : " idporto " , " values " : " query=SELECT id, descrizione FROM dt_porto ORDER BY descrizione " , " value " : " $idporto $ " ]}
</ div -->
2019-11-29 18:21:31 +01:00
2017-08-04 16:28:16 +02:00
< div class = " col-md-3 " >
2019-04-08 18:50:28 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Tempi di consegna'); ?> " , " name " : " tempi_consegna " , " value " : " $tempi_consegna $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
2019-11-29 18:21:31 +01:00
2017-08-04 16:28:16 +02:00
</ div >
< div class = " row " >
</ div >
< 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 >
2018-02-20 10:55:00 +01:00
<!-- div class = " pull-right " >
2017-09-04 12:02:29 +02:00
< button type = " submit " class = " btn btn-success " >< i class = " fa fa-check " ></ i > < ? php echo tr ( 'Salva modifiche' ); ?> </button>
2018-02-20 10:55:00 +01:00
</ div -->
2017-08-04 16:28:16 +02:00
</ div >
</ div >
2019-11-29 18:21:31 +01:00
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' ); ?>
2019-11-29 18:21:31 +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 >
2019-01-24 20:31:01 +01:00
</ div >
</ div >
</ div >
2017-08-04 16:28:16 +02:00
</ form >
<!-- RIGHE -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
< h3 class = " panel-title " > Righe </ h3 >
</ div >
< div class = " panel-body " >
2019-03-29 12:46:17 +01:00
< ? php
2019-07-24 12:42:45 +02:00
if ( ! $block_edit ) {
2019-03-29 12:46:17 +01:00
echo '
< a class = " btn btn-sm btn-primary " data - href = " '. $structure->fileurl ('row-add.php').'?id_module='. $id_module .'&id_record='. $id_record .'&is_articolo " data - toggle = " tooltip " data - title = " '.tr('Aggiungi articolo').' " >
< i class = " fa fa-plus " ></ i > '.tr(' Articolo ').'
</ a > ' ;
2018-01-18 19:03:06 +01:00
2020-07-20 14:40:11 +02:00
echo '
< a class = " btn btn-sm btn-primary " data - href = " '. $structure->fileurl ('row-add.php').'?id_module='. $id_module .'&id_record='. $id_record .'&is_barcode " data - toggle = " tooltip " data - title = " '.tr('Aggiungi articoli tramite barcode').' " >
< i class = " fa fa-plus " ></ i > '.tr(' Barcode ').'
</ 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_barcode " data - toggle = " tooltip " data - title = " '.tr('Aggiungi articoli tramite barcode').' " >
< i class = " fa fa-plus " ></ i > '.tr(' Barcode ').'
</ a > ' ;
2019-03-29 12:46:17 +01:00
echo '
< a class = " btn btn-sm btn-primary " data - href = " '. $structure->fileurl ('row-add.php').'?id_module='. $id_module .'&id_record='. $id_record .'&is_riga " data - toggle = " tooltip " data - title = " '.tr('Aggiungi riga').' " >
< i class = " fa fa-plus " ></ i > '.tr(' Riga ').'
</ a > ' ;
2018-01-18 19:03:06 +01:00
2019-03-29 12:46:17 +01:00
echo '
< a class = " btn btn-sm btn-primary " data - href = " '. $structure->fileurl ('row-add.php').'?id_module='. $id_module .'&id_record='. $id_record .'&is_descrizione " data - toggle = " tooltip " data - title = " '.tr('Aggiungi descrizione').' " >
< i class = " fa fa-plus " ></ i > '.tr(' Descrizione ').'
</ a > ' ;
2018-02-19 11:25:56 +01:00
2019-03-29 12:46:17 +01:00
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 > ' ;
}
2018-01-18 19:03:06 +01:00
2019-03-29 12:46:17 +01:00
?>
2017-08-04 16:28:16 +02:00
2018-02-20 10:55:00 +01:00
<!-- div class = " pull-right " >
2018-02-18 19:53:23 +01:00
{( " name " : " button " , " type " : " print " , " id_module " : " <?php echo $id_module ; ?> " , " id_record " : " <?php echo $id_record ; ?> " )}
2018-02-20 10:55:00 +01:00
</ div -->
2018-02-21 09:53:38 +01:00
2017-08-04 16:28:16 +02:00
< div class = " clearfix " ></ div >
< br >
< div class = " row " >
< div class = " col-md-12 " >
< ? php
include $docroot . '/modules/preventivi/row-list.php' ;
?>
</ div >
</ div >
</ div >
</ div >
2018-11-09 11:34:27 +01:00
< script type = " text/javascript " >
$ ( document ) . ready ( function (){
2019-11-29 18:21:31 +01:00
$ ( '#idanagrafica' ) . change ( function (){
session_set ( 'superselect,idanagrafica' , $ ( this ) . val (), 0 );
$ ( " #idsede " ) . selectReset ();
});
2018-11-09 11:34:27 +01:00
$ ( '#data_accettazione' ) . on ( " dp.change " , function (){
if ( $ ( this ) . val ()){
$ ( '#data_rifiuto' ) . attr ( 'disabled' , true );
} else {
$ ( '#data_rifiuto' ) . attr ( 'disabled' , false );
}
});
$ ( '#data_rifiuto' ) . on ( " dp.change " , function (){
if ( $ ( this ) . val ()){
$ ( '#data_accettazione' ) . attr ( 'disabled' , true );
} else {
$ ( '#data_accettazione' ) . attr ( 'disabled' , false );
}
});
$ ( " #data_accettazione " ) . trigger ( " dp.change " );
$ ( " #data_rifiuto " ) . trigger ( " dp.change " );
2019-11-29 18:21:31 +01:00
2019-03-12 17:22:25 +01:00
$ ( '#codice_cig, #codice_cup' ) . bind ( " keyup change " , function ( e ) {
2019-11-29 18:21:31 +01:00
2019-03-12 17:22:25 +01:00
if ( $ ( '#codice_cig' ) . val () == '' && $ ( '#codice_cup' ) . val () == '' ){
$ ( '#id_documento_fe' ) . prop ( 'required' , false );
} else {
$ ( '#id_documento_fe' ) . prop ( 'required' , true );
}
2019-11-29 18:21:31 +01:00
2019-03-12 17:22:25 +01:00
});
2019-11-29 18:21:31 +01:00
2018-11-09 11:34:27 +01:00
});
</ script >
2017-09-14 10:27:49 +02:00
2018-12-07 10:47:44 +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-11-16 14:27:43 +01:00
< ? php
2018-12-07 10:47:44 +01:00
//fatture, ordini collegate a questo preventivo
2019-11-29 18:21:31 +01:00
$elementi = $dbo -> fetchArray ( 'SELECT `co_documenti`.`id`, `co_documenti`.`data`, `co_documenti`.`numero`, `co_documenti`.`numero_esterno`, `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 `idpreventivo` = ' . prepare ( $id_record ) . ' )
2018-12-07 10:47:44 +01:00
UNION
SELECT `or_ordini` . `id` , `or_ordini` . `data` , `or_ordini` . `numero` , `or_ordini` . `numero_esterno` , " Ordine cliente " AS tipo_documento , 0 AS dir FROM `or_ordini` JOIN `or_righe_ordini` ON `or_righe_ordini` . `idordine` = `or_ordini` . `id` WHERE `or_righe_ordini` . `idpreventivo` = '.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 > ' ;
2018-12-07 10:47:44 +01:00
foreach ( $elementi as $elemento ) {
2017-09-14 10:27:49 +02:00
$descrizione = tr ( '_DOC_ num. _NUM_ del _DATE_' , [
2018-12-07 10:47:44 +01:00
'_DOC_' => $elemento [ 'tipo_documento' ],
'_NUM_' => ! empty ( $elemento [ 'numero_esterno' ]) ? $elemento [ 'numero_esterno' ] : $elemento [ 'numero' ],
'_DATE_' => Translator :: dateToLocale ( $elemento [ 'data' ]),
2017-09-14 10:27:49 +02:00
]);
2018-12-23 14:01:59 +01:00
if ( in_array ( $elemento [ 'tipo_documento' ], [ 'Ordine cliente' ])) {
2018-12-07 10:47:44 +01:00
$modulo = 'Ordini cliente' ;
2018-12-23 14:01:59 +01:00
} else {
2018-12-07 10:47:44 +01:00
$modulo = ( $elemento [ 'dir' ] == 'entrata' ) ? 'Fatture di vendita' : 'Fatture di acquisto' ;
}
$id = $elemento [ 'id' ];
2017-09-14 10:27:49 +02:00
echo '
2018-09-05 10:05:23 +02:00
< 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 > ' ;
2017-09-14 10:27:49 +02:00
}
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 >