diff --git a/core.php b/core.php
index 50685b13e..33635b843 100755
--- a/core.php
+++ b/core.php
@@ -258,8 +258,8 @@ if (!API\Response::isAPIRequest()) {
$plugin = Plugins::getCurrent();
$structure = isset($plugin) ? $plugin : $module;
- $id_module = $module['id'];
- $id_plugin = $plugin['id'];
+ $id_module = $module ? $module['id'] : null;
+ $id_plugin = $plugin ? $plugin['id'] : null;
$user = Auth::user();
diff --git a/include/riferimenti/riferimenti.php b/include/riferimenti/riferimenti.php
index 24077c153..d0150ce5d 100644
--- a/include/riferimenti/riferimenti.php
+++ b/include/riferimenti/riferimenti.php
@@ -48,7 +48,7 @@ echo '
';
$documenti_disponibili = collect();
-$direzione_richiesta = $source->parent->direzione == 'entrata' ? 'uscita' : 'entrata';
+$direzione_richiesta = $source->getDocument()->direzione == 'entrata' ? 'uscita' : 'entrata';
// Individuazione DDT disponibili
$ddt = DDT::whereHas('stato', function ($query) {
diff --git a/include/riferimenti/righe_riferimenti.php b/include/riferimenti/righe_riferimenti.php
index 35cd9bd63..6ba5ea477 100644
--- a/include/riferimenti/righe_riferimenti.php
+++ b/include/riferimenti/righe_riferimenti.php
@@ -55,7 +55,7 @@ if (!$riferimenti->isEmpty()) {
'.$riferimento->target->descrizione.'
- '.reference($riferimento->target->parent).'
+ '.reference($riferimento->target->getDocument()).'
';
diff --git a/include/top.php b/include/top.php
index c072e5b0c..0af6d18a7 100755
--- a/include/top.php
+++ b/include/top.php
@@ -289,7 +289,8 @@ if (Auth::check()) {
}
}
-$hide_sidebar = Auth::check() && (setting('Nascondere la barra sinistra di default') or $_SESSION['settings']['sidebar-collapse']);
+$settings_collapse = session('settings.sidebar-collapse') ? 1 : 0;
+$hide_sidebar = Auth::check() && (setting('Nascondere la barra sinistra di default') || $settings_collapse);
echo '
@@ -520,10 +521,16 @@ if (Auth::check()) {
';
// Eventuale messaggio personalizzato per l'installazione corrente
- include_once App::filepath('include/custom/extra', 'extra.php');
+ $extra_file = App::filepath('include/custom/extra', 'extra.php');
+ if ($extra_file) {
+ include_once $extra_file;
+ }
} else {
// Eventuale messaggio personalizzato per l'installazione corrente
- include_once App::filepath('include/custom/extra', 'login.php');
+ $extra_file = App::filepath('include/custom/extra', 'login.php');
+ if ($extra_file) {
+ include_once $extra_file;
+ }
if (!empty($messages['info']) || !empty($messages['warning']) || !empty($messages['error'])) {
echo '
diff --git a/lib/common.php b/lib/common.php
index b5e9eeed4..50c4f2206 100755
--- a/lib/common.php
+++ b/lib/common.php
@@ -22,6 +22,7 @@
*
* @since 2.4.2
*/
+use Common\Components\Accounting;
/**
* Esegue una somma precisa tra due interi/array.
@@ -113,7 +114,7 @@ function orderValue($table, $field, $id)
*
* @return string|null
*/
-function discountInfo(\Common\Components\Row $riga, $mostra_maggiorazione = true)
+function discountInfo(Accounting $riga, $mostra_maggiorazione = true)
{
if (empty($riga->sconto_unitario) || (!$mostra_maggiorazione && $riga->sconto_unitario < 0)) {
return null;
diff --git a/lib/functions.php b/lib/functions.php
index 8cbce7bad..8e0c0dde5 100755
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -17,11 +17,13 @@
* along with this program. If not, see .
*/
-/**
+/*
* Funzioni fondamentali per il corretto funzionamento del nucleo del progetto.
*
* @since 2.3
*/
+
+use HTMLBuilder\HTMLBuilder;
use Models\OperationLog;
/**
@@ -213,8 +215,10 @@ function translateTemplate()
$id_record = filter('id_record');
$id_parent = filter('id_parent');
- $id_module = Modules::getCurrent()['id'];
- $id_plugin = Plugins::getCurrent()['id'];
+ $module = Modules::getCurrent();
+ $plugin = Plugins::getCurrent();
+ $id_module = $module ? $module['id'] : null;
+ $id_plugin = $plugin ? $plugin['id'] : null;
$template = ob_get_clean();
@@ -225,7 +229,7 @@ function translateTemplate()
];
$template = replace($template, $replaces);
- $template = \HTMLBuilder\HTMLBuilder::replace($template);
+ $template = HTMLBuilder::replace($template);
$template = replace($template, $replaces);
// Informazioni estese sulle azioni dell'utente
@@ -406,3 +410,22 @@ function check_query($query)
return true;
}
+
+function session($name = '')
+{
+ $session = &$_SESSION;
+ if (empty($name)) {
+ return $session;
+ }
+
+ $pieces = explode('.', $name);
+ foreach ($pieces as $piece) {
+ if (!isset($session[$piece])) {
+ return null;
+ }
+
+ $session = &$session[$piece];
+ }
+
+ return $session;
+}
diff --git a/modules/anagrafiche/src/Anagrafica.php b/modules/anagrafiche/src/Anagrafica.php
index 964af7a60..68715ee27 100755
--- a/modules/anagrafiche/src/Anagrafica.php
+++ b/modules/anagrafiche/src/Anagrafica.php
@@ -19,7 +19,8 @@
namespace Modules\Anagrafiche;
-use Common\Model;
+use Common\SimpleModelTrait;
+use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Modules\Contratti\Contratto;
use Modules\DDT\DDT;
@@ -34,6 +35,7 @@ use Util\Generator;
class Anagrafica extends Model
{
+ use SimpleModelTrait;
use RecordTrait;
use SoftDeletes;
@@ -62,7 +64,7 @@ class Anagrafica extends Model
*/
public static function build($ragione_sociale, $nome = '', $cognome = '', array $tipologie = [])
{
- $model = parent::build();
+ $model = new static();
$model->ragione_sociale = $ragione_sociale;
diff --git a/modules/anagrafiche/src/Nazione.php b/modules/anagrafiche/src/Nazione.php
index 7e46b3cc5..234b227eb 100755
--- a/modules/anagrafiche/src/Nazione.php
+++ b/modules/anagrafiche/src/Nazione.php
@@ -19,10 +19,13 @@
namespace Modules\Anagrafiche;
-use Common\Model;
+use Common\SimpleModelTrait;
+use Illuminate\Database\Eloquent\Model;
class Nazione extends Model
{
+ use SimpleModelTrait;
+
protected $table = 'an_nazioni';
public function anagrafiche()
diff --git a/modules/anagrafiche/src/Sede.php b/modules/anagrafiche/src/Sede.php
index b8ce1b6c3..6b6dcbe7e 100644
--- a/modules/anagrafiche/src/Sede.php
+++ b/modules/anagrafiche/src/Sede.php
@@ -19,10 +19,13 @@
namespace Modules\Anagrafiche;
-use Common\Model;
+use Common\SimpleModelTrait;
+use Illuminate\Database\Eloquent\Model;
class Sede extends Model
{
+ use SimpleModelTrait;
+
protected $table = 'an_sedi';
/**
diff --git a/modules/anagrafiche/src/Tipo.php b/modules/anagrafiche/src/Tipo.php
index 102750fea..0c84a17b2 100755
--- a/modules/anagrafiche/src/Tipo.php
+++ b/modules/anagrafiche/src/Tipo.php
@@ -19,10 +19,13 @@
namespace Modules\Anagrafiche;
-use Common\Model;
+use Common\SimpleModelTrait;
+use Illuminate\Database\Eloquent\Model;
class Tipo extends Model
{
+ use SimpleModelTrait;
+
protected $table = 'an_tipianagrafiche';
protected $primaryKey = 'idtipoanagrafica';
diff --git a/modules/articoli/src/Articolo.php b/modules/articoli/src/Articolo.php
index a073f0e3b..c7f4439a3 100755
--- a/modules/articoli/src/Articolo.php
+++ b/modules/articoli/src/Articolo.php
@@ -19,7 +19,8 @@
namespace Modules\Articoli;
-use Common\Model;
+use Common\SimpleModelTrait;
+use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Modules;
use Modules\Interventi\Components\Articolo as ArticoloIntervento;
@@ -30,6 +31,7 @@ use Uploads;
class Articolo extends Model
{
+ use SimpleModelTrait;
use SoftDeletes;
use RecordTrait;
@@ -41,7 +43,7 @@ class Articolo extends Model
public static function build($codice, $nome, Categoria $categoria = null, Categoria $sottocategoria = null)
{
- $model = parent::build();
+ $model = new static();
$model->codice = $codice;
$model->descrizione = $nome;
diff --git a/modules/articoli/src/Categoria.php b/modules/articoli/src/Categoria.php
index acb5cb735..c3c82b430 100755
--- a/modules/articoli/src/Categoria.php
+++ b/modules/articoli/src/Categoria.php
@@ -19,11 +19,13 @@
namespace Modules\Articoli;
-use Common\Model;
+use Common\SimpleModelTrait;
+use Illuminate\Database\Eloquent\Model;
use Traits\HierarchyTrait;
class Categoria extends Model
{
+ use SimpleModelTrait;
use HierarchyTrait;
protected $table = 'mg_categorie';
@@ -31,7 +33,7 @@ class Categoria extends Model
public static function build($nome)
{
- $model = parent::build();
+ $model = new static();
$model->nome = $nome;
$model->save();
diff --git a/modules/articoli/src/Movimento.php b/modules/articoli/src/Movimento.php
index 184c9b1bb..0c8ecdc9a 100755
--- a/modules/articoli/src/Movimento.php
+++ b/modules/articoli/src/Movimento.php
@@ -19,9 +19,10 @@
namespace Modules\Articoli;
-use Common\Model;
+use Common\SimpleModelTrait;
+use Illuminate\Database\Eloquent\Model;
-/**
+/*
* Classe dedicata alla gestione dei movimenti di magazzino degli articoli.
*
* Alcuni appunti sull'utilizzo dei campi *idsede_azienda* e *idsede_controparte*
@@ -32,12 +33,14 @@ use Common\Model;
*/
class Movimento extends Model
{
+ use SimpleModelTrait;
+
protected $document;
protected $table = 'mg_movimenti';
public static function build(Articolo $articolo, $qta, $descrizone, $data, $document = null)
{
- $model = parent::build();
+ $model = new static();
$model->articolo()->associate($articolo);
diff --git a/modules/categorie_documenti/src/Categoria.php b/modules/categorie_documenti/src/Categoria.php
index f3e8182ee..db9c55f27 100755
--- a/modules/categorie_documenti/src/Categoria.php
+++ b/modules/categorie_documenti/src/Categoria.php
@@ -19,18 +19,20 @@
namespace Modules\CategorieDocumentali;
-use Common\Model;
+use Common\SimpleModelTrait;
+use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Categoria extends Model
{
+ use SimpleModelTrait;
use SoftDeletes;
protected $table = 'do_categorie';
public static function build($descrizione)
{
- $model = parent::build();
+ $model = new static();
$model->descrizione = $descrizione;
$model->save();
diff --git a/modules/checklists/src/Check.php b/modules/checklists/src/Check.php
index 48d28b878..53468d796 100755
--- a/modules/checklists/src/Check.php
+++ b/modules/checklists/src/Check.php
@@ -19,7 +19,8 @@
namespace Modules\Checklists;
-use Common\Model;
+use Common\SimpleModelTrait;
+use Illuminate\Database\Eloquent\Model;
use Models\Group;
use Models\Module;
use Models\Plugin;
@@ -29,6 +30,7 @@ use Traits\HierarchyTrait;
class Check extends Model
{
+ use SimpleModelTrait;
use HierarchyTrait;
protected static $parent_identifier = 'id_parent';
@@ -46,7 +48,7 @@ class Check extends Model
*/
public static function build(User $user, $structure, $id_record, $content, $parent_id = null)
{
- $model = parent::build();
+ $model = new static();
$model->user()->associate($user);
$model->id_parent = $parent_id;
diff --git a/modules/checklists/src/Checklist.php b/modules/checklists/src/Checklist.php
index 6195322d7..98522aa3d 100755
--- a/modules/checklists/src/Checklist.php
+++ b/modules/checklists/src/Checklist.php
@@ -19,13 +19,16 @@
namespace Modules\Checklists;
-use Common\Model;
+use Common\SimpleModelTrait;
+use Illuminate\Database\Eloquent\Model;
use Models\Module;
use Models\Plugin;
use Models\User;
class Checklist extends Model
{
+ use SimpleModelTrait;
+
protected $table = 'zz_checklists';
/**
@@ -37,7 +40,7 @@ class Checklist extends Model
*/
public static function build($nome)
{
- $model = parent::build();
+ $model = new static();
$model->name = $nome;
$model->save();
diff --git a/modules/checklists/src/ChecklistItem.php b/modules/checklists/src/ChecklistItem.php
index f7bbc910d..9089c11e4 100755
--- a/modules/checklists/src/ChecklistItem.php
+++ b/modules/checklists/src/ChecklistItem.php
@@ -19,11 +19,13 @@
namespace Modules\Checklists;
-use Common\Model;
+use Common\SimpleModelTrait;
+use Illuminate\Database\Eloquent\Model;
use Traits\HierarchyTrait;
class ChecklistItem extends Model
{
+ use SimpleModelTrait;
use HierarchyTrait;
protected static $parent_identifier = 'id_parent';
@@ -39,7 +41,7 @@ class ChecklistItem extends Model
*/
public static function build(Checklist $checklist, $contenuto, $id_parent = null)
{
- $model = parent::build();
+ $model = new static();
$model->checklist()->associate($checklist);
$model->id_parent = $id_parent;
diff --git a/modules/contratti/actions.php b/modules/contratti/actions.php
index 10a87b48a..63b4059b0 100644
--- a/modules/contratti/actions.php
+++ b/modules/contratti/actions.php
@@ -121,7 +121,7 @@ switch (post('op')) {
$righe = $contratto->getRighe();
foreach ($righe as $riga) {
$new_riga = $riga->replicate();
- $new_riga->setParent($new);
+ $new_riga->setDocument($new);
$new_riga->qta_evasa = 0;
$new_riga->save();
diff --git a/modules/contratti/row-list.php b/modules/contratti/row-list.php
index c333f3bbd..6319d51d2 100755
--- a/modules/contratti/row-list.php
+++ b/modules/contratti/row-list.php
@@ -51,9 +51,9 @@ foreach ($righe as $riga) {
';
// Aggiunta dei riferimenti ai documenti
- if ($riga->hasOriginal()) {
+ if ($riga->hasOriginalComponent()) {
echo '
- '.reference($riga->getOriginal()->parent, tr('Origine')).'';
+ '.reference($riga->getOriginalComponent()->getDocument(), tr('Origine')).'';
}
// Descrizione
diff --git a/modules/contratti/src/Components/RelationTrait.php b/modules/contratti/src/Components/RelationTrait.php
index d9f44166d..a14497eae 100755
--- a/modules/contratti/src/Components/RelationTrait.php
+++ b/modules/contratti/src/Components/RelationTrait.php
@@ -23,18 +23,18 @@ use Modules\Contratti\Contratto;
trait RelationTrait
{
- public function getParentID()
+ public function getDocumentID()
{
return 'idcontratto';
}
- public function parent()
+ public function document()
{
- return $this->belongsTo(Contratto::class, $this->getParentID());
+ return $this->belongsTo(Contratto::class, $this->getDocumentID());
}
public function contratto()
{
- return $this->parent();
+ return $this->document();
}
}
diff --git a/modules/contratti/src/Contratto.php b/modules/contratti/src/Contratto.php
index 231967e0d..4cc1046b5 100755
--- a/modules/contratti/src/Contratto.php
+++ b/modules/contratti/src/Contratto.php
@@ -21,7 +21,7 @@ namespace Modules\Contratti;
use Carbon\Carbon;
use Carbon\CarbonInterval;
-use Common\Components\Description;
+use Common\Components\Component;
use Common\Document;
use Modules\Anagrafiche\Anagrafica;
use Modules\Interventi\Intervento;
@@ -58,7 +58,7 @@ class Contratto extends Document
*/
public static function build(Anagrafica $anagrafica, $nome)
{
- $model = parent::build();
+ $model = new static();
$stato_documento = Stato::where('descrizione', 'Bozza')->first();
@@ -220,7 +220,7 @@ class Contratto extends Document
* Effettua un controllo sui campi del documento.
* Viene richiamato dalle modifiche alle righe del documento.
*/
- public function triggerEvasione(Description $trigger)
+ public function triggerEvasione(Component $trigger)
{
parent::triggerEvasione($trigger);
diff --git a/modules/contratti/src/Stato.php b/modules/contratti/src/Stato.php
index dcea1da30..8256cd693 100755
--- a/modules/contratti/src/Stato.php
+++ b/modules/contratti/src/Stato.php
@@ -19,10 +19,13 @@
namespace Modules\Contratti;
-use Common\Model;
+use Common\SimpleModelTrait;
+use Illuminate\Database\Eloquent\Model;
class Stato extends Model
{
+ use SimpleModelTrait;
+
protected $table = 'co_staticontratti';
public function preventivi()
diff --git a/modules/dashboard/edit.php b/modules/dashboard/edit.php
index 9b2d54a2a..2fca88336 100755
--- a/modules/dashboard/edit.php
+++ b/modules/dashboard/edit.php
@@ -31,10 +31,11 @@ echo '
|