mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
Miglioramento della documentazione automatica
Miglioramento del processo di documentazione automatica per il branch gh-pages, con generalizzazione della struttura della classe Auth. Aggiunto sistema per la formattazione automatica del codice sfruttanto PHP CS Fixer (https://github.com/FriendsOfPHP/PHP-CS-Fixer).
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -73,7 +73,7 @@ vendor/
|
|||||||
*.old
|
*.old
|
||||||
*.mo
|
*.mo
|
||||||
.couscous/
|
.couscous/
|
||||||
assets/dist
|
assets/dist/
|
||||||
backup/*
|
backup/*
|
||||||
!backup/.htaccess
|
!backup/.htaccess
|
||||||
files/*
|
files/*
|
||||||
|
20
.php_cs
Normal file
20
.php_cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return PhpCsFixer\Config::create()
|
||||||
|
->setRules(array(
|
||||||
|
'@Symfony' => true,
|
||||||
|
'array_syntax' => array('syntax' => 'short'),
|
||||||
|
))
|
||||||
|
->setFinder(
|
||||||
|
PhpCsFixer\Finder::create()
|
||||||
|
->files()
|
||||||
|
->in(__DIR__)
|
||||||
|
->exclude('vendor')
|
||||||
|
->exclude('resources/views')
|
||||||
|
->exclude('storage')
|
||||||
|
->exclude('public')
|
||||||
|
->notName("*.txt")
|
||||||
|
->ignoreDotFiles(true)
|
||||||
|
->ignoreVCS(true)
|
||||||
|
)
|
||||||
|
;
|
@@ -13,11 +13,10 @@ Un software gestionale, identificato nell'insieme degli applicativi che automati
|
|||||||
|
|
||||||
Secondo questa definizione, OpenSTAManager riesce a generalizzare al proprio interno le funzionalità caratteristiche della contabilità e della gestione del magazzino, presentando inoltre moduli piuttosto avanzati e destinati a complementare l'attività aziendale in relazione agli interventi di assistenza della realtà lavorativa in oggetto.
|
Secondo questa definizione, OpenSTAManager riesce a generalizzare al proprio interno le funzionalità caratteristiche della contabilità e della gestione del magazzino, presentando inoltre moduli piuttosto avanzati e destinati a complementare l'attività aziendale in relazione agli interventi di assistenza della realtà lavorativa in oggetto.
|
||||||
|
|
||||||
## Tabella dei contenuti
|
La documentazione ufficiale risulta disponibile all'indirizzo <https://devcode-it.github.io/openstamanager/>.
|
||||||
|
|
||||||
<!-- TOC depthFrom:2 depthTo:6 orderedList:false updateOnSave:true withLinks:true -->
|
<!-- TOC depthFrom:2 depthTo:6 orderedList:false updateOnSave:true withLinks:true -->
|
||||||
|
|
||||||
- [Tabella dei contenuti](#tabella-dei-contenuti)
|
|
||||||
- [Requisiti](#requisiti)
|
- [Requisiti](#requisiti)
|
||||||
- [Installazione](#installazione)
|
- [Installazione](#installazione)
|
||||||
- [Versioni](#versioni)
|
- [Versioni](#versioni)
|
||||||
@@ -37,10 +36,10 @@ Prima di iniziare l'installazione, è necessario procedere al download di una ve
|
|||||||
|
|
||||||
L'installazione del gestionale richiede la presenza di un server web con abilitato il [DBMS (Database Management System)](https://it.wikipedia.org/wiki/Database_management_system) MySQL e il linguaggio di programmazione [PHP](http://php.net/).
|
L'installazione del gestionale richiede la presenza di un server web con abilitato il [DBMS (Database Management System)](https://it.wikipedia.org/wiki/Database_management_system) MySQL e il linguaggio di programmazione [PHP](http://php.net/).
|
||||||
|
|
||||||
- PHP >= 5.4 (si consiglia come minimo la versione 5.6 per poter usufruire di tutte le funzionalità del progetto)
|
- PHP >= 5.4 (si consiglia la versione 5.6 per poter usufruire di tutte le funzionalità del progetto)
|
||||||
- MySQL >= 5.0
|
- MySQL >= 5.0
|
||||||
|
|
||||||
Per ulteriori informazioni sui pacchetti che forniscono questi elementi di default, visitare la sezione [Informazioni](https://devcode-it.github.io/openstamanager/installazione.html) della documentazione.
|
Per ulteriori informazioni sui pacchetti che forniscono questi elementi di default, visitare la sezione [Installazione](https://devcode-it.github.io/openstamanager/installazione.html) della documentazione.
|
||||||
|
|
||||||
## Installazione
|
## Installazione
|
||||||
|
|
||||||
@@ -69,7 +68,6 @@ Nel caso si stia utilizzando la versione direttamente ottenuta dalla repository
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
php composer.phar install
|
php composer.phar install
|
||||||
php composer.phar update
|
|
||||||
yarn global add gulp
|
yarn global add gulp
|
||||||
yarn install
|
yarn install
|
||||||
gulp
|
gulp
|
||||||
|
@@ -345,7 +345,7 @@ switch ($module_name) {
|
|||||||
for ($i = 0; $i < sizeof($fatture); ++$i) {
|
for ($i = 0; $i < sizeof($fatture); ++$i) {
|
||||||
($fatture[$i]['n2_fattura'] != '') ? $n_fattura = $fatture[$i]['n2_fattura'] : $n_fattura = $fatture[$i]['n_fattura'];
|
($fatture[$i]['n2_fattura'] != '') ? $n_fattura = $fatture[$i]['n2_fattura'] : $n_fattura = $fatture[$i]['n_fattura'];
|
||||||
|
|
||||||
$id_module = $modules_info['Fatture di vendita']['id'];
|
$id_module = Modules::getModule('Fatture di vendita')['id'];
|
||||||
echo "<tr><td class='first_cell text-left'><a href='".$rootdir.'/editor.php?id_module='.$id_module.'&id_record='.$fatture[$i]['iddocumento']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">Fattura n<sup>o</sup> ".$n_fattura."</a></td>\n";
|
echo "<tr><td class='first_cell text-left'><a href='".$rootdir.'/editor.php?id_module='.$id_module.'&id_record='.$fatture[$i]['iddocumento']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">Fattura n<sup>o</sup> ".$n_fattura."</a></td>\n";
|
||||||
|
|
||||||
echo "<td class='table_cell text-left'>".Translator::dateToLocale($fatture[$i]['data_fattura'])."</td>\n";
|
echo "<td class='table_cell text-left'>".Translator::dateToLocale($fatture[$i]['data_fattura'])."</td>\n";
|
||||||
@@ -377,7 +377,7 @@ switch ($module_name) {
|
|||||||
for ($i = 0; $i < sizeof($fatture); ++$i) {
|
for ($i = 0; $i < sizeof($fatture); ++$i) {
|
||||||
($fatture[$i]['n2_fattura'] != '') ? $n_fattura = $fatture[$i]['n2_fattura'] : $n_fattura = $fatture[$i]['n_fattura'];
|
($fatture[$i]['n2_fattura'] != '') ? $n_fattura = $fatture[$i]['n2_fattura'] : $n_fattura = $fatture[$i]['n_fattura'];
|
||||||
|
|
||||||
$id_module = $modules_info['Fatture di vendita']['id'];
|
$id_module = Modules::getModule('Fatture di vendita')['id'];
|
||||||
echo "<tr><td class='first_cell text-left'><a href='".$rootdir.'/editor.php?id_module='.$id_module.'&id_record='.$fatture[$i]['iddocumento']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">Fattura n<sup>o</sup> ".$n_fattura."</a></td>\n";
|
echo "<tr><td class='first_cell text-left'><a href='".$rootdir.'/editor.php?id_module='.$id_module.'&id_record='.$fatture[$i]['iddocumento']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">Fattura n<sup>o</sup> ".$n_fattura."</a></td>\n";
|
||||||
|
|
||||||
echo "<td class='table_cell text-left'>".Translator::dateToLocale($fatture[$i]['data_fattura'])."</td>\n";
|
echo "<td class='table_cell text-left'>".Translator::dateToLocale($fatture[$i]['data_fattura'])."</td>\n";
|
||||||
@@ -408,7 +408,7 @@ switch ($module_name) {
|
|||||||
for ($i = 0; $i < sizeof($fatture); ++$i) {
|
for ($i = 0; $i < sizeof($fatture); ++$i) {
|
||||||
($fatture[$i]['n2_fattura'] != '') ? $n_fattura = $fatture[$i]['n2_fattura'] : $n_fattura = $fatture[$i]['n_fattura'];
|
($fatture[$i]['n2_fattura'] != '') ? $n_fattura = $fatture[$i]['n2_fattura'] : $n_fattura = $fatture[$i]['n_fattura'];
|
||||||
|
|
||||||
$id_module = $modules_info['Fatture di vendita']['id'];
|
$id_module = Modules::getModule('Fatture di vendita')['id'];
|
||||||
echo "<tr><td class='first_cell text-left'><a href='".$rootdir.'/editor.php?id_module='.$id_module.'&id_record='.$fatture[$i]['iddocumento']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">Fattura n<sup>o</sup> ".$n_fattura."</a></td>\n";
|
echo "<tr><td class='first_cell text-left'><a href='".$rootdir.'/editor.php?id_module='.$id_module.'&id_record='.$fatture[$i]['iddocumento']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">Fattura n<sup>o</sup> ".$n_fattura."</a></td>\n";
|
||||||
|
|
||||||
echo "<td class='table_cell text-left'>".Translator::dateToLocale($fatture[$i]['data_fattura'])."</td>\n";
|
echo "<td class='table_cell text-left'>".Translator::dateToLocale($fatture[$i]['data_fattura'])."</td>\n";
|
||||||
|
285
core.php
285
core.php
@@ -37,15 +37,16 @@ define('ROOTDIR', $rootdir);
|
|||||||
// Caricamento delle dipendenze e delle librerie del progetto
|
// Caricamento delle dipendenze e delle librerie del progetto
|
||||||
require_once __DIR__.'/vendor/autoload.php';
|
require_once __DIR__.'/vendor/autoload.php';
|
||||||
|
|
||||||
|
// Redirect al percorso HTTPS se impostato nella configurazione
|
||||||
|
if (!empty($redirectHTTPS) && !isHTTPS(true)) {
|
||||||
|
header('HTTP/1.1 301 Moved Permanently');
|
||||||
|
header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
// Forzamento del debug
|
// Forzamento del debug
|
||||||
// $debug = true;
|
// $debug = true;
|
||||||
|
|
||||||
/*
|
|
||||||
// Controllo CSRF
|
|
||||||
if(!CSRF::getInstance()->validate()){
|
|
||||||
die(_('Constrollo CSRF fallito!'));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// Logger per la segnalazione degli errori
|
// Logger per la segnalazione degli errori
|
||||||
$logger = new Monolog\Logger(_('OpenSTAManager'));
|
$logger = new Monolog\Logger(_('OpenSTAManager'));
|
||||||
$logger->pushProcessor(new Monolog\Processor\UidProcessor());
|
$logger->pushProcessor(new Monolog\Processor\UidProcessor());
|
||||||
@@ -61,8 +62,8 @@ $handlers[] = new StreamHandler(__DIR__.'/logs/setup.log', Monolog\Logger::EMERG
|
|||||||
|
|
||||||
// Impostazioni di debug
|
// Impostazioni di debug
|
||||||
if (!empty($debug)) {
|
if (!empty($debug)) {
|
||||||
|
// Ignoramento degli avvertimenti e delle informazioni relative alla deprecazione di componenti
|
||||||
if (empty($strict)) {
|
if (empty($strict)) {
|
||||||
// Ignoramento degli avvertimenti e delle informazioni relative alla deprecazione di componenti
|
|
||||||
error_reporting(E_ALL & ~E_NOTICE & ~E_USER_DEPRECATED);
|
error_reporting(E_ALL & ~E_NOTICE & ~E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,158 +107,160 @@ Monolog\ErrorHandler::register($logger);
|
|||||||
$formatter = !empty($formatter) ? $formatter : [];
|
$formatter = !empty($formatter) ? $formatter : [];
|
||||||
Translator::setLocaleFormatter($formatter);
|
Translator::setLocaleFormatter($formatter);
|
||||||
|
|
||||||
// Aggiunta del wrapper personalizzato per la generazione degli input
|
|
||||||
if (!empty($HTMLWrapper)) {
|
|
||||||
HTMLBuilder\HTMLBuilder::setWrapper($HTMLWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Aggiunta dei gestori personalizzati per la generazione degli input
|
|
||||||
foreach ((array) $HTMLHandlers as $key => $value) {
|
|
||||||
HTMLBuilder\HTMLBuilder::setHandler($key, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Aggiunta dei gestori per componenti personalizzate
|
|
||||||
foreach ((array) $HTMLManagers as $key => $value) {
|
|
||||||
HTMLBuilder\HTMLBuilder::setManager($key, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Registrazione globale del template per gli input HTML
|
|
||||||
register_shutdown_function('translateTemplate');
|
|
||||||
|
|
||||||
// Redirect al percorso HTTPS se impostato nella configurazione
|
|
||||||
if (!empty($redirectHTTPS) && !isHTTPS(true)) {
|
|
||||||
header('HTTP/1.1 301 Moved Permanently');
|
|
||||||
header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
session_set_cookie_params(0, $rootdir);
|
|
||||||
session_start();
|
|
||||||
|
|
||||||
// Impostazione della sessione di base
|
|
||||||
$_SESSION['infos'] = isset($_SESSION['infos']) ? $_SESSION['infos'] : [];
|
|
||||||
$_SESSION['warnings'] = isset($_SESSION['warnings']) ? $_SESSION['warnings'] : [];
|
|
||||||
$_SESSION['errors'] = (array) $_SESSION['errors'];
|
|
||||||
|
|
||||||
// Imposto il periodo di visualizzazione dei record dal 01-01-yyy al 31-12-yyyy
|
|
||||||
if (!empty($_GET['period_start'])) {
|
|
||||||
$_SESSION['period_start'] = $_GET['period_start'];
|
|
||||||
$_SESSION['period_end'] = $_GET['period_end'];
|
|
||||||
} elseif (!isset($_SESSION['period_start'])) {
|
|
||||||
$_SESSION['period_start'] = date('Y').'-01-01';
|
|
||||||
$_SESSION['period_end'] = date('Y').'-12-31';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Impostazione del tema grafico di default
|
|
||||||
$theme = !empty($theme) ? $theme : 'default';
|
|
||||||
|
|
||||||
// Istanziamento del gestore delle traduzioni del progetto
|
// Istanziamento del gestore delle traduzioni del progetto
|
||||||
$lang = !empty($lang) ? $lang : 'it';
|
$lang = !empty($lang) ? $lang : 'it';
|
||||||
$translator = new Translator($lang);
|
$translator = new Translator($lang);
|
||||||
$translator->addLocalePath($docroot.'/locale');
|
$translator->addLocalePath($docroot.'/locale');
|
||||||
$translator->addLocalePath($docroot.'/modules/*/locale');
|
$translator->addLocalePath($docroot.'/modules/*/locale');
|
||||||
|
|
||||||
// Istanziamento del gestore degli utenti
|
// Individuazione di versione e revisione del progetto
|
||||||
if (!Update::isUpdateAvailable()) {
|
|
||||||
$auth = new Auth();
|
|
||||||
}
|
|
||||||
|
|
||||||
$version = Update::getVersion();
|
$version = Update::getVersion();
|
||||||
$revision = Update::getRevision();
|
$revision = Update::getRevision();
|
||||||
|
|
||||||
$assets = $rootdir.'/assets/dist';
|
if (!API::isAPIRequest()) {
|
||||||
$css = $assets.'/css';
|
session_set_cookie_params(0, $rootdir);
|
||||||
$js = $assets.'/js';
|
session_start();
|
||||||
$img = $assets.'/img';
|
|
||||||
|
|
||||||
// CSS di base del progetto
|
|
||||||
$css_modules = [];
|
|
||||||
|
|
||||||
$css_modules[] = $css.'/app.min.css';
|
|
||||||
$css_modules[] = $css.'/style.min.css';
|
|
||||||
$css_modules[] = $css.'/themes.min.css';
|
|
||||||
$css_modules[] = [
|
|
||||||
'href' => $css.'/print.min.css',
|
|
||||||
'media' => 'print',
|
|
||||||
];
|
|
||||||
|
|
||||||
// JS di base del progetto
|
|
||||||
$jscript_modules = [];
|
|
||||||
|
|
||||||
$jscript_modules[] = $js.'/app.min.js';
|
|
||||||
$jscript_modules[] = $js.'/custom.min.js';
|
|
||||||
$jscript_modules[] = $js.'/i18n/parsleyjs/'.$lang.'.min.js';
|
|
||||||
$jscript_modules[] = $js.'/i18n/select2/'.$lang.'.min.js';
|
|
||||||
$jscript_modules[] = $js.'/i18n/moment/'.$lang.'.min.js';
|
|
||||||
$jscript_modules[] = $js.'/i18n/fullcalendar/'.$lang.'.min.js';
|
|
||||||
|
|
||||||
if (Auth::check()) {
|
|
||||||
$jscript_modules[] = $rootdir.'/lib/functions.js';
|
|
||||||
$jscript_modules[] = $rootdir.'/lib/init.js';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$dbo = Database::getConnection();
|
$dbo = Database::getConnection();
|
||||||
|
|
||||||
// Controllo sull'esistenza delle informazioni necessarie prima di effettuare la connessione al database
|
$continue = $dbo->isInstalled() && Auth::check() && !Update::isUpdateAvailable();
|
||||||
if ($dbo->isConnected() && $dbo->isInstalled() && (Auth::check() || API::isAPIRequest()) && !Update::isUpdateAvailable()) {
|
|
||||||
if (!empty($debugbar)) {
|
|
||||||
$debugbar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($dbo->getPDO()));
|
|
||||||
}
|
|
||||||
|
|
||||||
$id_module = filter('id_module');
|
// Controllo sulla presenza dei permessi di accesso basilari
|
||||||
$id_record = filter('id_record');
|
if (!$continue && slashes($_SERVER['SCRIPT_FILENAME']) != slashes(DOCROOT.'/index.php')) {
|
||||||
$id_plugin = filter('id_plugin');
|
|
||||||
$id_parent = filter('id_parent');
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Creazione array con l'elenco dei moduli
|
|
||||||
* es. $modules['Anagrafiche']['nome_campo'];
|
|
||||||
*/
|
|
||||||
$rs = $dbo->fetchArray('SELECT * FROM `zz_modules` LEFT JOIN (SELECT `idmodule`, `permessi` FROM `zz_permissions` WHERE `idgruppo`=(SELECT `idgruppo` FROM `zz_users` WHERE `idutente`='.prepare($_SESSION['idutente']).')) AS `zz_permissions` ON `zz_modules`.`id`=`zz_permissions`.`idmodule` LEFT JOIN (SELECT `idmodule`, `clause` FROM `zz_group_module` WHERE `idgruppo`=(SELECT `idgruppo` FROM `zz_users` WHERE `idutente`='.prepare($_SESSION['idutente']).')) AS `zz_group_module` ON `zz_modules`.`id`=`zz_group_module`.`idmodule`');
|
|
||||||
|
|
||||||
$modules_info = [];
|
|
||||||
for ($i = 0; $i < count($rs); ++$i) {
|
|
||||||
foreach ($rs[$i] as $name => $value) {
|
|
||||||
if ($name == 'permessi' && (Auth::isAdmin() || $value == null)) {
|
|
||||||
if (Auth::isAdmin()) {
|
|
||||||
$value = 'rw';
|
|
||||||
} else {
|
|
||||||
$value = '-';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($name != 'idmodule' && $name != 'updated_at' && $name != 'created_at' && $name != 'clause') {
|
|
||||||
$modules_info[$rs[$i]['name']][$name] = $value;
|
|
||||||
} elseif ($name == 'clause') {
|
|
||||||
$additional_where[$rs[$i]['name']] = !empty($value) ? ' AND '.$value : $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$modules_info[$rs[$i]['id']]['name'] = $rs[$i]['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = Auth::getUser();
|
|
||||||
$user_idanagrafica = $user['idanagrafica'];
|
|
||||||
|
|
||||||
if (!empty($id_module)) {
|
|
||||||
$module = Modules::getModule($id_module);
|
|
||||||
|
|
||||||
$pageTitle = $module['title'];
|
|
||||||
|
|
||||||
Permissions::addModule($id_module);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($skip_permissions)) {
|
|
||||||
Permissions::skip();
|
|
||||||
}
|
|
||||||
|
|
||||||
Permissions::check();
|
|
||||||
} elseif (slashes($_SERVER['SCRIPT_FILENAME']) != slashes(DOCROOT.'/index.php')) {
|
|
||||||
redirect(ROOTDIR.'/index.php?op=logout');
|
redirect(ROOTDIR.'/index.php?op=logout');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Istanziamento di HTMLHelper
|
// Operazione aggiuntive (richieste non API)
|
||||||
$html = new HTMLHelper();
|
if (!API::isAPIRequest()) {
|
||||||
|
/*
|
||||||
|
// Controllo CSRF
|
||||||
|
if(!CSRF::getInstance()->validate()){
|
||||||
|
die(_('Constrollo CSRF fallito!'));
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// Aggiunta del wrapper personalizzato per la generazione degli input
|
||||||
|
if (!empty($HTMLWrapper)) {
|
||||||
|
HTMLBuilder\HTMLBuilder::setWrapper($HTMLWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggiunta dei gestori personalizzati per la generazione degli input
|
||||||
|
foreach ((array) $HTMLHandlers as $key => $value) {
|
||||||
|
HTMLBuilder\HTMLBuilder::setHandler($key, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggiunta dei gestori per componenti personalizzate
|
||||||
|
foreach ((array) $HTMLManagers as $key => $value) {
|
||||||
|
HTMLBuilder\HTMLBuilder::setManager($key, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Registrazione globale del template per gli input HTML
|
||||||
|
register_shutdown_function('translateTemplate');
|
||||||
|
|
||||||
|
// Impostazione della sessione di base
|
||||||
|
$_SESSION['infos'] = (array) $_SESSION['errors'];
|
||||||
|
$_SESSION['warnings'] = (array) $_SESSION['errors'];
|
||||||
|
$_SESSION['errors'] = (array) $_SESSION['errors'];
|
||||||
|
|
||||||
|
// Imposto il periodo di visualizzazione dei record dal 01-01-yyy al 31-12-yyyy
|
||||||
|
if (!empty($_GET['period_start'])) {
|
||||||
|
$_SESSION['period_start'] = $_GET['period_start'];
|
||||||
|
$_SESSION['period_end'] = $_GET['period_end'];
|
||||||
|
} elseif (!isset($_SESSION['period_start'])) {
|
||||||
|
$_SESSION['period_start'] = date('Y').'-01-01';
|
||||||
|
$_SESSION['period_end'] = date('Y').'-12-31';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Impostazione del tema grafico di default
|
||||||
|
$theme = !empty($theme) ? $theme : 'default';
|
||||||
|
|
||||||
|
$assets = $rootdir.'/assets/dist';
|
||||||
|
$css = $assets.'/css';
|
||||||
|
$js = $assets.'/js';
|
||||||
|
$img = $assets.'/img';
|
||||||
|
|
||||||
|
// CSS di base del progetto
|
||||||
|
$css_modules = [];
|
||||||
|
|
||||||
|
$css_modules[] = $css.'/app.min.css';
|
||||||
|
$css_modules[] = $css.'/style.min.css';
|
||||||
|
$css_modules[] = $css.'/themes.min.css';
|
||||||
|
$css_modules[] = [
|
||||||
|
'href' => $css.'/print.min.css',
|
||||||
|
'media' => 'print',
|
||||||
|
];
|
||||||
|
|
||||||
|
// JS di base del progetto
|
||||||
|
$jscript_modules = [];
|
||||||
|
|
||||||
|
$jscript_modules[] = $js.'/app.min.js';
|
||||||
|
$jscript_modules[] = $js.'/custom.min.js';
|
||||||
|
$jscript_modules[] = $js.'/i18n/parsleyjs/'.$lang.'.min.js';
|
||||||
|
$jscript_modules[] = $js.'/i18n/select2/'.$lang.'.min.js';
|
||||||
|
$jscript_modules[] = $js.'/i18n/moment/'.$lang.'.min.js';
|
||||||
|
$jscript_modules[] = $js.'/i18n/fullcalendar/'.$lang.'.min.js';
|
||||||
|
|
||||||
|
if (Auth::check()) {
|
||||||
|
$jscript_modules[] = $rootdir.'/lib/functions.js';
|
||||||
|
$jscript_modules[] = $rootdir.'/lib/init.js';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($continue) {
|
||||||
|
if (!empty($debugbar)) {
|
||||||
|
$debugbar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($dbo->getPDO()));
|
||||||
|
}
|
||||||
|
|
||||||
|
$id_module = filter('id_module');
|
||||||
|
$id_record = filter('id_record');
|
||||||
|
$id_plugin = filter('id_plugin');
|
||||||
|
$id_parent = filter('id_parent');
|
||||||
|
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
if (!empty($id_module)) {
|
||||||
|
$module = Modules::getModule($id_module);
|
||||||
|
|
||||||
|
$pageTitle = $module['title'];
|
||||||
|
|
||||||
|
Permissions::addModule($id_module);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($skip_permissions)) {
|
||||||
|
Permissions::skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
Permissions::check();
|
||||||
|
|
||||||
|
// Retrocompatibilità
|
||||||
|
$user_idanagrafica = $user['idanagrafica'];
|
||||||
|
|
||||||
|
$rs = $dbo->fetchArray('SELECT * FROM `zz_modules` LEFT JOIN (SELECT `idmodule`, `permessi` FROM `zz_permissions` WHERE `idgruppo`=(SELECT `idgruppo` FROM `zz_users` WHERE `idutente`='.prepare($_SESSION['idutente']).')) AS `zz_permissions` ON `zz_modules`.`id`=`zz_permissions`.`idmodule` LEFT JOIN (SELECT `idmodule`, `clause` FROM `zz_group_module` WHERE `idgruppo`=(SELECT `idgruppo` FROM `zz_users` WHERE `idutente`='.prepare($_SESSION['idutente']).')) AS `zz_group_module` ON `zz_modules`.`id`=`zz_group_module`.`idmodule`');
|
||||||
|
|
||||||
|
$modules_info = [];
|
||||||
|
for ($i = 0; $i < count($rs); ++$i) {
|
||||||
|
foreach ($rs[$i] as $name => $value) {
|
||||||
|
if ($name == 'permessi' && (Auth::admin() || $value == null)) {
|
||||||
|
if (Auth::admin()) {
|
||||||
|
$value = 'rw';
|
||||||
|
} else {
|
||||||
|
$value = '-';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($name != 'idmodule' && $name != 'updated_at' && $name != 'created_at' && $name != 'clause') {
|
||||||
|
$modules_info[$rs[$i]['name']][$name] = $value;
|
||||||
|
} elseif ($name == 'clause') {
|
||||||
|
$additional_where[$rs[$i]['name']] = !empty($value) ? ' AND '.$value : $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$modules_info[$rs[$i]['id']]['name'] = $rs[$i]['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Istanziamento di HTMLHelper (retrocompatibilità)
|
||||||
|
$html = new HTMLHelper();
|
||||||
|
}
|
||||||
|
|
||||||
// Variabili GET e POST
|
// Variabili GET e POST
|
||||||
$post = Filter::getPOST();
|
$post = Filter::getPOST();
|
||||||
|
12
couscous.yml
12
couscous.yml
@@ -6,7 +6,7 @@ include:
|
|||||||
|
|
||||||
branch: gh-pages
|
branch: gh-pages
|
||||||
|
|
||||||
baseUrl: /openstamanager
|
baseUrl: .
|
||||||
|
|
||||||
github:
|
github:
|
||||||
user: devcode-it
|
user: devcode-it
|
||||||
@@ -16,6 +16,10 @@ title: OpenSTAManager
|
|||||||
subTitle: Il gestionale open source per l'assistenza tecnica e la fatturazione
|
subTitle: Il gestionale open source per l'assistenza tecnica e la fatturazione
|
||||||
fontAwesomeIcon: fa fa-cog
|
fontAwesomeIcon: fa fa-cog
|
||||||
|
|
||||||
|
scripts:
|
||||||
|
after:
|
||||||
|
- php sami.phar update sami.config.php
|
||||||
|
|
||||||
# The left menu bar
|
# The left menu bar
|
||||||
menu:
|
menu:
|
||||||
sections:
|
sections:
|
||||||
@@ -43,9 +47,9 @@ menu:
|
|||||||
api:
|
api:
|
||||||
text: API
|
text: API
|
||||||
relativeUrl: api.html
|
relativeUrl: api.html
|
||||||
#docs:
|
docs:
|
||||||
# text: Documentazione completa
|
text: Documentazione completa
|
||||||
# relativeUrl: docs/
|
relativeUrl: docs/
|
||||||
osm:
|
osm:
|
||||||
text: Sito ufficiale
|
text: Sito ufficiale
|
||||||
absoluteUrl: http://www.openstamanager.com/
|
absoluteUrl: http://www.openstamanager.com/
|
||||||
|
@@ -1,11 +1,16 @@
|
|||||||
---
|
---
|
||||||
currentMenu: nucleo
|
currentMenu: struttura
|
||||||
---
|
---
|
||||||
|
|
||||||
# Nucleo
|
# Struttura generale
|
||||||
|
|
||||||
<!-- TOC depthFrom:2 depthTo:6 orderedList:false updateOnSave:true withLinks:true -->
|
<!-- TOC depthFrom:2 depthTo:6 orderedList:false updateOnSave:true withLinks:true -->
|
||||||
|
|
||||||
|
- [Caratteristiche](#caratteristiche)
|
||||||
|
- [Open source](#open-source)
|
||||||
|
- [Modulare e personalizzabile](#modulare-e-personalizzabile)
|
||||||
|
- [Multipiattaforma e user friendly](#multipiattaforma-e-user-friendly)
|
||||||
|
- [Struttura](#struttura)
|
||||||
- [Root](#root)
|
- [Root](#root)
|
||||||
- [add.php](#addphp)
|
- [add.php](#addphp)
|
||||||
- [ajax_autocomplete.php](#ajax_autocompletephp)
|
- [ajax_autocomplete.php](#ajax_autocompletephp)
|
||||||
@@ -49,6 +54,25 @@ currentMenu: nucleo
|
|||||||
|
|
||||||
<!-- /TOC -->
|
<!-- /TOC -->
|
||||||
|
|
||||||
|
## Caratteristiche
|
||||||
|
|
||||||
|
### Open source
|
||||||
|
La natura open source (termine inglese che significa _sorgente aperta_) del progetto evidenzia lo spirito di collaborazione e condivisione che pervade l'attività di sviluppo del gestionale, di cui gli autori rendono pubblico il codice sorgente e ne favoriscono il libero studio, permettendo a programmatori indipendenti di apportarvi modifiche ed estensioni.
|
||||||
|
|
||||||
|
Particolarmente espressiva in questo senso risulta essere la documentazione ufficiale del progetto:
|
||||||
|
> Il progetto è un software open source perché permette agli utilizzatori di studiarne il funzionamento ed adattarlo alle proprie esigenze; inoltre, in ambito commerciale, non obbliga l'utilizzatore ad essere legato allo stesso fornitore di assistenza.
|
||||||
|
|
||||||
|
La licenza in utilizzo è la GNU General Public License 3.0 (GPL 3.0).
|
||||||
|
|
||||||
|
### Modulare e personalizzabile
|
||||||
|
OpenSTAManager possiede una struttura fortemente modulare, che ne permette la rapida espandibilità e, nello specifico, la realizzazione di funzionalità _ad hoc_, personalizzate nel modo più completo secondo le richieste del cliente.
|
||||||
|
|
||||||
|
### Multipiattaforma e user friendly
|
||||||
|
Il progetto risulta compatibile con numerose piattaforme, necessitando esclusivamente un browser moderno da parte dei suoi utilizzatori per sfruttare appieno le sue potenzialità.
|
||||||
|
L'interfaccia di interazione con l'utente finale risulta inoltre estremamente semplificata e _user friendly_, oltre che _responsive_, presentando caratteristiche completamente compatibili con tutti i dispositivi mobili (in particolare, tablet e smartphone).
|
||||||
|
|
||||||
|
## Struttura
|
||||||
|
|
||||||
Scaricando la versione GIT del progetto dovreste trovare una struttura di base molto simile a quella seguente.
|
Scaricando la versione GIT del progetto dovreste trovare una struttura di base molto simile a quella seguente.
|
||||||
|
|
||||||
.
|
.
|
@@ -231,7 +231,7 @@ gulp.task('release', function () {
|
|||||||
var archiver = require('archiver');
|
var archiver = require('archiver');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
|
||||||
// shell.exec('svn info --show-item=revision . > REVISION');
|
shell.exec('git rev-parse --short HEAD > REVISION');
|
||||||
|
|
||||||
del([
|
del([
|
||||||
'./vendor/tecnickcom/tcpdf/fonts/*',
|
'./vendor/tecnickcom/tcpdf/fonts/*',
|
||||||
@@ -242,7 +242,7 @@ gulp.task('release', function () {
|
|||||||
var archive = archiver('zip');
|
var archive = archiver('zip');
|
||||||
|
|
||||||
output.on('close', function() {
|
output.on('close', function() {
|
||||||
console.log('done!');
|
console.log('ZIP completato!');
|
||||||
});
|
});
|
||||||
|
|
||||||
archive.on('error', function(err) {
|
archive.on('error', function(err) {
|
||||||
@@ -258,6 +258,7 @@ gulp.task('release', function () {
|
|||||||
'node_modules/**',
|
'node_modules/**',
|
||||||
'backup/**',
|
'backup/**',
|
||||||
'files/**',
|
'files/**',
|
||||||
|
'logs/**',
|
||||||
'config.inc.php',
|
'config.inc.php',
|
||||||
'*.lock',
|
'*.lock',
|
||||||
'*.phar',
|
'*.phar',
|
||||||
@@ -271,6 +272,7 @@ gulp.task('release', function () {
|
|||||||
archive.file('backup/.htaccess');
|
archive.file('backup/.htaccess');
|
||||||
archive.file('files/.htaccess');
|
archive.file('files/.htaccess');
|
||||||
archive.file('files/my_impianti/componente.ini');
|
archive.file('files/my_impianti/componente.ini');
|
||||||
|
archive.file('logs/.htaccess');
|
||||||
|
|
||||||
archive.finalize();
|
archive.finalize();
|
||||||
});
|
});
|
||||||
|
@@ -10,7 +10,7 @@ switch ($op) {
|
|||||||
case 'login':
|
case 'login':
|
||||||
$username = filter('username');
|
$username = filter('username');
|
||||||
$password = filter('password');
|
$password = filter('password');
|
||||||
if ($dbo->isConnected() && $dbo->isInstalled() && $auth->attempt($username, $password)) {
|
if ($dbo->isConnected() && $dbo->isInstalled() && Auth::getInstance()->attempt($username, $password)) {
|
||||||
$_SESSION['keep_alive'] = (filter('keep_alive') != null);
|
$_SESSION['keep_alive'] = (filter('keep_alive') != null);
|
||||||
|
|
||||||
// Auto backup del database giornaliero
|
// Auto backup del database giornaliero
|
||||||
@@ -59,7 +59,7 @@ switch ($op) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Auth::check() && isset($dbo) && $dbo->isConnected() && $dbo->isInstalled()) {
|
if (Auth::check() && isset($dbo) && $dbo->isConnected() && $dbo->isInstalled()) {
|
||||||
$module = $auth->getFirstModule();
|
$module = Auth::firstModule();
|
||||||
|
|
||||||
if (!empty($module)) {
|
if (!empty($module)) {
|
||||||
redirect(ROOTDIR.'/controller.php?id_module='.$module, 'js');
|
redirect(ROOTDIR.'/controller.php?id_module='.$module, 'js');
|
||||||
|
@@ -34,7 +34,7 @@ class API extends \Util\Singleton
|
|||||||
|
|
||||||
public function __construct($token)
|
public function __construct($token)
|
||||||
{
|
{
|
||||||
$user = Auth::getUser();
|
$user = Auth::user();
|
||||||
|
|
||||||
if (!self::isAPIRequest() || empty($user)) {
|
if (!self::isAPIRequest() || empty($user)) {
|
||||||
throw new InvalidArgumentException();
|
throw new InvalidArgumentException();
|
||||||
|
@@ -5,21 +5,57 @@
|
|||||||
*
|
*
|
||||||
* @since 2.3
|
* @since 2.3
|
||||||
*/
|
*/
|
||||||
class Auth
|
class Auth extends \Util\Singleton
|
||||||
{
|
{
|
||||||
protected static $infos;
|
protected static $status = [
|
||||||
protected static $first_module = null;
|
'success' => [
|
||||||
|
'code' => 1,
|
||||||
|
'message' => 'Login riuscito!',
|
||||||
|
],
|
||||||
|
'failed' => [
|
||||||
|
'code' => 0,
|
||||||
|
'message' => 'Autenticazione fallita!',
|
||||||
|
],
|
||||||
|
'disabled' => [
|
||||||
|
'code' => 2,
|
||||||
|
'message' => 'Utente non abilitato!',
|
||||||
|
],
|
||||||
|
'unauthorized' => [
|
||||||
|
'code' => 3,
|
||||||
|
'message' => "L'utente non ha nessun permesso impostato!",
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
public function __construct()
|
protected $infos;
|
||||||
|
protected $first_module;
|
||||||
|
|
||||||
|
protected $passwordOptions = [
|
||||||
|
'algorithm' => PASSWORD_BCRYPT,
|
||||||
|
'options' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function __construct()
|
||||||
{
|
{
|
||||||
$database = Database::getConnection();
|
$database = Database::getConnection();
|
||||||
|
|
||||||
if (API::isAPIRequest()) {
|
if ($database->isInstalled()) {
|
||||||
$this->api(filter('token'));
|
if (API::isAPIRequest()) {
|
||||||
}
|
$token = filter('token');
|
||||||
// Controllo sulla sessione attiva
|
|
||||||
elseif (!empty($_SESSION['idutente']) && $database->isConnected() && $database->isInstalled()) {
|
$id = $database->fetchArray('SELECT `id_utente` FROM `zz_tokens` WHERE `token` = '.prepare($token))[0]['id_utente'];
|
||||||
$this->find();
|
}
|
||||||
|
// Controllo sulla sessione attiva
|
||||||
|
elseif (!empty($_SESSION['idutente'])) {
|
||||||
|
$id = $_SESSION['idutente'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($id)) {
|
||||||
|
$this->identifyUser($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($_SESSION['idutente']) && $this->isAuthenticated()) {
|
||||||
|
$this->saveToSession();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,187 +65,126 @@ class Auth
|
|||||||
|
|
||||||
$database = Database::getConnection();
|
$database = Database::getConnection();
|
||||||
|
|
||||||
$users = $database->fetchArray('SELECT idutente, username, password, enabled FROM zz_users WHERE username = '.prepare($username).' LIMIT 1');
|
|
||||||
|
|
||||||
$log = [];
|
$log = [];
|
||||||
$log['username'] = $username;
|
$log['username'] = $username;
|
||||||
$log['ip'] = get_client_ip();
|
$log['ip'] = get_client_ip();
|
||||||
$log['stato'] = 0;
|
$log['stato'] = self::$status['failed']['code'];
|
||||||
|
|
||||||
|
$users = $database->fetchArray('SELECT idutente, password, enabled FROM zz_users WHERE username = '.prepare($username).' LIMIT 1');
|
||||||
if (!empty($users)) {
|
if (!empty($users)) {
|
||||||
$user = $users[0];
|
$user = $users[0];
|
||||||
|
|
||||||
if (empty($user['enabled'])) {
|
if (!empty($user['enabled'])) {
|
||||||
$log['stato'] = 2;
|
$this->identifyUser($user['idutente']);
|
||||||
|
$module = $this->getFirstModule();
|
||||||
|
|
||||||
|
if (
|
||||||
|
$this->isAuthenticated() &&
|
||||||
|
$this->password_check($password, $user['password'], $user['idutente']) &&
|
||||||
|
!empty($module)
|
||||||
|
) {
|
||||||
|
$log['idutente'] = $this->infos['idutente'];
|
||||||
|
$log['stato'] = self::$status['success']['code'];
|
||||||
|
|
||||||
|
$this->saveToSession();
|
||||||
|
} else {
|
||||||
|
if (empty($module)) {
|
||||||
|
$log['stato'] = self::$status['unauthorized']['code'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->logout();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$_SESSION['idutente'] = $user['idutente'];
|
$log['stato'] = self::$status['disabled']['code'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$continue = $this->password_check($password, $user['password']) && $this->find();
|
if ($log['stato'] != self::$status['success']['code']) {
|
||||||
if (!$continue || empty(self::$first_module)) {
|
foreach (self::$status as $key => $value) {
|
||||||
if ($continue && empty(self::$first_module)) {
|
if ($log['stato'] == $value['code']) {
|
||||||
$log['stato'] = 3;
|
$_SESSION['errors'][] = $value['message'];
|
||||||
}
|
break;
|
||||||
|
|
||||||
self::logout();
|
|
||||||
} else {
|
|
||||||
$log['idutente'] = self::$infos['idutente'];
|
|
||||||
$log['stato'] = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$messages = [
|
$database->insert('zz_logs', $log);
|
||||||
0 => _('Autenticazione fallita!'),
|
|
||||||
2 => _('Utente non abilitato!'),
|
|
||||||
3 => _("L'utente non ha nessun permesso impostato!"),
|
|
||||||
];
|
|
||||||
if (!empty($messages[$log['stato']])) {
|
|
||||||
$_SESSION['errors'][] = $messages[$log['stato']];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($log as $key => $value) {
|
return $this->isAuthenticated();
|
||||||
$log[$key] = prepare($value);
|
|
||||||
}
|
|
||||||
$database->query('INSERT INTO zz_logs('.implode(', ', array_keys($log)).') VALUES('.implode(', ', $log).')');
|
|
||||||
|
|
||||||
return self::check();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function password_check($password, $hash)
|
protected function password_check($password, $hash, $user_id = null)
|
||||||
{
|
{
|
||||||
|
$result = false;
|
||||||
|
|
||||||
|
// Retrocompatibilità
|
||||||
if ($hash == md5($password)) {
|
if ($hash == md5($password)) {
|
||||||
$database = Database::getConnection();
|
$rehash = true;
|
||||||
|
|
||||||
$database->query('UPDATE zz_users SET password='.prepare(self::hashPassword($password)).' WHERE idutente = '.prepare($_SESSION['idutente']));
|
$result = true;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Nuova versione
|
||||||
if (password_verify($password, $hash)) {
|
if (password_verify($password, $hash)) {
|
||||||
return true;
|
$rehash = password_needs_rehash($hash, $this->passwordOptions['algorithm'], $this->passwordOptions['options']);
|
||||||
|
|
||||||
|
$result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
// Controllo in automatico per futuri cambiamenti dell'algoritmo di password
|
||||||
|
if ($rehash) {
|
||||||
|
$database = Database::getConnection();
|
||||||
|
$database->update('zz_users', ['password' => password_hash($password, $this->passwordOptions['algorithm'], $this->passwordOptions['options'])], ['idutente' => $user_id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function saveToSession()
|
||||||
* Crea la l'hash della password per il successivo salvataggio all'interno del database.
|
|
||||||
*
|
|
||||||
* @since 2.3
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function hashPassword($password)
|
|
||||||
{
|
{
|
||||||
return password_hash($password, PASSWORD_BCRYPT);
|
foreach ($this->infos as $key => $value) {
|
||||||
|
$_SESSION[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$identifier = md5($_SESSION['idutente'].$_SERVER['HTTP_USER_AGENT']);
|
||||||
|
if ((empty($_SESSION['last_active']) || time() < $_SESSION['last_active'] + (60 * 60)) && (empty($_SESSION['identifier']) || $_SESSION['identifier'] == $identifier)) {
|
||||||
|
$_SESSION['last_active'] = time();
|
||||||
|
$_SESSION['identifier'] = $identifier;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function find()
|
protected function identifyUser($user_id)
|
||||||
{
|
{
|
||||||
$database = Database::getConnection();
|
$database = Database::getConnection();
|
||||||
|
|
||||||
$user = self::userInfo($_SESSION['idutente']);
|
$results = $database->fetchArray('SELECT idutente, idanagrafica, username, (SELECT nome FROM zz_groups WHERE id=idgruppo) AS gruppo FROM zz_users WHERE idutente = '.prepare($user_id).' AND enabled = 1 LIMIT 1');
|
||||||
|
|
||||||
if (!empty($user)) {
|
|
||||||
foreach ($user as $key => $value) {
|
|
||||||
$_SESSION[$key] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$infos = $user;
|
|
||||||
|
|
||||||
$query = 'SELECT id FROM zz_modules WHERE enabled = 1';
|
|
||||||
if (!self::isAdmin()) {
|
|
||||||
$query .= ' AND id IN (SELECT idmodule FROM zz_permissions WHERE idgruppo = (SELECT id FROM zz_groups WHERE nome = '.prepare($_SESSION['gruppo']).") AND permessi IN ('r', 'rw'))";
|
|
||||||
}
|
|
||||||
|
|
||||||
$results = $database->fetchArray($query.' ORDER BY `order` ASC');
|
|
||||||
|
|
||||||
if (!empty($results)) {
|
|
||||||
$module = null;
|
|
||||||
|
|
||||||
$first = get_var('Prima pagina');
|
|
||||||
if (array_search($first, array_column($results, 'id')) === false) {
|
|
||||||
foreach ($results as $result) {
|
|
||||||
if (!empty($result['options']) && $result['options'] != 'menu') {
|
|
||||||
$module = $result['id'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$module = $first;
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$first_module = $module;
|
|
||||||
}
|
|
||||||
|
|
||||||
$identifier = md5($_SESSION['idutente'].$_SERVER['HTTP_USER_AGENT']);
|
|
||||||
if ((empty($_SESSION['last_active']) || time() < $_SESSION['last_active'] + (60 * 60)) && (empty($_SESSION['identifier']) || $_SESSION['identifier'] == $identifier)) {
|
|
||||||
$_SESSION['last_active'] = time();
|
|
||||||
$_SESSION['identifier'] = $identifier;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self::logout();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function userInfo($user_id)
|
|
||||||
{
|
|
||||||
$database = Database::getConnection();
|
|
||||||
|
|
||||||
$results = $database->fetchArray('SELECT *, (SELECT nome FROM zz_groups WHERE id=idgruppo) AS gruppo FROM zz_users WHERE idutente = '.prepare($user_id).' AND enabled = 1 LIMIT 1');
|
|
||||||
|
|
||||||
$infos = [];
|
|
||||||
|
|
||||||
if (!empty($results)) {
|
if (!empty($results)) {
|
||||||
$infos['idutente'] = $results[0]['idutente'];
|
$results[0]['is_admin'] = ($results[0]['gruppo'] == 'Amministratori');
|
||||||
$infos['is_admin'] = ($results[0]['gruppo'] == 'Amministratori');
|
|
||||||
$infos['idanagrafica'] = $results[0]['idanagrafica'];
|
$this->infos = $results[0];
|
||||||
$infos['username'] = $results[0]['username'];
|
|
||||||
$infos['gruppo'] = $results[0]['gruppo'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $infos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function isAuthenticated()
|
||||||
* Controlla se la chiave di accesso per l'API abilita l'accesso di un utente.
|
|
||||||
*
|
|
||||||
* @param string $token Chiave
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function api($token)
|
|
||||||
{
|
{
|
||||||
$database = Database::getConnection();
|
return !empty($this->infos);
|
||||||
|
|
||||||
$results = $database->fetchArray('SELECT `id_utente` FROM `zz_tokens` WHERE `token` = '.prepare($token));
|
|
||||||
|
|
||||||
if (!empty($results)) {
|
|
||||||
self::$infos = self::userInfo($results[0]['id_utente']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$infos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function check()
|
public function isAdmin()
|
||||||
{
|
{
|
||||||
return !empty(self::$infos);
|
return $this->isAuthenticated() && !empty($this->infos['is_admin']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isAdmin()
|
public function getUser()
|
||||||
{
|
{
|
||||||
return self::check() && !empty(self::$infos['is_admin']);
|
return $this->infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function logout()
|
public function destory()
|
||||||
{
|
{
|
||||||
if (self::check() || !empty($_SESSION['idutente'])) {
|
if ($this->isAuthenticated() || !empty($_SESSION['idutente'])) {
|
||||||
self::$infos = null;
|
$this->infos = null;
|
||||||
self::$first_module = null;
|
$this->first_module = null;
|
||||||
|
|
||||||
session_unset();
|
session_unset();
|
||||||
session_destroy();
|
session_destroy();
|
||||||
@@ -222,13 +197,61 @@ class Auth
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFirstModule()
|
public function getFirstModule()
|
||||||
{
|
{
|
||||||
return self::$first_module;
|
if (empty($this->first_module)) {
|
||||||
|
$query = 'SELECT id FROM zz_modules WHERE enabled = 1';
|
||||||
|
if (!$this->isAdmin()) {
|
||||||
|
$query .= ' AND id IN (SELECT idmodule FROM zz_permissions WHERE idgruppo = (SELECT id FROM zz_groups WHERE nome = '.prepare($_SESSION['gruppo']).") AND permessi IN ('r', 'rw'))";
|
||||||
|
}
|
||||||
|
|
||||||
|
$database = Database::getConnection();
|
||||||
|
$results = $database->fetchArray($query." AND options != '' AND options != 'menu' AND options IS NOT NULL ORDER BY `order` ASC");
|
||||||
|
|
||||||
|
if (!empty($results)) {
|
||||||
|
$module = null;
|
||||||
|
|
||||||
|
$first = Settings::get('Prima pagina');
|
||||||
|
if (!in_array($first, array_column($results, 'id'))) {
|
||||||
|
$module = $results[0]['id'];
|
||||||
|
} else {
|
||||||
|
$module = $first;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->first_module = $module;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->first_module;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUser()
|
public static function check()
|
||||||
{
|
{
|
||||||
return self::$infos;
|
return self::getInstance()->isAuthenticated();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function admin()
|
||||||
|
{
|
||||||
|
return self::getInstance()->isAdmin();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function user()
|
||||||
|
{
|
||||||
|
return self::getInstance()->getUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function logout()
|
||||||
|
{
|
||||||
|
return self::getInstance()->destory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function firstModule()
|
||||||
|
{
|
||||||
|
return self::getInstance()->getFirstModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getStatus()
|
||||||
|
{
|
||||||
|
return self::$status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -135,10 +135,6 @@ class CSRF extends Util\Singleton
|
|||||||
return $this->storage;
|
return $this->storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session_status() == PHP_SESSION_NONE) {
|
|
||||||
session_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!array_key_exists($this->prefix, $_SESSION)) {
|
if (!array_key_exists($this->prefix, $_SESSION)) {
|
||||||
$_SESSION[$this->prefix] = [];
|
$_SESSION[$this->prefix] = [];
|
||||||
}
|
}
|
||||||
|
@@ -90,16 +90,18 @@ class Database extends Util\Singleton
|
|||||||
*/
|
*/
|
||||||
public static function getConnection($new = false)
|
public static function getConnection($new = false)
|
||||||
{
|
{
|
||||||
if (empty(parent::$instance) || !parent::$instance->isConnected() || $new) {
|
$class = get_called_class(); // late-static-bound class name
|
||||||
|
|
||||||
|
if (empty(parent::$instance[$class]) || !parent::$instance[$class]->isConnected() || $new) {
|
||||||
global $db_host;
|
global $db_host;
|
||||||
global $db_username;
|
global $db_username;
|
||||||
global $db_password;
|
global $db_password;
|
||||||
global $db_name;
|
global $db_name;
|
||||||
|
|
||||||
parent::$instance = new self($db_host, $db_username, $db_password, $db_name);
|
parent::$instance[$class] = new self($db_host, $db_username, $db_password, $db_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::$instance;
|
return parent::$instance[$class];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getInstance()
|
public static function getInstance()
|
||||||
|
@@ -28,7 +28,7 @@ class Modules
|
|||||||
if (empty(self::$modules)) {
|
if (empty(self::$modules)) {
|
||||||
$database = Database::getConnection();
|
$database = Database::getConnection();
|
||||||
|
|
||||||
$user = Auth::getUser();
|
$user = Auth::user();
|
||||||
|
|
||||||
$results = $database->fetchArray('SELECT * FROM `zz_modules` LEFT JOIN (SELECT `idmodule`, `permessi` FROM `zz_permissions` WHERE `idgruppo` = (SELECT `idgruppo` FROM `zz_users` WHERE `idutente` = '.prepare($user['idutente']).')) AS `zz_permissions` ON `zz_modules`.`id`=`zz_permissions`.`idmodule` LEFT JOIN (SELECT `idmodule`, `clause`, `position` FROM `zz_group_module` WHERE `idgruppo` = (SELECT `idgruppo` FROM `zz_users` WHERE `idutente` = '.prepare($user['idutente']).') AND `enabled` = 1) AS `zz_group_module` ON `zz_modules`.`id`=`zz_group_module`.`idmodule`');
|
$results = $database->fetchArray('SELECT * FROM `zz_modules` LEFT JOIN (SELECT `idmodule`, `permessi` FROM `zz_permissions` WHERE `idgruppo` = (SELECT `idgruppo` FROM `zz_users` WHERE `idutente` = '.prepare($user['idutente']).')) AS `zz_permissions` ON `zz_modules`.`id`=`zz_permissions`.`idmodule` LEFT JOIN (SELECT `idmodule`, `clause`, `position` FROM `zz_group_module` WHERE `idgruppo` = (SELECT `idgruppo` FROM `zz_users` WHERE `idutente` = '.prepare($user['idutente']).') AND `enabled` = 1) AS `zz_group_module` ON `zz_modules`.`id`=`zz_group_module`.`idmodule`');
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ class Modules
|
|||||||
|
|
||||||
if (empty($modules[$result['id']])) {
|
if (empty($modules[$result['id']])) {
|
||||||
if (empty($result['permessi'])) {
|
if (empty($result['permessi'])) {
|
||||||
if (Auth::isAdmin()) {
|
if (Auth::admin()) {
|
||||||
$result['permessi'] = 'rw';
|
$result['permessi'] = 'rw';
|
||||||
} else {
|
} else {
|
||||||
$result['permessi'] = '-';
|
$result['permessi'] = '-';
|
||||||
@@ -200,7 +200,7 @@ class Modules
|
|||||||
if (strpos($options, '|select|') !== false) {
|
if (strpos($options, '|select|') !== false) {
|
||||||
$query = $options;
|
$query = $options;
|
||||||
|
|
||||||
$user = Auth::getUser();
|
$user = Auth::user();
|
||||||
|
|
||||||
$datas = $database->fetchArray('SELECT * FROM `zz_views` WHERE `id_module`='.prepare($id).' AND `id` IN (SELECT `id_vista` FROM `zz_group_view` WHERE `id_gruppo`=(SELECT `idgruppo` FROM `zz_users` WHERE `idutente`='.prepare($user['idutente']).')) ORDER BY `order` ASC');
|
$datas = $database->fetchArray('SELECT * FROM `zz_views` WHERE `id_module`='.prepare($id).' AND `id` IN (SELECT `id_vista` FROM `zz_group_view` WHERE `id_gruppo`=(SELECT `idgruppo` FROM `zz_users` WHERE `idutente`='.prepare($user['idutente']).')) ORDER BY `order` ASC');
|
||||||
|
|
||||||
@@ -270,7 +270,7 @@ class Modules
|
|||||||
|
|
||||||
public static function replacePlaceholder($query, $custom = null)
|
public static function replacePlaceholder($query, $custom = null)
|
||||||
{
|
{
|
||||||
$user = Auth::getUser();
|
$user = Auth::user();
|
||||||
|
|
||||||
$custom = empty($custom) ? $user['idanagrafica'] : $custom;
|
$custom = empty($custom) ? $user['idanagrafica'] : $custom;
|
||||||
$result = str_replace(['|idagente|', '|idtecnico|', '|idanagrafica|'], prepare($custom), $query);
|
$result = str_replace(['|idagente|', '|idtecnico|', '|idanagrafica|'], prepare($custom), $query);
|
||||||
|
@@ -5,10 +5,10 @@ namespace Util;
|
|||||||
/**
|
/**
|
||||||
* @since 2.3
|
* @since 2.3
|
||||||
*/
|
*/
|
||||||
class Singleton
|
abstract class Singleton
|
||||||
{
|
{
|
||||||
/** @var \Util\Singleton Oggetto istanziato */
|
/** @var \Util\Singleton Oggetto istanziato */
|
||||||
protected static $instance = null;
|
protected static $instance = [];
|
||||||
|
|
||||||
protected function __construct()
|
protected function __construct()
|
||||||
{
|
{
|
||||||
@@ -21,11 +21,13 @@ class Singleton
|
|||||||
*/
|
*/
|
||||||
public static function getInstance()
|
public static function getInstance()
|
||||||
{
|
{
|
||||||
if (self::$instance === null) {
|
$class = get_called_class(); // late-static-bound class name
|
||||||
self::$instance = new static();
|
|
||||||
|
if (self::$instance[$class] === null) {
|
||||||
|
self::$instance[$class] = new static();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$instance;
|
return self::$instance[$class];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function __clone()
|
private function __clone()
|
||||||
|
17
log.php
17
log.php
@@ -32,7 +32,7 @@ echo '
|
|||||||
/*
|
/*
|
||||||
LEGGO DALLA TABELLA ZZ_LOG
|
LEGGO DALLA TABELLA ZZ_LOG
|
||||||
*/
|
*/
|
||||||
if (Auth::isAdmin()) {
|
if (Auth::admin()) {
|
||||||
$q = 'SELECT * FROM `zz_logs` ORDER BY `created_at` DESC LIMIT 0, 100';
|
$q = 'SELECT * FROM `zz_logs` ORDER BY `created_at` DESC LIMIT 0, 100';
|
||||||
} else {
|
} else {
|
||||||
$q = 'SELECT * FROM `zz_logs` WHERE `idutente`='.prepare($_SESSION['idutente']).' ORDER BY `created_at` DESC LIMIT 0, 100';
|
$q = 'SELECT * FROM `zz_logs` WHERE `idutente`='.prepare($_SESSION['idutente']).' ORDER BY `created_at` DESC LIMIT 0, 100';
|
||||||
@@ -48,18 +48,19 @@ for ($i = 0; $i < $n; ++$i) {
|
|||||||
|
|
||||||
$timestamp = Translator::timestampToLocale($rs[$i]['created_at']);
|
$timestamp = Translator::timestampToLocale($rs[$i]['created_at']);
|
||||||
|
|
||||||
if ($rs[$i]['stato'] == 1) {
|
$status = Auth::getStatus();
|
||||||
|
if ($rs[$i]['stato'] == $status['success']['code']) {
|
||||||
$type = 'success';
|
$type = 'success';
|
||||||
$stato = _('Login riuscito!');
|
$stato = $status['success']['message'];
|
||||||
} elseif ($rs[$i]['stato'] == 2) {
|
} elseif ($rs[$i]['stato'] == $status['disabled']['code']) {
|
||||||
$type = 'warning';
|
$type = 'warning';
|
||||||
$stato = _('Utente non abilitato!');
|
$stato = $status['disabled']['message'];
|
||||||
} elseif ($rs[$i]['stato'] == 3) {
|
} elseif ($rs[$i]['stato'] == $status['unauthorized']['code']) {
|
||||||
$type = 'warning';
|
$type = 'warning';
|
||||||
$stato = _("L'utente non ha nessun permesso impostato!");
|
$stato = $status['unauthorized']['message'];
|
||||||
} else {
|
} else {
|
||||||
$type = 'danger';
|
$type = 'danger';
|
||||||
$stato = _('Autenticazione fallita!');
|
$stato = $status['failed']['message'];
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
@@ -161,7 +161,7 @@ switch (post('op')) {
|
|||||||
// Lettura tipologia dell'utente loggato
|
// Lettura tipologia dell'utente loggato
|
||||||
$agente_is_logged = false;
|
$agente_is_logged = false;
|
||||||
|
|
||||||
$rs = $dbo->fetchArray('SELECT descrizione FROM an_tipianagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche.idtipoanagrafica = an_tipianagrafiche_anagrafiche.idtipoanagrafica WHERE idanagrafica = '.prepare($user_idanagrafica));
|
$rs = $dbo->fetchArray('SELECT descrizione FROM an_tipianagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche.idtipoanagrafica = an_tipianagrafiche_anagrafiche.idtipoanagrafica WHERE idanagrafica = '.prepare($user['idanagrafica']));
|
||||||
|
|
||||||
for ($i = 0; $i < count($rs); ++$i) {
|
for ($i = 0; $i < count($rs); ++$i) {
|
||||||
if ($rs[$i]['descrizione'] == 'Agente') {
|
if ($rs[$i]['descrizione'] == 'Agente') {
|
||||||
@@ -170,7 +170,7 @@ switch (post('op')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$idagente = ($agente_is_logged && strpos($tipoanagrafica_dst, 'Cliente') !== false) ? $user_idanagrafica : 0;
|
$idagente = ($agente_is_logged && strpos($tipoanagrafica_dst, 'Cliente') !== false) ? $user['idanagrafica'] : 0;
|
||||||
|
|
||||||
// Inserisco l'anagrafica
|
// Inserisco l'anagrafica
|
||||||
$query = 'INSERT INTO an_anagrafiche(ragione_sociale, codice, idagente) VALUES ('.prepare($ragione_sociale).', '.prepare($codice).', '.prepare($idagente).')';
|
$query = 'INSERT INTO an_anagrafiche(ragione_sociale, codice, idagente) VALUES ('.prepare($ragione_sociale).', '.prepare($codice).', '.prepare($idagente).')';
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
include_once __DIR__.'/../../core.php';
|
include_once __DIR__.'/../../core.php';
|
||||||
|
|
||||||
if (!isset($user_idanagrafica)) {
|
if (!isset($user['idanagrafica'])) {
|
||||||
$user_idanagrafica = '';
|
$user['idanagrafica'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (get('op')) {
|
switch (get('op')) {
|
||||||
|
@@ -14,12 +14,12 @@ if (!empty($rs)) {
|
|||||||
<th>'._('Articolo').'</th>
|
<th>'._('Articolo').'</th>
|
||||||
<th width="8%">'._('Q.tà').'</th>';
|
<th width="8%">'._('Q.tà').'</th>';
|
||||||
|
|
||||||
if (Auth::isAdmin() || $_SESSION['gruppo'] != 'Tecnici') {
|
if (Auth::admin() || $_SESSION['gruppo'] != 'Tecnici') {
|
||||||
echo '
|
echo '
|
||||||
<th width="15%">'._('Prezzo di acquisto').'</th>';
|
<th width="15%">'._('Prezzo di acquisto').'</th>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Auth::isAdmin() || $_SESSION['gruppo'] != 'Tecnici') {
|
if (Auth::admin() || $_SESSION['gruppo'] != 'Tecnici') {
|
||||||
echo '
|
echo '
|
||||||
<th width="15%">'._('Prezzo di vendita').'</th>
|
<th width="15%">'._('Prezzo di vendita').'</th>
|
||||||
<th width="15%">'._('Subtotale').'</th>';
|
<th width="15%">'._('Subtotale').'</th>';
|
||||||
@@ -94,14 +94,14 @@ if (!empty($rs)) {
|
|||||||
'.Translator::numberToLocale($r['qta']).' '.$r['um'].'
|
'.Translator::numberToLocale($r['qta']).' '.$r['um'].'
|
||||||
</td>';
|
</td>';
|
||||||
|
|
||||||
if (Auth::isAdmin() || $_SESSION['gruppo'] != 'Tecnici') {
|
if (Auth::admin() || $_SESSION['gruppo'] != 'Tecnici') {
|
||||||
echo '
|
echo '
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
'.Translator::numberToLocale($r['prezzo_acquisto']).' €
|
'.Translator::numberToLocale($r['prezzo_acquisto']).' €
|
||||||
</td>';
|
</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Auth::isAdmin() || $_SESSION['gruppo'] != 'Tecnici') {
|
if (Auth::admin() || $_SESSION['gruppo'] != 'Tecnici') {
|
||||||
// Prezzo unitario
|
// Prezzo unitario
|
||||||
echo '
|
echo '
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
|
@@ -7,7 +7,7 @@ $rss = $dbo->fetchArray('SELECT idtipointervento, sconto_globale, tipo_sconto_gl
|
|||||||
$sconto = $rss[0]['sconto_globale'];
|
$sconto = $rss[0]['sconto_globale'];
|
||||||
$tipo_sconto = $rss[0]['tipo_sconto_globale'];
|
$tipo_sconto = $rss[0]['tipo_sconto_globale'];
|
||||||
|
|
||||||
if (Auth::isAdmin() || $_SESSION['gruppo'] != 'Tecnici') {
|
if (Auth::admin() || $_SESSION['gruppo'] != 'Tecnici') {
|
||||||
$rsr = $dbo->fetchArray('SELECT * FROM vw_activity_subtotal WHERE id='.prepare($id_record));
|
$rsr = $dbo->fetchArray('SELECT * FROM vw_activity_subtotal WHERE id='.prepare($id_record));
|
||||||
|
|
||||||
$manodopera_costo = $rsr[0]['manodopera_costo'];
|
$manodopera_costo = $rsr[0]['manodopera_costo'];
|
||||||
|
@@ -13,7 +13,7 @@ if (count($rs2) > 0) {
|
|||||||
<th width="8%">'._('Q.tà').'</th>
|
<th width="8%">'._('Q.tà').'</th>
|
||||||
<th width="15%">'._('Prezzo di acquisto').'</th>';
|
<th width="15%">'._('Prezzo di acquisto').'</th>';
|
||||||
|
|
||||||
if (Auth::isAdmin() || $_SESSION['gruppo'] != 'Tecnici') {
|
if (Auth::admin() || $_SESSION['gruppo'] != 'Tecnici') {
|
||||||
echo '
|
echo '
|
||||||
<th width="15%">'._('Prezzo di vendita').'</th>
|
<th width="15%">'._('Prezzo di vendita').'</th>
|
||||||
<th width="15%">'._('Subtotale').'</th>';
|
<th width="15%">'._('Subtotale').'</th>';
|
||||||
@@ -46,7 +46,7 @@ if (count($rs2) > 0) {
|
|||||||
'.Translator::numberToLocale($r['prezzo_acquisto']).' €
|
'.Translator::numberToLocale($r['prezzo_acquisto']).' €
|
||||||
</td>';
|
</td>';
|
||||||
|
|
||||||
if (Auth::isAdmin() || $_SESSION['gruppo'] != 'Tecnici') {
|
if (Auth::admin() || $_SESSION['gruppo'] != 'Tecnici') {
|
||||||
// Prezzo unitario
|
// Prezzo unitario
|
||||||
$netto = $r['prezzo_vendita'] - $r['sconto_unitario'];
|
$netto = $r['prezzo_vendita'] - $r['sconto_unitario'];
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ $show_costi = true;
|
|||||||
|
|
||||||
// Limitazione delle azioni dei tecnici
|
// Limitazione delle azioni dei tecnici
|
||||||
if ($user['gruppo'] == 'Tecnici') {
|
if ($user['gruppo'] == 'Tecnici') {
|
||||||
$show_costi = !empty($user_idanagrafica) && get_var('Mostra i prezzi al tecnico');
|
$show_costi = !empty($user['idanagrafica']) && get_var('Mostra i prezzi al tecnico');
|
||||||
}
|
}
|
||||||
|
|
||||||
// RECUPERO IL TIPO DI INTERVENTO
|
// RECUPERO IL TIPO DI INTERVENTO
|
||||||
@@ -205,7 +205,7 @@ if (!empty($rs2)) {
|
|||||||
// Sconto ore
|
// Sconto ore
|
||||||
echo '
|
echo '
|
||||||
<td style="border-right:1px solid #aaa;">';
|
<td style="border-right:1px solid #aaa;">';
|
||||||
if ($user_idanagrafica == 0 || $show_costi) {
|
if ($user['idanagrafica'] == 0 || $show_costi) {
|
||||||
echo '
|
echo '
|
||||||
{[ "type": "number", "name": "sconto['.$id.']", "value": "'.$sconto_unitario.'", "icon-after": "choice|untprc|'.$tipo_sconto.'" ]}';
|
{[ "type": "number", "name": "sconto['.$id.']", "value": "'.$sconto_unitario.'", "icon-after": "choice|untprc|'.$tipo_sconto.'" ]}';
|
||||||
} else {
|
} else {
|
||||||
@@ -220,7 +220,7 @@ if (!empty($rs2)) {
|
|||||||
// Sconto km
|
// Sconto km
|
||||||
echo '
|
echo '
|
||||||
<td style="border-right:1px solid #aaa;">';
|
<td style="border-right:1px solid #aaa;">';
|
||||||
if ($user_idanagrafica == 0 || $show_costi) {
|
if ($user['idanagrafica'] == 0 || $show_costi) {
|
||||||
echo '
|
echo '
|
||||||
{[ "type": "number", "name": "scontokm['.$id.']", "value": "'.$scontokm_unitario.'", "icon-after": "choice|untprc|'.$tipo_scontokm.'" ]}';
|
{[ "type": "number", "name": "scontokm['.$id.']", "value": "'.$scontokm_unitario.'", "icon-after": "choice|untprc|'.$tipo_scontokm.'" ]}';
|
||||||
} else {
|
} else {
|
||||||
|
30
sami.config.php
Normal file
30
sami.config.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Sami\Sami;
|
||||||
|
use Sami\RemoteRepository\GitHubRemoteRepository;
|
||||||
|
use Symfony\Component\Finder\Finder;
|
||||||
|
use Sami\Parser\Filter\TrueFilter;
|
||||||
|
|
||||||
|
$iterator = Finder::create()
|
||||||
|
->files()
|
||||||
|
->name('*.php')
|
||||||
|
->exclude('.couscous')
|
||||||
|
->exclude('node_modules')
|
||||||
|
->exclude('vendor')
|
||||||
|
->exclude('tests')
|
||||||
|
->in(__DIR__)
|
||||||
|
;
|
||||||
|
|
||||||
|
$sami = new Sami($iterator, array(
|
||||||
|
'theme' => 'default',
|
||||||
|
'title' => 'OpenSTAManager',
|
||||||
|
'build_dir' => __DIR__.'/.couscous/generated/docs',
|
||||||
|
'cache_dir' => __DIR__.'/.couscous/cache',
|
||||||
|
'default_opened_level' => 2,
|
||||||
|
));
|
||||||
|
|
||||||
|
$sami['filter'] = function () {
|
||||||
|
return new TrueFilter();
|
||||||
|
};
|
||||||
|
|
||||||
|
return $sami;
|
@@ -14,7 +14,7 @@ if ($rs[0]['dir'] == 'entrata') {
|
|||||||
$module_name = 'Fatture di acquisto';
|
$module_name = 'Fatture di acquisto';
|
||||||
}
|
}
|
||||||
|
|
||||||
$additional_where[$module_name] = str_replace('|idanagrafica|', "'".$user_idanagrafica."'", $additional_where[$module_name]);
|
$additional_where[$module_name] = str_replace('|idanagrafica|', "'".$user['idanagrafica']."'", $additional_where[$module_name]);
|
||||||
|
|
||||||
// Lettura info fattura
|
// Lettura info fattura
|
||||||
$q = 'SELECT *, (SELECT descrizione FROM co_tipidocumento WHERE id=idtipodocumento) AS tipo_doc, (SELECT descrizione FROM co_pagamenti WHERE id=idpagamento) AS tipo_pagamento, (SELECT dir FROM co_tipidocumento WHERE id=idtipodocumento) AS dir FROM co_documenti WHERE id="'.$iddocumento.'" '.$additional_where[$module_name];
|
$q = 'SELECT *, (SELECT descrizione FROM co_tipidocumento WHERE id=idtipodocumento) AS tipo_doc, (SELECT descrizione FROM co_pagamenti WHERE id=idpagamento) AS tipo_pagamento, (SELECT dir FROM co_tipidocumento WHERE id=idtipodocumento) AS dir FROM co_documenti WHERE id="'.$iddocumento.'" '.$additional_where[$module_name];
|
||||||
|
@@ -14,7 +14,7 @@ if ($rs[0]['dir'] == 'entrata') {
|
|||||||
$module_name = 'Fatture di acquisto';
|
$module_name = 'Fatture di acquisto';
|
||||||
}
|
}
|
||||||
|
|
||||||
$additional_where[$module_name] = str_replace('|idanagrafica|', "'".$user_idanagrafica."'", $additional_where[$module_name]);
|
$additional_where[$module_name] = str_replace('|idanagrafica|', "'".$user['idanagrafica']."'", $additional_where[$module_name]);
|
||||||
|
|
||||||
// Lettura info fattura
|
// Lettura info fattura
|
||||||
$q = 'SELECT *, (SELECT descrizione FROM co_tipidocumento WHERE id=idtipodocumento) AS tipo_doc, (SELECT descrizione FROM co_pagamenti WHERE id=idpagamento) AS tipo_pagamento, (SELECT dir FROM co_tipidocumento WHERE id=idtipodocumento) AS dir FROM co_documenti WHERE id="'.$iddocumento.'" '.$additional_where[$module_name];
|
$q = 'SELECT *, (SELECT descrizione FROM co_tipidocumento WHERE id=idtipodocumento) AS tipo_doc, (SELECT descrizione FROM co_pagamenti WHERE id=idpagamento) AS tipo_pagamento, (SELECT dir FROM co_tipidocumento WHERE id=idtipodocumento) AS dir FROM co_documenti WHERE id="'.$iddocumento.'" '.$additional_where[$module_name];
|
||||||
@@ -27,7 +27,7 @@ $idcliente = $rs[0]['idanagrafica'];
|
|||||||
$report = file_get_contents($docroot.'/templates/fatture_accompagnatorie/fattura.html');
|
$report = file_get_contents($docroot.'/templates/fatture_accompagnatorie/fattura.html');
|
||||||
$body = file_get_contents($docroot.'/templates/fatture_accompagnatorie/fattura_body.html');
|
$body = file_get_contents($docroot.'/templates/fatture_accompagnatorie/fattura_body.html');
|
||||||
|
|
||||||
if (!($idcliente == $user_idanagrafica || Auth::isAdmin())) {
|
if (!($idcliente == $user['idanagrafica'] || Auth::admin())) {
|
||||||
die('Non hai i permessi per questa stampa!');
|
die('Non hai i permessi per questa stampa!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,8 +4,8 @@ include_once __DIR__.'/../../core.php';
|
|||||||
|
|
||||||
$module_name = 'Interventi';
|
$module_name = 'Interventi';
|
||||||
|
|
||||||
$additional_where['Interventi'] = str_replace('|idtecnico|', "'".$user_idanagrafica."'", $additional_where['Interventi']);
|
$additional_where['Interventi'] = str_replace('|idtecnico|', "'".$user['idanagrafica']."'", $additional_where['Interventi']);
|
||||||
$additional_where['Interventi'] = str_replace('|idanagrafica|', "'".$user_idanagrafica."'", $additional_where['Interventi']);
|
$additional_where['Interventi'] = str_replace('|idanagrafica|', "'".$user['idanagrafica']."'", $additional_where['Interventi']);
|
||||||
|
|
||||||
// ############mostro o nascondo i costi dell'intervento..#################
|
// ############mostro o nascondo i costi dell'intervento..#################
|
||||||
// true o false
|
// true o false
|
||||||
|
@@ -4,7 +4,7 @@ include_once __DIR__.'/../../core.php';
|
|||||||
|
|
||||||
$module_name = 'Contratti';
|
$module_name = 'Contratti';
|
||||||
|
|
||||||
$additional_where['Contratti'] = str_replace('|idtecnico|', "'".$user_idanagrafica."'", $additional_where['Contratti']);
|
$additional_where['Contratti'] = str_replace('|idtecnico|', "'".$user['idanagrafica']."'", $additional_where['Contratti']);
|
||||||
|
|
||||||
// carica parametri di ricerca
|
// carica parametri di ricerca
|
||||||
$search_numero = save($_GET['search_numerocontratto']);
|
$search_numero = save($_GET['search_numerocontratto']);
|
||||||
|
@@ -628,7 +628,7 @@ INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALU
|
|||||||
|
|
||||||
-- Aggiunta del campo per permettere la modifica delle prima pagina di OSM
|
-- Aggiunta del campo per permettere la modifica delle prima pagina di OSM
|
||||||
INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES
|
INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES
|
||||||
('Prima pagina', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Dashboard'), 'query=SELECT id, title AS \'descrizione\' FROM zz_modules WHERE enabled=1', 1, 'Generali');
|
('Prima pagina', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Dashboard'), 'query=SELECT id, title AS \'descrizione\' FROM zz_modules WHERE enabled = 1 AND options != \'\' AND options != \'menu\' AND options IS NOT NULL ORDER BY `order` ASC', 1, 'Generali');
|
||||||
|
|
||||||
-- Aggiunta del campo idagente in Anagrafiche per la visione da parte degli agenti
|
-- Aggiunta del campo idagente in Anagrafiche per la visione da parte degli agenti
|
||||||
INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES ((SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'), 'idagente', 'idagente', 9, 0, 0, 0, 1);
|
INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `enabled`, `default`) VALUES ((SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'), 'idagente', 'idagente', 9, 0, 0, 0, 1);
|
||||||
|
Reference in New Issue
Block a user