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

@ -31,7 +31,7 @@ $_SESSION['superselect']['idanagrafica'] = $records[0]['idanagrafica'];
{[ "type": "select", "label": "<?php echo tr('Cliente'); ?>", "name": "idanagrafica", "id": "idanagrafica_c", "required": 1, "value": "$idanagrafica$", "ajax-source": "clienti" ]}
</div>
<div class="col-md-3">
{[ "type": "select", "label": "<?php echo tr('Sede'); ?>", "name": "idsede", "values": "query=SELECT 0 AS id, 'Sede legale' AS descrizione UNION SELECT id, CONCAT_WS( ' - ', nomesede, citta ) AS descrizione FROM an_sedi WHERE idanagrafica='$idanagrafica$'", "value": "$idsede$", "ajax-source": "sedi", "extra": "<?php echo $readonly; ?>" ]}
</div>
@ -50,7 +50,7 @@ $_SESSION['superselect']['idanagrafica'] = $records[0]['idanagrafica'];
<div class="col-md-3">
{[ "type": "select", "label": "<?php echo tr('Referente'); ?>", "name": "idreferente", "value": "$idreferente$", "ajax-source": "referenti" ]}
</div>
<div class="col-md-6">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": 1, "value": "$nome$" ]}
</div>
@ -68,7 +68,7 @@ $_SESSION['superselect']['idanagrafica'] = $records[0]['idanagrafica'];
<div class="col-md-2">
{[ "type": "number", "label": "<?php echo tr('Preavviso per rinnovo'); ?>", "name": "giorni_preavviso_rinnovo", "decimals": "0", "value": "$giorni_preavviso_rinnovo$", "icon-after": "giorni" ]}
</div>
<div class="col-md-2">
{[ "type": "date", "label": "<?php echo tr('Data bozza'); ?>", "maxlength": 10, "name": "data_bozza", "value": "$data_bozza$" ]}
</div>
@ -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; ?>">
@ -370,11 +370,11 @@ if (!empty($records[0]['idcontratto_prev'])) {
$("#data_accettazione").trigger("dp.change");
$("#data_rifiuto").trigger("dp.change");
});
function fattura_da_contratto(){
$('#form_creafattura').submit();
}
$('#idanagrafica_c').change( function(){
session_set('superselect,idanagrafica', $(this).val(), 0);

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'); ?>">
@ -109,7 +109,7 @@ include_once __DIR__.'/../../core.php';
}
}
?>
<div class="row">
<div class="col-md-12">
{[ "type": "select", "label": "<?php echo tr('Modello primanota'); ?>", "id": "modello_primanota", "required": 0, "values": "query=SELECT idmastrino AS id, descrizione FROM co_movimenti_modelli GROUP BY idmastrino", "value": "" ]}
@ -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>
@ -318,18 +317,18 @@ include_once __DIR__.'/../../core.php';
$("select[id*=idconto]").click( function(){
$("input[id*=dare][value!=''], input[id*=avere][value!='']").keyup();
});
$('#modello_primanota').change(function(){
var idmastrino = $(this).val();
if(idmastrino!=''){
$('#btn_crea_modello').hide();
var causale = $(this).find('option:selected').text();
$('#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(';');
@ -342,12 +341,12 @@ include_once __DIR__.'/../../core.php';
$('#btn_crea_modello').show();
}
});
$('#btn_crea_modello').click(function(){
$("#crea_modello").val("1");
$("#add-form").submit();
});
});
</script>
</form>

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

@ -56,10 +56,10 @@ class Database extends Util\Singleton
$host = $temp[0];
$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)) {
$this->port = $port;

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.
*