2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
$module = Modules :: getModule ( $id_module );
if ( $module [ 'name' ] == 'Fatture di vendita' ) {
$dir = 'entrata' ;
$conti = 'conti-vendite' ;
} else {
$dir = 'uscita' ;
$conti = 'conti-acquisti' ;
}
$record = $dbo -> fetchArray ( 'SELECT * FROM co_documenti WHERE id=' . prepare ( $id_record ));
$numero = ( $record [ 0 ][ 'numero_esterno' ] != '' ) ? $record [ 0 ][ 'numero_esterno' ] : $record [ 0 ][ 'numero' ];
$idconto = $record [ 0 ][ 'idconto' ];
$idanagrafica = $record [ 0 ][ 'idanagrafica' ];
/*
Form di inserimento riga documento
*/
echo '
2017-09-10 14:35:41 +02:00
< p > '.tr(' Documento numero _NUM_ ' , [
'_NUM_' => $numero ,
]) . ' </ p >
2017-08-04 16:28:16 +02:00
< form action = " '. $rootdir .'/editor.php?id_module='. $id_module .'&id_record='. $id_record .' " method = " post " >
< input type = " hidden " name = " op " value = " addriga " >
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " dir " value = " '. $dir .' " > ' ;
// Descrizione
echo '
< div class = " row " >
< div class = " col-md-12 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " textarea " , " label " : " '.tr('Descrizione').' " , " name " : " descrizione " , " required " : 1 ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div > ' ;
if ( get_var ( 'Percentuale rivalsa INPS' ) != '' || get_var ( " Percentuale ritenuta d'acconto " ) != '' ) {
echo '
< div class = " row " > ' ;
// Rivalsa INPS
if ( get_var ( 'Percentuale rivalsa INPS' ) != '' ) {
echo '
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " '.tr('Rivalsa INPS').' " , " name " : " idrivalsainps " , " required " : 1 , " value " : " '.get_var('Percentuale rivalsa INPS').' " , " values " : " query=SELECT * FROM co_rivalsainps " ]}
2017-08-04 16:28:16 +02:00
</ div > ' ;
}
// Ritenuta d'acconto
if ( get_var ( " Percentuale ritenuta d'acconto " ) != '' ) {
echo '
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " '.tr( " Ritenuta d 'acconto").' " , " name " : " idritenutaacconto " , " required " : 1, " value " : " '.get_var("Percentuale ritenuta d' acconto " ).' " , " values " : " query=SELECT * FROM co_ritenutaacconto " ]}
2017-08-04 16:28:16 +02:00
</ div > ' ;
}
echo '
</ div > ' ;
}
// Nelle fatture di acquisto leggo l'iva di acquisto dal fornitore
if ( $dir == 'uscita' ) {
2017-09-10 14:35:41 +02:00
$rsf = $dbo -> fetchArray ( 'SELECT idiva FROM an_anagrafiche WHERE idanagrafica=' . prepare ( $idanagrafica ));
2017-08-04 16:28:16 +02:00
$idiva_predefinita = $rsf [ 0 ][ 'idiva' ];
}
// Leggo l'iva predefinita dall'articolo e se non c'è leggo quella predefinita generica
$idiva = $idiva ? : get_var ( 'Iva predefinita' );
// Iva
echo '
< div class = " row " >
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " '.tr('Iva').' " , " name " : " idiva " , " required " : 1 , " value " : " '. $idiva .' " , " values " : " query=SELECT * FROM co_iva ORDER BY descrizione ASC " ]}
2017-08-04 16:28:16 +02:00
</ div > ' ;
echo '
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " '.tr('Conto').' " , " name " : " idconto " , " required " : 1 , " value " : " '. $idconto .' " , " ajax-source " : " '. $conti .' " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div > ' ;
// Quantità
echo '
< div class = " row " >
< div class = " col-md-2 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " '.tr('Q.tà').' " , " name " : " qta " , " required " : 1 , " value " : " 1 " , " decimals " : " qta " ]}
2017-08-04 16:28:16 +02:00
</ div > ' ;
// Unità di misura
echo '
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " '.tr('Unità di misura').' " , " icon-after " : " add|'.Modules::getModule('Unità di misura')['id'].' " , " name " : " um " , " ajax-source " : " misure " ]}
2017-08-04 16:28:16 +02:00
</ div > ' ;
// Costo unitario
echo '
< div class = " col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " '.tr('Costo unitario').' " , " name " : " prezzo " , " required " : 1 , " icon-after " : " € " ]}
2017-08-04 16:28:16 +02:00
</ div > ' ;
// Sconto unitario
echo '
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " '.tr('Sconto unitario').' " , " name " : " sconto " , " icon-after " : " choice|untprc " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div > ' ;
echo '
<!-- PULSANTI -->
< div class = " row " >
< div class = " col-md-12 text-right " >
2017-09-04 12:02:29 +02:00
< button type = " submit " class = " btn btn-primary pull-right " >< i class = " fa fa-plus " ></ i > '.tr(' Aggiungi ').' </ button >
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ form > ' ;
echo '
< script src = " '. $rootdir .'/lib/init.js " ></ script > ' ;