1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-29 09:11:11 +01:00
openstamanager/bug.php

204 lines
6.7 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/>.
*/
2019-09-28 10:43:41 +02:00
use Modules\Emails\Account;
2019-08-26 18:02:05 +02:00
use Notifications\EmailNotification;
include_once __DIR__.'/core.php';
2019-09-28 10:43:41 +02:00
$account = Account::where('predefined', true)->first();
2018-03-02 20:27:22 +01:00
$bug_email = 'info@openstamanager.com';
$user = Auth::user();
if (filter('op') == 'send') {
// Preparazione email
2019-09-28 10:43:41 +02:00
$mail = new EmailNotification();
// Destinatario
2018-03-02 20:27:22 +01:00
$mail->AddAddress($bug_email);
2018-03-02 20:27:22 +01:00
// Oggetto
$mail->Subject = 'Segnalazione bug OSM '.$version;
2018-03-02 20:27:22 +01:00
// Aggiunta dei file di log (facoltativo)
if (!empty(post('log')) && file_exists(base_dir().'/logs/error.log')) {
$mail->AddAttachment(base_dir().'/logs/error.log');
}
2018-03-02 20:27:22 +01:00
// Aggiunta della copia del database (facoltativo)
2018-07-19 15:33:32 +02:00
if (!empty(post('sql'))) {
$backup_file = base_dir().'/Backup OSM '.date('Y-m-d').' '.date('H_i_s').'.sql';
Backup::database($backup_file);
$mail->AddAttachment($backup_file);
2018-07-19 17:29:21 +02:00
flash()->info(tr('Backup del database eseguito ed allegato correttamente!'));
}
2018-03-02 20:27:22 +01:00
// Aggiunta delle informazioni di base sull'installazione
$infos = [
'Utente' => $user['username'],
'IP' => get_client_ip(),
'Versione OSM' => $version.' ('.(!empty($revision) ? $revision : 'In sviluppo').')',
'PHP' => phpversion(),
];
2018-03-02 20:27:22 +01:00
// Aggiunta delle informazioni sul sistema (facoltativo)
2018-07-19 15:33:32 +02:00
if (!empty(post('info'))) {
2018-03-02 20:27:22 +01:00
$infos['Sistema'] = $_SERVER['HTTP_USER_AGENT'].' - '.getOS();
}
// Completamento del body
2018-07-19 15:33:32 +02:00
$body = post('body').'<hr>';
2018-03-02 20:27:22 +01:00
foreach ($infos as $key => $value) {
$body .= '<p>'.$key.': '.$value.'</p>';
}
$mail->Body = $body;
$mail->AltBody = 'Questa email arriva dal modulo bug di segnalazione bug di OSM';
// Invio mail
if (!$mail->send()) {
2018-07-19 17:29:21 +02:00
flash()->error(tr("Errore durante l'invio della segnalazione").': '.$mail->ErrorInfo);
} else {
2018-07-19 17:29:21 +02:00
flash()->info(tr('Email inviata correttamente!'));
}
2018-03-02 20:27:22 +01:00
// Rimozione del dump del database
2018-07-19 15:33:32 +02:00
if (!empty(post('sql'))) {
delete($backup_file);
}
redirect(base_path().'/bug.php');
exit();
}
2018-03-02 20:27:22 +01:00
$pageTitle = tr('Bug');
2018-06-26 09:41:43 +02:00
include_once App::filepath('include|custom|', 'top.php');
2019-09-28 10:43:41 +02:00
if (empty($account['from_address']) || empty($account['server'])) {
2018-03-02 20:27:22 +01:00
echo '
<div class="alert alert-warning">
<i class="fa fa-warning"></i>
<b>'.tr('Attenzione!').'</b> '.tr('Per utilizzare correttamente il modulo di segnalazione bug devi configurare alcuni parametri riguardanti le impostazione delle email').'.
2019-09-28 10:43:41 +02:00
'.Modules::link('Account email', $account['id'], tr('Correggi account'), null, 'class="btn btn-warning pull-right"').'
2018-03-02 20:27:22 +01:00
<div class="clearfix"></div>
</div>';
}
2018-03-02 20:27:22 +01:00
echo '
<div class="box">
<div class="box-header">
<h3 class="box-title"><i class="fa fa-bug"></i> '.tr('Segnalazione bug').'</h3>
</div>
<div class="box-body">
<form method="post" action="">
<input type="hidden" name="op" value="send">
<table class="table table-bordered table-condensed table-striped table-hover">
<tr>
<th width="150" class="text-right">'.tr('Da').':</th>
2019-09-28 10:43:41 +02:00
<td>'.$account['from_address'].'</td>
2018-03-02 20:27:22 +01:00
</tr>
<!-- A -->
<tr>
<th class="text-right">'.tr('A').':</th>
<td>'.$bug_email.'</td>
</tr>
<!-- Versione -->
<tr>
<th class="text-right">'.tr('Versione OSM').':</th>
<td>'.$version.' ('.(!empty($revision) ? $revision : tr('In sviluppo')).')</td>
</tr>
</table>
<div class="row">
<div class="col-md-4">
{[ "type": "checkbox", "placeholder": "'.tr('Allega file di log').'", "name": "log", "value": "1" ]}
</div>
2018-03-02 20:27:22 +01:00
<div class="col-md-4">
{[ "type": "checkbox", "placeholder": "'.tr('Allega copia del database').'", "name": "sql" ]}
</div>
2018-03-02 20:27:22 +01:00
<div class="col-md-4">
{[ "type": "checkbox", "placeholder": "'.tr('Allega informazioni sul PC').'", "name": "info", "value": "1" ]}
</div>
</div>
2018-03-02 20:27:22 +01:00
<div class="clearfix"></div>
<br>
2018-09-07 17:43:52 +02:00
{[ "type": "ckeditor", "label": "'.tr('Descrizione del bug').'", "name": "body" ]}
2018-03-02 20:27:22 +01:00
<!-- PULSANTI -->
<div class="row">
<div class="col-md-12 text-right">
<button type="submit" class="btn btn-primary" id="send" disabled>
<i class="fa fa-envelope"></i> '.tr('Invia segnalazione').'
</button>
</div>
2018-03-02 20:27:22 +01:00
</div>
</form>
</div>
</div>
<script>
$(document).ready(function() {
init();
2018-03-02 20:27:22 +01:00
var html = "<p>'.tr('Se hai riscontrato un bug ricordati di specificare').':</p>" +
"<ul>" +
"<li>'.tr('Modulo esatto (o pagina relativa) in cui questi si è verificato').';</li>" +
2018-09-28 09:57:25 +02:00
"<li>'.tr('Dopo quali specifiche operazioni hai notato il malfunzionamento').'.</li>" +
2018-03-02 20:27:22 +01:00
"</ul>" +
"<p>'.tr('Assicurati inoltre di controllare che il checkbox relativo ai file di log sia contrassegnato, oppure riporta qui l\'errore visualizzato').'.</p>" +
"<p>'.tr('Ti ringraziamo per il tuo contributo').',<br>" +
"'.tr('Lo staff di OSM').'</p>";
var firstFocus = true;
let editor = input("body");
editor.set(html);
2018-03-02 20:27:22 +01:00
editor.on("change", function() {
setTimeout(function() {
$("#send").prop("disabled", editor.get() === "");
2018-03-02 20:27:22 +01:00
}, 10);
});
editor.on("focus", function() {
if (firstFocus) {
editor.set("");
firstFocus = false;
2018-03-02 20:27:22 +01:00
}
});
});
2018-06-23 15:41:32 +02:00
</script>
<script type="text/javascript" charset="utf-8" src="'.App::getPaths()['js'].'/ckeditor/ckeditor.js'.'"></script>';
2018-06-26 09:41:43 +02:00
include_once App::filepath('include|custom|', 'bottom.php');