diff --git a/src/Models/Module.php b/src/Models/Module.php index ec510fb61..da41e1e3a 100644 --- a/src/Models/Module.php +++ b/src/Models/Module.php @@ -32,7 +32,7 @@ class Module extends Model parent::boot(); static::addGlobalScope('enabled', function (Builder $builder) { - //$builder->where('enabled', true); + $builder->where('enabled', true); }); static::addGlobalScope('permission', function (Builder $builder) { @@ -126,13 +126,13 @@ class Module extends Model public function children() { - return $this->hasMany(self::class, 'parent') + return $this->hasMany(self::class, 'parent')->withoutGlobalScope('enabled') ->orderBy('order'); } public function parent() { - return $this->belongsTo(self::class, 'parent'); + return $this->belongsTo(self::class, 'parent')->withoutGlobalScope('enabled'); } public function allParents() @@ -154,13 +154,4 @@ class Module extends Model ->orderBy('order') ->get(); } - - public static function getCompleteHierarchy() - { - return self::withoutGlobalScope('enabled') - ->with('allChildren') - ->whereNull('parent') - ->orderBy('order') - ->get(); - } } diff --git a/src/Modules.php b/src/Modules.php index f54a71750..f90ef31ba 100644 --- a/src/Modules.php +++ b/src/Modules.php @@ -213,7 +213,7 @@ class Modules public static function getHierarchy() { if (!isset(self::$hierarchy)) { - self::$hierarchy = Module::getCompleteHierarchy()->toArray(); + self::$hierarchy = Module::getHierarchy()->toArray(); } return self::$hierarchy; diff --git a/src/Prints.php b/src/Prints.php index b1d46e456..0f1c8a3f0 100644 --- a/src/Prints.php +++ b/src/Prints.php @@ -27,7 +27,8 @@ class Prints $prints = []; // Inizializzazione dei riferimenti - foreach (Modules::getModules() as $module) { + $modules = Modules::getModules(); + foreach ($modules as $module) { self::$modules[$module['id']] = []; } @@ -207,6 +208,7 @@ class Prints { $infos = self::get($id_print); $options = self::readOptions($infos['options']); + $docroot = DOCROOT; $dbo = $database = Database::getConnection(); diff --git a/templates/magazzino_inventario/pdfgen.magazzino_inventario.php b/templates/magazzino_inventario/pdfgen.magazzino_inventario.php index 8abb47f30..6d7b328f0 100644 --- a/templates/magazzino_inventario/pdfgen.magazzino_inventario.php +++ b/templates/magazzino_inventario/pdfgen.magazzino_inventario.php @@ -3,8 +3,8 @@ include_once __DIR__.'/../../core.php'; // carica report html -$report = file_get_contents($docroot.'/templates/magazzino_inventario/magazzino_inventario.html'); -$body = file_get_contents($docroot.'/templates/magazzino_inventario/magazzino_inventario_body.html'); +$report = file_get_contents(__DIR__.'/magazzino_inventario.html'); +$body = file_get_contents(__DIR__.'/magazzino_inventario_body.html'); $search_codice = $_GET['search_codice']; $search_descrizione = $_GET['search_descrizione']; @@ -52,7 +52,7 @@ include_once $docroot.'/templates/pdfgen_variables.php'; // LEFT OUTER JOIN mg_categorie ON (mg_categorie.id=mg_articoli.id_categoria AND mg_categorie.parent = 0) OR (mg_categorie.id=mg_articoli.id_sottocategoria AND mg_categorie.parent = 1) $period_end = $_SESSION['period_end']; -$query = 'SELECT *, mg_articoli.id AS id_articolo, (SELECT nome FROM mg_categorie WHERE mg_categorie.parent = 0 AND mg_categorie.id = mg_articoli.id_categoria) AS categoria, (SELECT nome FROM mg_categorie WHERE mg_categorie.parent = 1 AND mg_categorie.id = mg_articoli.id_sottocategoria) AS subcategoria, (SELECT SUM(qta) FROM mg_movimenti WHERE mg_movimenti.idarticolo=mg_articoli.id AND (mg_movimenti.idintervento IS NULL OR mg_movimenti.idautomezzo = 0) AND data <= '.prepare($period_end).' ) AS qta FROM mg_articoli WHERE 1=1 '.$add_where.' HAVING 2=2 '.$add_having.' ORDER BY codice ASC'; +$query = 'SELECT *, mg_articoli.id AS id_articolo, (SELECT nome FROM mg_categorie WHERE mg_categorie.parent = 0 AND mg_categorie.id = mg_articoli.id_categoria) AS categoria, (SELECT nome FROM mg_categorie WHERE mg_categorie.parent = 1 AND mg_categorie.id = mg_articoli.id_sottocategoria) AS subcategoria, (SELECT SUM(qta) FROM mg_movimenti WHERE mg_movimenti.idarticolo=mg_articoli.id AND (mg_movimenti.idintervento IS NULL OR mg_movimenti.idautomezzo = 0) AND data <= '.prepare($period_end).' ) AS qta FROM mg_articoli WHERE 1=1 '.$add_where.' HAVING 2=2 AND qta > 0 '.$add_having.' ORDER BY codice ASC'; $rs = $dbo->fetchArray($query); $totrows = sizeof($rs);