Miglioramenti vari.
This commit is contained in:
Thomas Zilio 2018-05-11 14:48:46 +02:00
parent 916eaee3f8
commit d298f5d703
7 changed files with 83 additions and 46 deletions

View File

@ -95,7 +95,18 @@ if (empty($debug)) {
}
// Imposta il formato di salvataggio dei log
$monologFormatter = new Monolog\Formatter\LineFormatter('[%datetime%] %channel%.%level_name%: %message%'.PHP_EOL.'%extra% '.PHP_EOL);
$pattern = '[%datetime%] %channel%.%level_name%: %message%';
if (!empty($debug)) {
$pattern .= ' %context%';
}
$pattern .= PHP_EOL.'%extra% '.PHP_EOL;
$monologFormatter = new Monolog\Formatter\LineFormatter($pattern);
if (!empty($debug)) {
$monologFormatter->includeStacktraces(true);
}
foreach ($handlers as $handler) {
$handler->setFormatter($monologFormatter);
$logger->pushHandler(new FilterHandler($handler, [$handler->getLevel()]));
@ -171,15 +182,6 @@ if (!API::isAPIRequest()) {
$_SESSION['warnings'] = array_unique((array) $_SESSION['warnings']);
$_SESSION['errors'] = array_unique((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';
@ -197,6 +199,23 @@ if (!API::isAPIRequest()) {
$id_plugin = filter('id_plugin');
$id_parent = filter('id_parent');
// Periodo di visualizzazione dei record
// Personalizzato
if (!empty($_GET['period_start'])) {
$_SESSION['period_start'] = $_GET['period_start'];
$_SESSION['period_end'] = $_GET['period_end'];
}
// Dal 01-01-yyy al 31-12-yyyy
elseif (!isset($_SESSION['period_start'])) {
$_SESSION['period_start'] = date('Y').'-01-01';
$_SESSION['period_end'] = date('Y').'-12-31';
}
// Segmenti
if (empty($_SESSION['m'.$id_module]['id_segment'])) {
$_SESSION['m'.$id_module]['id_segment'] = Modules::getSegments($id_module)[0]['id'];
}
$user = Auth::user();
if (!empty($id_module)) {

View File

@ -47,16 +47,8 @@ if (file_exists($docroot.$directory.'/custom/controller_before.php')) {
include $docroot.$directory.'/controller_before.php';
}
// Segmenti
/*deve sempre essere impostato almeno un sezionale*/
if (empty($_SESSION['m'.$id_module]['id_segment'])) {
$rs = $dbo->fetchArray('SELECT id FROM zz_segments WHERE predefined = 1 AND id_module = '.prepare($id_module).'LIMIT 0,1');
$_SESSION['m'.$id_module]['id_segment'] = $rs[0]['id'];
}
if (count($dbo->fetchArray("SELECT id FROM zz_segments WHERE id_module = \"$id_module\"")) > 1) {
?>
if (count(Modules::getSegments($id_module)) > 1) {
?>
<div class="row">
<div class="col-md-4 pull-right">
{[ "type": "select", "label": "", "name": "id_segment_", "required": 0, "class": "", "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module = '<?php echo $id_module; ?>'", "value": "<?php echo $_SESSION['m'.$id_module]['id_segment']; ?>", "extra": "" ]}
@ -64,20 +56,16 @@ if (count($dbo->fetchArray("SELECT id FROM zz_segments WHERE id_module = \"$id_m
</div>
<br>
<script>
$(document).ready(function () {
$("#id_segment_").on("change", function(){
if ($(this).val()<1){
session_set('<?php echo 'm'.$id_module; ?>,id_segment', '', 1, 1);
}else{
session_set('<?php echo 'm'.$id_module; ?>,id_segment', $(this).val(), 0, 1);
}
});
});
</script>

View File

@ -342,7 +342,7 @@ if (!empty($records[0]['idcontratto_prev'])) {
}
?>
<form action='<?=$rootdir?>/editor.php?id_module=<?=Modules::get('Fatture di vendita')['id']?>' method='post' id='form_creafattura'>
<form action='<?php echo $rootdir; ?>/editor.php?id_module=<?php echo Modules::get('Fatture di vendita')['id']; ?>' method='post' id='form_creafattura'>
<input type="hidden" name="backto" value="record-edit">
<input type='hidden' name='op' value='fattura_da_contratto'>
<input type="hidden" name="id_record" value="<?php echo $id_record; ?>">

View File

@ -2,7 +2,7 @@
include_once __DIR__.'/../../core.php';
?><form action="<?php echo ROOTDIR ?>/editor.php?id_module=<?php echo Modules::get('Prima nota')['id']; ?>" method="post" id="add-form">
?><form action="<?php echo ROOTDIR; ?>/editor.php?id_module=<?php echo Modules::get('Prima nota')['id']; ?>" method="post" id="add-form">
<input type="hidden" name="op" value="add">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="iddocumento" value="<?php echo get('iddocumento'); ?>">
@ -146,9 +146,8 @@ include_once __DIR__.'/../../core.php';
</tr>';
for ($i = 0; $i < 10; ++$i) {
($i<=1) ? $required = 1 : $required = 0;
// Conto
($i <= 1) ? $required = 1 : $required = 0;
// Conto
echo '
<tr>
<td>
@ -329,7 +328,7 @@ include_once __DIR__.'/../../core.php';
$('#desc').val(causale);
$.get('<?=$rootdir?>/ajax_complete.php?op=get_conti&idmastrino='+idmastrino, function(data){
$.get('<?php echo $rootdir; ?>/ajax_complete.php?op=get_conti&idmastrino='+idmastrino, function(data){
var conti = data.split(',');
for(i=0;i<conti.length;i++){
var conto = conti[i].split(';');

View File

@ -57,6 +57,8 @@ class API extends \Util\Singleton
*/
public function retrieve($request)
{
global $logger;
$user = Auth::user();
// Controllo sulla compatibilità dell'API
@ -147,6 +149,9 @@ class API extends \Util\Singleton
$results['pages'] = $cont[0]['pages'];
}
} catch (PDOException $e) {
// Log dell'errore
$logger->addRecord(\Monolog\Logger::ERROR, $e);
return self::error('internalError');
}
}

View File

@ -57,8 +57,8 @@ class Database extends Util\Singleton
$port = !empty($temp[1]) ? $temp[1] : null;
}
//possibilità di specificare una porta per il servizio mysql diversa dalla standard 3306
$port = (!empty(App::getConfig()['port'])) ? App::getConfig()['port'] : $port;
// Possibilità di specificare una porta per il servizio MySQL diversa dalla standard 3306
$port = !empty(App::getConfig()['port']) ? App::getConfig()['port'] : $port;
$this->host = $host;
if (!empty($port) && is_int($port * 1)) {

View File

@ -16,6 +16,8 @@ class Modules
protected static $modules = [];
/** @var array Elenco delle condizioni aggiuntive disponibili */
protected static $additionals = [];
/** @var array Elenco dei segmenti disponibili */
protected static $segments = [];
/** @var array Elenco delle query generiche dei moduli */
protected static $queries = [];
@ -149,6 +151,30 @@ class Modules
return (array) self::$additionals[self::get($module)['id']];
}
/**
* Restituisce i filtri aggiuntivi dell'utente in relazione al modulo specificato.
*
* @param int $id
*
* @return string
*/
public static function getSegments($module)
{
if (Update::isUpdateAvailable()) {
return [];
}
$module = self::get($module)['id'];
if (!isset(self::$segments[$module])) {
$database = Database::getConnection();
self::$segments[$module] = $database->fetchArray('SELECT * FROM zz_segments WHERE id_module = '.prepare($module).' ORDER BY predefined DESC, id ASC');
}
return (array) self::$segments[$module];
}
/**
* Restituisce le condizioni SQL aggiuntive del modulo.
*