2018-02-19 11:50:42 +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 />.
*/
2018-02-19 11:50:42 +01:00
2019-03-29 12:46:17 +01:00
use Modules\Ordini\Ordine ;
2018-02-19 11:50:42 +01:00
include_once __DIR__ . '/../../core.php' ;
// Info contratto
2019-03-29 12:46:17 +01:00
$documento = Ordine :: find ( $id_record );
2019-05-24 20:42:15 +02:00
$dir = $documento -> direzione ;
2018-02-19 11:50:42 +01:00
// Impostazioni per la gestione
$options = [
2019-07-23 15:39:00 +02:00
'op' => 'manage_riga' ,
2018-02-19 11:50:42 +01:00
'action' => 'add' ,
2019-03-29 12:46:17 +01:00
'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-08-17 16:25:01 +02:00
'select-options' => [
'articoli' => [
'idanagrafica' => $documento -> idanagrafica ,
'dir' => $documento -> direzione ,
2020-08-18 09:53:58 +02:00
'permetti_movimento_a_zero' => 1 ,
2022-05-19 17:42:41 +02:00
'idagente' => $documento -> idagente ,
2020-08-17 16:25:01 +02:00
],
],
2018-02-19 11:50:42 +01:00
];
// Dati di default
$result = [
'descrizione' => '' ,
'qta' => 1 ,
'um' => '' ,
'prezzo' => 0 ,
'sconto_unitario' => 0 ,
'tipo_sconto' => '' ,
'idiva' => '' ,
2022-05-19 17:42:41 +02:00
'provvigione_default' => 0 ,
'tipo_provvigione_default' => 'PRC' ,
2018-02-19 11:50:42 +01:00
];
2022-05-19 17:42:41 +02:00
// Leggo la provvigione predefinita per l'anagrafica
2023-08-04 14:54:28 +02:00
$result [ 'provvigione_default' ] = $dbo -> fetchOne ( 'SELECT provvigione_default FROM an_anagrafiche WHERE idanagrafica=' . prepare ( $documento -> idagente ))[ 'provvigione_default' ];
2022-05-19 17:42:41 +02:00
2018-02-19 11:50:42 +01:00
// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica
2019-03-29 12:46:17 +01:00
$iva = $dbo -> fetchArray ( 'SELECT idiva_' . ( $dir == 'uscita' ? 'acquisti' : 'vendite' ) . ' AS idiva FROM an_anagrafiche WHERE idanagrafica=' . prepare ( $documento [ 'idanagrafica' ]));
2018-07-08 18:11:17 +02:00
$result [ 'idiva' ] = $iva [ 0 ][ 'idiva' ] ? : setting ( 'Iva predefinita' );
2018-02-19 11:50:42 +01:00
// Importazione della gestione dedicata
$file = 'riga' ;
2018-07-19 15:33:32 +02:00
if ( get ( 'is_descrizione' ) !== null ) {
2018-02-19 11:50:42 +01:00
$file = 'descrizione' ;
2019-07-23 15:39:00 +02:00
$options [ 'op' ] = 'manage_descrizione' ;
2019-03-29 12:46:17 +01:00
} elseif ( get ( 'is_sconto' ) !== null ) {
$file = 'sconto' ;
$options [ 'op' ] = 'manage_sconto' ;
2018-02-19 11:50:42 +01:00
}
echo App :: load ( $file . '.php' , $result , $options );