2018-08-09 10:14:26 +02: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-08-09 10:14:26 +02:00
|
|
|
|
|
|
|
namespace Modules\Anagrafiche;
|
|
|
|
|
2020-09-22 20:28:37 +02:00
|
|
|
use Common\SimpleModelTrait;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2019-07-08 12:25:51 +02:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2024-02-05 17:07:33 +01:00
|
|
|
use Modules\Anagrafiche\Tipo as TipoAnagrafica;
|
2019-09-13 11:29:45 +02:00
|
|
|
use Modules\Contratti\Contratto;
|
|
|
|
use Modules\DDT\DDT;
|
2018-08-09 10:14:26 +02:00
|
|
|
use Modules\Fatture\Fattura;
|
2021-07-21 11:43:48 +02:00
|
|
|
use Modules\Interventi\Intervento;
|
2019-09-13 11:29:45 +02:00
|
|
|
use Modules\Ordini\Ordine;
|
|
|
|
use Modules\Preventivi\Preventivo;
|
2019-07-08 15:48:48 +02:00
|
|
|
use Modules\TipiIntervento\Tipo as TipoSessione;
|
2019-09-13 11:29:45 +02:00
|
|
|
use Plugins\DichiarazioniIntento\Dichiarazione;
|
2018-11-30 19:40:06 +01:00
|
|
|
use Traits\RecordTrait;
|
2018-09-24 18:10:16 +02:00
|
|
|
use Util\Generator;
|
2018-08-09 10:14:26 +02:00
|
|
|
|
|
|
|
class Anagrafica extends Model
|
|
|
|
{
|
2020-09-22 20:28:37 +02:00
|
|
|
use SimpleModelTrait;
|
2019-07-11 17:20:58 +02:00
|
|
|
use RecordTrait;
|
|
|
|
use SoftDeletes;
|
2018-11-30 19:40:06 +01:00
|
|
|
|
2018-08-09 10:14:26 +02:00
|
|
|
protected $table = 'an_anagrafiche';
|
|
|
|
protected $primaryKey = 'idanagrafica';
|
2018-11-30 19:40:06 +01:00
|
|
|
protected $module = 'Anagrafiche';
|
|
|
|
|
2018-11-09 11:34:27 +01:00
|
|
|
protected $guarded = [];
|
2018-08-09 10:14:26 +02:00
|
|
|
|
2018-09-24 18:10:16 +02:00
|
|
|
protected $appends = [
|
|
|
|
'id',
|
|
|
|
'partita_iva',
|
|
|
|
];
|
|
|
|
|
|
|
|
protected $hidden = [
|
|
|
|
'idanagrafica',
|
|
|
|
'piva',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
2018-09-25 16:47:44 +02:00
|
|
|
* Crea una nuova anagrafica.
|
2018-09-24 18:10:16 +02:00
|
|
|
*
|
2018-09-25 16:47:44 +02:00
|
|
|
* @param string $ragione_sociale
|
|
|
|
*
|
|
|
|
* @return self
|
2018-09-24 18:10:16 +02:00
|
|
|
*/
|
2019-04-19 03:18:05 +02:00
|
|
|
public static function build($ragione_sociale, $nome = '', $cognome = '', array $tipologie = [])
|
2018-09-24 18:10:16 +02:00
|
|
|
{
|
2020-09-22 20:28:37 +02:00
|
|
|
$model = new static();
|
2018-09-24 18:10:16 +02:00
|
|
|
|
2018-09-25 16:47:44 +02:00
|
|
|
$model->ragione_sociale = $ragione_sociale;
|
2018-09-24 18:10:16 +02:00
|
|
|
|
2019-04-19 03:18:05 +02:00
|
|
|
$model->nome = $nome;
|
|
|
|
$model->cognome = $cognome;
|
|
|
|
|
2019-07-04 21:03:33 +02:00
|
|
|
$model->codice = static::getNextCodice();
|
2022-01-15 18:21:48 +01:00
|
|
|
$model->id_ritenuta_acconto_vendite = setting("Ritenuta d'acconto predefinita");
|
2018-09-24 18:10:16 +02:00
|
|
|
$model->save();
|
|
|
|
|
2018-11-09 11:34:27 +01:00
|
|
|
$model->tipologie = $tipologie;
|
2018-09-26 15:37:46 +02:00
|
|
|
$model->save();
|
|
|
|
|
2023-12-28 16:18:02 +01:00
|
|
|
if ($model->isTipo('Cliente') && setting('Listino cliente predefinito')) {
|
|
|
|
$model->id_listino = setting('Listino cliente predefinito');
|
|
|
|
$model->save();
|
|
|
|
}
|
|
|
|
|
2018-09-24 18:10:16 +02:00
|
|
|
return $model;
|
|
|
|
}
|
|
|
|
|
2019-07-08 12:25:51 +02:00
|
|
|
public static function fromTipo($type)
|
|
|
|
{
|
2024-02-16 10:10:17 +01:00
|
|
|
$tipologia = (new TipoAnagrafica())->getByName($type)->id_record;
|
2019-07-08 12:24:59 +02:00
|
|
|
|
|
|
|
$anagrafiche = self::whereHas('tipi', function ($query) use ($tipologia) {
|
2024-02-16 10:10:17 +01:00
|
|
|
$query->where('an_tipianagrafiche.id', '=', $tipologia->id);
|
2019-07-08 12:24:59 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
return $anagrafiche;
|
|
|
|
}
|
|
|
|
|
2018-09-24 18:10:16 +02:00
|
|
|
public static function fixAzienda(Anagrafica $anagrafica)
|
|
|
|
{
|
2024-01-15 15:30:45 +01:00
|
|
|
\Settings::setValue('Azienda predefinita', $anagrafica->id);
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function fixCliente(Anagrafica $anagrafica)
|
|
|
|
{
|
|
|
|
// Creo il relativo conto nel partitario se non esiste
|
|
|
|
if (empty($anagrafica->idconto_cliente)) {
|
2021-02-25 14:47:10 +01:00
|
|
|
$id_conto = self::creaConto($anagrafica, 'idconto_cliente');
|
2018-09-24 18:10:16 +02:00
|
|
|
|
|
|
|
// Collegamento conto
|
2021-02-25 14:47:10 +01:00
|
|
|
$anagrafica->idconto_cliente = $id_conto;
|
2018-09-24 18:10:16 +02:00
|
|
|
$anagrafica->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function fixFornitore(Anagrafica $anagrafica)
|
|
|
|
{
|
|
|
|
// Creo il relativo conto nel partitario se non esiste
|
|
|
|
if (empty($anagrafica->idconto_fornitore)) {
|
2021-02-25 14:47:10 +01:00
|
|
|
$id_conto = self::creaConto($anagrafica, 'idconto_fornitore');
|
2018-09-24 18:10:16 +02:00
|
|
|
|
|
|
|
// Collegamento conto
|
2021-02-25 14:47:10 +01:00
|
|
|
$anagrafica->idconto_fornitore = $id_conto;
|
2018-09-24 18:10:16 +02:00
|
|
|
$anagrafica->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function fixTecnico(Anagrafica $anagrafica)
|
|
|
|
{
|
2019-07-08 12:24:59 +02:00
|
|
|
$database = database();
|
|
|
|
|
2024-02-29 09:55:44 +01:00
|
|
|
$presenti = $database->fetchArray('SELECT idtipointervento FROM in_tariffe WHERE idtecnico = '.prepare($anagrafica->id));
|
2018-09-24 18:10:16 +02:00
|
|
|
|
2019-07-08 15:48:48 +02:00
|
|
|
// Aggiunta associazioni costi unitari al contratto
|
2024-02-29 09:55:44 +01:00
|
|
|
$tipi = TipoSessione::whereNotIn('id', array_column($presenti, 'idtipointervento'))->get();
|
2019-07-08 15:48:48 +02:00
|
|
|
|
|
|
|
foreach ($tipi as $tipo) {
|
|
|
|
$database->insert('in_tariffe', [
|
|
|
|
'idtecnico' => $anagrafica->id,
|
|
|
|
'idtipointervento' => $tipo->id,
|
|
|
|
'costo_ore' => $tipo->costo_orario,
|
|
|
|
'costo_km' => $tipo->costo_km,
|
|
|
|
'costo_dirittochiamata' => $tipo->costo_diritto_chiamata,
|
|
|
|
'costo_ore_tecnico' => $tipo->costo_orario_tecnico,
|
|
|
|
'costo_km_tecnico' => $tipo->costo_km_tecnico,
|
|
|
|
'costo_dirittochiamata_tecnico' => $tipo->costo_diritto_chiamata_tecnico,
|
|
|
|
]);
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Aggiorna la tipologia dell'anagrafica.
|
|
|
|
*/
|
2018-11-09 11:34:27 +01:00
|
|
|
public function setTipologieAttribute(array $tipologie)
|
2018-09-24 18:10:16 +02:00
|
|
|
{
|
|
|
|
if ($this->isAzienda()) {
|
2024-02-05 17:07:33 +01:00
|
|
|
$tipologie[] = (new TipoAnagrafica())->getByName('Azienda')->id_record;
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
|
2018-11-09 11:34:27 +01:00
|
|
|
$tipologie = array_clean($tipologie);
|
|
|
|
|
2018-09-24 18:10:16 +02:00
|
|
|
$previous = $this->tipi()->get();
|
|
|
|
$this->tipi()->sync($tipologie);
|
|
|
|
$actual = $this->tipi()->get();
|
|
|
|
|
|
|
|
$diff = $actual->diff($previous);
|
|
|
|
|
|
|
|
foreach ($diff as $tipo) {
|
2024-02-05 17:07:33 +01:00
|
|
|
$method = 'fix'.$tipo->name;
|
2018-09-24 18:10:16 +02:00
|
|
|
if (method_exists($this, $method)) {
|
|
|
|
self::$method($this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Controlla se l'anagrafica è di tipo 'Azienda'.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isAzienda()
|
|
|
|
{
|
2019-07-10 17:22:39 +02:00
|
|
|
return $this->isTipo('Azienda');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-02-05 17:07:33 +01:00
|
|
|
* Controlla il tipo di anagrafica.
|
2019-07-10 17:22:39 +02:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isTipo($type)
|
|
|
|
{
|
|
|
|
return $this->tipi()->get()->search(function ($item, $key) use ($type) {
|
2024-02-06 17:25:50 +01:00
|
|
|
return TipoAnagrafica::find($item->id)->name == $type;
|
2018-09-25 16:47:44 +02:00
|
|
|
}) !== false;
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 11:29:45 +02:00
|
|
|
public function delete()
|
|
|
|
{
|
|
|
|
if (!$this->isAzienda()) {
|
|
|
|
return parent::delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-19 16:17:17 +02:00
|
|
|
public function save(array $options = [])
|
|
|
|
{
|
|
|
|
$this->fixRagioneSociale();
|
|
|
|
|
|
|
|
return parent::save($options);
|
|
|
|
}
|
|
|
|
|
2019-09-13 11:29:45 +02:00
|
|
|
// Attributi Eloquent
|
|
|
|
|
2020-03-03 10:33:32 +01:00
|
|
|
public function getModuleAttribute()
|
|
|
|
{
|
|
|
|
return 'Anagrafiche';
|
|
|
|
}
|
|
|
|
|
2018-09-24 18:10:16 +02:00
|
|
|
/**
|
|
|
|
* Restituisce l'identificativo.
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getIdAttribute()
|
|
|
|
{
|
|
|
|
return $this->idanagrafica;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPartitaIvaAttribute()
|
|
|
|
{
|
2020-03-06 09:40:56 +01:00
|
|
|
return $this->attributes['piva'];
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setPartitaIvaAttribute($value)
|
|
|
|
{
|
2020-03-06 09:40:56 +01:00
|
|
|
if (in_array($value, ['99999999999', '00000000000'])) {
|
|
|
|
$value = null;
|
|
|
|
}
|
|
|
|
|
2018-09-24 18:10:16 +02:00
|
|
|
$this->attributes['piva'] = trim(strtoupper($value));
|
|
|
|
}
|
|
|
|
|
2019-04-19 03:18:05 +02:00
|
|
|
public function setNomeAttribute($value)
|
|
|
|
{
|
|
|
|
$this->attributes['nome'] = trim($value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCognomeAttribute($value)
|
|
|
|
{
|
|
|
|
$this->attributes['cognome'] = trim($value);
|
|
|
|
}
|
|
|
|
|
2018-09-24 18:10:16 +02:00
|
|
|
public function setCodiceFiscaleAttribute($value)
|
|
|
|
{
|
|
|
|
$this->attributes['codice_fiscale'] = trim(strtoupper($value));
|
|
|
|
}
|
|
|
|
|
2018-11-09 07:02:59 +01:00
|
|
|
public function setCodiceDestinatarioAttribute($value)
|
|
|
|
{
|
2023-05-15 15:52:44 +02:00
|
|
|
if (!empty($this->sedeLegale->nazione) && !(($this->sedeLegale->nazione->iso2 === 'IT') || ($this->sedeLegale->nazione->iso2 === 'SM'))) {
|
2020-03-16 10:54:25 +01:00
|
|
|
$value = '';
|
2018-11-09 07:02:59 +01:00
|
|
|
}
|
|
|
|
|
2020-03-16 10:54:25 +01:00
|
|
|
$this->attributes['codice_destinatario'] = trim(strtoupper($value));
|
2018-11-09 07:02:59 +01:00
|
|
|
}
|
|
|
|
|
2019-09-13 11:29:45 +02:00
|
|
|
/**
|
|
|
|
* Restituisce la sede legale collegata.
|
|
|
|
*
|
|
|
|
* @return self
|
|
|
|
*/
|
|
|
|
public function getSedeLegaleAttribute()
|
|
|
|
{
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Relazioni Eloquent
|
|
|
|
|
2018-09-24 18:10:16 +02:00
|
|
|
public function tipi()
|
|
|
|
{
|
2024-02-05 17:07:33 +01:00
|
|
|
return $this->belongsToMany(TipoAnagrafica::class, 'an_tipianagrafiche_anagrafiche', 'idanagrafica', 'idtipoanagrafica');
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
|
2020-08-25 10:07:46 +02:00
|
|
|
public function sedi()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Sede::class, 'idanagrafica');
|
|
|
|
}
|
|
|
|
|
2019-09-13 11:29:45 +02:00
|
|
|
public function nazione()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Nazione::class, 'id_nazione');
|
|
|
|
}
|
|
|
|
|
2018-08-09 10:14:26 +02:00
|
|
|
public function fatture()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Fattura::class, 'idanagrafica');
|
|
|
|
}
|
2018-09-24 18:10:16 +02:00
|
|
|
|
2020-02-24 12:21:47 +01:00
|
|
|
public function fattureVendita()
|
|
|
|
{
|
2020-03-16 10:04:49 +01:00
|
|
|
return $this->fatture()->vendita();
|
2020-02-24 12:21:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function fattureAcquisto()
|
|
|
|
{
|
2020-03-16 10:04:49 +01:00
|
|
|
return $this->fatture()->acquisto();
|
2020-02-24 12:21:47 +01:00
|
|
|
}
|
|
|
|
|
2019-09-13 11:29:45 +02:00
|
|
|
public function ordini()
|
2018-09-24 18:10:16 +02:00
|
|
|
{
|
2019-09-13 11:29:45 +02:00
|
|
|
return $this->hasMany(Ordine::class, 'idanagrafica');
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 11:29:45 +02:00
|
|
|
public function ddt()
|
2018-09-24 18:10:16 +02:00
|
|
|
{
|
2019-09-13 11:29:45 +02:00
|
|
|
return $this->hasMany(DDT::class, 'idanagrafica');
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
2019-04-19 03:18:05 +02:00
|
|
|
|
2019-09-13 11:29:45 +02:00
|
|
|
public function contratti()
|
2019-07-19 15:23:00 +02:00
|
|
|
{
|
2019-09-13 11:29:45 +02:00
|
|
|
return $this->hasMany(Contratto::class, 'idanagrafica');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function preventivi()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Preventivo::class, 'idanagrafica');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dichiarazioni()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Dichiarazione::class, 'id_anagrafica');
|
2019-07-19 15:23:00 +02:00
|
|
|
}
|
|
|
|
|
2021-07-21 11:43:48 +02:00
|
|
|
public function interventi()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Intervento::class, 'idanagrafica');
|
|
|
|
}
|
|
|
|
|
2019-07-04 21:03:33 +02:00
|
|
|
// Metodi statici
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calcola il nuovo codice di anagrafica.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function getNextCodice()
|
|
|
|
{
|
|
|
|
// Recupero maschera per le anagrafiche
|
|
|
|
$maschera = setting('Formato codice anagrafica');
|
|
|
|
|
|
|
|
$ultimo = Generator::getPreviousFrom($maschera, 'an_anagrafiche', 'codice', [
|
|
|
|
"codice != ''",
|
2019-07-05 18:29:14 +02:00
|
|
|
'deleted_at IS NULL',
|
2019-07-04 21:03:33 +02:00
|
|
|
]);
|
|
|
|
$codice = Generator::generate($maschera, $ultimo);
|
|
|
|
|
|
|
|
return $codice;
|
|
|
|
}
|
|
|
|
|
2021-02-25 14:47:10 +01:00
|
|
|
protected static function creaConto(Anagrafica $anagrafica, $campo)
|
|
|
|
{
|
2022-05-13 17:24:55 +02:00
|
|
|
$categoria_conto_id = null;
|
2021-02-25 14:47:10 +01:00
|
|
|
if ($campo == 'idconto_cliente') {
|
2022-05-13 17:24:55 +02:00
|
|
|
$categoria_conto_id = setting('Conto di secondo livello per i crediti clienti');
|
2021-02-25 14:47:10 +01:00
|
|
|
} else {
|
2022-05-13 17:24:55 +02:00
|
|
|
$categoria_conto_id = setting('Conto di secondo livello per i debiti fornitori');
|
2021-02-25 14:47:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$database = database();
|
|
|
|
|
|
|
|
// Query di base
|
|
|
|
$table = $database->table('co_pianodeiconti3')
|
2022-05-13 17:24:55 +02:00
|
|
|
->where('idpianodeiconti2', '=', $categoria_conto_id);
|
2021-02-25 14:47:10 +01:00
|
|
|
|
|
|
|
// Verifica su un possibile conto esistente ma non collegato
|
2022-09-07 17:45:12 +02:00
|
|
|
if (!empty($anagrafica->ragione_sociale)) {
|
|
|
|
$conto = (clone $table)
|
2023-12-05 10:48:07 +01:00
|
|
|
->where('descrizione', $anagrafica->ragione_sociale)
|
2022-09-07 17:45:12 +02:00
|
|
|
->first();
|
|
|
|
if (!empty($conto)) {
|
|
|
|
$anagrafiche_collegate = Anagrafica::where($campo, '=', $conto->id)->count();
|
|
|
|
$conto = $anagrafiche_collegate == 0 ? $conto : null;
|
|
|
|
}
|
2021-02-25 14:47:10 +01:00
|
|
|
|
2022-09-07 17:45:12 +02:00
|
|
|
// Collegamento a conto esistente
|
|
|
|
if (!empty($conto)) {
|
|
|
|
return $conto->id;
|
|
|
|
}
|
2021-02-25 14:47:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Calcolo prossimo numero cliente
|
|
|
|
$numero = (clone $table)
|
|
|
|
->selectRaw('MAX(CAST(numero AS UNSIGNED)) AS max_numero')
|
|
|
|
->first();
|
|
|
|
$new_numero = $numero->max_numero + 1;
|
|
|
|
$new_numero = str_pad($new_numero, 6, '0', STR_PAD_LEFT);
|
|
|
|
|
|
|
|
// Creazione del conto
|
|
|
|
$id_conto = $database->table('co_pianodeiconti3')
|
|
|
|
->insertGetId([
|
|
|
|
'numero' => $new_numero,
|
2022-09-07 17:45:12 +02:00
|
|
|
'descrizione' => $anagrafica->ragione_sociale ?: 'N.D.',
|
2022-05-13 17:24:55 +02:00
|
|
|
'idpianodeiconti2' => $categoria_conto_id,
|
2021-02-25 14:47:10 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
return $id_conto;
|
|
|
|
}
|
|
|
|
|
2023-02-23 10:18:03 +01:00
|
|
|
protected function aggiornaConto()
|
|
|
|
{
|
|
|
|
$database = database();
|
|
|
|
|
|
|
|
if ($this->isTipo('Cliente')) {
|
|
|
|
$database->update('co_pianodeiconti3', ['descrizione' => $this->ragione_sociale], ['id' => $this->idconto_cliente]);
|
2023-08-04 14:54:28 +02:00
|
|
|
}
|
|
|
|
|
2023-02-23 10:18:03 +01:00
|
|
|
if ($this->isTipo('Fornitore')) {
|
|
|
|
$database->update('co_pianodeiconti3', ['descrizione' => $this->ragione_sociale], ['id' => $this->idconto_fornitore]);
|
|
|
|
}
|
|
|
|
}
|
2023-08-04 14:54:28 +02:00
|
|
|
|
2019-07-05 09:53:53 +02:00
|
|
|
protected function fixRagioneSociale()
|
|
|
|
{
|
|
|
|
if (!empty($this->cognome) || !empty($this->nome)) {
|
|
|
|
$this->ragione_sociale = $this->cognome.' '.$this->nome;
|
|
|
|
}
|
2023-02-23 10:18:03 +01:00
|
|
|
$this->aggiornaConto();
|
2019-07-05 09:53:53 +02:00
|
|
|
}
|
2018-08-09 10:14:26 +02:00
|
|
|
}
|