2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
$rs = $dbo -> fetchArray ( 'SELECT co_tipidocumento.descrizione, dir FROM co_tipidocumento INNER JOIN co_documenti ON co_tipidocumento.id=co_documenti.idtipodocumento WHERE co_documenti.id=' . prepare ( $id_record ));
$dir = $rs [ 0 ][ 'dir' ];
$tipodoc = $rs [ 0 ][ 'descrizione' ];
2017-08-31 16:23:26 +02:00
$_SESSION [ 'superselect' ][ 'idanagrafica' ] = $records [ 0 ][ 'idanagrafica' ];
2018-02-09 14:25:40 +01:00
$_SESSION [ 'superselect' ][ 'ddt' ] = $dir ;
2017-08-31 16:23:26 +02:00
2017-08-04 16:28:16 +02:00
?>
< form action = " " class = " text-right " method = " post " id = " form-copy " >
2017-08-30 11:50:46 +02:00
< input type = " hidden " name = " backto " value = " record-edit " >
2017-08-04 16:28:16 +02:00
< input type = " hidden " name = " op " value = " copy " >
</ form >
< form action = " " method = " post " role = " form " >
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " op " value = " update " >
2018-02-09 14:25:40 +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 " >
2018-02-09 14:25:40 +01:00
< h3 class = " panel-title " >< ? php echo tr ( 'Intestazione' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " >
2018-02-11 20:24:29 +01:00
2018-02-09 15:43:51 +01:00
< ? php
2018-02-11 20:24:29 +01:00
if ( $dir == 'entrata' ) {
$rs2 = $dbo -> fetchArray ( 'SELECT piva, codice_fiscale, citta, indirizzo, cap, provincia FROM an_anagrafiche WHERE idanagrafica=' . prepare ( $records [ 0 ][ '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 />
2018-02-09 15:43:51 +01:00
'.Modules::link(' Anagrafiche ', $records[0][' idanagrafica '], tr(' Vai alla scheda anagrafica '), null).' </ div > ' ;
2018-02-11 20:24:29 +01:00
}
}
?>
2017-08-04 16:28:16 +02:00
< div class = " pull-right " >
2018-02-11 20:24:29 +01:00
2017-09-04 12:02:29 +02:00
< button type = " button " class = " btn btn-primary " onclick = " if( confirm('Duplicare questa fattura?') ) { $ ('#form-copy').submit(); } " >< i class = " fa fa-copy " ></ i > < ? php echo tr ( 'Duplica fattura' ); ?> </button>
2017-08-04 16:28:16 +02:00
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-11 20:24:29 +01:00
2017-08-04 16:28:16 +02:00
</ div >
2018-02-11 20:24:29 +01:00
2017-08-04 16:28:16 +02:00
< div class = " clearfix " ></ div >
< div class = " row " >
2017-11-07 19:19:52 +01:00
< ? php
if ( $dir == 'uscita' ) {
echo '
< div class = " col-md-3 " >
{[ " type " : " span " , " label " : " '.tr('Numero fattura').' " , " name " : " numero " , " class " : " text-center " , " value " : " $numero $ " ]}
</ div > ' ;
$label = tr ( 'Numero secondario' );
} else {
2018-02-04 17:26:25 +01:00
$label = tr ( 'Numero fattura' );
2017-11-07 19:19:52 +01:00
}
?>
2017-08-04 16:28:16 +02:00
< div class = " col-md-3 " >
2017-11-07 19:19:52 +01:00
{[ " type " : " text " , " label " : " <?php echo $label ; ?> " , " name " : " numero_esterno " , " class " : " text-center " , " value " : " $numero_esterno $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " date " , " label " : " <?php echo tr('Data emissione'); ?> " , " maxlength " : 10 , " name " : " data " , " required " : 1 , " value " : " $data $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-15 10:12:40 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Stato'); ?> " , " name " : " idstatodocumento " , " required " : 1 , " values " : " query=SELECT * FROM co_statidocumento " , " value " : " $idstatodocumento $ " , " extra " : " onchange = \" if ( $ ('#idstatodocumento option:selected').text()=='Pagato') { if( confirm('Sicuri di voler impostare manualmente la fattura come pagata senza aggiungerla in prima nota?') ) { return true; }else { $ ('#idstatodocumento').selectSet(<?php echo $records[0] ['idstatodocumento']; ?>); }} \" " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-3 " >
< ? php
2018-01-15 20:28:36 +01:00
echo Modules :: link ( 'Anagrafiche' , $records [ 0 ][ 'idanagrafica' ], null , null , 'class="pull-right"' );
2017-08-04 16:28:16 +02:00
if ( $dir == 'entrata' ) {
?>
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Cliente'); ?> " , " name " : " idanagrafica " , " required " : 1 , " ajax-source " : " clienti " , " value " : " $idanagrafica $ " ]}
2017-08-04 16:28:16 +02:00
< ? php
} else {
?>
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Fornitore'); ?> " , " name " : " idanagrafica " , " required " : 1 , " ajax-source " : " fornitori " , " value " : " $idanagrafica $ " ]}
2017-08-04 16:28:16 +02:00
< ? php
}
?>
</ div >
< div class = " col-md-3 " >
2017-09-18 18:34:13 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Riferimento sede'); ?> " , " name " : " idsede " , " ajax-source " : " sedi " , " value " : " $idsede $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< ? php if ( $dir == 'entrata' ) {
?>
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Agente di riferimento'); ?> " , " name " : " idagente " , " ajax-source " : " agenti " , " value " : " $idagente_fattura $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< ? php
} ?>
< ? php
2017-08-28 15:01:02 +02:00
if ( $records [ 0 ][ 'stato' ] != 'Bozza' && $records [ 0 ][ 'stato' ] != 'Annullata' ) {
2017-08-04 16:28:16 +02:00
$scadenze = $dbo -> fetchArray ( 'SELECT * FROM co_scadenziario WHERE iddocumento = ' . prepare ( $id_record ));
echo '
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
< p >< strong > '.tr(' Scadenze ').' </ strong ></ p > ' ;
2017-08-04 16:28:16 +02:00
foreach ( $scadenze as $scadenza ) {
echo '
2017-10-12 20:10:27 +02:00
< p > '.Translator::dateToLocale($scadenza[' scadenza ']).' : '.Translator::numberToLocale($scadenza[' da_pagare ']).' & euro ; </ p > ' ;
2017-08-04 16:28:16 +02:00
}
echo '
</ div > ' ;
}
?>
</ div >
< hr >
< div class = " row " >
< div class = " col-md-3 " >
2018-02-09 14:25:40 +01:00
{[ " type " : " select " , " label " : " <?php echo tr('Tipo fattura'); ?> " , " name " : " idtipodocumento " , " required " : 1 , " values " : " query=SELECT id, descrizione FROM co_tipidocumento WHERE dir='<?php echo $dir ; ?>' " , " value " : " $idtipodocumento $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
< ? php
if ( $dir == 'entrata' ) {
$ajaxsource = 'conti-vendite' ;
} else {
$ajaxsource = 'conti-acquisti' ;
}
?>
2018-02-09 14:25:40 +01:00
{[ " type " : " select " , " label " : " <?php echo tr('Conto'); ?> " , " name " : " idconto " , " required " : 1 , " value " : " $idconto $ " , " ajax-source " : " <?php echo $ajaxsource ; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Pagamento'); ?> " , " name " : " idpagamento " , " required " : 1 , " values " : " query=SELECT id, descrizione FROM co_pagamenti GROUP BY descrizione ORDER BY descrizione ASC " , " value " : " $idpagamento $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< ? php
if ( $tipodoc == 'Fattura accompagnatoria di vendita' ) {
?>
< div class = " row " >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Aspetto beni'); ?> " , " name " : " idaspettobeni " , " placeholder " : " - " , " values " : " query=SELECT id, descrizione FROM dt_aspettobeni ORDER BY descrizione ASC " , " value " : " $idaspettobeni $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Causale trasporto'); ?> " , " name " : " idcausalet " , " placeholder " : " - " , " values " : " query=SELECT id, descrizione FROM dt_causalet ORDER BY descrizione ASC " , " value " : " $idcausalet $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Porto'); ?> " , " name " : " idporto " , " placeholder " : " - " , " 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 " >
2017-09-14 10:27:49 +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 >
2017-08-31 16:23:26 +02:00
< div class = " row " >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Tipo di spedizione'); ?> " , " name " : " idspedizione " , " values " : " query=SELECT id, descrizione FROM dt_spedizione ORDER BY descrizione ASC " , " value " : " $idspedizione $ " ]}
2017-08-31 16:23:26 +02:00
</ div >
< div class = " col-md-3 " >
2017-11-14 19:14:41 +01:00
{[ " type " : " select " , " label " : " <?php echo tr('Vettore'); ?> " , " name " : " idvettore " , " values " : " query=SELECT DISTINCT an_anagrafiche.idanagrafica AS id, an_anagrafiche.ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE an_tipianagrafiche_anagrafiche.idtipoanagrafica=(SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione='Vettore') ORDER BY descrizione ASC " , " value " : " $idvettore $ " ]}
2017-08-31 16:23:26 +02:00
</ div >
</ div >
2017-08-04 16:28:16 +02:00
< ? php
}
if ( $dir == 'uscita' ) {
?>
< div class = " row " >
< div class = " col-md-3 " >
2017-09-18 18:34:13 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Marca da bollo'); ?> " , " name " : " bollo " , " value " : " $bollo $ " , " help " : " <?php echo tr('Applicato solo se il totale della fattura è maggiore di _TOT_ €', [
2017-09-18 17:24:25 +02:00
'_TOT_' => Translator :: numberToLocale ( get_var ( " Soglia minima per l'applicazione della marca da bollo " )),
]), '.' ; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< ? php
}
?>
< div class = " pull-right " >
< ? php
2017-09-19 16:20:44 +02:00
// Aggiunta prima nota solo se non c'è già, se non si è in bozza o se il pagamento non è completo
2017-08-04 16:28:16 +02:00
$query2 = 'SELECT id FROM co_movimenti WHERE iddocumento=' . $id_record . ' AND primanota=1' ;
$n2 = $dbo -> fetchNum ( $query2 );
$query3 = 'SELECT SUM(da_pagare-pagato) AS differenza, SUM(da_pagare) FROM co_scadenziario GROUP BY iddocumento HAVING iddocumento=' . $id_record . '' ;
$rs3 = $dbo -> fetchArray ( $query3 );
$differenza = $rs3 [ 0 ][ 'differenza' ];
$da_pagare = $rs3 [ 0 ][ 'da_pagare' ];
if (( $n2 <= 0 && $records [ 0 ][ 'stato' ] == 'Emessa' ) || $differenza != 0 ) {
?>
2018-02-09 14:25:40 +01:00
< a class = " btn btn-sm btn-primary " href = " javascript:; " onclick = " launch_modal( 'Aggiungi prima nota', '<?php echo $rootdir ; ?>/add.php?id_module=<?php echo Modules::get('Prima nota')['id']; ?>&iddocumento=<?php echo $id_record ; ?>&dir=<?php echo $dir ; ?>', 1 ); " >< i class = " fa fa-euro " ></ i > < ? php echo tr ( 'Aggiungi prima nota' ); ?> ...</a><br><br>
2017-08-04 16:28:16 +02:00
< ? php
}
if ( $records [ 0 ][ 'stato' ] == 'Pagato' ) {
?>
2018-02-09 14:25:40 +01:00
< a class = " btn btn-sm btn-primary " href = " javascript:; " onclick = " if( confirm('Se riapri questa fattura verrà azzerato lo scadenzario e la prima nota. Continuare?') ) { $ .post( '<?php echo $rootdir ; ?>/editor.php?id_module=<?php echo Modules::get( $name )['id']; ?>&id_record=<?php echo $id_record ; ?>', { id_module: '<?php echo Modules::get( $name )['id']; ?>', id_record: '<?php echo $id_record ; ?>', op: 'reopen' }, function() { location.href='<?php echo $rootdir ; ?>/editor.php?id_module=<?php echo Modules::get( $name )['id']; ?>&id_record=<?php echo $id_record ; ?>'; } ); } " title = " Aggiungi prima nota " >< i class = " fa fa-folder-open " ></ i > < ? php echo tr ( 'Riapri fattura' ); ?> ...</a>
2017-08-04 16:28:16 +02:00
< ? php
}
?>
</ div >
< div class = " clearfix " ></ div >
< div class = " row " >
< div class = " col-md-3 " >
2018-02-09 14:25:40 +01:00
{[ " type " : " number " , " label " : " <?php echo tr('Sconto incondizionato'); ?> " , " name " : " sconto_generico " , " value " : " $sconto_globale $ " , " help " : " <?php echo tr('Sconto complessivo della fattura.'); ?> " , " icon-after " : " choice|untprc| $tipo_sconto_globale $ " < ? php
2017-08-28 15:01:02 +02:00
if ( $records [ 0 ][ 'stato' ] == 'Emessa' ) {
echo ', "disabled" : 1' ;
}
?> ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-12 " >
2017-09-18 18:34:13 +02:00
{[ " type " : " textarea " , " label " : " <?php echo tr('Note'); ?> " , " name " : " note " , " help " : " <?php echo tr('Note visibili anche in stampa.'); ?> " , " value " : " $note $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-12 " >
2017-09-18 18:34:13 +02:00
{[ " type " : " textarea " , " label " : " <?php echo tr('Note aggiuntive'); ?> " , " name " : " note_aggiuntive " , " help " : " <?php echo tr('Note interne.'); ?> " , " value " : " $note_aggiuntive $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< 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>
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
</ form >
<!-- RIGHE -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
< h3 class = " panel-title " > Righe </ h3 >
</ div >
< div class = " panel-body " >
< div class = " row " >
< div class = " col-md-12 " >
< div class = " pull-left " >
< ? php
if ( $records [ 0 ][ 'stato' ] != 'Pagato' && $records [ 0 ][ 'stato' ] != 'Emessa' ) {
if ( $dir == 'entrata' ) {
2017-09-19 16:20:44 +02:00
// Lettura interventi non rifiutati, non fatturati e non collegati a preventivi o contratti
2018-02-09 14:25:40 +01:00
$int_query = 'SELECT COUNT(*) AS tot FROM in_interventi WHERE idanagrafica=' . prepare ( $records [ 0 ][ 'idanagrafica' ]) . " AND NOT idstatointervento='DENY' AND id NOT IN (SELECT idintervento FROM co_righe_documenti WHERE idintervento IS NOT NULL) AND id NOT IN (SELECT idintervento FROM co_preventivi_interventi WHERE idintervento IS NOT NULL) AND id NOT IN (SELECT idintervento FROM co_righe_contratti WHERE idintervento IS NOT NULL) " ;
$interventi = $dbo -> fetchArray ( $int_query )[ 0 ][ 'tot' ];
2017-08-04 16:28:16 +02:00
2017-09-19 16:20:44 +02:00
// Se non trovo niente provo a vedere se ce ne sono per clienti terzi
2017-09-19 17:27:31 +02:00
if ( empty ( $interventi )) {
2017-09-19 16:20:44 +02:00
// Lettura interventi non rifiutati, non fatturati e non collegati a preventivi o contratti (clienti terzi)
2018-02-09 14:25:40 +01:00
$int_query = 'SELECT COUNT(*) AS tot FROM in_interventi WHERE idclientefinale=' . prepare ( $records [ 0 ][ 'idanagrafica' ]) . " AND NOT idstatointervento='DENY' AND id NOT IN (SELECT idintervento FROM co_righe_documenti WHERE idintervento IS NOT NULL) AND id NOT IN (SELECT idintervento FROM co_preventivi_interventi WHERE idintervento IS NOT NULL) AND id NOT IN (SELECT idintervento FROM co_righe_contratti WHERE idintervento IS NOT NULL) " ;
$interventi = $dbo -> fetchArray ( $int_query )[ 0 ][ 'tot' ];
2017-08-04 16:28:16 +02:00
}
2017-09-19 17:27:31 +02:00
echo '
< a class = " btn btn-sm btn-primary'.(!empty( $interventi ) ? '' : ' disabled').' " data - href = " '. $rootdir .'/modules/fatture/add_intervento.php?id_module='. $id_module .'&id_record='. $id_record .' " data - toggle = " modal " data - title = " Aggiungi intervento " data - target = " #bs-popup " >
< i class = " fa fa-plus " ></ i > Intervento
</ a > ' ;
2017-09-19 16:20:44 +02:00
// Lettura preventivi accettati, in attesa di conferma o in lavorazione
2018-02-09 14:25:40 +01:00
$prev_query = 'SELECT COUNT(*) AS tot FROM co_preventivi WHERE idanagrafica=' . prepare ( $records [ 0 ][ 'idanagrafica' ]) . " AND id NOT IN (SELECT idpreventivo FROM co_righe_documenti WHERE NOT idpreventivo=NULL) AND idstato IN( SELECT id FROM co_statipreventivi WHERE descrizione='Accettato' OR descrizione='In lavorazione' OR descrizione='In attesa di conferma') " ;
$preventivi = $dbo -> fetchArray ( $prev_query )[ 0 ][ 'tot' ];
2017-09-19 17:27:31 +02:00
echo '
< a class = " btn btn-sm btn-primary'.(!empty( $preventivi ) ? '' : ' disabled').' " data - href = " '. $rootdir .'/modules/fatture/add_preventivo.php?id_module='. $id_module .'&id_record='. $id_record .' " data - toggle = " modal " data - title = " Aggiungi preventivo " data - target = " #bs-popup " >
< i class = " fa fa-plus " ></ i > Preventivo
</ a > ' ;
2017-08-04 16:28:16 +02:00
2017-09-19 16:20:44 +02:00
// Lettura contratti accettati, in attesa di conferma o in lavorazione
2018-02-09 14:25:40 +01:00
$contr_query = 'SELECT COUNT(*) AS tot FROM co_contratti WHERE idanagrafica=' . prepare ( $records [ 0 ][ 'idanagrafica' ]) . ' AND id NOT IN (SELECT idcontratto FROM co_righe_documenti WHERE NOT idcontratto=NULL) AND idstato IN( SELECT id FROM co_staticontratti WHERE fatturabile = 1) AND NOT EXISTS (SELECT id FROM co_righe_documenti WHERE co_righe_documenti.idcontratto = co_contratti.id)' ;
$contratti = $dbo -> fetchArray ( $contr_query )[ 0 ][ 'tot' ];
2017-09-19 17:27:31 +02:00
echo '
< a class = " btn btn-sm btn-primary'.(!empty( $contratti ) ? '' : ' disabled').' " data - href = " '. $rootdir .'/modules/fatture/add_contratto.php?id_module='. $id_module .'&id_record='. $id_record .' " data - toggle = " modal " data - title = " Aggiungi contratto " data - target = " #bs-popup " >
< i class = " fa fa-plus " ></ i > Contratto
</ a > ' ;
2017-08-04 16:28:16 +02:00
2017-09-19 16:20:44 +02:00
// Lettura ddt
2018-02-09 14:25:40 +01:00
$ddt_query = 'SELECT COUNT(*) AS tot FROM dt_ddt WHERE idanagrafica=' . prepare ( $records [ 0 ][ 'idanagrafica' ]) . ' AND idstatoddt IN (SELECT id FROM dt_statiddt WHERE descrizione IN(\'Bozza\', \'Parzialmente fatturato\')) AND idtipoddt=(SELECT id FROM dt_tipiddt WHERE dir=' . prepare ( $dir ) . ') 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' ];
2017-09-19 16:20:44 +02:00
echo '
2017-09-19 17:27:31 +02:00
< a class = " btn btn-sm btn-primary'.(!empty( $ddt ) ? '' : ' disabled').' " data - href = " '. $rootdir .'/modules/fatture/add_ddt.php?id_module='. $id_module .'&id_record='. $id_record .' " data - toggle = " modal " data - title = " Aggiungi ddt " data - target = " #bs-popup " >
< i class = " fa fa-plus " ></ i > Ddt
</ a > ' ;
}
2017-08-04 16:28:16 +02:00
2017-09-19 17:27:31 +02:00
// Lettura articoli
2018-02-09 14:25:40 +01:00
$art_query = 'SELECT COUNT(*) AS tot FROM mg_articoli WHERE attivo = 1' ;
if ( $dir == 'entrata' ) {
$art_query .= ' AND (qta > 0 OR servizio = 1)' ;
}
$articoli = $dbo -> fetchArray ( $art_query )[ 0 ][ 'tot' ];
2017-09-19 17:27:31 +02:00
echo '
2018-02-19 17:57:27 +01:00
< a class = " btn btn-sm btn-primary'.(!empty( $articoli ) ? '' : ' disabled').' " data - href = " '. $rootdir .'/modules/fatture/row-add.php?id_module='. $id_module .'&id_record='. $id_record .'&is_articolo " data - toggle = " modal " data - title = " Aggiungi articolo " data - target = " #bs-popup " >
< i class = " fa fa-plus " ></ i > '.tr(' Articolo ').'
2017-09-19 17:27:31 +02:00
</ a > ' ;
2017-09-19 16:20:44 +02:00
2017-09-19 17:27:31 +02:00
echo '
2018-02-19 17:57:27 +01:00
< a class = " btn btn-sm btn-primary " data - href = " '. $rootdir .'/modules/fatture/row-add.php?id_module='. $id_module .'&id_record='. $id_record .'&is_riga " data - toggle = " modal " data - title = " Aggiungi riga " data - target = " #bs-popup " >
< i class = " fa fa-plus " ></ i > '.tr(' Riga ').'
2017-09-19 17:27:31 +02:00
</ a > ' ;
2018-02-04 17:26:25 +01:00
2018-01-18 19:03:06 +01:00
echo '
2018-02-19 17:57:27 +01:00
< a class = " btn btn-sm btn-primary " data - href = " '. $rootdir .'/modules/fatture/row-add.php?id_module='. $id_module .'&id_record='. $id_record .'&is_descrizione " data - toggle = " modal " data - title = " Aggiungi descrizione " data - target = " #bs-popup " >
< i class = " fa fa-plus " ></ i > '.tr(' Descrizione ').'
2018-01-18 19:03:06 +01:00
</ a > ' ;
2017-08-04 16:28:16 +02:00
}
2017-09-19 17:27:31 +02:00
?>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " pull-right " >
<!-- Stampe -->
< ? php
2018-02-09 15:43:51 +01:00
//stampa solo per fatture di vendita
2017-08-04 16:28:16 +02:00
if ( $dir == 'entrata' ) {
2018-02-11 20:24:29 +01:00
if ( sizeof ( $campi_mancanti ) > 0 ) {
echo '{( "name": "button", "type": "print", "id_module": "' . $id_module . '", "id_record": "' . $id_record . '", "class": "btn-info disabled" )}' ;
} else {
echo '{( "name": "button", "type": "print", "id_module": "' . $id_module . '", "id_record": "' . $id_record . '" )}' ;
2017-08-04 16:28:16 +02:00
}
}
?>
</ div >
</ div >
</ div >
< div class = " clearfix " ></ div >
< br >
< div class = " row " >
< div class = " col-md-12 " >
< ? php
include $docroot . '/modules/fatture/row-list.php' ;
?>
</ div >
</ div >
</ div >
</ div >
2018-02-09 14:25:40 +01:00
{( " name " : " filelist_and_upload " , " id_module " : " <?php echo $id_module ; ?> " , " id_record " : " <?php echo $id_record ; ?> " )}
2017-08-04 16:28:16 +02:00
< script type = " text/javascript " >
$ ( '#idanagrafica' ) . change ( function (){
session_set ( 'superselect,idanagrafica' , $ ( this ) . val (), 0 );
$ ( " #idsede " ) . selectReset ();
});
</ script >
< a class = " btn btn-danger ask " data - backto = " record-list " >
2017-09-04 12:02:29 +02:00
< i class = " fa fa-trash " ></ i > < ? php echo tr ( 'Elimina' ); ?>
2017-08-04 16:28:16 +02:00
</ a >