2020-02-17 13:18:25 +01: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 />.
*/
2020-02-17 13:18:25 +01:00
use Plugins\PianificazioneInterventi\Promemoria ;
include_once __DIR__ . '/../../core.php' ;
$documento = Promemoria :: find ( $id_record );
// Impostazioni per la gestione
$options = [
'op' => 'manage_riga' ,
'action' => 'add' ,
'dir' => $documento -> direzione ,
'idanagrafica' => $documento [ 'idanagrafica' ],
2020-09-29 15:27:00 +02:00
'totale_imponibile_documento' => $documento -> totale_imponibile ,
'totale_documento' => $documento -> totale ,
2020-02-17 13:18:25 +01:00
'id_plugin' => $id_plugin , // Modificato
];
// Dati di default
$result = [
'descrizione' => '' ,
'qta' => 1 ,
'um' => '' ,
'prezzo' => 0 ,
'sconto_unitario' => 0 ,
'tipo_sconto' => '' ,
'idiva' => '' ,
'idconto' => $idconto ,
'ritenuta_contributi' => true ,
];
// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica
$iva = $dbo -> fetchArray ( 'SELECT idiva_vendite AS idiva FROM an_anagrafiche WHERE idanagrafica=' . prepare ( $documento [ 'idanagrafica' ]));
$result [ 'idiva' ] = $iva [ 0 ][ 'idiva' ] ? : setting ( 'Iva predefinita' );
// Importazione della gestione dedicata
$file = 'riga' ;
if ( get ( 'is_descrizione' ) !== null ) {
$file = 'descrizione' ;
$options [ 'op' ] = 'manage_descrizione' ;
} elseif ( get ( 'is_articolo' ) !== null ) {
$file = 'articolo' ;
// Aggiunta sconto di default da listino per le vendite
$listino = $dbo -> fetchOne ( 'SELECT prc_guadagno FROM an_anagrafiche INNER JOIN mg_listini ON an_anagrafiche.idlistino_vendite=mg_listini.id WHERE idanagrafica=' . prepare ( $documento [ 'idanagrafica' ]));
if ( ! empty ( $listino [ 'prc_guadagno' ])) {
$result [ 'sconto_percentuale' ] = $listino [ 'prc_guadagno' ];
$result [ 'tipo_sconto' ] = 'PRC' ;
}
$options [ 'op' ] = 'manage_articolo' ;
} elseif ( get ( 'is_sconto' ) !== null ) {
$file = 'sconto' ;
$options [ 'op' ] = 'manage_sconto' ;
}
// Modificato
echo '
< div id = " riga-promemoria " > ' ;
echo App :: load ( $file . '.php' , $result , $options );
echo '
</ div >
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
$ ( " #riga-promemoria " ) . ajaxForm ({
success : function ( responseText , statusText , xhr , form ){
$ ( form ) . closest ( " .modal " ) . modal ( " hide " );
refreshRighe ( '.$id_record.' );
}
});
});
</ script > ' ;