mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-23 14:57:46 +01:00
Merge branch 'revisione-banche'
This commit is contained in:
commit
fd283988dc
@ -18,45 +18,47 @@
|
||||
*/
|
||||
|
||||
return [
|
||||
/*
|
||||
'modules/aggiornamenti' => 'Modules\Aggiornamenti',
|
||||
'modules/anagrafiche' => 'Modules\Anagrafiche',
|
||||
'modules/backups' => 'Modules\Backups',
|
||||
'modules/emails' => 'Modules\Emails',
|
||||
'modules/articoli' => 'Modules\Articoli',
|
||||
'modules/checklists' => 'Modules\Checklists',
|
||||
'modules/ritenute' => 'Modules\Ritenute',
|
||||
'modules/ritenute_contributi' => 'Modules\RitenuteContributi',
|
||||
'modules/rivalse' => 'Modules\Rivalse',
|
||||
'modules/newsletter' => 'Modules\Newsletter',
|
||||
'modules/iva' => 'Modules\Iva',
|
||||
'modules/ddt' => 'Modules\DDT',
|
||||
'modules/fatture' => 'Modules\Fatture',
|
||||
'modules/ordini' => 'Modules\Ordini',
|
||||
'modules/preventivi' => 'Modules\Preventivi',
|
||||
'modules/contratti' => 'Modules\Contratti',
|
||||
'modules/interventi' => 'Modules\Interventi',
|
||||
'modules/pagamenti' => 'Modules\Pagamenti',
|
||||
'modules/statistiche' => 'Modules\Statistiche',
|
||||
'modules/scadenzario' => 'Modules\Scadenzario',
|
||||
'modules/primanota' => 'Modules\PrimaNota',
|
||||
'modules/utenti' => 'Modules\Utenti',
|
||||
'modules/stato_servizi' => 'Modules\StatoServizi',
|
||||
'modules/stati_intervento' => 'Modules\StatiIntervento',
|
||||
'modules/stati_preventivo' => 'Modules\StatiPreventivo',
|
||||
'modules/stati_contratto' => 'Modules\StatiContratto',
|
||||
'modules/tipi_intervento' => 'Modules\TipiIntervento',
|
||||
'modules/categorie_documenti' => 'Modules\CategorieDocumentali',
|
||||
'modules/listini' => 'Modules\Listini',
|
||||
'modules/impianti' => 'Modules\Impianti',
|
||||
'modules/impostazioni' => 'Modules\Impostazioni',
|
||||
'plugins/exportFE' => 'Plugins\ExportFE',
|
||||
'plugins/importFE' => 'Plugins\ImportFE',
|
||||
'plugins/receiptFE' => 'Plugins\ReceiptFE',
|
||||
'plugins/dichiarazioni_intento' => 'Plugins\DichiarazioniIntento',
|
||||
'plugins/pianificazione_interventi' => 'Plugins\PianificazioneInterventi',
|
||||
'plugins/pianificazione_fatturazione' => 'Plugins\PianificazioneFatturazione',
|
||||
'plugins/statistiche_articoli' => 'Plugins\StatisticheArticoli',
|
||||
'plugins/dettagli_articolo' => 'Plugins\DettagliArticolo',
|
||||
*/
|
||||
'modules/banche' => 'Modules\Banche',
|
||||
];
|
||||
|
||||
/*
|
||||
'modules/aggiornamenti' => 'Modules\Aggiornamenti',
|
||||
'modules/anagrafiche' => 'Modules\Anagrafiche',
|
||||
'modules/backups' => 'Modules\Backups',
|
||||
'modules/emails' => 'Modules\Emails',
|
||||
'modules/articoli' => 'Modules\Articoli',
|
||||
'modules/checklists' => 'Modules\Checklists',
|
||||
'modules/ritenute' => 'Modules\Ritenute',
|
||||
'modules/ritenute_contributi' => 'Modules\RitenuteContributi',
|
||||
'modules/rivalse' => 'Modules\Rivalse',
|
||||
'modules/newsletter' => 'Modules\Newsletter',
|
||||
'modules/iva' => 'Modules\Iva',
|
||||
'modules/ddt' => 'Modules\DDT',
|
||||
'modules/fatture' => 'Modules\Fatture',
|
||||
'modules/ordini' => 'Modules\Ordini',
|
||||
'modules/preventivi' => 'Modules\Preventivi',
|
||||
'modules/contratti' => 'Modules\Contratti',
|
||||
'modules/interventi' => 'Modules\Interventi',
|
||||
'modules/pagamenti' => 'Modules\Pagamenti',
|
||||
'modules/statistiche' => 'Modules\Statistiche',
|
||||
'modules/scadenzario' => 'Modules\Scadenzario',
|
||||
'modules/primanota' => 'Modules\PrimaNota',
|
||||
'modules/utenti' => 'Modules\Utenti',
|
||||
'modules/stato_servizi' => 'Modules\StatoServizi',
|
||||
'modules/stati_intervento' => 'Modules\StatiIntervento',
|
||||
'modules/stati_preventivo' => 'Modules\StatiPreventivo',
|
||||
'modules/stati_contratto' => 'Modules\StatiContratto',
|
||||
'modules/tipi_intervento' => 'Modules\TipiIntervento',
|
||||
'modules/categorie_documenti' => 'Modules\CategorieDocumentali',
|
||||
'modules/listini' => 'Modules\Listini',
|
||||
'modules/impianti' => 'Modules\Impianti',
|
||||
'modules/impostazioni' => 'Modules\Impostazioni',
|
||||
'plugins/exportFE' => 'Plugins\ExportFE',
|
||||
'plugins/importFE' => 'Plugins\ImportFE',
|
||||
'plugins/receiptFE' => 'Plugins\ReceiptFE',
|
||||
'plugins/dichiarazioni_intento' => 'Plugins\DichiarazioniIntento',
|
||||
'plugins/pianificazione_interventi' => 'Plugins\PianificazioneInterventi',
|
||||
'plugins/pianificazione_fatturazione' => 'Plugins\PianificazioneFatturazione',
|
||||
'plugins/statistiche_articoli' => 'Plugins\StatisticheArticoli',
|
||||
'plugins/dettagli_articolo' => 'Plugins\DettagliArticolo',
|
||||
*/
|
||||
|
@ -39,7 +39,10 @@ if (!empty($id_record)) {
|
||||
]);
|
||||
Util\Query::setSegments(true);
|
||||
}
|
||||
$query = str_replace(['AND `deleted_at` IS NULL', '`deleted_at` IS NULL AND', '`deleted_at` IS NULL', 'AND deleted_at IS NULL', 'deleted_at IS NULL AND', 'deleted_at IS NULL'], '', $query);
|
||||
// Replace automatico del campo deleted_at se non specifico a una tabella
|
||||
if (!str_contains($query, '.`deleted_at`') && !str_contains($query, '.deleted_at')) {
|
||||
$query = str_replace(['AND `deleted_at` IS NULL', '`deleted_at` IS NULL AND', '`deleted_at` IS NULL', 'AND deleted_at IS NULL', 'deleted_at IS NULL AND', 'deleted_at IS NULL'], '', $query);
|
||||
}
|
||||
|
||||
$has_access = !empty($query) ? $dbo->fetchNum($query) !== 0 : true;
|
||||
|
||||
|
@ -334,7 +334,7 @@ switch ($resource) {
|
||||
* - idanagrafica
|
||||
*/
|
||||
case 'dichiarazioni_intento':
|
||||
$query = "SELECT id, CONCAT_WS(' - ', numero_protocollo, numero_progressivo) as descrizione FROM co_dichiarazioni_intento |where| ORDER BY data";
|
||||
$query = "SELECT id, CONCAT_WS(' - ', numero_protocollo, numero_progressivo) AS descrizione FROM co_dichiarazioni_intento |where| ORDER BY data";
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$filter[] = 'id='.prepare($element);
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Banche\Banca;
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
@ -379,7 +380,7 @@ if ($is_cliente or $is_fornitore or $is_tecnico) {
|
||||
|
||||
<div class="tab-content '.(!$is_cliente && !$is_fornitore && !$is_tecnico ? 'hide' : '').'">
|
||||
<div class="tab-pane '.(!$is_cliente && !$is_fornitore ? ' hide' : '').'" id="cliente_fornitore">
|
||||
<div class="row">
|
||||
<!--div class="row">
|
||||
<div class="col-md-6">
|
||||
{[ "type": "text", "label": "'.tr('Appoggio bancario').'", "name": "appoggiobancario", "value": "$appoggiobancario$" ]}
|
||||
</div>
|
||||
@ -388,6 +389,7 @@ if ($is_cliente or $is_fornitore or $is_tecnico) {
|
||||
{[ "type": "text", "label": "'.tr('Filiale banca').'", "name": "filiale", "value": "$filiale$" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{[ "type": "text", "label": "'.tr('Codice IBAN').'", "name": "codiceiban", "value": "$codiceiban$" ]}
|
||||
@ -396,7 +398,7 @@ if ($is_cliente or $is_fornitore or $is_tecnico) {
|
||||
<div class="col-md-6">
|
||||
{[ "type": "text", "label": "'.tr('Codice BIC').'", "name": "bic", "value": "$bic$" ]}
|
||||
</div>
|
||||
</div>
|
||||
</div-->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
@ -406,10 +408,36 @@ if ($is_cliente or $is_fornitore or $is_tecnico) {
|
||||
<div class="col-md-9">
|
||||
{[ "type": "text", "label": "'.tr('Dicitura fissa in fattura').'", "name": "diciturafissafattura", "value": "$diciturafissafattura$" ]}
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
</div>';
|
||||
|
||||
$banche = Banca::where('id_anagrafica', $anagrafica->id)->get();
|
||||
$banca_predefinita = $banche->first(function ($item) {
|
||||
return !empty($item['predefined']);
|
||||
});
|
||||
$modulo_banche = Modules::get('Banche');
|
||||
if (!$banche->isEmpty()) {
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<a href="'.base_path().'/editor.php?id_module='.$modulo_banche['id'].'&id_record='.$banca_predefinita->id.'">
|
||||
'.tr("Visualizza la banca predefinita per l'Anagrafica").' <i class="fa fa-external-link"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<a href="'.base_path().'/controller.php?id_module='.$modulo_banche['id'].'&search_Anagrafica='.rawurlencode($anagrafica['ragione_sociale']).'">
|
||||
'.tr("Visualizza le banche disponibili per l'Anagrafica").' <i class="fa fa-external-link"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>';
|
||||
} else {
|
||||
echo '
|
||||
<p>'.tr("Nessuna banca disponibile per l'Anagrafica").'</p>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</div>
|
||||
|
||||
<div class="tab-pane '.(!$is_cliente ? 'hide' : 'active').'" id="cliente">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
@ -427,7 +455,7 @@ if ($is_cliente or $is_fornitore or $is_tecnico) {
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "'.tr('Banca predefinita').'", "name": "idbanca_vendite", "values": "query=SELECT id, nome AS descrizione FROM co_banche WHERE deleted_at IS NULL ORDER BY nome ASC", "value": "$idbanca_vendite$", "icon-after": "add|'.Modules::get('Banche')['id'].'", "help": "'.tr('Banca predefinita su cui accreditare i pagamenti.').'" ]}
|
||||
{[ "type": "select", "label": "'.tr('Banca predefinita per accrediti').'", "name": "idbanca_vendite", "ajax-source": "banche", "select-options": '.json_encode(['id_anagrafica' => $anagrafica_azienda->id]).', "value": "$idbanca_vendite$", "help": "'.tr("Banca predefinita dell'Azienda su cui accreditare i pagamenti").'" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -462,7 +490,7 @@ if ($is_cliente or $is_fornitore or $is_tecnico) {
|
||||
</div>';
|
||||
|
||||
// Collegamento con il conto
|
||||
$conto = $dbo->fetchOne('SELECT co_pianodeiconti3.id, co_pianodeiconti2.numero as numero, co_pianodeiconti3.numero as numero_conto, co_pianodeiconti3.descrizione as descrizione FROM co_pianodeiconti3 INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE co_pianodeiconti3.id = '.prepare($record['idconto_cliente']));
|
||||
$conto = $dbo->fetchOne('SELECT co_pianodeiconti3.id, co_pianodeiconti2.numero as numero, co_pianodeiconti3.numero as numero_conto, co_pianodeiconti3.descrizione AS descrizione FROM co_pianodeiconti3 INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE co_pianodeiconti3.id = '.prepare($record['idconto_cliente']));
|
||||
|
||||
echo '
|
||||
<div class="row">
|
||||
@ -489,7 +517,7 @@ if ($is_cliente or $is_fornitore or $is_tecnico) {
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "'.tr('Banca predefinita').'", "name": "idbanca_acquisti", "values": "query=SELECT id, nome AS descrizione FROM co_banche ORDER BY nome ASC", "value": "$idbanca_acquisti$", "icon-after": "add|'.Modules::get('Banche')['id'].'" ]}
|
||||
{[ "type": "select", "label": "'.tr('Banca predefinita per addebiti').'", "name": "idbanca_acquisti", "ajax-source": "banche", "select-options": '.json_encode(['id_anagrafica' => $anagrafica_azienda->id]).', "value": "$idbanca_acquisti$", "help": "'.tr("Banca predefinita dell'Azienda da cui addebitare i pagamenti").'" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -509,7 +537,7 @@ if ($is_cliente or $is_fornitore or $is_tecnico) {
|
||||
</div>';
|
||||
|
||||
// Collegamento con il conto
|
||||
$conto = $dbo->fetchOne('SELECT co_pianodeiconti3.id, co_pianodeiconti2.numero as numero, co_pianodeiconti3.numero as numero_conto, co_pianodeiconti3.descrizione as descrizione FROM co_pianodeiconti3 INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE co_pianodeiconti3.id = '.prepare($record['idconto_fornitore']));
|
||||
$conto = $dbo->fetchOne('SELECT co_pianodeiconti3.id, co_pianodeiconti2.numero as numero, co_pianodeiconti3.numero as numero_conto, co_pianodeiconti3.descrizione AS descrizione FROM co_pianodeiconti3 INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE co_pianodeiconti3.id = '.prepare($record['idconto_fornitore']));
|
||||
|
||||
echo '
|
||||
<div class="col-md-6">
|
||||
@ -562,7 +590,6 @@ if ($is_cliente or $is_fornitore or $is_tecnico) {
|
||||
]); ?>" ]}
|
||||
</div>
|
||||
|
||||
|
||||
<!-- campi già specificati in Codice R.E.A., da eliminare nelle prossime release -->
|
||||
<!--div class="col-md-3">
|
||||
{[ "type": "text", "label": "<?php echo tr('Num. iscr. C.C.I.A.A.'); ?>", "name": "cciaa", "value": "$cciaa$" ]}
|
||||
@ -571,8 +598,8 @@ if ($is_cliente or $is_fornitore or $is_tecnico) {
|
||||
<div class="col-md-3">
|
||||
{[ "type": "text", "label": "<?php echo tr('Città iscr. C.C.I.A.A.'); ?>", "name": "cciaa_citta", "value": "$cciaa_citta$" ]}
|
||||
</div-->
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
{[ "type": "text", "label": "<?php echo tr('Num. iscr. tribunale'); ?>", "name": "iscrizione_tribunale", "value": "$iscrizione_tribunale$" ]}
|
||||
|
@ -17,59 +17,57 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Banche\Banca;
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
switch (filter('op')) {
|
||||
case 'update':
|
||||
case 'add':
|
||||
$id_anagrafica = filter('id_anagrafica');
|
||||
$anagrafica = Anagrafica::find($id_anagrafica);
|
||||
|
||||
$nome = filter('nome');
|
||||
$iban = filter('iban');
|
||||
$bic = filter('bic');
|
||||
|
||||
if (isset($nome)) {
|
||||
$array = [
|
||||
'nome' => $nome,
|
||||
'filiale' => post('filiale'),
|
||||
'iban' => post('iban'),
|
||||
'bic' => post('bic'),
|
||||
'id_pianodeiconti3' => post('id_pianodeiconti3'),
|
||||
'note' => post('note'),
|
||||
];
|
||||
$banca = Banca::build($anagrafica, $nome, $iban, $bic);
|
||||
$id_record = $banca->id;
|
||||
|
||||
if (!empty($id_record)) {
|
||||
$dbo->update('co_banche', $array, ['id' => $id_record]);
|
||||
}
|
||||
|
||||
flash()->info(tr('Salvataggio completato.'));
|
||||
} else {
|
||||
flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!'));
|
||||
if (isAjaxRequest()) {
|
||||
echo json_encode([
|
||||
'id' => $id_record,
|
||||
'text' => $nome,
|
||||
]);
|
||||
}
|
||||
|
||||
flash()->info(tr('Aggiunta nuova _TYPE_', [
|
||||
'_TYPE_' => 'banca',
|
||||
]));
|
||||
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
case 'update':
|
||||
$nome = filter('nome');
|
||||
$bic = filter('bic');
|
||||
$iban = filter('iban');
|
||||
|
||||
if (isset($nome)) {
|
||||
$dbo->query('INSERT INTO `co_banche` (`nome`, `bic`, `iban`) VALUES ('.prepare($nome).', '.prepare($bic).', '.prepare($iban).')');
|
||||
$id_record = $dbo->lastInsertedID();
|
||||
$banca->nome = post('nome');
|
||||
$banca->iban = post('iban');
|
||||
$banca->bic = post('bic');
|
||||
|
||||
if (isAjaxRequest()) {
|
||||
echo json_encode(['id' => $id_record, 'text' => $nome]);
|
||||
}
|
||||
$banca->note = post('note');
|
||||
$banca->id_pianodeiconti3 = post('id_pianodeiconti3');
|
||||
$banca->filiale = post('filiale');
|
||||
|
||||
flash()->info(tr('Aggiunta nuova _TYPE_', [
|
||||
'_TYPE_' => 'banca',
|
||||
]));
|
||||
} else {
|
||||
flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!'));
|
||||
}
|
||||
$banca->predefined = post('predefined');
|
||||
|
||||
$banca->save();
|
||||
|
||||
flash()->info(tr('Salvataggio completato'));
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$dbo->update('co_banche', [
|
||||
'deleted_at' => date('Y-m-d H:i:s'),
|
||||
], ['id' => $id_record]);
|
||||
$banca->delete();
|
||||
|
||||
flash()->info(tr('_TYPE_ eliminata con successo!', [
|
||||
'_TYPE_' => 'Banca',
|
||||
|
@ -19,29 +19,38 @@
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
?><form action="" method="post" id="add-form">
|
||||
$id_anagrafica = filter('id_anagrafica');
|
||||
|
||||
echo '
|
||||
<form action="" method="post" id="add-form">
|
||||
<input type="hidden" name="op" value="add">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": "1" ]}
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "'.tr('Anagrafica').'", "name": "id_anagrafica", "required": "1", "value": "$id_anagrafica$", "ajax-source": "anagrafiche", "value": "'.$id_anagrafica.'", "disabled": "'.intval(!empty($id_anagrafica)).'" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "text", "label": "'.tr('Nome').'", "name": "nome", "required": "1" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{[ "type": "text", "label": "<?php echo tr('IBAN'); ?>", "name": "iban", "required": "1", "class": "alphanumeric-mask", "maxlength": 32, "value": "$iban$" ]}
|
||||
{[ "type": "text", "label": "'.tr('IBAN').'", "name": "iban", "required": "1", "class": "alphanumeric-mask", "maxlength": 32, "value": "$iban$" ]}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('BIC'); ?>", "name": "bic", "class": "alphanumeric-mask", "maxlength": 11, "value": "$bic$" ]}
|
||||
{[ "type": "text", "label": "'.tr('BIC').'", "name": "bic", "required": "1", "class": "alphanumeric-mask", "maxlength": 11, "value": "$bic$" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fa fa-plus"></i> '.tr('Aggiungi').'
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>';
|
||||
|
47
modules/banche/ajax/select.php
Normal file
47
modules/banche/ajax/select.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
include_once __DIR__.'/../../../core.php';
|
||||
|
||||
switch ($resource) {
|
||||
/*
|
||||
* Opzioni utilizzate:
|
||||
* - id_anagrafica
|
||||
*/
|
||||
case 'banche':
|
||||
$query = "SELECT id, CONCAT (nome, ' - ' , iban) AS descrizione FROM co_banche |where| ORDER BY nome";
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$filter[] = 'id = '.prepare($element);
|
||||
}
|
||||
|
||||
if (empty($filter)) {
|
||||
$where[] = 'deleted_at IS NULL';
|
||||
}
|
||||
|
||||
$where[] = 'id_anagrafica='.prepare($superselect['id_anagrafica']);
|
||||
|
||||
if (!empty($search)) {
|
||||
$search_fields[] = 'nome LIKE '.prepare('%'.$search.'%');
|
||||
$search_fields[] = 'filiale LIKE '.prepare('%'.$search.'%');
|
||||
$search_fields[] = 'iban LIKE '.prepare('%'.$search.'%');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
@ -20,7 +20,6 @@
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
?><form action="" method="post" id="edit-form">
|
||||
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="op" value="update">
|
||||
|
||||
@ -32,24 +31,39 @@ include_once __DIR__.'/../../core.php';
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": "1", "value": "$nome$" ]}
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "<?php echo tr('Anagrafica'); ?>", "name": "id_anagrafica", "required": "1", "value": "$id_anagrafica$", "ajax-source": "anagrafiche", "disabled": 1 ]}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "checkbox", "label": "<?php echo tr('Predefinito'); ?>", "name": "predefined", "value": "$predefined$", "disabled": "<?php echo intval($record['predefined']); ?>" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": "1", "value": "$nome$" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{[ "type": "text", "label": "<?php echo tr('Filiale'); ?>", "name": "filiale", "value": "$filiale$" ]}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "<?php echo tr('Conto predefinito'); ?>", "name": "id_pianodeiconti3", "value": "$id_pianodeiconti3$", "values": "query=SELECT id, descrizione FROM co_pianodeiconti3 WHERE idpianodeiconti2 = 1" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{[ "type": "text", "label": "<?php echo tr('IBAN'); ?>", "name": "iban", "required": "1", "class": "alphanumeric-mask", "maxlength": 32, "value": "$iban$" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('BIC'); ?>", "name": "bic", "class": "alphanumeric-mask", "maxlength": 11, "value": "$bic$" ]}
|
||||
{[ "type": "text", "label": "<?php echo tr('BIC'); ?>", "name": "bic", "required": "1", "class": "alphanumeric-mask", "maxlength": 11, "value": "$bic$" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "textarea", "label": "<?php echo tr('Note'); ?>", "name": "note", "value": "$note$" ]}
|
||||
@ -62,15 +76,15 @@ include_once __DIR__.'/../../core.php';
|
||||
|
||||
<?php
|
||||
// Collegamenti diretti (numerici)
|
||||
$documenti = $dbo->fetchNum('SELECT idanagrafica FROM an_anagrafiche WHERE idbanca_vendite='.prepare($id_record).'
|
||||
$numero_documenti = $dbo->fetchNum('SELECT idanagrafica FROM an_anagrafiche WHERE idbanca_vendite='.prepare($id_record).'
|
||||
UNION SELECT idanagrafica FROM an_anagrafiche WHERE idbanca_acquisti='.prepare($id_record).'
|
||||
UNION SELECT idanagrafica FROM co_documenti WHERE idbanca='.prepare($id_record));
|
||||
UNION SELECT idanagrafica FROM co_documenti WHERE id_banca_azienda = '.prepare($id_record).' OR id_banca_controparte = '.prepare($id_record));
|
||||
|
||||
if (!empty($documenti)) {
|
||||
if (!empty($numero_documenti)) {
|
||||
echo '
|
||||
<div class="alert alert-danger">
|
||||
'.tr('Ci sono _NUM_ documenti collegati', [
|
||||
'_NUM_' => count($documenti),
|
||||
'_NUM_' => $numero_documenti,
|
||||
]).'.
|
||||
</div>';
|
||||
}
|
||||
|
@ -17,8 +17,12 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Modules\Banche\Banca;
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
if (isset($id_record)) {
|
||||
$record = $dbo->fetchOne('SELECT * FROM `co_banche` WHERE id='.prepare($id_record));
|
||||
$banca = Banca::find($id_record);
|
||||
|
||||
$record = $banca->toArray();
|
||||
}
|
||||
|
93
modules/banche/src/Banca.php
Normal file
93
modules/banche/src/Banca.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Modules\Banche;
|
||||
|
||||
use Common\SimpleModelTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
|
||||
class Banca extends Model
|
||||
{
|
||||
use SimpleModelTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'co_banche';
|
||||
|
||||
/**
|
||||
* Crea una nuovo banca.
|
||||
*
|
||||
* @param string $nome
|
||||
* @param string $iban
|
||||
* @param string $bic
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function build(Anagrafica $anagrafica, $nome, $iban, $bic)
|
||||
{
|
||||
$model = new static();
|
||||
|
||||
// Informazioni di base
|
||||
$model->anagrafica()->associate($anagrafica);
|
||||
$model->nome = $nome;
|
||||
$model->iban = $iban;
|
||||
$model->bic = $bic;
|
||||
|
||||
// Salvataggio delle informazioni
|
||||
$model->save();
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function anagrafica()
|
||||
{
|
||||
return $this->belongsTo(Anagrafica::class, 'id_anagrafica');
|
||||
}
|
||||
|
||||
public function save(array $options = [])
|
||||
{
|
||||
$this->fixPredefined();
|
||||
|
||||
return parent::save($options);
|
||||
}
|
||||
|
||||
protected function fixPredefined()
|
||||
{
|
||||
$predefined = isset($this->predefined) ? $this->predefined : false;
|
||||
|
||||
// Selezione automatica per primo record
|
||||
$count = self::where('id_anagrafica', $this->id_anagrafica)
|
||||
->where('id', '!=', $this->id)
|
||||
->count();
|
||||
if (empty($predefined) && empty($count)) {
|
||||
$predefined = true;
|
||||
}
|
||||
|
||||
if (!empty($predefined)) {
|
||||
self::where('id_anagrafica', $this->id_anagrafica)
|
||||
->where('id', '!=', $this->id)
|
||||
->update([
|
||||
'predefined' => 0,
|
||||
]);
|
||||
|
||||
$this->attributes['predefined'] = $predefined;
|
||||
}
|
||||
}
|
||||
}
|
@ -43,15 +43,15 @@ include_once __DIR__.'/../../core.php';
|
||||
|
||||
<?php
|
||||
// Collegamenti diretti (numerici)
|
||||
$documenti = $dbo->fetchNum('SELECT id FROM dt_ddt WHERE idaspettobeni='.prepare($id_record).'
|
||||
$numero_documenti = $dbo->fetchNum('SELECT id FROM dt_ddt WHERE idaspettobeni='.prepare($id_record).'
|
||||
|
||||
UNION SELECT id FROM co_documenti WHERE idaspettobeni='.prepare($id_record));
|
||||
|
||||
if (!empty($documenti)) {
|
||||
if (!empty($numero_documenti)) {
|
||||
echo '
|
||||
<div class="alert alert-danger">
|
||||
'.tr('Ci sono _NUM_ documenti collegati', [
|
||||
'_NUM_' => count($documenti),
|
||||
'_NUM_' => $numero_documenti,
|
||||
]).'.
|
||||
</div>';
|
||||
}
|
||||
|
@ -54,14 +54,14 @@ include_once __DIR__.'/../../core.php';
|
||||
|
||||
<?php
|
||||
// Collegamenti diretti (numerici)
|
||||
$documenti = $dbo->fetchNum('SELECT id FROM dt_ddt WHERE idcausalet='.prepare($id_record).'
|
||||
$numero_documenti = $dbo->fetchNum('SELECT id FROM dt_ddt WHERE idcausalet='.prepare($id_record).'
|
||||
UNION SELECT id FROM co_documenti WHERE idcausalet='.prepare($id_record));
|
||||
|
||||
if (!empty($documenti)) {
|
||||
if (!empty($numero_documenti)) {
|
||||
echo '
|
||||
<div class="alert alert-danger">
|
||||
'.tr('Ci sono _NUM_ documenti collegati', [
|
||||
'_NUM_' => count($documenti),
|
||||
'_NUM_' => $numero_documenti,
|
||||
]).'.
|
||||
</div>';
|
||||
}
|
||||
|
@ -20,8 +20,6 @@
|
||||
namespace Modules\DDT\Components;
|
||||
|
||||
use Common\Components\Article;
|
||||
use Modules\Articoli\Articolo as Original;
|
||||
use Modules\DDT\DDT;
|
||||
|
||||
class Articolo extends Article
|
||||
{
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace Modules\DDT\Components;
|
||||
|
||||
use Common\Components\Description;
|
||||
use Modules\DDT\DDT;
|
||||
|
||||
class Descrizione extends Description
|
||||
{
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace Modules\DDT\Components;
|
||||
|
||||
use Common\Components\Row;
|
||||
use Modules\DDT\DDT;
|
||||
|
||||
class Riga extends Row
|
||||
{
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace Modules\DDT\Components;
|
||||
|
||||
use Common\Components\Discount;
|
||||
use Modules\DDT\DDT;
|
||||
|
||||
class Sconto extends Discount
|
||||
{
|
||||
|
@ -89,7 +89,8 @@ switch (post('op')) {
|
||||
$fattura->idanagrafica = post('idanagrafica');
|
||||
$fattura->idagente = post('idagente');
|
||||
$fattura->idpagamento = post('idpagamento');
|
||||
$fattura->idbanca = post('idbanca');
|
||||
$fattura->id_banca_azienda = post('id_banca_azienda');
|
||||
$fattura->id_banca_controparte = post('id_banca_controparte');
|
||||
$fattura->idcausalet = post('idcausalet');
|
||||
$fattura->idspedizione = post('idspedizione');
|
||||
$fattura->idporto = post('idporto');
|
||||
@ -753,7 +754,8 @@ switch (post('op')) {
|
||||
$nota->ref_documento = $fattura->id;
|
||||
$nota->idconto = $fattura->idconto;
|
||||
$nota->idpagamento = $fattura->idpagamento;
|
||||
$nota->idbanca = $fattura->idbanca;
|
||||
$nota->id_banca_azienda = $fattura->id_banca_azienda;
|
||||
$nota->id_banca_controparte = $fattura->id_banca_controparte;
|
||||
$nota->idsede_partenza = $fattura->idsede_partenza;
|
||||
$nota->idsede_destinazione = $fattura->idsede_destinazione;
|
||||
$nota->split_payment = $fattura->split_payment;
|
||||
@ -809,7 +811,8 @@ if (get('op') == 'nota_addebito') {
|
||||
$nota->ref_documento = $fattura->id;
|
||||
$nota->idconto = $fattura->idconto;
|
||||
$nota->idpagamento = $fattura->idpagamento;
|
||||
$nota->idbanca = $fattura->idbanca;
|
||||
$nota->id_banca_azienda = $fattura->id_banca_azienda;
|
||||
$nota->id_banca_controparte = $fattura->id_banca_controparte;
|
||||
$nota->idsede_partenza = $fattura->idsede_partenza;
|
||||
$nota->idsede_destinazione = $fattura->idsede_destinazione;
|
||||
$nota->save();
|
||||
|
@ -17,10 +17,13 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Iva\Aliquota;
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$anagrafica_azienda = Anagrafica::find(setting('Azienda predefinita'));
|
||||
|
||||
$block_edit = !empty($note_accredito) || $record['stato'] == 'Emessa' || $record['stato'] == 'Pagato' || $record['stato'] == 'Parzialmente pagato';
|
||||
|
||||
$rs = $dbo->fetchArray('SELECT co_tipidocumento.descrizione, dir FROM co_tipidocumento INNER JOIN co_documenti ON co_tipidocumento.id=co_documenti.idtipodocumento WHERE co_documenti.id='.prepare($id_record));
|
||||
@ -263,11 +266,11 @@ elseif ($record['stato'] == 'Bozza') {
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "<?php echo tr('Pagamento'); ?>", "name": "idpagamento", "required": 1, "ajax-source": "pagamenti", "value": "$idpagamento$", "extra": "onchange=\"$('#idbanca').val($(this).selectData().id_banca_<?php echo $conto; ?>).change(); \" " ]}
|
||||
{[ "type": "select", "label": "<?php echo tr('Pagamento'); ?>", "name": "idpagamento", "required": 1, "ajax-source": "pagamenti", "value": "$idpagamento$", "extra": "onchange=\"$('#id_banca_azienda').val($(this).selectData().id_banca_<?php echo $conto; ?>).change(); \" " ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "<?php echo tr('Banca'); ?>", "name": "idbanca", "values": "query=SELECT id, CONCAT (nome, ' - ' , iban) AS descrizione FROM co_banche WHERE deleted_at IS NULL ORDER BY nome ASC", "value": "$idbanca$", "icon-after": "add|<?php echo Modules::get('Banche')['id']; ?>||", "extra": " <?php echo (intval($block_edit)) ? 'disabled' : ''; ?> " ]}
|
||||
{[ "type": "select", "label": "<?php echo tr('Banca azienda'); ?>", "name": "id_banca_azienda", "ajax-source": "banche", "select-options": <?php echo json_encode(['id_anagrafica' => $anagrafica_azienda->id]); ?>, "value": "$id_banca_azienda$", "icon-after": "add|<?php echo Modules::get('Banche')['id']; ?>||", "extra": " <?php echo (intval($block_edit)) ? 'disabled' : ''; ?> " ]}
|
||||
</div>
|
||||
|
||||
<?php
|
||||
@ -335,7 +338,7 @@ elseif ($record['stato'] == 'Bozza') {
|
||||
</div>
|
||||
|
||||
<?php
|
||||
//TODO: Fattura per conto del fornitore (es. cooperative agricole che emettono la fattura per conto dei propri soci produttori agricoli conferenti)
|
||||
// TODO: Fattura per conto del fornitore (es. cooperative agricole che emettono la fattura per conto dei propri soci produttori agricoli conferenti)
|
||||
if ($dir == 'entrata') {
|
||||
?>
|
||||
<div class="col-md-3">
|
||||
|
@ -25,6 +25,7 @@ use Common\Components\Component;
|
||||
use Common\Document;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Banche\Banca;
|
||||
use Modules\Fatture\Gestori\Bollo as GestoreBollo;
|
||||
use Modules\Fatture\Gestori\Movimenti as GestoreMovimenti;
|
||||
use Modules\Fatture\Gestori\Scadenze as GestoreScadenze;
|
||||
@ -89,12 +90,13 @@ class Fattura extends Document
|
||||
$model = new static();
|
||||
|
||||
$user = Auth::user();
|
||||
$database = database();
|
||||
|
||||
// Individuazione dello stato predefinito per il documento
|
||||
$stato_documento = Stato::where('descrizione', 'Bozza')->first();
|
||||
$direzione = $tipo_documento->dir;
|
||||
|
||||
$database = database();
|
||||
|
||||
// Conto predefinito sulla base del flusso di denaro
|
||||
if ($direzione == 'entrata') {
|
||||
$id_conto = setting('Conto predefinito fatture di vendita');
|
||||
$conto = 'vendite';
|
||||
@ -103,6 +105,7 @@ class Fattura extends Document
|
||||
$conto = 'acquisti';
|
||||
}
|
||||
|
||||
// Informazioni di base
|
||||
$model->anagrafica()->associate($anagrafica);
|
||||
$model->tipo()->associate($tipo_documento);
|
||||
$model->stato()->associate($stato_documento);
|
||||
@ -114,55 +117,65 @@ class Fattura extends Document
|
||||
$model->data_registrazione = $data;
|
||||
$model->data_competenza = $data;
|
||||
$model->id_segment = $id_segment;
|
||||
$model->idconto = $id_conto;
|
||||
if ($numero_esterno) {
|
||||
$model->numero_esterno = $numero_esterno;
|
||||
}
|
||||
|
||||
$model->idconto = $id_conto;
|
||||
|
||||
// Imposto, come sede aziendale, la prima sede disponibile come utente
|
||||
// Sede aziendale scelta tra le sedi disponibili per l'utente
|
||||
$id_sede = $user->sedi[0];
|
||||
if ($direzione == 'entrata') {
|
||||
$model->idsede_destinazione = $user->sedi[0];
|
||||
$model->idsede_destinazione = $id_sede;
|
||||
} else {
|
||||
$model->idsede_partenza = $user->sedi[0];
|
||||
$model->idsede_partenza = $id_sede;
|
||||
}
|
||||
|
||||
// Gestione della marca da bollo predefinita
|
||||
$model->addebita_bollo = setting('Addebita marca da bollo al cliente');
|
||||
|
||||
// Ritenuta contributi predefinita
|
||||
$id_ritenuta_contributi = ($tipo_documento->dir == 'entrata') ? setting('Ritenuta contributi') : null;
|
||||
$model->id_ritenuta_contributi = $id_ritenuta_contributi ?: null;
|
||||
|
||||
// Tipo di pagamento e banca predefinite dall'anagrafica
|
||||
$id_pagamento = $database->fetchOne('SELECT id FROM co_pagamenti WHERE id = :id_pagamento', [
|
||||
':id_pagamento' => $anagrafica['idpagamento_'.$conto],
|
||||
])['id'];
|
||||
$id_banca = $anagrafica['idbanca_'.$conto];
|
||||
// Banca predefinita per l'anagrafica controparte
|
||||
//$model->id_banca_controparte = ;
|
||||
|
||||
// Se la fattura è di vendita e non è stato associato un pagamento predefinito al cliente leggo il pagamento dalle impostazioni
|
||||
// Tipo di pagamento dall'anagrafica controparte
|
||||
$id_pagamento = $database->fetchOne('SELECT id FROM co_pagamenti WHERE id = :id_pagamento', [
|
||||
':id_pagamento' => $anagrafica->{'idpagamento_'.$conto},
|
||||
])['id'];
|
||||
|
||||
// Per Fatture di Vendita senza pagamento predefinito per il Cliente, si utilizza il pagamento predefinito dalle Impostazioni
|
||||
if ($direzione == 'entrata' && empty($id_pagamento)) {
|
||||
$id_pagamento = setting('Tipo di pagamento predefinito');
|
||||
}
|
||||
|
||||
// Se non è impostata la banca dell'anagrafica, uso quella del pagamento.
|
||||
if (empty($id_banca)) {
|
||||
$id_banca = $database->fetchOne('SELECT id FROM co_banche WHERE id_pianodeiconti3 = (SELECT idconto_'.$conto.' FROM co_pagamenti WHERE id = :id_pagamento)', [
|
||||
':id_pagamento' => $id_pagamento,
|
||||
])['id'];
|
||||
}
|
||||
|
||||
// Salvataggio del pagamento
|
||||
if (!empty($id_pagamento)) {
|
||||
$model->idpagamento = $id_pagamento;
|
||||
}
|
||||
if (!empty($id_banca)) {
|
||||
$model->idbanca = $id_banca;
|
||||
|
||||
// Banca predefinita per l'azienda, con ricerca della banca impostata per il pagamento
|
||||
$id_banca_azienda = $anagrafica->{'idbanca_'.$conto};
|
||||
if (empty($id_banca_azienda)) {
|
||||
$azienda = Anagrafica::find(setting('Azienda predefinita'));
|
||||
$id_banca_azienda = $database->fetchOne('SELECT id FROM co_banche WHERE id_pianodeiconti3 = (SELECT idconto_'.$conto.' FROM co_pagamenti WHERE id = :id_pagamento) AND id_anagrafica = :id_anagrafica', [
|
||||
':id_pagamento' => $id_pagamento,
|
||||
':id_anagrafica' => $azienda->id,
|
||||
])['id'];
|
||||
if (empty($id_banca_azienda)) {
|
||||
$id_banca_azienda = $azienda->{'idbanca_'.$conto};
|
||||
}
|
||||
$model->id_banca_azienda = $id_banca_azienda;
|
||||
}
|
||||
|
||||
// Split Payment
|
||||
// Gestione dello Split Payment sulla base dell'anagrafica Controparte
|
||||
$split_payment = $anagrafica->split_payment;
|
||||
if (!empty($split_payment)) {
|
||||
$model->split_payment = $split_payment;
|
||||
}
|
||||
|
||||
// Dichiarazione d'Intento
|
||||
// Gestione della Dichiarazione d'Intento associata all'anargafica Controparte
|
||||
$now = new Carbon();
|
||||
$dichiarazione = $anagrafica->dichiarazioni()
|
||||
->where('massimale', '>', 'totale')
|
||||
@ -172,6 +185,7 @@ class Fattura extends Document
|
||||
if (!empty($dichiarazione)) {
|
||||
$model->dichiarazione()->associate($dichiarazione);
|
||||
|
||||
// Registrazione dell'operazione nelle note
|
||||
$model->note = tr("Operazione non imponibile come da vostra dichiarazione d'intento nr _PROT_ del _PROT_DATE_ emessa in data _RELEASE_DATE_, da noi registrata al nr _ID_ del _DATE_", [
|
||||
'_PROT_' => $dichiarazione->numero_protocollo,
|
||||
'_PROT_DATE_' => $dichiarazione->data_protocollo,
|
||||
@ -641,12 +655,14 @@ class Fattura extends Document
|
||||
$riba = database()->fetchOne('SELECT riba FROM co_pagamenti WHERE id ='.prepare($this->idpagamento));
|
||||
|
||||
if ($riba['riba'] == 1) {
|
||||
$result = database()->fetchOne('SELECT codiceiban, appoggiobancario, bic FROM an_anagrafiche WHERE idanagrafica ='.prepare($this->idanagrafica));
|
||||
$banca = Banca::where('id_anagrafica', $this->idanagrafica)
|
||||
->where('predefined', 1)
|
||||
->first();
|
||||
} else {
|
||||
$result = database()->fetchOne('SELECT iban AS codiceiban, nome AS appoggiobancario, bic FROM co_banche WHERE id='.prepare($this->idbanca));
|
||||
$banca = Banca::find($this->id_banca_azienda);
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $banca;
|
||||
}
|
||||
|
||||
// Metodi statici
|
||||
|
@ -20,8 +20,6 @@
|
||||
namespace Modules\Interventi\Components;
|
||||
|
||||
use Common\Components\Article;
|
||||
use Modules\Articoli\Articolo as Original;
|
||||
use Modules\Interventi\Intervento;
|
||||
|
||||
class Articolo extends Article
|
||||
{
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace Modules\Interventi\Components;
|
||||
|
||||
use Common\Components\Row;
|
||||
use Modules\Interventi\Intervento;
|
||||
|
||||
class Riga extends Row
|
||||
{
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace Modules\Interventi\Components;
|
||||
|
||||
use Common\Components\Discount;
|
||||
use Modules\Interventi\Intervento;
|
||||
|
||||
class Sconto extends Discount
|
||||
{
|
||||
|
@ -20,8 +20,6 @@
|
||||
namespace Modules\Ordini\Components;
|
||||
|
||||
use Common\Components\Article;
|
||||
use Modules\Articoli\Articolo as Original;
|
||||
use Modules\Ordini\Ordine;
|
||||
|
||||
class Articolo extends Article
|
||||
{
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace Modules\Ordini\Components;
|
||||
|
||||
use Common\Components\Description;
|
||||
use Modules\Ordini\Ordine;
|
||||
|
||||
class Descrizione extends Description
|
||||
{
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace Modules\Ordini\Components;
|
||||
|
||||
use Common\Components\Row;
|
||||
use Modules\Ordini\Ordine;
|
||||
|
||||
class Riga extends Row
|
||||
{
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace Modules\Ordini\Components;
|
||||
|
||||
use Common\Components\Discount;
|
||||
use Modules\Ordini\Ordine;
|
||||
|
||||
class Sconto extends Discount
|
||||
{
|
||||
|
@ -46,15 +46,15 @@ include_once __DIR__.'/../../core.php';
|
||||
|
||||
<?php
|
||||
// Collegamenti diretti (numerici)
|
||||
$documenti = $dbo->fetchNum('SELECT id FROM dt_ddt WHERE idporto='.prepare($id_record).'
|
||||
$numero_documenti = $dbo->fetchNum('SELECT id FROM dt_ddt WHERE idporto='.prepare($id_record).'
|
||||
UNION SELECT id FROM co_documenti WHERE idporto='.prepare($id_record).'
|
||||
UNION SELECT id FROM co_preventivi WHERE idporto='.prepare($id_record));
|
||||
|
||||
if (!empty($documenti)) {
|
||||
if (!empty($numero_documenti)) {
|
||||
echo '
|
||||
<div class="alert alert-danger">
|
||||
'.tr('Ci sono _NUM_ documenti collegati', [
|
||||
'_NUM_' => count($documenti),
|
||||
'_NUM_' => $numero_documenti,
|
||||
]).'.
|
||||
</div>';
|
||||
}
|
||||
|
@ -20,8 +20,6 @@
|
||||
namespace Modules\Preventivi\Components;
|
||||
|
||||
use Common\Components\Article;
|
||||
use Modules\Articoli\Articolo as Original;
|
||||
use Modules\Preventivi\Preventivo;
|
||||
|
||||
class Articolo extends Article
|
||||
{
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace Modules\Preventivi\Components;
|
||||
|
||||
use Common\Components\Description;
|
||||
use Modules\Preventivi\Preventivo;
|
||||
|
||||
class Descrizione extends Description
|
||||
{
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace Modules\Preventivi\Components;
|
||||
|
||||
use Common\Components\Row;
|
||||
use Modules\Preventivi\Preventivo;
|
||||
|
||||
class Riga extends Row
|
||||
{
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace Modules\Preventivi\Components;
|
||||
|
||||
use Common\Components\Discount;
|
||||
use Modules\Preventivi\Preventivo;
|
||||
|
||||
class Sconto extends Discount
|
||||
{
|
||||
|
@ -46,14 +46,14 @@ include_once __DIR__.'/../../core.php';
|
||||
|
||||
<?php
|
||||
// Collegamenti diretti (numerici)
|
||||
$documenti = $dbo->fetchNum('SELECT id FROM dt_ddt WHERE idspedizione='.prepare($id_record).'
|
||||
$numero_documenti = $dbo->fetchNum('SELECT id FROM dt_ddt WHERE idspedizione='.prepare($id_record).'
|
||||
UNION SELECT id FROM co_documenti WHERE idspedizione='.prepare($id_record));
|
||||
|
||||
if (!empty($documenti)) {
|
||||
if (!empty($numero_documenti)) {
|
||||
echo '
|
||||
<div class="alert alert-danger">
|
||||
'.tr('Ci sono _NUM_ documenti collegati', [
|
||||
'_NUM_' => count($documenti),
|
||||
'_NUM_' => $numero_documenti,
|
||||
]).'.
|
||||
</div>';
|
||||
}
|
||||
|
@ -1414,14 +1414,14 @@ class FatturaElettronica
|
||||
'ImportoPagamento' => abs($scadenza['da_pagare']),
|
||||
];
|
||||
|
||||
if (!empty($banca['appoggiobancario'])) {
|
||||
$pagamento['IstitutoFinanziario'] = $banca['appoggiobancario'];
|
||||
if (!empty($banca->nome)) {
|
||||
$pagamento['IstitutoFinanziario'] = $banca->nome;
|
||||
}
|
||||
if (!empty($banca['codiceiban'])) {
|
||||
$pagamento['IBAN'] = clean($banca['codiceiban']);
|
||||
if (!empty($banca->iban)) {
|
||||
$pagamento['IBAN'] = clean($banca->iban);
|
||||
}
|
||||
if (!empty($banca['bic'])) {
|
||||
$pagamento['BIC'] = $banca['bic'];
|
||||
if (!empty($banca->bic)) {
|
||||
$pagamento['BIC'] = $banca->bic;
|
||||
}
|
||||
|
||||
$result[]['DettaglioPagamento'] = $pagamento;
|
||||
|
@ -35,7 +35,7 @@ $record = $dbo->fetchOne('SELECT *,
|
||||
(SELECT descrizione FROM dt_aspettobeni WHERE id=idaspettobeni) AS aspettobeni,
|
||||
(SELECT descrizione FROM dt_spedizione WHERE id=idspedizione) AS spedizione,
|
||||
(SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=idvettore) AS vettore,
|
||||
(SELECT id FROM co_banche WHERE id=idbanca) AS id_banca,
|
||||
(SELECT id FROM co_banche WHERE id = id_banca_azienda) AS id_banca,
|
||||
(SELECT is_fiscale FROM zz_segments WHERE id = id_segment) AS is_fiscale
|
||||
FROM co_documenti WHERE id='.prepare($id_record));
|
||||
|
||||
@ -43,9 +43,9 @@ $record['rivalsainps'] = floatval($record['rivalsainps']);
|
||||
$record['ritenutaacconto'] = floatval($record['ritenutaacconto']);
|
||||
$record['bollo'] = floatval($record['bollo']);
|
||||
|
||||
$nome_banca = $banca['appoggiobancario'];
|
||||
$iban_banca = $banca['codiceiban'];
|
||||
$bic_banca = $banca['bic'];
|
||||
$nome_banca = $banca->nome;
|
||||
$iban_banca = $banca->iban;
|
||||
$bic_banca = $banca->bic;
|
||||
|
||||
$module_name = ($record['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto';
|
||||
|
||||
|
@ -28,12 +28,21 @@ if (empty($id_sede) || $id_sede == '-1') {
|
||||
} else {
|
||||
$queryc = 'SELECT an_anagrafiche.*, an_sedi.*, if(an_sedi.codice_fiscale != "", an_sedi.codice_fiscale, an_anagrafiche.codice_fiscale) AS codice_fiscale, if(an_sedi.piva != "", an_sedi.piva, an_anagrafiche.piva) AS piva FROM an_sedi JOIN an_anagrafiche ON an_anagrafiche.idanagrafica=an_sedi.idanagrafica WHERE an_sedi.idanagrafica='.prepare($id_cliente).' AND an_sedi.id='.prepare($id_sede);
|
||||
}
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
$cliente = $dbo->fetchOne($queryc);
|
||||
|
||||
// Lettura dati aziendali
|
||||
$azienda = $dbo->fetchOne('SELECT *, (SELECT iban FROM co_banche WHERE id IN (SELECT idbanca FROM co_documenti WHERE id = '.prepare($id_record).' ) ) AS codiceiban, (SELECT nome FROM co_banche WHERE id IN (SELECT idbanca FROM co_documenti WHERE id = '.prepare($id_record).' ) ) AS appoggiobancario, (SELECT bic FROM co_banche WHERE id IN (SELECT idbanca FROM co_documenti WHERE id = '.prepare($id_record)." ) ) AS bic FROM an_anagrafiche WHERE idanagrafica = (SELECT valore FROM zz_settings WHERE nome='Azienda predefinita')");
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
$azienda = $dbo->fetchOne('SELECT *, (SELECT iban FROM co_banche WHERE id IN (SELECT id_banca_azienda FROM co_documenti WHERE id = '.prepare($id_record).')) AS codiceiban, (SELECT nome FROM co_banche WHERE id IN (SELECT id_banca_azienda FROM co_documenti WHERE id = '.prepare($id_record).')) AS appoggiobancario, (SELECT bic FROM co_banche WHERE id IN (SELECT id_banca_azienda FROM co_documenti WHERE id = '.prepare($id_record).")) AS bic FROM an_anagrafiche WHERE idanagrafica = (SELECT valore FROM zz_settings WHERE nome='Azienda predefinita')");
|
||||
|
||||
// Prefissi e contenuti del replace
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
$replace = [
|
||||
'c_' => isset($cliente) ? $cliente : [],
|
||||
'f_' => isset($azienda) ? $azienda : [],
|
||||
|
@ -176,4 +176,44 @@ UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `mg_articoli` LEFT JOI
|
||||
UPDATE `zz_plugins` SET `options` = ' { "main_query": [ { "type": "table", "fields": "Matricola, Nome, Data, Descrizione", "query": "SELECT id, (SELECT `id` FROM `zz_modules` WHERE `name` = ''Impianti'') AS _link_module_, id AS _link_record_, matricola AS Matricola, nome AS Nome, DATE_FORMAT(data, ''%d/%m/%Y'') AS Data, descrizione AS Descrizione FROM my_impianti WHERE idanagrafica=|id_parent| HAVING 2=2 ORDER BY id DESC"} ]}' WHERE `zz_plugins`.`name` = 'Impianti del cliente';
|
||||
|
||||
-- Fix per plugin Storico attività
|
||||
UPDATE `zz_plugins` SET `options` = '{"main_query": [{"type": "table", "fields": "Numero, Data inizio, Data fine, Tipo", "query": "SELECT in_interventi.id, in_interventi.codice AS Numero, DATE_FORMAT(MAX(orario_inizio),''%d/%m/%Y'') AS ''Data inizio'', DATE_FORMAT(MAX(orario_fine),''%d/%m/%Y'') AS ''Data fine'', (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=in_interventi.idtipointervento) AS ''Tipo'', (SELECT `id` FROM `zz_modules` WHERE `name` = ''Interventi'') AS _link_module_, in_interventi.id AS _link_record_ FROM in_interventi LEFT JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` LEFT JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento`=`in_statiintervento`.`idstatointervento` WHERE 1=1 AND in_interventi.deleted_at IS NULL AND idanagrafica = |id_parent| GROUP BY `in_interventi`.`id` HAVING 2=2 ORDER BY in_interventi.id DESC"}]}'
|
||||
UPDATE `zz_plugins` SET `options` = '{"main_query": [{"type": "table", "fields": "Numero, Data inizio, Data fine, Tipo", "query": "SELECT in_interventi.id, in_interventi.codice AS Numero, DATE_FORMAT(MAX(orario_inizio),''%d/%m/%Y'') AS ''Data inizio'', DATE_FORMAT(MAX(orario_fine),''%d/%m/%Y'') AS ''Data fine'', (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=in_interventi.idtipointervento) AS ''Tipo'', (SELECT `id` FROM `zz_modules` WHERE `name` = ''Interventi'') AS _link_module_, in_interventi.id AS _link_record_ FROM in_interventi LEFT JOIN `in_interventi_tecnici` ON `in_interventi_tecnici`.`idintervento` = `in_interventi`.`id` LEFT JOIN `in_statiintervento` ON `in_interventi`.`idstatointervento`=`in_statiintervento`.`idstatointervento` WHERE 1=1 AND in_interventi.deleted_at IS NULL AND idanagrafica = |id_parent| GROUP BY `in_interventi`.`id` HAVING 2=2 ORDER BY in_interventi.id DESC"}]}';
|
||||
|
||||
-- Aggiornamento del modulo Banche per il supporto completo alle Anagrafiche
|
||||
ALTER TABLE `co_banche` ADD `id_anagrafica` INT(11) NOT NULL, CHANGE `note` `note` TEXT, CHANGE `filiale` `filiale` varchar(255), ADD `predefined` BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
UPDATE `co_banche` SET `id_anagrafica` = (SELECT `valore` FROM `zz_settings` WHERE `nome` = 'Azienda predefinita');
|
||||
ALTER TABLE `co_banche` ADD FOREIGN KEY (`id_anagrafica`) REFERENCES `an_anagrafiche`(`idanagrafica`) ON DELETE CASCADE;
|
||||
|
||||
-- Collegamento sulla base dei campi aggiuntivi per le Anagrafiche
|
||||
UPDATE `co_banche` SET `co_banche`.`id_anagrafica` = (SELECT valore FROM zz_settings WHERE nome = 'Azienda predefinita');
|
||||
|
||||
-- Aggiornamento ID relativo sulle Anagrafiche
|
||||
ALTER TABLE `an_anagrafiche` CHANGE `idbanca_acquisti` `idbanca_acquisti` INT(11),
|
||||
CHANGE `idbanca_vendite` `idbanca_vendite` INT(11);
|
||||
UPDATE `an_anagrafiche` SET `idbanca_acquisti` = NULL WHERE `idbanca_vendite` = 0;
|
||||
UPDATE `an_anagrafiche` SET `idbanca_vendite` = NULL WHERE `idbanca_vendite` = 0;
|
||||
|
||||
INSERT INTO `co_banche` (`id_anagrafica`, `nome`, `iban`, `bic`, `filiale`) SELECT idanagrafica, IF(appoggiobancario != '', appoggiobancario, CONCAT('Banca predefinita di ', ragione_sociale)), codiceiban, bic, filiale FROM an_anagrafiche WHERE codiceiban IS NOT NULL AND codiceiban != '';
|
||||
|
||||
UPDATE `an_anagrafiche` SET `idbanca_acquisti` = (SELECT `id` FROM `co_banche` WHERE `co_banche`.`id_anagrafica` = `an_anagrafiche`.`idanagrafica` LIMIT 1) WHERE `idbanca_acquisti` IS NULL;
|
||||
UPDATE `an_anagrafiche` SET `idbanca_vendite` = (SELECT `id` FROM `co_banche` WHERE `co_banche`.`id_anagrafica` = `an_anagrafiche`.`idanagrafica` LIMIT 1) WHERE `idbanca_vendite` IS NULL;
|
||||
|
||||
-- Aggiornamento tabella principale per Banche
|
||||
UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_banche` INNER JOIN an_anagrafiche ON `an_anagrafiche`.`idanagrafica` = `co_banche`.`id_anagrafica` WHERE 1=1 AND `co_banche`.`deleted_at` IS NULL AND `an_anagrafiche`.`deleted_at` IS NULL HAVING 2=2' WHERE `name` = 'Banche';
|
||||
INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `visible`, `summable`, `default`) VALUES
|
||||
(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche'), 'Anagrafica', 'an_anagrafiche.ragione_sociale', 0, 1, 0, 0, 1, 0, 1),
|
||||
(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche'), 'Predefinito', 'IF(`co_banche`.`predefined`, ''Si'', ''No'')', 6, 1, 0, 0, 1, 0, 1);
|
||||
|
||||
-- Campo id_banca_controparte e id_banca_azienda per i Documenti
|
||||
ALTER TABLE `co_documenti` ADD `id_banca_controparte` INT(11) AFTER `idpagamento`;
|
||||
ALTER TABLE `co_preventivi` ADD `id_banca_controparte` INT(11) AFTER `idpagamento`;
|
||||
ALTER TABLE `co_contratti` ADD `id_banca_controparte` INT(11) AFTER `idpagamento`;
|
||||
ALTER TABLE `dt_ddt` ADD `id_banca_controparte` INT(11) AFTER `idpagamento`;
|
||||
ALTER TABLE `or_ordini` ADD `id_banca_controparte` INT(11) NOT NULL AFTER `idpagamento`;
|
||||
|
||||
ALTER TABLE `co_documenti` CHANGE `idbanca` `id_banca_azienda` INT(11) AFTER `idpagamento`;
|
||||
ALTER TABLE `co_preventivi` ADD `id_banca_azienda` INT(11) AFTER `idpagamento`;
|
||||
ALTER TABLE `co_contratti` ADD `id_banca_azienda` INT(11) AFTER `idpagamento`;
|
||||
ALTER TABLE `dt_ddt` ADD `id_banca_azienda` INT(11) AFTER `idpagamento`;
|
||||
ALTER TABLE `or_ordini` ADD `id_banca_azienda` INT(11) AFTER `idpagamento`;
|
||||
|
||||
UPDATE `co_documenti` SET `id_banca_azienda` = NULL WHERE `id_banca_azienda` = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user