openstamanager/modules/aggiornamenti/edit.php

295 lines
10 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/>.
*/
include_once __DIR__.'/../../core.php';
// Personalizzazioni di codice
2020-10-12 09:19:03 +02:00
if (function_exists('customComponents')) {
$custom = customComponents();
2018-12-23 14:01:59 +01:00
$tables = customTables();
if (!empty($custom) || !empty($tables)) {
echo '
2024-05-16 18:02:50 +02:00
<div class="card card-warning">
<div class="card-header with-border">
<h3 class="card-title"><span class="tip" title="'.tr('Elenco delle personalizzazioni rilevabili dal gestionale').'.">
2018-12-21 16:54:34 +01:00
<i class="fa fa-edit"></i> '.tr('Personalizzazioni').'
</span></h3>
</div>
2024-05-16 18:02:50 +02:00
<div class="card-body">';
2018-12-21 16:54:34 +01:00
2018-12-23 14:01:59 +01:00
if (!empty($custom)) {
echo '
2018-12-21 16:54:34 +01:00
<table class="table table-hover table-striped">
<tr>
<th width="10%">'.tr('Percorso').'</th>
<th width="15%">'.tr('Cartella personalizzata').'</th>
<th width="15%">'.tr('Database personalizzato').'</th>
</tr>';
2018-12-23 14:01:59 +01:00
foreach ($custom as $element) {
echo '
2018-12-21 16:54:34 +01:00
<tr>
<td>'.$element['path'].'</td>
<td>'.($element['directory'] ? 'Si' : 'No').'</td>
<td>'.($element['database'] ? 'Si' : 'No').'</td>
</tr>';
2018-12-23 14:01:59 +01:00
}
2018-12-21 16:54:34 +01:00
2018-12-23 14:01:59 +01:00
echo '
2018-12-21 16:54:34 +01:00
</table>
<div class="alert alert-warning" role="alert"> <i class="fa fa-exclamation-triangle"></i> '.tr("Attenzione, il gestionale presenta delle personalizzazioni: si sconsiglia l'aggiornamento senza il supporto dell'assistenza ufficiale").'.</div>';
2018-12-23 14:01:59 +01:00
} else {
echo '
2018-12-21 16:54:34 +01:00
<p>'.tr('Non ci sono strutture personalizzate').'.</p>';
2018-12-23 14:01:59 +01:00
}
2018-12-21 16:54:34 +01:00
2018-12-23 14:01:59 +01:00
if (!empty($tables)) {
echo '
2018-12-21 16:54:34 +01:00
<div class="alert alert-warning">
<i class="fa fa-warning"></i>
<b>'.tr('Attenzione!').'</b> '.tr('Ci sono delle tabelle non previste nella versione standard del gestionale: _LIST_', [
2024-03-22 15:52:24 +01:00
'_LIST_' => implode(', ', $tables),
]).'.
2018-12-21 16:54:34 +01:00
</div>';
2018-12-23 14:01:59 +01:00
}
2018-12-21 16:54:34 +01:00
2018-12-23 14:01:59 +01:00
echo '
2018-12-21 16:54:34 +01:00
</div>
</div>';
2018-12-23 14:01:59 +01:00
}
}
2024-01-15 15:30:45 +01:00
// Fix per funzione base_path non trovata in fase di aggiornamento da versione < 2.4.19
if (!function_exists('base_path')) {
function base_path()
{
return ROOTDIR;
}
}
if (!function_exists('base_dir')) {
function base_dir()
{
return DOCROOT;
}
}
// Aggiornamenti
2024-01-15 15:30:45 +01:00
$alerts = [];
2024-01-15 15:30:45 +01:00
if (!extension_loaded('zip')) {
$alerts[tr('Estensione ZIP')] = tr('da abilitare');
}
2024-01-15 15:30:45 +01:00
$upload_max_filesize = ini_get('upload_max_filesize');
$upload_max_filesize = str_replace(['k', 'M'], ['000', '000000'], $upload_max_filesize);
// Dimensione minima: 32MB
if ($upload_max_filesize < 32000000) {
$alerts['upload_max_filesize'] = '32MB';
}
2024-01-15 15:30:45 +01:00
$post_max_size = ini_get('post_max_size');
$post_max_size = str_replace(['k', 'M'], ['000', '000000'], $post_max_size);
// Dimensione minima: 32MB
if ($post_max_size < 32000000) {
$alerts['post_max_size'] = '32MB';
}
2024-01-15 15:30:45 +01:00
if (!empty($alerts)) {
echo '
<div class="alert alert-info">
<p>'.tr('Devi modificare il seguenti parametri del file di configurazione PHP (_FILE_) per poter caricare gli aggiornamenti', [
2024-03-22 15:52:24 +01:00
'_FILE_' => '<b>php.ini</b>',
]).':<ul>';
2024-01-15 15:30:45 +01:00
foreach ($alerts as $key => $value) {
echo '
2024-01-15 15:30:45 +01:00
<li><b>'.$key.'</b> = '.$value.'</li>';
}
echo '
</ul></p>
</div>';
2024-01-15 15:30:45 +01:00
}
2024-01-15 15:30:45 +01:00
echo '
2018-09-19 17:15:01 +02:00
<script>
function update() {
if ($("#blob").val()) {
swal({
title: "'.tr('Avviare la procedura?').'",
type: "warning",
showCancelButton: true,
confirmButtonText: "'.tr('Sì').'"
}).then(function (result) {
$("#update").submit();
})
} else {
swal({
title: "'.tr('Selezionare un file!').'",
type: "error",
})
}
}
function checksum(button) {
openModal("'.tr('Controllo dei file').'", "'.$module->fileurl('checksum.php').'?id_module='.$id_module.'");
}
function database(button) {
openModal("'.tr('Controllo del database').'", "'.$module->fileurl('database.php').'?id_module='.$id_module.'");
}
function controlli(button) {
2024-04-23 09:56:36 +02:00
openModal("'.tr('Controlli del gestionale').'", "'.$module->fileurl('controlli.php').'?id_module='.$id_module.'");
}
2018-09-19 17:15:01 +02:00
function search(button) {
let restore = buttonLoading(button);
2018-09-19 17:15:01 +02:00
$.ajax({
url: globals.rootdir + "/actions.php",
type: "post",
data: {
id_module: globals.id_module,
op: "check",
},
success: function(data){
if (data === "none" || !data) {
2024-04-23 09:56:36 +02:00
$("#update-search").html("<i class=\"fa fa-check-circle text-success\" aria-hidden=\"true\"></i> '.tr('Nessun aggiornamento disponibile').'.");
2018-09-19 17:15:01 +02:00
} else {
2024-04-12 18:10:45 +02:00
let beta_warning = data.includes("beta") ? "<br><i class=\"fa-exclamation-triangle text-danger\" aria-hidden=\"true\"></i> <b class=\"text-danger\">'.tr('Attenzione: la versione individuata è in fase sperimentale e potrebbe pertanto presentare diversi malfunzionamenti. Se ne sconsiglia l\'aggiornamento in installazioni di produzione').'.</b>" : "";
$("#update-search").html("'.tr("E' stato individuato un nuovo aggiornamento").': " + data + "." + beta_warning + "<br>'.tr('Scaricalo ora: _LINK_', [
2024-03-22 15:52:24 +01:00
'_LINK_' => "<a target='_blank' href='https://github.com/devcode-it/openstamanager/releases'>https://github.com/devcode-it/openstamanager/releases</a>",
]).'");
2018-09-19 17:15:01 +02:00
}
}
});
}
</script>
2018-09-19 17:15:01 +02:00
<div class="row">';
2024-03-22 15:52:24 +01:00
// Verifiche di integrità
2023-08-04 14:54:28 +02:00
echo '
<div class="col-md-4">
2024-08-07 09:34:28 +02:00
<div class="card card-primary card-outline">
2024-05-16 18:02:50 +02:00
<div class="card-header with-border">
<h3 class="card-title">
2022-05-30 16:21:42 +02:00
'.tr("Verifica l'integrità dell'installazione").' <span class="tip" title="'.tr("Verifica l'integrità della tua installazione attraverso un controllo sui checksum dei file e sulla struttura del database").'."><i class="fa fa-question-circle-o"></i></span>
</h3>
</div>
2024-05-16 18:02:50 +02:00
<div class="card-body">
2024-08-07 09:34:28 +02:00
<button type="button" class="btn btn-info btn-block" onclick="checksum(this)">
<i class="fa fa-list-alt"></i> '.tr('Controlla file').'
</button>
<button type="button" class="btn btn-info btn-block" onclick="database(this)">
<i class="fa fa-database"></i> '.tr('Controlla database').'
</button>
2024-08-07 09:34:28 +02:00
<button type="button" class="btn btn-info btn-block" onclick="controlli(this)">
2021-03-11 15:09:13 +01:00
<i class="fa fa-stethoscope"></i> '.tr('Controlla gestionale').'
</button>
</div>
</div>
</div>';
2024-03-22 15:52:24 +01:00
// Controllo automatico della presenza di aggiornamenti per il gestionale
echo '
2018-09-19 09:51:36 +02:00
<div class="col-md-4">
2024-08-07 09:34:28 +02:00
<div class="card card-primary card-outline">
2024-05-16 18:02:50 +02:00
<div class="card-header with-border">
<h3 class="card-title">
'.tr('Ricerca aggiornamenti').' <span class="tip" title="'.tr('Controllo automatico della presenza di aggiornamenti per il gestionale').'."><i class="fa fa-question-circle-o"></i></span>
2018-09-19 09:51:36 +02:00
</h3>
</div>
2024-05-16 18:02:50 +02:00
<div class="card-body" id="update-search">';
2024-01-15 15:30:45 +01:00
if (extension_loaded('curl')) {
echo ' <button type="button" class="btn btn-info btn-block" onclick="search(this)">
2018-09-19 09:51:36 +02:00
<i class="fa fa-search"></i> '.tr('Ricerca').'
</button>';
2024-01-15 15:30:45 +01:00
} else {
echo ' <button type="button" class="btn btn-warning btn-block disabled" >
<i class="fa fa-warning"></i> '.tr('Estensione curl non supportata').'.
2018-11-30 16:10:15 +01:00
</button>';
2024-01-15 15:30:45 +01:00
}
2018-11-30 16:10:15 +01:00
echo ' </div>
2018-09-19 09:51:36 +02:00
</div>
</div>';
2024-03-22 15:52:24 +01:00
// Form di caricamento aggiornamenti gestionale o moduli
echo '
<div class="col-md-4">
2024-08-07 09:34:28 +02:00
<div class="card card-primary card-outline">
2024-05-16 18:02:50 +02:00
<div class="card-header with-border">
<h3 class="card-title">
'.tr('Carica aggiornamenti o nuovi moduli').' <span class="tip" title="'.tr('Form di caricamento aggiornamenti del gestionale e innesti di moduli e plugin').'."><i class="fa fa-question-circle-o"></i></span>
</h3>
</div>
2024-05-16 18:02:50 +02:00
<div class="card-body">
<form action="'.base_path().'/controller.php?id_module='.$id_module.'" method="post" enctype="multipart/form-data" id="update">
<input type="hidden" name="op" value="upload">
{[ "type": "file", "name": "blob", "required": 1, "accept": ".zip", "disabled": '.(setting('Attiva aggiornamenti') ? 0 : 1).' ]}
';
if (!empty($custom) || !empty($tables)) {
$disabled = 'disabled';
echo ' <input type="checkbox" id="aggiorna_custom" class="pull-left" style="margin-top:10px;" value="1" >&nbsp;
<label for="aggiorna_custom" style="margin-top:7px;" >'.tr("Desidero comunque procedere all'aggiornamento").'.</label>
<script>
$("#aggiorna_custom").change(function() {
if(this.checked) {
$("#aggiorna").removeClass("disabled");
}else{
$("#aggiorna").addClass("disabled");
}
});
</script>';
}
echo '
<button type="button" class="btn btn-primary pull-right '.$disabled.'" id="aggiorna" onclick="update()">
<i class="fa fa-upload"></i> '.tr('Carica').'
</button>';
echo '
</form>
</div>
</div>
</div>';
echo '
2018-07-04 17:15:14 +02:00
</div>';
2018-10-05 11:53:11 +02:00
// Requisiti
echo '
<hr>
2018-12-14 13:01:13 +01:00
<div>
2018-10-05 11:53:11 +02:00
<h3>'.tr('Requisiti').'</h3>';
include base_dir().'/include/init/requirements.php';
2018-10-05 11:53:11 +02:00
echo '
</div>';