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
2024-03-05 16:01:45 +01:00
use Models\Module ;
use Models\Plugin ;
2024-03-22 15:52:24 +01:00
use Modules\Anagrafiche\Anagrafica ;
use Modules\Anagrafiche\Sede ;
2024-03-28 12:10:13 +01:00
use Modules\DDT\Stato ;
2023-09-25 16:54:36 +02:00
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' ];
2024-05-03 12:15:09 +02:00
$id_segment = $record [ 'id_segment' ];
2023-08-04 14:54:28 +02:00
if ( $dir == 'entrata' ) {
2024-04-11 16:24:29 +02:00
$numero_previsto = verifica_numero_ddt ( $ddt , $id_segment );
2022-10-27 11:04:10 +02:00
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 " , [
2024-03-26 17:22:40 +01:00
'_TYPE_' => $module_name ,
2024-03-22 15:52:24 +01:00
'_DATE_' => dateFormat ( $ddt -> data ),
'_NUM_' => '"' . $numero_previsto . '"' ,
]) . ' .</ b >
2022-10-27 11:04:10 +02:00
</ div > ' ;
}
2023-09-25 16:54:36 +02:00
$rs2 = $dbo -> fetchArray ( 'SELECT piva, codice_fiscale, citta, indirizzo, cap, provincia FROM an_anagrafiche WHERE idanagrafica=' . prepare ( $record [ 'idanagrafica' ]));
$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 />
'.Modules::link(' Anagrafiche ', $record[' idanagrafica '], tr(' Vai alla scheda anagrafica '), null).' </ div > ' ;
}
2022-02-21 18:49:31 +01:00
}
2024-02-23 14:40:08 +01:00
$righe = $ddt -> getRighe ();
$righe_vuote = false ;
foreach ( $righe as $riga ) {
if ( $riga -> qta == 0 ) {
$righe_vuote = true ;
}
}
if ( $righe_vuote ) {
2024-03-22 15:52:24 +01:00
echo '
2024-02-23 14:40:08 +01:00
< div class = " alert alert-warning " id = " righe-vuote " >
2024-03-22 15:52:24 +01:00
< i class = " fa fa-warning " ></ i > '.tr(' Nel ddt sono presenti delle righe con quantità a 0. ').' </ b >
2024-02-23 14:40:08 +01:00
</ div > ' ;
}
2024-05-23 13:04:47 +02:00
$sede_anagrafica = $ddt -> anagrafica -> sedeLegale ;
$id_sede_anagrafica = $dir == 'entrata' ? $ddt -> idsede_destinazione : $ddt -> idsede_partenza ;
if ( ! empty ( $id_sede_anagrafica )) {
$sede_anagrafica = Sede :: find ( $id_sede_anagrafica );
}
$anagrafica_azienda = Anagrafica :: find ( setting ( 'Azienda predefinita' ));
$sede_azienda = $anagrafica_azienda -> sedeLegale ;
$id_sede_azienda = $dir == 'entrata' ? $ddt -> idsede_partenza : $ddt -> idsede_destinazione ;
if ( ! empty ( $id_sede_azienda )) {
$sede_azienda = Sede :: find ( $id_sede_azienda );
}
2024-05-24 09:17:38 +02:00
echo '
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 " >
2024-05-23 13:04:47 +02:00
< input type = " hidden " name = " id_record " value = " '. $id_record .' " >
2017-08-04 16:28:16 +02:00
2023-09-25 16:54:36 +02:00
< div class = " row " >
2024-05-23 13:04:47 +02:00
< div class = " col-md-2 offset-md-10 " > ' ;
2024-05-24 09:17:38 +02:00
if ( setting ( 'Cambia automaticamente stato ddt fatturati' )) {
2024-06-11 16:58:27 +02:00
$id_stato_fatt = Stato :: where ( 'name' , 'Fatturato' ) -> first () -> id ;
$id_stato_parz_fatt = Stato :: where ( 'name' , 'Parzialmente fatturato' ) -> first () -> id ;
2024-03-28 12:10:13 +01:00
2024-06-28 11:46:25 +02:00
if ( $ddt -> stato -> id == $id_stato_fatt || $ddt -> stato -> id == $id_stato_parz_fatt ) {
2024-05-24 09:17:38 +02:00
echo '
2024-05-23 13:04:47 +02:00
{[ " type " : " select " , " label " : " '.tr('Stato').' " , " name " : " idstatoddt " , " required " : 1 , " values " : " query=SELECT `dt_statiddt`.*, `dt_statiddt_lang`.`title` as descrizione, `colore` AS _bgcolor_ FROM `dt_statiddt` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang`= '.prepare(Models \ Locale::getDefault()->id).') ORDER BY `title` " , " value " : " $idstatoddt $ " , " extra " : " readonly " , " class " : " unblockable " ]} ' ;
2024-01-15 15:30:45 +01:00
} else {
2024-06-11 16:58:27 +02:00
$id_stato_bozza = Stato :: where ( 'name' , 'Bozza' ) -> first () -> id ;
$id_stato_evaso = Stato :: where ( 'name' , 'Evaso' ) -> first () -> id ;
$id_stato_parz_evaso = Stato :: where ( 'name' , 'Parzialmente evaso' ) -> first () -> id ;
2024-05-24 09:17:38 +02:00
echo '
{[ " type " : " select " , " label " : " '.tr('Stato').' " , " name " : " idstatoddt " , " required " : 1 , " values " : " query=SELECT `dt_statiddt`.*, `dt_statiddt_lang`.`title` as descrizione, `colore` AS _bgcolor_ FROM `dt_statiddt` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang`= '.prepare(Models \ Locale::getDefault()->id).') WHERE `dt_statiddt`.`id` IN ('.implode(',', [ $id_stato_bozza , $id_stato_evaso , $id_stato_parz_evaso ]).') ORDER BY `title` " , " value " : " $idstatoddt $ " , " class " : " unblockable " ]} ' ;
2024-01-15 15:30:45 +01:00
}
2024-05-24 09:17:38 +02:00
} else {
echo '
{[ " type " : " select " , " label " : " '.tr('Stato').' " , " name " : " idstatoddt " , " required " : 1 , " values " : " query=SELECT `dt_statiddt`.*, `colore` AS _bgcolor_, `dt_statiddt_lang`.`title` as descrizione FROM `dt_statiddt` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang`= '.prepare(Models \ Locale::getDefault()->id).') ORDER BY `title` " , " value " : " $idstatoddt $ " , " class " : " unblockable " ]} ' ;
}
2024-05-23 13:04:47 +02:00
2024-05-24 09:17:38 +02:00
echo '
2024-05-23 13:04:47 +02:00
</ div >
</ div >
<!-- DATI INTESTAZIONE -->
2024-08-27 14:12:30 +02:00
< div class = " card card-primary collapsable " >
2024-05-23 13:04:47 +02:00
< div class = " card-header with-border " >
2024-10-24 16:19:13 +02:00
< h3 class = " card-title " > '.($dir == ' entrata ' ? tr(' Dati destinatario ') : tr(' Dati mittente ')).' </ h3 >
2024-05-23 13:04:47 +02:00
< div class = " card-tools pull-right " >
2024-05-23 17:51:21 +02:00
< button type = " button " class = " btn btn-tool " data - card - widget = " collapse " >
2024-08-27 14:12:30 +02:00
< i class = " fa fa-minus " ></ i >
2024-05-23 13:04:47 +02:00
</ button >
</ div >
</ div >
2024-10-24 16:16:11 +02:00
2024-05-23 13:04:47 +02:00
< div class = " card-body " >
2024-10-24 16:16:11 +02:00
<!-- RIGA 1 -->
< div class = " row " >
< div class = " col-md-3 " >
'.Modules::link(' Anagrafiche ', $record[' idanagrafica '], null, null, ' class = " pull-right " ').'
{[ " type " : " select " , " label " : " '.( $dir == 'uscita' ? tr('Mittente') : tr('Destinatario')).' " , " name " : " idanagrafica " , " required " : 1 , " value " : " $idanagrafica $ " , " ajax-source " : " clienti_fornitori " ]}
</ div > ' ;
2024-05-24 09:17:38 +02:00
if ( $dir == 'entrata' ) {
2024-10-24 16:16:11 +02:00
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 > ' ;
2024-05-24 09:17:38 +02:00
}
echo '
2024-10-24 16:16:11 +02:00
< div class = " col-md-3 " > ' ;
2024-05-24 09:17:38 +02:00
if ( ! empty ( $record [ 'idreferente' ])) {
2024-10-24 16:16:11 +02:00
echo Plugins :: link ( 'Referenti' , $record [ 'idanagrafica' ], null , null , 'class="pull-right"' );
2024-05-24 09:17:38 +02:00
}
echo '
2024-10-24 16:16:11 +02:00
{[ " type " : " select " , " label " : " '.tr('Referente').' " , " name " : " idreferente " , " value " : " $idreferente $ " , " ajax-source " : " referenti " , " select-options " : { " idanagrafica " : '.$record[' idanagrafica '].' , " idsede_destinazione " : '.$record[' idsede_destinazione '].' } ]}
2024-05-23 13:04:47 +02:00
</ div >
</ div >
</ div >
</ div > ' ;
?>
< div class = " row " >
< div class = " col-md-12 " >
<!-- INTESTAZIONE -->
< div class = " card card-primary " >
< div class = " card-header " >
< h3 class = " card-title " >< ? php echo tr ( 'Intestazione' ); ?> </h3>
</ div >
2017-08-04 16:28:16 +02:00
2024-05-23 13:04:47 +02:00
< div class = " card-body " >
2023-09-25 16:54:36 +02:00
< div class = " row " >
2024-05-23 13:04:47 +02:00
< ? php
if ( $dir == 'uscita' ) {
echo '
< div class = " col-md-2 " >
{[ " type " : " span " , " label " : " '.tr('Numero ddt').' " , " class " : " text-center " , " value " : " $numero $ " ]}
2023-09-25 16:54:36 +02:00
</ div > ' ;
2024-05-23 13:04:47 +02:00
}
?>
< div class = " col-md-2 " >
{[ " type " : " text " , " label " : " <?php echo tr('Numero secondario'); ?> " , " name " : " numero_esterno " , " class " : " text-center " , " value " : " $numero_esterno $ " ]}
</ div >
< div class = " col-md-2 " >
{[ " type " : " date " , " label " : " <?php echo tr('Data'); ?> " , " name " : " data " , " required " : 1 , " value " : " $data $ " ]}
</ div >
2024-05-24 09:17:38 +02:00
< ? php
2023-09-25 16:54:36 +02:00
2024-01-15 15:30:45 +01:00
// Conteggio numero articoli ddt in uscita
2024-02-29 15:10:55 +01: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 ));
2024-06-11 16:58:27 +02:00
$id_modulo_anagrafiche = Module :: where ( 'name' , 'Anagrafiche' ) -> first () -> id ;
$id_plugin_sedi = Plugin :: where ( 'name' , 'Sedi' ) -> first () -> id ;
2024-01-15 15:30:45 +01:00
if ( $dir == 'entrata' ) {
echo '
2024-05-23 13:04:47 +02:00
< div class = " col-md-4 " >
2024-10-16 10:06:39 +02:00
{[ " type " : " select " , " label " : " '.tr('Partenza merce').' " , " name " : " idsede_partenza " , " ajax-source " : " sedi_azienda " , " value " : " $idsede_partenza $ " , " select-options " : '.json_encode([' idsede_partenza ' => $record[' idsede_partenza ']]).' , " help " : " '.tr( " Sedi di partenza dell 'azienda").' " ]}
2023-09-25 16:54:36 +02:00
</ div >
2024-05-23 13:04:47 +02:00
< div class = " col-md-4 " >
2023-09-25 16:54:36 +02:00
{[ " 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 > ' ;
2024-01-15 15:30:45 +01:00
} else {
echo '
2024-05-23 16:05:30 +02:00
< div class = " col-md-3 " >
2023-09-25 16:54:36 +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' : '').' " ]}
</ div >
2024-05-23 16:05:30 +02:00
< div class = " col-md-3 " >
2023-09-25 16:54:36 +02:00
{[ " type " : " select " , " label " : " '.tr('Destinazione merce').' " , " name " : " idsede_destinazione " , " ajax-source " : " sedi_azienda " , " value " : " $idsede_destinazione $ " , " help " : " '.tr( " Sedi di arrivo dell 'azienda").' " ]}
</ div > ' ;
2024-01-15 15:30:45 +01:00
}
?>
2023-09-25 16:54:36 +02:00
</ div >
2024-05-23 13:04:47 +02:00
< div class = " row " >
< div class = " col-md-3 " >
{[ " type " : " select " , " label " : " <?php echo tr('Pagamento'); ?> " , " name " : " idpagamento " , " ajax-source " : " pagamenti " , " value " : " $idpagamento $ " ]}
</ div >
< div class = " col-md-2 " >
{[ " 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').'. " ]}
</ div >
</ div >
2023-09-25 16:54:36 +02:00
</ div >
</ div >
</ div >
</ div >
<!-- DATI DDT -->
2024-05-16 18:02:50 +02:00
< div class = " card card-primary " >
2024-05-17 12:11:00 +02:00
< div class = " card-header " >
2024-05-16 18:02:50 +02:00
< h3 class = " card-title " >< ? php echo tr ( 'Dati ddt' ); ?> </h3>
2023-09-25 16:54:36 +02:00
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2017-08-04 16:28:16 +02:00
< div class = " row " >
< div class = " col-md-3 " >
2024-06-11 16:58:27 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Aspetto beni'); ?> " , " name " : " idaspettobeni " , " value " : " $idaspettobeni $ " , " ajax-source " : " aspetto-beni " , " icon-after " : " add|<?php echo Module::where('name', 'Aspetto beni')->first()->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
2024-01-15 15:30:45 +01:00
if ( ! empty ( $record [ 'idcausalet' ])) {
echo Modules :: link ( 'Causali' , $record [ 'idcausalet' ], null , null , 'class="pull-right"' );
}
?>
2024-06-11 16:58:27 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Causale trasporto'); ?> " , " name " : " idcausalet " , " required " : 1 , " value " : " $idcausalet $ " , " ajax-source " : " causali " , " icon-after " : " add|<?php echo Module::where('name', 'Causali')->first()->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 " >
2024-04-18 17:44:05 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Tipo di spedizione'); ?> " , " name " : " idspedizione " , " placeholder " : " - " , " values " : " query=SELECT `dt_spedizione`.`id`, `dt_spedizione_lang`.`title` as `descrizione`, `esterno` FROM `dt_spedizione` LEFT JOIN `dt_spedizione_lang` ON (`dt_spedizione_lang`.`id_record` = `dt_spedizione`.`id` AND `dt_spedizione_lang`.`id_lang` = <?php echo prepare(Models \ Locale::getDefault()->id); ?>) ORDER BY `title` 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 " >
2019-08-29 19:00:05 +02:00
< div class = " col-md-3 " >
2024-04-18 17:44:05 +02:00
{[ " 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 `dt_porto`.`id`, `dt_porto_lang`.`title` as descrizione FROM `dt_porto` LEFT JOIN `dt_porto_lang` ON (`dt_porto`.`id` = `dt_porto_lang`.`id_record` AND `dt_porto_lang`.`id_lang` = <?php echo prepare(Models \ Locale::getDefault()->id); ?>) ORDER BY `title` 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
2024-01-15 15:30:45 +01:00
if ( ! empty ( $record [ 'idvettore' ])) {
echo Modules :: link ( 'Anagrafiche' , $record [ 'idvettore' ], null , null , 'class="pull-right"' );
}
2024-01-31 14:23:46 +01:00
$esterno = $dbo -> selectOne ( 'dt_spedizione' , 'esterno' , [
'id' => $record [ 'idspedizione' ],
])[ 'esterno' ];
2024-01-15 15:30:45 +01:00
?>
2024-11-08 16:30:19 +01: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 Module::where('name', 'Anagrafiche')->first()->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 '
2024-05-23 13:04:47 +02:00
< div class = " row " >
< div class = " col-md-3 " >
2024-08-09 13:04:24 +02: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').' " , " icon-after " : " KG " ]}
2024-07-25 12:40:22 +02:00
< input type = " hidden " id = " peso_calcolato " name = " peso_calcolato " value = " '. $ddt->peso_calcolato .' " , " decimals " : " qta " >
2024-05-23 13:04:47 +02:00
</ div >
2020-07-08 08:45:55 +02:00
2024-05-23 13:04:47 +02:00
< div class = " col-md-3 " >
{[ " 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').' " ]}
</ div >
2020-07-08 08:45:55 +02:00
2024-05-23 13:04:47 +02:00
< div class = " col-md-3 " >
{[ " 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').' " ]}
2024-07-25 12:40:22 +02:00
< input type = " hidden " id = " volume_calcolato " name = " volume_calcolato " value = " '. $ddt->volume_calcolato .' " , " decimals " : " qta " >
2024-05-23 13:04:47 +02:00
</ div >
2021-04-07 09:33:55 +02:00
2024-05-23 13:04:47 +02:00
< div class = " col-md-3 " >
{[ " 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').' " ]}
</ div >
</ div > ' ;
2020-07-08 08:45:55 +02:00
}
?>
2017-08-04 16:28:16 +02:00
< div class = " row " >
2023-04-13 17:28:41 +02:00
< div class = " col-md-6 " >
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 >
2023-04-13 17:28:41 +02:00
< div class = " col-md-6 " >
2018-05-22 14:41:42 +02:00
{[ " 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
2023-09-25 16:54:36 +02:00
if ( ! empty ( $record [ 'id_documento_fe' ]) || ! empty ( $record [ 'num_item' ]) || ! empty ( $record [ 'codice_cig' ]) || ! empty ( $record [ 'codice_cup' ])) {
$collapsed = '' ;
} else {
2024-05-16 18:02:50 +02:00
$collapsed = ' collapsed-card' ;
2023-09-25 16:54:36 +02:00
}
2024-01-15 15:30:45 +01: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
2024-05-16 18:02:50 +02:00
< div class = " card card-primary collapsable <?php echo ( $record['tipo_anagrafica'] == 'Ente pubblico' || $record['tipo_anagrafica'] == 'Azienda') ? 'show' : 'hide'; ?> <?php echo $collapsed ; ?> " >
< div class = " card-header " >
< h4 class = " card-title " >
2022-07-03 15:19:20 +02:00
< ? php echo tr ( 'Dati appalto' ); ?> </h4>
2024-05-16 18:02:50 +02:00
< div class = " card-tools pull-right " >
2024-05-23 17:51:21 +02:00
< button type = " button " class = " btn btn-tool " data - card - widget = " collapse " >
2022-07-03 15:19:20 +02:00
< i class = " fa fa-plus " ></ i >
</ button >
</ div >
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2022-07-03 15:19:20 +02:00
< div class = " row " >
2024-05-23 13:04:47 +02:00
< div class = " col-md-3 " >
2022-07-03 15:19:20 +02:00
{[ " 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 >
2024-05-23 13:04:47 +02:00
< div class = " col-md-3 " >
2022-07-03 15:19:20 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Numero Riga'); ?> " , " name " : " num_item " , " required " : 0 , " value " : " $num_item $ " , " maxlength " : 15 ]}
</ div >
2024-05-23 13:04:47 +02:00
< div class = " col-md-3 " >
2022-07-03 15:19:20 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Codice CIG'); ?> " , " name " : " codice_cig " , " required " : 0 , " value " : " $codice_cig $ " , " maxlength " : 15 ]}
</ div >
2024-05-23 13:04:47 +02:00
< div class = " col-md-3 " >
2022-07-03 15:19:20 +02:00
{[ " 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 -->
2024-05-16 18:02:50 +02:00
< div class = " card card-primary " >
2024-05-17 12:11:00 +02:00
< div class = " card-header " >
2024-05-16 18:02:50 +02:00
< h3 class = " card-title " >< ? php echo tr ( 'Righe' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2017-08-04 16:28:16 +02:00
< ? 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)
2024-03-01 11:32:13 +01:00
$ordini_query = ' SELECT
COUNT ( * ) AS tot
FROM
`or_ordini`
INNER JOIN `or_righe_ordini` ON `or_ordini` . `id` = `or_righe_ordini` . `idordine`
INNER JOIN `or_statiordine` ON `or_ordini` . `idstatoordine` = `or_statiordine` . `id`
2024-04-02 16:28:55 +02:00
INNER JOIN `or_tipiordine` ON `or_ordini` . `idtipoordine` = `or_tipiordine` . `id`
2024-03-22 15:52:24 +01:00
LEFT JOIN `or_statiordine_lang` ON ( `or_statiordine` . `id` = `or_statiordine_lang` . `id_record` AND `or_statiordine_lang` . `id_lang` = '.prepare(Models\Locale::getDefault()->id).' )
2024-03-01 11:32:13 +01:00
WHERE
`idanagrafica` = '.prepare($record[' idanagrafica ']).'
2024-04-18 17:44:05 +02:00
AND `or_statiordine_lang` . `title` IN ( \ ' Accettato\ ' , \ ' Evaso\ ' , \ ' Parzialmente evaso\ ' , \ ' Parzialmente fatturato\ ' )
2024-04-02 16:12:14 +02:00
AND `or_tipiordine` . `dir` = '.prepare($dir).'
AND ( `or_righe_ordini` . `qta` - `or_righe_ordini` . `qta_evasa` ) > 0
GROUP BY
`or_ordini` . `id` ' ;
2023-02-24 18:06:37 +01:00
$tot_ordini = $dbo -> fetchArray ( $ordini_query )[ 0 ][ 'tot' ];
2020-04-27 12:26:27 +02:00
2024-02-27 15:51:13 +01:00
$ddt_query = ' SELECT
COUNT ( * ) AS tot
FROM
`dt_ddt`
INNER JOIN `dt_statiddt` ON `dt_ddt` . `idstatoddt` = `dt_statiddt` . `id`
2024-03-22 15:52:24 +01:00
LEFT JOIN `dt_statiddt_lang` ON ( `dt_statiddt_lang` . `id_record` = `dt_statiddt` . `id` AND `dt_statiddt_lang` . `id_lang` = '.prepare(Models\Locale::getDefault()->id).' )
2024-02-27 15:51:13 +01:00
INNER JOIN `dt_tipiddt` ON `dt_ddt` . `idtipoddt` = `dt_tipiddt` . `id`
INNER JOIN `dt_righe_ddt` ON `dt_righe_ddt` . `idddt` = `dt_ddt` . `id`
WHERE
2024-04-18 17:44:05 +02:00
`title` IN ( " Evaso " , " Parzialmente evaso " , " Parzialmente fatturato " ) AND
2024-04-02 16:12:14 +02:00
`dt_tipiddt` . `dir` = " '.( $dir == 'entrata' ? 'uscita' : 'entrata').' " AND
2024-03-01 11:32:13 +01:00
( `dt_righe_ddt` . `qta` - `dt_righe_ddt` . `qta_evasa` ) > 0
2024-04-02 16:12:14 +02:00
GROUP BY
`dt_ddt` . `id` ' ;
2023-02-24 18:06:37 +01:00
$tot_ddt = $dbo -> fetchArray ( $ddt_query )[ 0 ][ 'tot' ];
2021-02-18 18:48:44 +01:00
2023-02-17 10:59:50 +01:00
// Form di inserimento riga documento
2018-06-25 11:44:06 +02:00
echo '
2023-02-17 10:59:50 +01:00
< form id = " link_form " action = " " method = " post " >
< input type = " hidden " name = " op " value = " add_articolo " >
< input type = " hidden " name = " backto " value = " record-edit " >
2021-10-29 11:56:39 +02:00
2023-02-17 10:59:50 +01:00
< div class = " row " >
2023-05-24 17:15:29 +02:00
< div class = " col-md-3 " >
2023-02-17 10:59:50 +01:00
{[ " type " : " text " , " label " : " '.tr('Aggiungi un articolo tramite barcode').' " , " name " : " barcode " , " extra " : " autocomplete= \" off \" " , " icon-before " : " <i class= \" fa fa-barcode \" ></i> " , " required " : 0 ]}
</ div >
2019-03-29 12:46:17 +01:00
2023-02-17 10:59:50 +01:00
< div class = " col-md-4 " >
2024-06-11 16:58:27 +02:00
{[ " type " : " select " , " label " : " '.tr('Articolo').' " , " name " : " id_articolo " , " value " : " " , " ajax-source " : " articoli " , " select-options " : { " permetti_movimento_a_zero " : '.($dir == ' entrata ' ? 0 : 1).' , " idsede_partenza " : '.intval($ddt->idsede_partenza).' , " idsede_destinazione " : '.intval($ddt->idsede_destinazione).' , " idanagrafica " : '.$ddt->idanagrafica.' , " dir " : " '. $dir .' " , " idagente " : '.$ddt->idagente.' }, " icon-after " : " add|'.Module::where('name', 'Articoli')->first()->id.' " ]}
2023-02-17 10:59:50 +01:00
</ div >
2019-03-29 12:46:17 +01:00
2023-05-24 17:15:29 +02:00
< div class = " col-md-3 " style = " margin-top: 25px " >
2023-02-17 10:59:50 +01:00
< button title = " '.tr('Aggiungi articolo alla vendita').' " class = " btn btn-primary tip " type = " button " onclick = " salvaArticolo() " >
< i class = " fa fa-plus " ></ i > '.tr(' Aggiungi ').'
</ button >
< a class = " btn btn-primary " onclick = " gestioneRiga(this) " data - title = " '.tr('Aggiungi riga').' " >
< i class = " fa fa-plus " ></ i > '.tr(' Riga ').'
</ a >
2024-05-16 18:02:50 +02:00
< div class = " btn-group tip " data - card - widget = " tooltip " >
2024-05-22 17:16:50 +02:00
< button type = " button " class = " btn btn-primary dropdown-toggle " data - toggle = " dropdown " aria - haspopup = " true " aria - expanded = " true " >
2023-02-17 10:59:50 +01:00
< i class = " fa fa-list " ></ i > '.tr(' Altro ').'
< span class = " caret " ></ span >
</ button >
< ul class = " dropdown-menu dropdown-menu-right " >
2024-05-22 12:00:54 +02:00
< a style = " cursor:pointer " class = " dropdown-item " onclick = " gestioneDescrizione(this) " data - title = " '.tr('Aggiungi descrizione').' " >
< i class = " fa fa-plus " ></ i > '.tr(' Descrizione ').'
</ a >
< a style = " cursor:pointer " class = " dropdown-item " onclick = " gestioneSconto(this) " data - title = " '.tr('Aggiungi sconto/maggiorazione').' " >
< i class = " fa fa-plus " ></ i > '.tr(' Sconto / maggiorazione ').'
</ a >
< a class = " '.(!empty( $tot_ddt ) ? '' : ' disabled').' dropdown-item " style = " cursor:pointer " data - href = " '. $structure->fileurl ('add_ddt.php').'?id_module='. $id_module .'&id_record='. $id_record .' " data - card - widget = " modal " data - title = " '.tr('Aggiungi Ddt').' " onclick = " saveForm() " >
< i class = " fa fa-plus " ></ i > '.tr(' Ddt ').'
</ a >
< a class = " '.(!empty( $tot_ordini ) ? '' : ' disabled').' dropdown-item " style = " cursor:pointer " data - href = " '. $structure->fileurl ('add_ordine.php').'?id_module='. $id_module .'&id_record='. $id_record .' " data - card - widget = " modal " data - title = " '.tr('Aggiungi Ordine').' " onclick = " saveForm() " >
< i class = " fa fa-plus " ></ i > '.tr(' Ordine ').'
</ a >
2023-02-17 10:59:50 +01:00
</ ul >
</ div >
</ div >
2023-05-24 17:15:29 +02:00
< div class = " col-md-2 " >
{[ " type " : " select " , " label " : " '.tr('Ordinamento').' " , " name " : " ordinamento " , " class " : " no-search " , " value " : " '.( $_SESSION['module_'.$id_module] ['order_row_desc'] ? 'desc' : 'manuale').' " , " values " : " list= \" desc \" : \" '.tr('Ultima riga inserita').' \" , \" manuale \" : \" '.tr('Manuale').' \" " ]}
</ div >
2023-02-17 10:59:50 +01:00
</ div >
</ form > ' ;
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 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 >
2023-03-30 16:36:24 +02:00
async function saveForm () {
// Salvataggio via AJAX
await salvaForm ( " #edit-form " );
2020-08-03 12:08:52 +02:00
}
2020-07-31 14:25:50 +02:00
2020-08-03 12:08:52 +02:00
function gestioneSconto ( button ) {
2024-04-12 10:54:05 +02:00
gestioneRiga ( button , " is_sconto=1 " );
2020-08-03 12:08:52 +02:00
}
function gestioneDescrizione ( button ) {
2024-04-12 10:54:05 +02:00
gestioneRiga ( button , " is_descrizione=1 " );
2020-08-03 12:08:52 +02:00
}
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
2023-02-17 10:59:50 +01:00
let title = $ ( button ) . attr ( " data-title " );
2020-08-03 12:08:52 +02:00
// Apertura modal
2024-04-12 10:54:05 +02:00
options = options ? options : " is_riga=1 " ;
2021-03-29 18:31:23 +02:00
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 .
*/
2023-02-17 10:59:50 +01:00
function caricaRighe ( id_riga ) {
2020-09-14 10:49:23 +02:00
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 );
2023-02-17 10:59:50 +01:00
if ( id_riga != null ) {
$ ( " tr[data-id= " + id_riga + " ] " ) . effect ( " highlight " , 1000 );
}
2020-09-14 10:49:23 +02:00
});
}
$ ( document ) . ready ( function () {
2023-02-17 10:59:50 +01:00
caricaRighe ( null );
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 ());
}
});
2023-02-17 10:59:50 +01:00
$ ( " #id_articolo " ) . on ( " change " , function ( e ) {
if ( $ ( this ) . val ()) {
var data = $ ( this ) . selectData ();
if ( data . barcode ) {
$ ( " #barcode " ) . val ( data . barcode );
} else {
$ ( " #barcode " ) . val ( " " );
}
}
e . preventDefault ();
setTimeout ( function (){
$ ( " #barcode " ) . focus ();
}, 100 );
});
$ ( " #barcode " ) . focus ();
2024-11-05 09:24:46 +01:00
content_was_modified = false ;
2020-09-14 10:49:23 +02:00
});
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
});
2023-02-17 10:59:50 +01:00
2023-03-30 16:36:24 +02:00
async function salvaArticolo () {
// Salvataggio via AJAX
await salvaForm ( " #edit-form " );
2023-02-17 10:59:50 +01:00
$ ( " #link_form " ) . ajaxSubmit ({
url : globals . rootdir + " /actions.php " ,
data : {
id_module : globals . id_module ,
id_record : globals . id_record ,
ajax : true ,
},
type : " post " ,
beforeSubmit : function ( arr , $form , options ) {
return $form . parsley () . validate ();
},
success : function ( response ){
renderMessages ();
if ( response . length > 0 ){
response = JSON . parse ( response );
swal ({
type : " error " ,
title : " '.tr('Errore').' " ,
text : response . error ,
});
}
$ ( " #barcode " ) . val ( " " );
$ ( " #id_articolo " ) . selectReset ();
2023-04-06 13:11:38 +02:00
content_was_modified = false ;
2023-02-17 10:59:50 +01:00
caricaRighe ( null );
}
});
}
2023-02-27 12:09:59 +01:00
$ ( " #link_form " ) . bind ( " keypress " , function ( e ) {
2023-02-17 10:59:50 +01:00
if ( e . keyCode == 13 ) {
e . preventDefault ();
salvaArticolo ();
return false ;
}
});
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
2024-04-18 17:44:05 +02:00
$elementi = $dbo -> fetchArray ( ' SELECT `co_documenti` . `id` , `co_documenti` . `data` , `co_documenti` . `numero` , `co_documenti` . `numero_esterno` , `co_tipidocumento_lang` . `title` AS tipo_documento , IF ( `co_tipidocumento` . `dir` = \ ' entrata\ ' , \ ' Fatture di vendita\ ' , \ ' Fatture di acquisto\ ' ) AS modulo
2024-04-02 16:28:55 +02:00
FROM `co_documenti`
INNER JOIN `co_righe_documenti` ON `co_righe_documenti` . `iddocumento` = `co_documenti` . `id`
INNER JOIN `co_tipidocumento` ON `co_tipidocumento` . `id` = `co_documenti` . `idtipodocumento`
LEFT JOIN `co_tipidocumento_lang` ON ( `co_tipidocumento_lang` . `id_record` = `co_tipidocumento` . `id` AND `co_tipidocumento_lang` . `id_lang` = '.prepare(Models\Locale::getDefault()->id).' )
WHERE `co_righe_documenti` . `idddt` = '.prepare($id_record).'
2024-02-14 13:06:44 +01:00
UNION
2024-04-02 16:28:55 +02:00
SELECT `in_interventi` . `id` , `in_interventi` . `data_richiesta` , `in_interventi` . `codice` , NULL , \ ' Attività\ ' AS tipo_documento , \ ' Interventi\ ' as modulo
FROM `in_interventi`
JOIN `in_righe_interventi` ON `in_righe_interventi` . `idintervento` = `in_interventi` . `id`
WHERE ( `in_righe_interventi` . `original_document_id` = '.prepare($id_record).' AND `in_righe_interventi` . `original_document_type` = \ ' Modules\\\\DDT\\\\DDT\ ' )
2024-02-14 13:06:44 +01:00
ORDER BY `data` ' );
2018-09-05 10:05:23 +02:00
if ( ! empty ( $elementi )) {
2017-09-14 10:27:49 +02:00
echo '
2024-05-16 18:02:50 +02:00
< div class = " card card-warning collapsable collapsed-card " >
< div class = " card-header with-border " >
< h3 class = " card-title " >< i class = " fa fa-warning " ></ i > '.tr(' Documenti collegati : _NUM_ ' , [
2024-03-22 15:52:24 +01:00
'_NUM_' => count ( $elementi ),
]) . ' </ h3 >
2024-05-16 18:02:50 +02:00
< div class = " card-tools pull-right " >
2024-05-23 17:51:21 +02:00
< button type = " button " class = " btn btn-tool " data - card - widget = " collapse " >< i class = " fa fa-plus " ></ i ></ button >
2018-09-05 10:05:23 +02:00
</ div >
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2018-09-05 10:05:23 +02:00
< ul > ' ;
2024-02-14 13:06:44 +01:00
foreach ( $elementi as $elemento ) {
2017-09-14 10:27:49 +02:00
$descrizione = tr ( '_DOC_ num. _NUM_ del _DATE_' , [
2024-02-14 13:06: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
]);
echo '
2024-02-14 13:06:44 +01:00
< li > '.Modules::link($elemento[' modulo '], $elemento[' 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 " >
2023-09-28 16:08:45 +02:00
< i id = " elimina " class = " fa fa-trash " ></ i > < ? php echo tr ( 'Elimina' ); ?>
2019-06-20 16:44:45 +02:00
</ a >
< ? php
}
2023-01-13 09:35:27 +01:00
echo '
< script >
2023-05-24 17:15:29 +02:00
$ ( " #idsede_destinazione " ) . change ( function (){
updateSelectOption ( " idsede_destinazione " , $ ( this ) . val ());
$ ( " #idreferente " ) . selectReset ();
});
2023-01-13 09:35:27 +01:00
2023-05-24 17:15:29 +02:00
input ( " ordinamento " ) . on ( " change " , function (){
if ( input ( this ) . get () == " desc " ) {
session_set ( " module_'. $id_module .',order_row_desc " , 1 , " " ) . then ( function () {
caricaRighe ( null );
});
} else {
session_set ( " module_'. $id_module .',order_row_desc " ) . then ( function () {
caricaRighe ( null );
});
}
});
2023-08-04 14:54:28 +02:00
</ script > ' ;