diff --git a/modules/banche/edit.php b/modules/banche/edit.php
index 4e947c6fb..e37d81672 100644
--- a/modules/banche/edit.php
+++ b/modules/banche/edit.php
@@ -50,7 +50,7 @@ include_once __DIR__.'/../../core.php';
- {[ "type": "select", "label": "", "name": "id_pianodeiconti3", "value": "$id_pianodeiconti3$", "ajax-source": "conti" ]}
+ {[ "type": "select", "label": "", "name": "id_pianodeiconti3", "value": "$id_pianodeiconti3$", "ajax-source": "conti", "help": "'.tr('Anche il tipo di pagamento dovrà avere configurato lo stesso conto.'); ?>" ]}
diff --git a/modules/ddt/edit.php b/modules/ddt/edit.php
index 92283e65c..a51cecc2c 100755
--- a/modules/ddt/edit.php
+++ b/modules/ddt/edit.php
@@ -35,7 +35,7 @@ if (!empty($numero_previsto)) {
'.tr("E' assente un _TYPE_ numero _NUM_ in data precedente o corrispondente a _DATE_: si potrebbero verificare dei problemi con la numerazione corrente delle fatture", [
'_TYPE_' => $module['name'],
- '_DATE_' => dateFormat($fattura->data),
+ '_DATE_' => dateFormat($ddt->data),
'_NUM_' => '"'.$numero_previsto.'"',
]).'.
';
diff --git a/modules/ddt/modutil.php b/modules/ddt/modutil.php
index d17c701bb..cc2dc67b5 100644
--- a/modules/ddt/modutil.php
+++ b/modules/ddt/modutil.php
@@ -219,12 +219,15 @@ function verifica_numero_ddt(DDT $ddt)
{
global $dbo;
- if (empty($ddt->numero_esterno)) {
- return null;
- }
-
$data = $ddt->data;
$tipo = $ddt->tipo;
+ $dir = $ddt->direzione;
+ $numero = ($dir == 'entrata' ? $ddt->numero_esterno : $ddt->numero);
+ $campo = ($dir == 'entrata' ? 'numero_esterno' : 'numero');
+
+ if (empty($numero)) {
+ return null;
+ }
$documenti = DDT::where('idtipoddt', $tipo->id)
->where('data', $data)
@@ -233,7 +236,7 @@ function verifica_numero_ddt(DDT $ddt)
// Recupero maschera per questo segmento
$maschera = setting('Formato numero secondario ddt');
- $ultimo = Generator::getPreviousFrom($maschera, 'dt_ddt', 'numero_esterno', [
+ $ultimo = Generator::getPreviousFrom($maschera, 'dt_ddt', $campo, [
'data < '.prepare(date('Y-m-d', strtotime($data))),
'YEAR(data) = '.prepare(date('Y', strtotime($data))),
'idtipoddt = '.prepare($tipo->id),
diff --git a/modules/fatture/actions.php b/modules/fatture/actions.php
index df26f8ca0..c105aedf7 100755
--- a/modules/fatture/actions.php
+++ b/modules/fatture/actions.php
@@ -350,10 +350,9 @@ switch (post('op')) {
case 'reopen':
if (!empty($id_record)) {
- $dbo->query("UPDATE co_documenti SET idstatodocumento=(SELECT id FROM co_statidocumento WHERE descrizione='Bozza') WHERE id=".prepare($id_record));
- elimina_movimenti($id_record, 1);
- elimina_scadenze($id_record);
- ricalcola_costiagg_fattura($id_record);
+ $stato = Stato::where('descrizione', 'Bozza')->first();
+ $fattura->stato()->associate($stato);
+ $fattura->save();
flash()->info(tr('Fattura riaperta!'));
}
diff --git a/modules/fatture/src/Export/CSV.php b/modules/fatture/src/Export/CSV.php
index 9a187e96c..d88827b0d 100644
--- a/modules/fatture/src/Export/CSV.php
+++ b/modules/fatture/src/Export/CSV.php
@@ -50,7 +50,7 @@ class CSV extends CSVExporter
'label' => 'Ragione sociale',
],
[
- 'field' => 'totale',
+ 'field' => 'totaleCSV',
'label' => 'Totale',
],
[
diff --git a/modules/fatture/src/Fattura.php b/modules/fatture/src/Fattura.php
index a07f78ff7..79238d3fd 100755
--- a/modules/fatture/src/Fattura.php
+++ b/modules/fatture/src/Fattura.php
@@ -898,4 +898,14 @@ class Fattura extends Document
{
return $this->anagrafica->ragione_sociale;
}
+
+ public function getTotaleCSVAttribute()
+ {
+ $totale = $this->totale_imponibile + $this->iva + $this->rivalsa_inps + $this->iva_rivalsa_inps;
+ if($this->isNota()){
+ return $totale*(-1);
+ }else{
+ return $totale;
+ }
+ }
}
diff --git a/modules/interventi/actions.php b/modules/interventi/actions.php
index 89128da67..920dba528 100644
--- a/modules/interventi/actions.php
+++ b/modules/interventi/actions.php
@@ -467,9 +467,7 @@ switch (post('op')) {
$articolo->id_dettaglio_fornitore = $id_dettaglio_fornitore ?: null;
$articolo->setPrezzoUnitario($prezzo_unitario, $id_iva);
- if ($dir == 'entrata') {
- $articolo->costo_unitario = $originale->prezzo_acquisto;
- }
+ $articolo->costo_unitario = $originale->prezzo_acquisto;
$articolo->setSconto($sconto, $tipo_sconto);
$articolo->qta = $qta;
diff --git a/plugins/presentazioni_bancarie/src/RiBa/Elemento.php b/plugins/presentazioni_bancarie/src/Cbi/Elemento.php
similarity index 95%
rename from plugins/presentazioni_bancarie/src/RiBa/Elemento.php
rename to plugins/presentazioni_bancarie/src/Cbi/Elemento.php
index 5d9b21a6b..a999689eb 100644
--- a/plugins/presentazioni_bancarie/src/RiBa/Elemento.php
+++ b/plugins/presentazioni_bancarie/src/Cbi/Elemento.php
@@ -1,6 +1,6 @@
numero_ricevuta = $ricevuta->numero_ricevuta;
$r51->denominazione_creditore = $intestazione->ragione_soc1_creditore;
$contenuto .= $r51->toCBI().$eol;
-
+
// Record 70
$r70 = new Record70();
$r70->numero_progressivo = $progressivo;
@@ -183,24 +183,4 @@ class RiBa
return $contenuto;
}
-
- public function asRibaAbiCbi()
- {
- $formato_intestazione = $this->intestazione->toCbiFormat();
-
- // Trasformazione delle ricevute nel formato relativo
- $formato_ricevute = [];
- foreach ($this->ricevute as $ricevuta) {
- $formato_ricevute[] = $ricevuta->toCbiFormat();
- }
-
- // Eccezione in caso di assenza di ricevute interne
- if (empty($formato_ricevute)) {
- throw new InvalidArgumentException();
- }
-
- $cbi = new RibaAbiCbi();
-
- return $cbi->creaFile($formato_intestazione, $formato_ricevute);
- }
}
diff --git a/plugins/presentazioni_bancarie/src/RiBa/Ricevuta.php b/plugins/presentazioni_bancarie/src/Cbi/Ricevuta.php
similarity index 98%
rename from plugins/presentazioni_bancarie/src/RiBa/Ricevuta.php
rename to plugins/presentazioni_bancarie/src/Cbi/Ricevuta.php
index 221398a7d..ace0933a9 100644
--- a/plugins/presentazioni_bancarie/src/RiBa/Ricevuta.php
+++ b/plugins/presentazioni_bancarie/src/Cbi/Ricevuta.php
@@ -1,6 +1,6 @@
- *
- * @license GPL-2.0
- * @copyright Copyright (C) 2004-2020 - Antonio De Vincentiis Montesilvano (PE) (http://www.devincentiis.it)
- */
-class RibaAbiCbi
-{
- protected $progressivo = 0;
- protected $assuntrice;
- protected $data;
- protected $valuta;
- protected $supporto;
- protected $totale;
- protected $creditore;
- protected $sia_code;
- protected $cab_ass;
-
- /**
- * @param array $intestazione = [
- * [0] => abi_assuntrice variabile lunghezza 5 numerico
- * [1] => cab_assuntrice variabile lunghezza 5 numerico
- * [2] => conto variabile lunghezza 12 alfanumerico
- * [3] => data_creazione variabile lunghezza 6 numerico formato GGMAA
- * [4] => nome_supporto variabile lunghezza 20 alfanumerico
- * [5] => codice_divisa variabile lunghezza 1 alfanumerico opzionale default "E"
- * [6] => ragione_soc1_creditore variabile lunghezza 24 alfanumerico
- * [7] => ragione_soc2_creditore variabile lunghezza 24 alfanumerico
- * [8] => indirizzo_creditore variabile lunghezza 24 alfanumerico
- * [9] => cap_citta_prov_creditore variabile lunghezza 24 alfanumerico
- * [10] => codice_fiscale_creditore variabile lunghezza 16 alfanumerico opzionale default ""
- * [11] => codice SIA 5 caratteri alfanumerici
- * [12] => carry booleano true per aggiungere i caratteri di fine rigo chr(13) e chr(10)
- * ]
- * @param array $ricevute_bancarie = [
- * [0] => numero ricevuta lunghezza 10 numerico
- * [1] => scadenza lunghezza 6 numerico
- * [2] => importo in centesimi di euro lunghezza 13 numerico
- * [3] => nome debitore lunghezza 60 alfanumerico
- * [4] => codice fiscale/partita iva debitore lunghezza 16 alfanumerico
- * [5] => indirizzo debitore lunghezza 30 alfanumerico
- * [6] => cap debitore lunghezza 5 numerico
- * [7] => comune debitore lunghezza 25 alfanumerico
- * [8] => abi banca domiciliataria lunghezza 5 numerico
- * [9] => cab banca domiciliataria lunghezza 5 numerico
- * [10] => descrizione banca domiciliataria lunghezza 50 alfanumerico
- * [11] => codice cliente attribuito dal creditore lunghezza 16 numerico
- * [12] => descrizione del debito lunghezza 40 alfanumerico (CIG CUP)
- * [13] => provincia debitore lunghezza 2 alfanumerico
- * [14] => descrizione del debito lunghezza 40 alfanumerico (Numero e data riferimento della fattura che ha generato l'effetto)
- * ]
- *
- * @return string
- */
- public function creaFile($intestazione, $ricevute_bancarie)
- {
- $eol = '';
- if (isset($intestazione[12])) {
- $eol = chr(13).chr(10);
- }
-
- $contenuto = $this->RecordIB($intestazione[0], $intestazione[3], $intestazione[4], $intestazione[5], $intestazione[11], $intestazione[1]).$eol;
- foreach ($ricevute_bancarie as $ricevuta) { //estraggo le ricevute dall'array
- ++$this->progressivo;
- $contenuto .= $this->Record14($ricevuta[1], $ricevuta[2], $intestazione[0], $intestazione[1], $intestazione[2], $ricevuta[8], $ricevuta[9], $ricevuta[11]).$eol;
- $contenuto .= $this->Record20($intestazione[6], $intestazione[7], $intestazione[8], $intestazione[9]).$eol;
- $contenuto .= $this->Record30($ricevuta[3], $ricevuta[4]).$eol;
- $contenuto .= $this->Record40($ricevuta[5], $ricevuta[6], $ricevuta[7], $ricevuta[10], $ricevuta[13]).$eol;
- $contenuto .= $this->Record50($ricevuta[12].' '.$ricevuta[14], $intestazione[10]).$eol;
- $contenuto .= $this->Record51($ricevuta[0]).$eol;
- $contenuto .= $this->Record70().$eol;
- }
- $contenuto .= $this->RecordEF().$eol;
-
- return $contenuto;
- }
-
- /**
- * @param string $string
- * @param int $length
- *
- * @return string
- */
- protected function padString($string, $length)
- {
- // Sostituzione di alcuni simboli noti
- $replaces = [
- ''' => "'",
- '"' => "'",
- '&' => '&',
- ];
- $string = str_replace(array_keys($replaces), array_values($replaces), $string);
-
- return substr(str_pad($string, $length), 0, $length);
- }
-
- /**
- * @param string $string
- * @param int $length
- *
- * @return string
- */
- protected function padNumber($string, $length)
- {
- return str_pad($string, $length, '0', STR_PAD_LEFT);
- }
-
- /**
- * Record di testa.
- *
- * @param $abi_assuntrice
- * @param $data_creazione
- * @param $nome_supporto
- * @param $codice_divisa
- * @param $sia_code
- * @param $cab_assuntrice
- *
- * @return string
- */
- protected function RecordIB($abi_assuntrice, $data_creazione, $nome_supporto, $codice_divisa, $sia_code, $cab_assuntrice)
- {
- $this->assuntrice = $this->padNumber($abi_assuntrice, 5);
- $this->cab_ass = $this->padNumber($cab_assuntrice, 5);
- $this->data = str_pad($data_creazione, 6, '0');
- $this->valuta = substr($codice_divisa, 0, 1);
- $this->supporto = str_pad($nome_supporto, 20, '*', STR_PAD_LEFT);
- $this->sia_code = $this->padNumber($sia_code, 5);
-
- return ' IB'.$this->sia_code.$this->assuntrice.$this->data.$this->supporto.str_repeat(' ', 65).'1$'.$this->assuntrice.str_repeat(' ', 2).$this->valuta.str_repeat(' ', 6);
- }
-
- /**
- * @param string $scadenza
- * @param float $importo
- * @param string $abi_assuntrice
- * @param string $cab_assuntrice
- * @param string $conto
- * @param string $abi_domiciliataria
- * @param string $cab_domiciliataria
- * @param string $codice_cliente
- *
- * @return string
- */
- protected function Record14($scadenza, $importo, $abi_assuntrice, $cab_assuntrice, $conto, $abi_domiciliataria, $cab_domiciliataria, $codice_cliente)
- {
- $this->totale += $importo;
-
- return ' 14'.$this->padNumber($this->progressivo, 7)
- .str_repeat(' ', 12).$scadenza.'30000'.$this->padNumber($importo, 13).'-'.$this->padNumber($abi_assuntrice, 5).$this->padNumber($cab_assuntrice, 5).str_pad($conto, 12)
- .$this->padNumber($abi_domiciliataria, 5)
- .$this->padNumber($cab_domiciliataria, 5)
- .str_repeat(' ', 12).$this->sia_code.'4'.str_pad($codice_cliente, 16)
- .str_repeat(' ', 6).$this->valuta;
- }
-
- /**
- * @param string $ragione_soc1_creditore
- * @param string $ragione_soc2_creditore
- * @param string $indirizzo_creditore
- * @param string $cap_citta_prov_creditore
- *
- * @return string
- */
- protected function Record20($ragione_soc1_creditore, $ragione_soc2_creditore, $indirizzo_creditore, $cap_citta_prov_creditore)
- {
- $this->creditore = str_pad($ragione_soc1_creditore, 24);
-
- return ' 20'.$this->padNumber($this->progressivo, 7)
- .substr($this->creditore, 0, 24)
- .$this->padString($ragione_soc2_creditore, 24)
- .$this->padString($indirizzo_creditore, 24)
- .$this->padString($cap_citta_prov_creditore, 24)
- .str_repeat(' ', 14);
- }
-
- /**
- * @param string $nome_debitore
- * @param string $codice_fiscale_debitore
- *
- * @return string
- */
- protected function Record30($nome_debitore, $codice_fiscale_debitore)
- {
- return ' 30'.$this->padNumber($this->progressivo, 7)
- .$this->padString($nome_debitore, 60)
- .str_pad($codice_fiscale_debitore, 16, ' ')
- .str_repeat(' ', 34);
- }
-
- /**
- * @param string $indirizzo_debitore
- * @param string $cap_debitore
- * @param string $comune_debitore
- * @param string $descrizione_domiciliataria
- * @param string $provincia_debitore
- *
- * @return string
- */
- protected function Record40($indirizzo_debitore, $cap_debitore, $comune_debitore, $descrizione_domiciliataria = '', $provincia_debitore = '')
- {
- return ' 40'.$this->padNumber($this->progressivo, 7)
- .$this->padString($indirizzo_debitore, 30)
- .$this->padNumber(intval($cap_debitore), 5)
- .$this->padString($comune_debitore, 22).' '.$this->padString($provincia_debitore, 2)
- .$this->padString($descrizione_domiciliataria, 50);
- }
-
- /**
- * @param string $descrizione_debito
- * @param string $codice_fiscale_creditore
- *
- * @return string
- */
- protected function Record50($descrizione_debito, $codice_fiscale_creditore)
- {
- return ' 50'.$this->padNumber($this->progressivo, 7)
- .$this->padString($descrizione_debito, 80)
- .str_repeat(' ', 10)
- .str_pad($codice_fiscale_creditore, 16, ' ')
- .str_repeat(' ', 4);
- }
-
- /**
- * @param string $numero_ricevuta_creditore
- *
- * @return string
- */
- protected function Record51($numero_ricevuta_creditore)
- {
- return ' 51'.$this->padNumber($this->progressivo, 7)
- .$this->padNumber($numero_ricevuta_creditore, 10)
- .substr($this->creditore, 0, 20)
- .str_repeat(' ', 80);
- }
-
- /**
- * @return string
- */
- protected function Record70()
- {
- return ' 70'.$this->padNumber($this->progressivo, 7)
- .str_repeat(' ', 110);
- }
-
- /**
- * Record di coda.
- *
- * @return string
- */
- protected function RecordEF()
- {
- return ' EF'.$this->sia_code.$this->assuntrice.$this->data.$this->supporto.str_repeat(' ', 6)
- .$this->padNumber($this->progressivo, 7)
- .$this->padNumber($this->totale, 15)
- .str_repeat('0', 15)
- .$this->padNumber($this->progressivo * 7 + 2, 7)
- .str_repeat(' ', 24).$this->valuta.str_repeat(' ', 6);
- }
-}
diff --git a/plugins/sedi/edit.php b/plugins/sedi/edit.php
index 627ee1704..4c355550f 100755
--- a/plugins/sedi/edit.php
+++ b/plugins/sedi/edit.php
@@ -153,19 +153,46 @@ if (!empty($google)) {
}
// Permetto eliminazione tipo sede solo se non è utilizzata da nessun'altra parte nel gestionale
-$elementi = $dbo->fetchArray('SELECT `zz_user_sedi`.`id_user` AS `id` FROM `zz_user_sedi` WHERE `zz_user_sedi`.`idsede` = '.prepare($id_record).'
+$elementi = $dbo->fetchArray('SELECT `zz_users`.`idgruppo` AS `id`, "Utente" AS tipo, NULL AS dir FROM `zz_user_sedi` INNER JOIN `zz_users` ON `zz_user_sedi`.`id_user`=`zz_users`.`id` WHERE `zz_user_sedi`.`idsede` = '.prepare($id_record).'
UNION
-SELECT `an_referenti`.`id` AS `id` FROM `an_referenti` WHERE `an_referenti`.`idsede` = '.prepare($id_record).'
+SELECT `an_referenti`.`id` AS `id`, "Referente" AS tipo, NULL AS dir FROM `an_referenti` WHERE `an_referenti`.`idsede` = '.prepare($id_record).'
UNION
-SELECT `co_documenti`.`id` AS `id` FROM `co_documenti` WHERE `co_documenti`.`idsede_destinazione` = '.prepare($id_record).'
+SELECT `co_documenti`.`id` AS `id`, "Fattura" AS tipo, `co_tipidocumento`.`dir` AS dir FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`idsede_destinazione` = '.prepare($id_record).'
ORDER BY `id`');
if (!empty($elementi)) {
echo '
-
- '.tr('Ci sono _NUM_ documenti collegati', [
- '_NUM_' => count($elementi),
- ]).'.
+
+
+
+
';
+
+ foreach ($elementi as $elemento) {
+ $descrizione = $elemento['tipo'];
+ $id = $elemento['id'];
+ if (in_array($elemento['tipo'], ['Fattura'])) {
+ $modulo = ($elemento['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto';
+ $link = Modules::link($modulo, $id, $descrizione);
+ } elseif (in_array($elemento['tipo'], ['Referente'])) {
+ $link = Plugins::link('Referenti', $id, $descrizione);
+ } else {
+ $link = Modules::link('Utenti e permessi', $id, $descrizione);
+ }
+
+ echo '
+ - '.$link.'
';
+ }
+
+ echo '
+
+
';
$disabled = 'disabled';
diff --git a/src/API/App/AppResource.php b/src/API/App/AppResource.php
index 3487908e8..ebd5f14b7 100644
--- a/src/API/App/AppResource.php
+++ b/src/API/App/AppResource.php
@@ -254,6 +254,7 @@ abstract class AppResource extends Resource implements RetrieveInterface, Create
$db_name = $database->getDatabaseName();
// Ottiene il valore successivo della colonna di tipo AUTO_INCREMENT
+ $database->query('ANALYZE TABLE '.$table_name);
$next_autoincrement = $database->fetchOne('SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '.prepare($table_name).' AND TABLE_SCHEMA = '.prepare($db_name))['AUTO_INCREMENT'];
/*
@@ -291,6 +292,10 @@ abstract class AppResource extends Resource implements RetrieveInterface, Create
$step['end'] = $next_autoincrement - 1;
}
+ if ($step['end'] == '-1') {
+ $step['end'] = $next_autoincrement;
+ }
+
if ($step['end'] >= $step['start']) {
$total = array_merge($total, range($step['start'], $step['end']));
}
diff --git a/templates/preventivi/body.php b/templates/preventivi/body.php
index 31933ee17..7d33af91a 100755
--- a/templates/preventivi/body.php
+++ b/templates/preventivi/body.php
@@ -197,7 +197,7 @@ foreach ($righe as $riga) {
if ($riga->isArticolo() && !empty($riga->articolo->image)) {
echo '
-
+ articolo->image.'" style="max-height: 60px; max-width:80px">
| ';
$autofill->set(5);