2018-02-19 17:57:27 +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 17:57:27 +01:00
|
|
|
|
2019-03-29 12:46:17 +01:00
|
|
|
use Modules\Fatture\Fattura;
|
2018-02-19 17:57:27 +01:00
|
|
|
|
2019-03-29 12:46:17 +01:00
|
|
|
include_once __DIR__.'/../../core.php';
|
2018-02-19 17:57:27 +01:00
|
|
|
|
2019-03-29 12:46:17 +01:00
|
|
|
$documento = Fattura::find($id_record);
|
2018-02-19 17:57:27 +01:00
|
|
|
|
|
|
|
// Impostazioni per la gestione
|
|
|
|
$options = [
|
2018-10-04 17:25:42 +02:00
|
|
|
'op' => 'manage_riga',
|
2018-02-19 17:57:27 +01:00
|
|
|
'action' => 'edit',
|
2019-03-29 12:46:17 +01:00
|
|
|
'dir' => $documento->direzione,
|
|
|
|
'conti' => $documento->direzione == 'entrata' ? 'conti-vendite' : 'conti-acquisti',
|
|
|
|
'idanagrafica' => $documento['idanagrafica'],
|
|
|
|
'show-ritenuta-contributi' => !empty($documento['id_ritenuta_contributi']),
|
2020-09-29 15:27:00 +02:00
|
|
|
'totale_imponibile_documento' => $documento->totale_imponibile,
|
|
|
|
'totale_documento' => $documento->totale,
|
2022-04-08 16:54:31 +02:00
|
|
|
'is_nota' => $documento->isNota(),
|
2020-08-17 16:25:01 +02:00
|
|
|
'select-options' => [
|
|
|
|
'articoli' => [
|
|
|
|
'idanagrafica' => $documento->idanagrafica,
|
|
|
|
'dir' => $documento->direzione,
|
|
|
|
'idsede_partenza' => $documento->idsede_partenza,
|
|
|
|
'idsede_destinazione' => $documento->idsede_destinazione,
|
2020-08-18 09:53:58 +02:00
|
|
|
'permetti_movimento_a_zero' => intval($documento->direzione == 'uscita'),
|
2020-08-17 16:25:01 +02:00
|
|
|
],
|
|
|
|
'iva' => [
|
|
|
|
'split_payment' => $documento['split_payment'],
|
|
|
|
],
|
|
|
|
],
|
2018-02-19 17:57:27 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
// Dati della riga
|
2020-07-06 13:19:20 +02:00
|
|
|
$id_riga = get('riga_id');
|
|
|
|
$type = get('riga_type');
|
2020-01-17 17:31:07 +01:00
|
|
|
$riga = $documento->getRiga($type, $id_riga);
|
2018-02-19 17:57:27 +01:00
|
|
|
|
2019-03-29 12:46:17 +01:00
|
|
|
$result = $riga->toArray();
|
2020-02-14 17:43:39 +01:00
|
|
|
$result['prezzo'] = $riga->prezzo_unitario;
|
2023-09-21 16:26:22 +02:00
|
|
|
if ($result['sconto'] == 0) {
|
|
|
|
$result['tipo_sconto'] = (setting('Tipo di sconto predefinito') == '%' ? 'PRC' : 'UNT');
|
|
|
|
}
|
2018-02-19 17:57:27 +01:00
|
|
|
// Importazione della gestione dedicata
|
|
|
|
$file = 'riga';
|
2019-03-29 12:46:17 +01:00
|
|
|
if ($riga->isDescrizione()) {
|
2018-02-19 17:57:27 +01:00
|
|
|
$file = 'descrizione';
|
2018-11-23 12:43:45 +01:00
|
|
|
|
2018-11-12 12:18:23 +01:00
|
|
|
$options['op'] = 'manage_descrizione';
|
2019-03-29 12:46:17 +01:00
|
|
|
} elseif ($riga->isArticolo()) {
|
2018-02-19 17:57:27 +01:00
|
|
|
$file = 'articolo';
|
2018-11-23 12:43:45 +01:00
|
|
|
|
2018-10-04 17:25:42 +02:00
|
|
|
$options['op'] = 'manage_articolo';
|
2019-03-29 12:46:17 +01:00
|
|
|
} elseif ($riga->isSconto()) {
|
|
|
|
$file = 'sconto';
|
|
|
|
|
|
|
|
$options['op'] = 'manage_sconto';
|
2018-02-19 17:57:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
echo App::load($file.'.php', $result, $options);
|