1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-01-01 02:28:04 +01:00
openstamanager/src/Extensions/MessageHandler.php

64 lines
2.0 KiB
PHP
Raw Normal View History

<?php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright (C) DevCode s.r.l.
2020-09-07 15:04:06 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace Extensions;
use Monolog\Handler\AbstractProcessingHandler;
/**
* Gestore dei messaggi di avvertenza in caso di malfunzionamento del gestionale.
*
* @since 2.4.6
*/
class MessageHandler extends AbstractProcessingHandler
{
protected function write(array $record)
{
2019-01-19 10:33:57 +01:00
if (\Whoops\Util\Misc::isAjaxRequest()) {
2019-01-11 12:02:11 +01:00
return;
}
2019-01-11 08:32:08 +01:00
$message = tr("Si è verificato un'errore").' <i>[uid: '.$record['extra']['uid'].']</i>.';
if (auth()->check()) {
$message .= '
2019-08-29 10:25:14 +02:00
'.tr('Se il problema persiste siete pregati di chiedere assistenza tramite il forum apposito (_LINK_FORUM_)', [
'_LINK_FORUM_' => '<a href="https://forum.openstamanager.com/">https://forum.openstamanager.com/</a>',
]).'.</a>';
2019-01-11 08:32:08 +01:00
if (auth()->isAdmin()) {
$message .= '
<br><small>'.$record['message'].'</small>';
2019-01-11 08:32:08 +01:00
}
}
2019-02-15 10:42:39 +01:00
// Messaggio nella sessione
try {
flash()->error($message);
} catch (\Exception $e) {
}
2019-02-15 10:42:39 +01:00
// Messaggio visivo immediato
echo '
<div class="alert alert-danger push">
<i class="fa fa-times"></i> '.$message.'
</div>';
}
}