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 // 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) { foreach ($handlers as $handler) {
$handler->setFormatter($monologFormatter); $handler->setFormatter($monologFormatter);
$logger->pushHandler(new FilterHandler($handler, [$handler->getLevel()])); $logger->pushHandler(new FilterHandler($handler, [$handler->getLevel()]));
@ -171,15 +182,6 @@ if (!API::isAPIRequest()) {
$_SESSION['warnings'] = array_unique((array) $_SESSION['warnings']); $_SESSION['warnings'] = array_unique((array) $_SESSION['warnings']);
$_SESSION['errors'] = array_unique((array) $_SESSION['errors']); $_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 // Impostazione del tema grafico di default
$theme = !empty($theme) ? $theme : 'default'; $theme = !empty($theme) ? $theme : 'default';
@ -197,6 +199,23 @@ if (!API::isAPIRequest()) {
$id_plugin = filter('id_plugin'); $id_plugin = filter('id_plugin');
$id_parent = filter('id_parent'); $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(); $user = Auth::user();
if (!empty($id_module)) { 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'; include $docroot.$directory.'/controller_before.php';
} }
// Segmenti if (count(Modules::getSegments($id_module)) > 1) {
/*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) {
?> ?>
<div class="row"> <div class="row">
<div class="col-md-4 pull-right"> <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": "" ]} {[ "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> </div>
<br> <br>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
$("#id_segment_").on("change", function(){ $("#id_segment_").on("change", function(){
if ($(this).val()<1){ if ($(this).val()<1){
session_set('<?php echo 'm'.$id_module; ?>,id_segment', '', 1, 1); session_set('<?php echo 'm'.$id_module; ?>,id_segment', '', 1, 1);
}else{ }else{
session_set('<?php echo 'm'.$id_module; ?>,id_segment', $(this).val(), 0, 1); session_set('<?php echo 'm'.$id_module; ?>,id_segment', $(this).val(), 0, 1);
} }
}); });
}); });
</script> </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="backto" value="record-edit">
<input type='hidden' name='op' value='fattura_da_contratto'> <input type='hidden' name='op' value='fattura_da_contratto'>
<input type="hidden" name="id_record" value="<?php echo $id_record; ?>"> <input type="hidden" name="id_record" value="<?php echo $id_record; ?>">

View File

@ -2,7 +2,7 @@
include_once __DIR__.'/../../core.php'; 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="op" value="add">
<input type="hidden" name="backto" value="record-edit"> <input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="iddocumento" value="<?php echo get('iddocumento'); ?>"> <input type="hidden" name="iddocumento" value="<?php echo get('iddocumento'); ?>">
@ -146,7 +146,6 @@ include_once __DIR__.'/../../core.php';
</tr>'; </tr>';
for ($i = 0; $i < 10; ++$i) { for ($i = 0; $i < 10; ++$i) {
($i <= 1) ? $required = 1 : $required = 0; ($i <= 1) ? $required = 1 : $required = 0;
// Conto // Conto
echo ' echo '
@ -329,7 +328,7 @@ include_once __DIR__.'/../../core.php';
$('#desc').val(causale); $('#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(','); var conti = data.split(',');
for(i=0;i<conti.length;i++){ for(i=0;i<conti.length;i++){
var conto = conti[i].split(';'); var conto = conti[i].split(';');

View File

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

View File

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

View File

@ -16,6 +16,8 @@ class Modules
protected static $modules = []; protected static $modules = [];
/** @var array Elenco delle condizioni aggiuntive disponibili */ /** @var array Elenco delle condizioni aggiuntive disponibili */
protected static $additionals = []; protected static $additionals = [];
/** @var array Elenco dei segmenti disponibili */
protected static $segments = [];
/** @var array Elenco delle query generiche dei moduli */ /** @var array Elenco delle query generiche dei moduli */
protected static $queries = []; protected static $queries = [];
@ -149,6 +151,30 @@ class Modules
return (array) self::$additionals[self::get($module)['id']]; 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. * Restituisce le condizioni SQL aggiuntive del modulo.
* *