1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-27 00:06:14 +01:00
openstamanager/modules/contratti/row-add.php

87 lines
2.7 KiB
PHP
Raw Normal View History

<?php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* 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/>.
*/
2019-03-29 12:46:17 +01:00
use Modules\Contratti\Contratto;
include_once __DIR__.'/../../core.php';
// Info contratto
2019-03-29 12:46:17 +01:00
$documento = Contratto::find($id_record);
// Impostazioni per la gestione
$options = [
2019-05-04 06:19:08 +02:00
'op' => 'manage_riga',
'action' => 'add',
2019-03-29 12:46:17 +01:00
'dir' => $documento->direzione,
'idanagrafica' => $documento['idanagrafica'],
2019-07-11 17:44:42 +02:00
'totale_imponibile' => $documento->totale_imponibile,
2020-08-17 16:25:01 +02:00
'select-options' => [
'articoli' => [
'idanagrafica' => $documento->idanagrafica,
'dir' => $documento->direzione,
'permetti_movimento_a_zero' => 1,
2020-08-17 16:25:01 +02:00
],
],
];
// Dati di default
$result = [
'descrizione' => '',
'qta' => 1,
'um' => '',
'prezzo' => 0,
'sconto_unitario' => 0,
'tipo_sconto' => '',
'idiva' => '',
];
// 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_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');
// Importazione della gestione dedicata
$file = 'riga';
2018-07-19 15:33:32 +02:00
if (get('is_descrizione') !== null) {
$file = 'descrizione';
2019-05-04 06:19:08 +02:00
$options['op'] = 'manage_descrizione';
2018-07-19 15:33:32 +02:00
} elseif (get('is_articolo') !== null) {
$file = 'articolo';
2019-07-11 17:20:58 +02:00
// 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'])) {
2020-02-15 14:11:44 +01:00
$result['sconto_percentuale'] = $listino['prc_guadagno'];
2019-07-11 17:20:58 +02:00
$result['tipo_sconto'] = 'PRC';
}
2019-07-17 18:30:20 +02:00
2019-05-04 06:19:08 +02:00
$options['op'] = 'manage_articolo';
2019-03-29 12:46:17 +01:00
} elseif (get('is_sconto') !== null) {
$file = 'sconto';
$options['op'] = 'manage_sconto';
} elseif (get('is_barcode') !== null) {
$file = 'barcode';
$options['op'] = 'manage_barcode';
}
echo App::load($file.'.php', $result, $options);