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 [ 'flag_completato' ];
2017-09-22 15:19:59 +02:00
$module = Modules :: get ( $id_module );
2017-08-04 16:28:16 +02:00
2022-03-09 17:30:07 +01:00
if ( $module [ 'name' ] == 'Ddt di acquisto' ) {
2017-08-04 16:28:16 +02:00
$dir = 'uscita' ;
2022-03-09 17:30:07 +01:00
} else {
$dir = 'entrata' ;
2017-08-04 16:28:16 +02:00
}
2018-11-22 10:05:45 +01:00
2022-10-27 11:04:10 +02:00
if ( $dir == 'entrata' ) {
$numero_previsto = verifica_numero_ddt ( $ddt );
if ( ! empty ( $numero_previsto )) {
echo '
< div class = " alert alert-warning " >
< i class = " fa fa-warning " ></ i > '.tr("E' assente un _TYPE_ numero _NUM_ in data precedente o corrispondente a _DATE_ : si potrebbero verificare dei problemi con la numerazione corrente dei DDT " , [
'_TYPE_' => $module [ 'name' ],
'_DATE_' => dateFormat ( $ddt -> data ),
'_NUM_' => '"' . $numero_previsto . '"' ,
]) . ' .</ b >
</ div > ' ;
}
2022-02-21 18:49:31 +01:00
}
2017-08-04 16:28:16 +02: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
<!-- INTESTAZIONE -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2017-09-04 12:02:29 +02:00
< h3 class = " panel-title " >< ? php echo tr ( 'Intestazione' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " >
2018-03-21 23:49:08 +01:00
< ? php
if ( $dir == 'entrata' ) {
2018-07-18 15:20:10 +02:00
$rs2 = $dbo -> fetchArray ( 'SELECT piva, codice_fiscale, citta, indirizzo, cap, provincia FROM an_anagrafiche WHERE idanagrafica=' . prepare ( $record [ 'idanagrafica' ]));
2018-03-21 23:49:08 +01:00
$campi_mancanti = [];
if ( $rs2 [ 0 ][ 'piva' ] == '' ) {
if ( $rs2 [ 0 ][ 'codice_fiscale' ] == '' ) {
array_push ( $campi_mancanti , 'codice fiscale' );
}
}
if ( $rs2 [ 0 ][ 'citta' ] == '' ) {
array_push ( $campi_mancanti , 'citta' );
}
if ( $rs2 [ 0 ][ 'indirizzo' ] == '' ) {
array_push ( $campi_mancanti , 'indirizzo' );
}
if ( $rs2 [ 0 ][ 'cap' ] == '' ) {
array_push ( $campi_mancanti , 'C.A.P.' );
}
if ( sizeof ( $campi_mancanti ) > 0 ) {
echo " <div class='alert alert-warning'><i class='fa fa-warning'></i> Prima di procedere alla stampa completa i seguenti campi dell'anagrafica:<br/><b> " . implode ( ', ' , $campi_mancanti ) . ' </ b >< br />
2018-07-18 15:20:10 +02:00
'.Modules::link(' Anagrafiche ', $record[' idanagrafica '], tr(' Vai alla scheda anagrafica '), null).' </ div > ' ;
2018-03-21 23:49:08 +01:00
}
}
?>
2018-07-08 18:11:17 +02:00
2017-08-04 16:28:16 +02:00
< div class = " row " >
2018-03-21 23:49:08 +01:00
< ? php
2018-03-22 15:40:20 +01:00
if ( $dir == 'uscita' ) {
echo '
2019-07-24 12:42:45 +02:00
< div class = " col-md-3 " >
{[ " type " : " span " , " label " : " '.tr('Numero ddt').' " , " class " : " text-center " , " value " : " $numero $ " ]}
</ div > ' ;
2018-03-22 15:40:20 +01:00
}
?>
2017-08-04 16:28:16 +02:00
< div class = " col-md-3 " >
2019-07-24 12:42:45 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Numero secondario'); ?> " , " name " : " numero_esterno " , " class " : " text-center " , " value " : " $numero_esterno $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2019-07-24 12:42:45 +02:00
{[ " type " : " date " , " label " : " <?php echo tr('Data'); ?> " , " name " : " data " , " required " : 1 , " value " : " $data $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2018-05-22 14:41:42 +02:00
< ? php
2018-07-08 18:11:17 +02:00
if ( setting ( 'Cambia automaticamente stato ddt fatturati' )) {
2018-07-18 15:20:10 +02:00
if ( $record [ 'stato' ] == 'Fatturato' || $record [ 'stato' ] == 'Parzialmente fatturato' ) {
2018-06-26 14:30:26 +02:00
?>
2019-07-24 12:42:45 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Stato'); ?> " , " name " : " idstatoddt " , " required " : 1 , " values " : " query=SELECT * FROM dt_statiddt " , " value " : " $idstatoddt $ " , " extra " : " readonly " , " class " : " unblockable " ]}
2018-06-26 14:30:26 +02:00
< ? php
} else {
?>
2019-07-24 12:42:45 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Stato'); ?> " , " name " : " idstatoddt " , " required " : 1 , " values " : " query=SELECT * FROM dt_statiddt WHERE descrizione IN('Bozza', 'Evaso', 'Parzialmente evaso') " , " value " : " $idstatoddt $ " , " class " : " unblockable " ]}
2018-05-22 14:41:42 +02:00
< ? php
}
2018-06-26 14:30:26 +02:00
} else {
?>
2019-07-24 12:42:45 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Stato'); ?> " , " name " : " idstatoddt " , " required " : 1 , " values " : " query=SELECT * FROM dt_statiddt " , " value " : " $idstatoddt $ " , " class " : " unblockable " ]}
2018-05-22 14:41:42 +02:00
< ? php
}
?>
2017-08-04 16:28:16 +02:00
</ div >
2022-05-18 16:36:22 +02:00
< ? php
if ( $dir == 'entrata' ) {
echo '
< div class = " col-md-3 " > ' ;
if ( $record [ 'idagente' ] != 0 ) {
echo Modules :: link ( 'Anagrafiche' , $record [ 'idagente' ], null , null , 'class="pull-right"' );
}
echo '
{[ " type " : " select " , " label " : " '.tr('Agente').' " , " name " : " idagente " , " ajax-source " : " agenti " , " select-options " : { " idanagrafica " : '.$record[' idanagrafica '].' }, " value " : " $idagente $ " ]}
</ div > ' ;
}
?>
2017-08-04 16:28:16 +02:00
</ div >
2019-07-29 16:54:20 +02:00
2020-07-31 14:25:50 +02:00
< div class = " row " >
< div class = " col-md-3 " >
< ? php echo Modules :: link ( 'Anagrafiche' , $record [ 'idanagrafica' ], null , null , 'class="pull-right"' ); ?>
{[ " type " : " select " , " label " : " <?php echo ( $dir == 'uscita') ? tr('Mittente') : tr('Destinatario'); ?> " , " name " : " idanagrafica " , " required " : 1 , " value " : " $idanagrafica $ " , " ajax-source " : " clienti_fornitori " ]}
</ div >
2021-02-11 15:05:29 +01:00
< ? php
echo '
< div class = " col-md-3 " > ' ;
if ( ! empty ( $record [ 'idreferente' ])) {
echo Plugins :: link ( 'Referenti' , $record [ 'idanagrafica' ], null , null , 'class="pull-right"' );
}
echo '
2023-01-13 09:35:27 +01:00
{[ " type " : " select " , " label " : " '.tr('Referente').' " , " name " : " idreferente " , " value " : " $idreferente $ " , " ajax-source " : " referenti " , " select-options " : { " idanagrafica " : '.$record[' idanagrafica '].' , " idsede_destinazione " : '.$record[' idsede_destinazione '].' } ]}
2021-02-11 15:05:29 +01:00
</ div > ' ;
2020-07-31 14:25:50 +02:00
2019-05-29 19:17:57 +02:00
// Conteggio numero articoli ddt in uscita
2019-06-04 20:45:40 +02:00
$articolo = $dbo -> fetchArray ( 'SELECT mg_articoli.id FROM ((mg_articoli INNER JOIN dt_righe_ddt ON mg_articoli.id=dt_righe_ddt.idarticolo) INNER JOIN dt_ddt ON dt_ddt.id=dt_righe_ddt.idddt) WHERE dt_ddt.id=' . prepare ( $id_record ));
2020-07-31 14:25:50 +02:00
$id_modulo_anagrafiche = Modules :: get ( 'Anagrafiche' )[ 'id' ];
$id_plugin_sedi = Plugins :: get ( 'Sedi' )[ 'id' ];
if ( $dir == 'entrata' ) {
echo '
< div class = " col-md-3 " >
{[ " type " : " select " , " label " : " '.tr('Partenza merce').' " , " name " : " idsede_partenza " , " ajax-source " : " sedi_azienda " , " value " : " $idsede_partenza $ " , " readonly " : " '.(sizeof( $articolo ) ? 1 : 0).' " , " help " : " '.tr( " Sedi di partenza dell 'azienda").' " ]}
</ div >
2017-08-04 16:28:16 +02:00
2020-07-31 14:25:50 +02:00
< div class = " col-md-3 " >
{[ " type " : " select " , " label " : " '.tr('Destinazione merce').' " , " name " : " idsede_destinazione " , " ajax-source " : " sedi " , " select-options " : { " idanagrafica " : '.$record[' idanagrafica '].' }, " value " : " $idsede_destinazione $ " , " help " : " '.tr('Sedi del destinatario').' " , " icon-after " : " add|'. $id_modulo_anagrafiche .'|id_plugin='. $id_plugin_sedi .'&id_parent='. $record['idanagrafica'] .'||'.(intval( $block_edit ) ? 'disabled' : '').' " ]}
</ div > ' ;
} else {
echo '
< div class = " col-md-3 " >
2020-08-11 08:10:06 +02:00
{[ " type " : " select " , " label " : " '.tr('Partenza merce').' " , " name " : " idsede_partenza " , " ajax-source " : " sedi " , " select-options " : { " idanagrafica " : '.$record[' idanagrafica '].' }, " value " : " $idsede_partenza $ " , " help " : " '.tr('Sedi del mittente').' " , " icon-after " : " add|'. $id_modulo_anagrafiche .'|id_plugin='. $id_plugin_sedi .'&id_parent='. $record['idanagrafica'] .'||'.(intval( $block_edit ) ? 'disabled' : '').' " ]}
2019-05-29 19:17:57 +02:00
</ div >
2020-07-31 14:25:50 +02:00
< div class = " col-md-3 " >
{[ " type " : " select " , " label " : " '.tr('Destinazione merce').' " , " name " : " idsede_destinazione " , " ajax-source " : " sedi_azienda " , " value " : " $idsede_destinazione $ " , " help " : " '.tr( " Sedi di arrivo dell 'azienda").' " ]}
</ div > ' ;
}
?>
</ div >
2019-05-29 19:17:57 +02:00
< hr >
2017-08-04 16:28:16 +02:00
< div class = " row " >
< div class = " col-md-3 " >
2020-08-11 08:10:06 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Aspetto beni'); ?> " , " name " : " idaspettobeni " , " value " : " $idaspettobeni $ " , " ajax-source " : " aspetto-beni " , " icon-after " : " add|<?php echo Modules::get('Aspetto beni')['id']; ?>|||<?php echo $block_edit ? 'disabled' : ''; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2021-03-31 15:25:14 +02:00
< ? php
if ( ! empty ( $record [ 'idcausalet' ])) {
echo Modules :: link ( 'Causali' , $record [ 'idcausalet' ], null , null , 'class="pull-right"' );
}
?>
2020-09-09 11:44:14 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Causale trasporto'); ?> " , " name " : " idcausalet " , " required " : 1 , " value " : " $idcausalet $ " , " ajax-source " : " causali " , " icon-after " : " add|<?php echo Modules::get('Causali')['id']; ?>|||<?php echo $block_edit ? 'disabled' : ''; ?> " , " help " : " <?php echo tr('Definisce la causale del trasporto'); ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2021-03-31 10:31:23 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Tipo di spedizione'); ?> " , " name " : " idspedizione " , " placeholder " : " - " , " values " : " query=SELECT id, descrizione, esterno FROM dt_spedizione ORDER BY descrizione ASC " , " value " : " $idspedizione $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2019-07-24 12:42:45 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Num. colli'); ?> " , " name " : " n_colli " , " value " : " $n_colli $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-3 " >
2019-07-24 12:42:45 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Pagamento'); ?> " , " name " : " idpagamento " , " ajax-source " : " pagamenti " , " value " : " $idpagamento $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
2019-08-29 19:00:05 +02:00
< div class = " col-md-3 " >
{[ " type " : " select " , " label " : " <?php echo tr('Porto'); ?> " , " name " : " idporto " , " placeholder " : " - " , " help " : " <?php echo tr('<ul><li>Franco: pagamento del trasporto a carico del mittente</li> <li>Assegnato: pagamento del trasporto a carico del destinatario</li> </ul>'); ?> " , " values " : " query=SELECT id, descrizione FROM dt_porto ORDER BY descrizione ASC " , " value " : " $idporto $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2020-11-06 10:46:42 +01:00
< ? php
if ( ! empty ( $record [ 'idvettore' ])) {
2020-10-30 13:15:36 +01:00
echo Modules :: link ( 'Anagrafiche' , $record [ 'idvettore' ], null , null , 'class="pull-right"' );
2020-11-06 10:46:42 +01:00
}
2021-03-31 10:31:23 +02:00
$esterno = $dbo -> selectOne ( 'dt_spedizione' , 'esterno' , [
'id' => $record [ 'idspedizione' ],
])[ 'esterno' ];
2020-10-30 13:15:36 +01:00
?>
2021-09-01 16:20:11 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Vettore'); ?> " , " name " : " idvettore " , " ajax-source " : " vettori " , " value " : " $idvettore $ " , " disabled " : < ? php echo empty ( $esterno ) || ( ! empty ( $esterno ) && ! empty ( $record [ 'idvettore' ])) ? 1 : 0 ; ?> , "required": <?php echo !empty($esterno) ?: 0; ?>, "icon-after": "add|<?php echo Modules::get('Anagrafiche')['id']; ?>|tipoanagrafica=Vettore&readonly_tipo=1|btn_idvettore|<?php echo ($esterno and (intval(!$record['flag_completato']) || empty($record['idvettore']))) ? '' : 'disabled'; ?>", "class": "<?php echo empty($record['idvettore']) ? 'unblockable' : ''; ?>" ]}
2017-08-04 16:28:16 +02:00
</ div >
2018-11-28 01:21:22 +01:00
2020-01-14 18:31:46 +01:00
< div class = " col-md-3 " >
2021-02-23 11:34:37 +01:00
{[ " type " : " timestamp " , " label " : " <?php echo tr('Data ora trasporto'); ?> " , " name " : " data_ora_trasporto " , " value " : " $data_ora_trasporto $ " , " help " : " <?php echo tr('Data e ora inizio del trasporto'); ?> " ]}
2020-01-14 18:31:46 +01:00
</ div >
2020-07-08 08:45:55 +02:00
2018-11-28 01:21:22 +01:00
< script >
2020-07-31 14:25:50 +02:00
$ ( " #idspedizione " ) . change ( function () {
2021-03-31 15:44:38 +02:00
if ( $ ( this ) . val ()){
if ( ! $ ( this ) . selectData () . esterno ) {
$ ( " #idvettore " ) . attr ( " required " , false );
input ( " idvettore " ) . disable ();
$ ( " label[for=idvettore] " ) . text ( " <?php echo tr('Vettore'); ?> " );
$ ( " #idvettore " ) . selectReset ( " <?php echo tr( " Seleziona un\ ' opzione " ); ?> " );
$ ( " .btn_idvettore " ) . prop ( " disabled " , true );
$ ( " .btn_idvettore " ) . addClass ( " disabled " );
} else {
$ ( " #idvettore " ) . attr ( " required " , true );
input ( " idvettore " ) . enable ();
$ ( " label[for=idvettore] " ) . text ( " <?php echo tr('Vettore'); ?>* " );
$ ( " .btn_idvettore " ) . prop ( " disabled " , false );
$ ( " .btn_idvettore " ) . removeClass ( " disabled " );
}
2021-03-31 15:50:49 +02:00
} else {
$ ( " #idvettore " ) . attr ( " required " , false );
input ( " idvettore " ) . disable ();
$ ( " label[for=idvettore] " ) . text ( " <?php echo tr('Vettore'); ?> " );
$ ( " #idvettore " ) . selectReset ( " <?php echo tr( " Seleziona un\ ' opzione " ); ?> " );
$ ( " .btn_idvettore " ) . prop ( " disabled " , true );
$ ( " .btn_idvettore " ) . addClass ( " disabled " );
2018-11-28 01:21:22 +01:00
}
});
2019-07-29 16:54:20 +02:00
2020-07-31 14:25:50 +02:00
$ ( " #idcausalet " ) . change ( function () {
2018-11-28 01:21:22 +01:00
if ( $ ( this ) . val () == 3 ) {
$ ( " #tipo_resa " ) . attr ( " disabled " , false );
} else {
$ ( " #tipo_resa " ) . attr ( " disabled " , true );
}
});
</ script >
2017-08-04 16:28:16 +02:00
</ div >
2020-07-08 08:45:55 +02:00
< ? php
if ( $dir == 'entrata' ) {
echo '
< div class = " row " >
< div class = " col-md-3 " >
2021-01-12 17:40:04 +01:00
{[ " type " : " number " , " label " : " '.tr('Peso').' " , " name " : " peso " , " value " : " $peso $ " , " readonly " : " '.intval(empty( $record['peso_manuale'] )).' " , " help " : " '.tr('Il valore del campo Peso viene calcolato in automatico sulla base degli articoli inseriti nel documento, a meno dell \ 'impostazione di un valore manuale in questo punto').' " ]}
< input type = " hidden " id = " peso_calcolato " name = " peso_calcolato " value = " '. $ddt->peso_calcolato .' " >
2020-07-08 08:45:55 +02:00
</ div >
< div class = " col-md-3 " >
2021-01-12 17:40:04 +01:00
{[ " type " : " checkbox " , " label " : " '.tr('Modifica peso').' " , " name " : " peso_manuale " , " value " : " $peso_manuale $ " , " help " : " '.tr('Seleziona per modificare manualmente il campo Peso').' " , " placeholder " : " '.tr('Modifica peso').' " ]}
2020-07-08 08:45:55 +02:00
</ div >
< div class = " col-md-3 " >
2021-01-12 17:40:04 +01:00
{[ " type " : " number " , " label " : " '.tr('Volume').' " , " name " : " volume " , " value " : " $volume $ " , " readonly " : " '.intval(empty( $record['volume_manuale'] )).' " , " help " : " '.tr('Il valore del campo volume viene calcolato in automatico sulla base degli articoli inseriti nel documento, a meno dell \ 'impostazione di un valore manuale in questo punto').' " ]}
< input type = " hidden " id = " volume_calcolato " name = " volume_calcolato " value = " '. $ddt->volume_calcolato .' " >
2020-07-08 08:45:55 +02:00
</ div >
< div class = " col-md-3 " >
2021-01-12 17:40:04 +01:00
{[ " type " : " checkbox " , " label " : " '.tr('Modifica volume').' " , " name " : " volume_manuale " , " value " : " $volume_manuale $ " , " help " : " '.tr('Seleziona per modificare manualmente il campo volume').' " , " placeholder " : " '.tr('Modifica volume').' " ]}
2020-07-08 08:45:55 +02:00
</ div >
2021-04-07 09:33:55 +02:00
</ div >
< div class = " row " >
< div class = " col-md-3 " >
2022-01-15 17:30:49 +01:00
{[ " type " : " number " , " label " : " '.('Sconto in fattura').' " , " name " : " sconto_finale " , " value " : " '.( $ddt->sconto_finale_percentuale ?: $ddt->sconto_finale ).' " , " icon-after " : " choice|untprc|'.(empty( $ddt->sconto_finale ) ? 'PRC' : 'UNT').' " , " help " : " '.tr('Sconto in fattura, utilizzabile per applicare sconti sul netto a pagare del documento').'. " ]}
2021-04-07 09:33:55 +02:00
</ div >
2020-07-08 08:45:55 +02:00
</ div > ' ;
}
?>
2017-08-04 16:28:16 +02:00
< div class = " row " >
< div class = " col-md-12 " >
2019-07-24 12:42:45 +02:00
{[ " type " : " textarea " , " label " : " <?php echo tr('Note'); ?> " , " name " : " note " , " value " : " $note $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
2018-07-08 18:11:17 +02:00
2018-05-22 14:41:42 +02:00
< div class = " row " >
< div class = " col-md-12 " >
{[ " type " : " textarea " , " label " : " <?php echo tr('Note aggiuntive'); ?> " , " name " : " note_aggiuntive " , " help " : " <?php echo tr('Note interne.'); ?> " , " value " : " $note_aggiuntive $ " ]}
</ div >
</ div >
2017-08-04 16:28:16 +02:00
</ 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 = '' ;
2022-07-03 15:19:20 +02:00
} else {
$collapsed = ' collapsed-box' ;
2019-10-14 19:13:11 +02:00
}
?>
2019-07-22 16:13:38 +02:00
2019-10-14 19:13:11 +02:00
<!-- Fatturazione Elettronica PA -->
2022-07-03 15:19:20 +02:00
< div class = " box box-primary collapsable <?php echo ( $record['tipo_anagrafica'] == 'Ente pubblico' || $record['tipo_anagrafica'] == 'Azienda') ? 'show' : 'hide'; ?> <?php echo $collapsed ; ?> " >
< div class = " box-header " >
< h4 class = " box-title " >
< ? php echo tr ( 'Dati appalto' ); ?> </h4>
< 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 " >
< 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 >
2019-07-22 16:13:38 +02:00
</ div >
2022-07-03 15:19:20 +02:00
< 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 ]}
2019-07-22 16:13:38 +02:00
</ div >
</ div >
</ div >
</ div >
</ form >
2017-08-04 16:28:16 +02:00
<!-- RIGHE -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2017-09-04 12:02:29 +02:00
< h3 class = " panel-title " >< ? php echo tr ( 'Righe' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " >
< div class = " pull-left " >
< ? php
2019-07-24 12:42:45 +02:00
if ( ! $block_edit ) {
2020-04-27 11:55:07 +02:00
// Lettura ordini (cliente o fornitore)
$ordini_query = 'SELECT COUNT(*) AS tot FROM or_ordini WHERE idanagrafica=' . prepare ( $record [ 'idanagrafica' ]) . ' AND idstatoordine IN (SELECT id FROM or_statiordine WHERE descrizione IN(\'Accettato\', \'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\')) AND idtipoordine=(SELECT id FROM or_tipiordine WHERE dir=' . prepare ( $dir ) . ') AND or_ordini.id IN (SELECT idordine FROM or_righe_ordini WHERE or_righe_ordini.idordine = or_ordini.id AND (qta - qta_evasa) > 0)' ;
2018-06-25 11:44:06 +02:00
$ordini = $dbo -> fetchArray ( $ordini_query )[ 0 ][ 'tot' ];
2020-04-27 12:26:27 +02:00
2021-07-28 10:15:46 +02:00
$ddt_query = 'SELECT COUNT(*) AS tot FROM dt_ddt WHERE idstatoddt IN (SELECT id FROM dt_statiddt WHERE descrizione IN(\'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\')) AND idtipoddt=(SELECT id FROM or_tipiordine WHERE dir="' . ( $dir == 'entrata' ? 'uscita' : 'entrata' ) . '") AND dt_ddt.id IN (SELECT idddt FROM dt_righe_ddt WHERE dt_righe_ddt.idddt = dt_ddt.id AND (qta - qta_evasa) > 0)' ;
$ddt = $dbo -> fetchArray ( $ddt_query )[ 0 ][ 'tot' ];
echo '
< a class = " btn btn-sm btn-primary'.(!empty( $ddt ) ? '' : ' disabled').' " data - href = " '.base_path().'/modules/ddt/add_ddt.php?id_module='. $id_module .'&id_record='. $id_record .' " data - toggle = " modal " data - title = " '.tr('Aggiungi DDT').' " >
< i class = " fa fa-plus " ></ i > '.tr(' Ddt ').'
</ a > ' ;
2021-02-18 18:48:44 +01:00
2018-06-25 11:44:06 +02:00
echo '
2021-03-10 12:20:04 +01:00
< a class = " btn btn-sm btn-primary'.(!empty( $ordini ) ? '' : ' disabled').' " data - href = " '.base_path().'/modules/ddt/add_ordine.php?id_module='. $id_module .'&id_record='. $id_record .' " data - toggle = " modal " data - title = " '.tr('Aggiungi Ordine').' " >
2018-06-25 11:44:06 +02:00
< i class = " fa fa-plus " ></ i > '.tr(' Ordine ').'
2019-03-29 12:46:17 +01:00
</ a > ' ;
2021-10-29 11:56:39 +02:00
// Lettura articoli
$art_query = 'SELECT id FROM mg_articoli WHERE attivo = 1 AND deleted_at IS NULL' ;
if ( $dir == 'entrata' && ! setting ( 'Permetti selezione articoli con quantità minore o uguale a zero in Documenti di Vendita' )) {
$art_query .= ' AND (qta > 0 OR servizio = 1)' ;
} else {
//Gli articoli possono essere creati al volo direttamente dal modale di aggiunta articolo
$art_query .= ' OR 1=1' ;
}
$articoli = $dbo -> fetchNum ( $art_query );
2019-03-29 12:46:17 +01:00
echo '
2021-10-29 11:56:39 +02:00
< button type = " button " class = " btn btn-sm btn-primary tip'.(!empty( $articoli ) ? '' : ' disabled').' " 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 > ' ;
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 > ' ;
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-09-14 10:49:23 +02:00
echo '
2017-08-04 16:28:16 +02:00
</ div >
< div class = " clearfix " ></ div >
< br >
< div class = " row " >
2020-09-14 10:49:23 +02:00
< div class = " col-md-12 " id = " righe " ></ div >
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
2018-09-28 16:17:10 +02: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-15 18:41:59 +01:00
2017-08-04 16:28:16 +02:00
< script >
2020-08-03 12:08:52 +02:00
function gestioneArticolo ( button ) {
gestioneRiga ( button , " is_articolo " );
}
function gestioneBarcode ( button ) {
gestioneRiga ( button , " is_barcode " );
}
2020-07-31 14:25:50 +02:00
2020-08-03 12:08:52 +02:00
function gestioneSconto ( button ) {
gestioneRiga ( button , " is_sconto " );
}
function gestioneDescrizione ( button ) {
gestioneRiga ( button , " is_descrizione " );
}
async function gestioneRiga ( button , options ) {
// Salvataggio via AJAX
2021-03-29 18:31:23 +02:00
await salvaForm ( " #edit-form " , {}, button );
// Lettura titolo e chiusura tooltip
let title = $ ( button ) . tooltipster ( " content " );
$ ( button ) . tooltipster ( " close " )
2020-08-03 12:08:52 +02:00
// Apertura modal
2021-03-29 18:31:23 +02:00
options = options ? options : " is_riga " ;
openModal ( title , " '. $structure->fileurl ('row-add.php').'?id_module='. $id_module .'&id_record='. $id_record .'& " + options );
2020-08-03 12:08:52 +02:00
}
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 () {
2021-01-12 17:40:04 +01:00
if ( ! $ ( " #peso_manuale " ) . is ( " :checked " )){
input ( " peso " ) . set ( $ ( " #peso_calcolato " ) . val ());
}
$ ( " #peso_manuale " ) . click ( function () {
$ ( " #peso " ) . prop ( " readonly " , ! $ ( " #peso_manuale " ) . is ( " :checked " ));
if ( ! $ ( " #peso_manuale " ) . is ( " :checked " )){
input ( " peso " ) . set ( $ ( " #peso_calcolato " ) . val ());
}
});
if ( ! $ ( " #volume_manuale " ) . is ( " :checked " )){
input ( " volume " ) . set ( $ ( " #volume_calcolato " ) . val ());
}
$ ( " #volume_manuale " ) . click ( function () {
$ ( " #volume " ) . prop ( " readonly " , ! $ ( " #volume_manuale " ) . is ( " :checked " ));
if ( ! $ ( " #volume_manuale " ) . is ( " :checked " )){
input ( " volume " ) . set ( $ ( " #volume_calcolato " ) . val ());
}
});
2020-09-14 10:49:23 +02:00
caricaRighe ();
});
2020-08-03 12:08:52 +02:00
$ ( " #idanagrafica " ) . change ( function () {
updateSelectOption ( " idanagrafica " , $ ( this ) . val ());
session_set ( " superselect,idanagrafica " , $ ( this ) . val (), 0 );
$ ( " #idsede_'.( $dir == 'uscita' ? 'partenza' : 'destinazione').' " ) . selectReset ();
2022-07-07 17:28:18 +02:00
$ ( " #idpagamento " ) . selectReset ();
let data = $ ( this ) . selectData ();
if ( data ) {
// Impostazione del tipo di pagamento da anagrafica
if ( data . id_pagamento ) {
input ( " idpagamento " ) . getElement ()
. selectSetNew ( data . id_pagamento , data . desc_pagamento );
}
}
2020-08-03 12:08:52 +02:00
});
</ script > ' ;
2017-08-04 16:28:16 +02:00
2018-09-05 10:05:23 +02:00
// Collegamenti diretti
// Fatture collegate a questo ddt
$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 `idddt` = ' . prepare ( $id_record ) . ') ORDER BY `data`' );
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 > ' ;
foreach ( $elementi as $fattura ) {
2017-09-14 10:27:49 +02:00
$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 > ' ;
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
?>
2019-06-20 16:44:45 +02:00
< ? php
// Eliminazione ddt solo se ho accesso alla sede aziendale
2019-06-29 11:01:26 +02:00
$field_name = ( $dir == 'entrata' ) ? 'idsede_partenza' : 'idsede_destinazione' ;
if ( in_array ( $record [ $field_name ], $user -> sedi )) {
?>
2019-06-20 16:44:45 +02:00
< a class = " btn btn-danger ask " data - backto = " record-list " >
< i class = " fa fa-trash " ></ i > < ? php echo tr ( 'Elimina' ); ?>
</ a >
< ? php
}
2023-01-13 09:35:27 +01:00
echo '
< script >
$ ( " #idsede_destinazione " ) . change ( function (){
updateSelectOption ( " idsede_destinazione " , $ ( this ) . val ());
$ ( " #idreferente " ) . selectReset ();
});
</ script > ' ;