2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
2018-07-08 18:11:17 +02:00
if ( setting ( 'Attiva aggiornamenti' )) {
2017-08-04 16:28:16 +02:00
$alerts = [];
if ( ! extension_loaded ( 'zip' )) {
2017-09-04 12:02:29 +02:00
$alerts [ tr ( 'Estensione ZIP' )] = tr ( 'da abilitare' );
2017-08-04 16:28:16 +02:00
}
$upload_max_filesize = ini_get ( 'upload_max_filesize' );
$upload_max_filesize = str_replace ([ 'k' , 'M' ], [ '000' , '000000' ], $upload_max_filesize );
// Dimensione minima: 16MB
if ( $upload_max_filesize < 16000000 ) {
$alerts [ 'upload_max_filesize' ] = '16MB' ;
}
$post_max_size = ini_get ( 'post_max_size' );
$post_max_size = str_replace ([ 'k' , 'M' ], [ '000' , '000000' ], $post_max_size );
// Dimensione minima: 16MB
if ( $post_max_size < 16000000 ) {
$alerts [ 'post_max_size' ] = '16MB' ;
}
if ( ! empty ( $alerts )) {
echo '
< div class = " alert alert-warning " >
2017-09-10 14:35:41 +02:00
< p > '.tr(' Devi modificare il seguenti parametri del file di configurazione PHP ( _FILE_ ) per poter caricare gli aggiornamenti ' , [
'_FILE_' => '<b>php.ini</b>' ,
]) . ':<ul>' ;
2017-08-04 16:28:16 +02:00
foreach ( $alerts as $key => $value ) {
echo '
< li >< b > '.$key.' </ b > = '.$value.' </ li > ' ;
}
echo '
</ ul ></ p >
</ div > ' ;
}
2018-09-19 17:15:01 +02:00
echo '
< 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 search ( button ) {
buttonLoading ( button );
$ . ajax ({
url : globals . rootdir + " /actions.php " ,
type : " post " ,
data : {
id_module : globals . id_module ,
op : " check " ,
},
success : function ( data ){
if ( data == " none " ) {
$ ( " #update-search " ) . html ( " '.tr('Nessun aggiornamento presente').'. " );
} else {
$ ( " #update-search " ) . html ( " '.tr( " E ' stato individuato un nuovo aggiornamento").' : " + data + " .< br > '.tr(' Scaricalo ora : _LINK_ ' , [
'_LINK_' => " <a href='https://github.com/devcode-it/openstamanager/releases'>https://github.com/devcode-it/openstamanager/releases</a> " ,
]) . ' " );
}
}
});
}
</ script > ' ;
2017-08-04 16:28:16 +02:00
echo '
2018-09-19 09:51:36 +02:00
< div class = " row " >
< div class = " col-md-8 " >
< div class = " box box-success " >
< div class = " box-header with-border " >
< h3 class = " box-title " >
'.tr(' Carica un aggiornamento ').' < span class = " tip " title = " '.tr('Form di caricamento per aggiornamenti del gestionale e innesti di moduli e plugin').' " >< i class = " fa fa-question-circle-o " ></ i ></ span >
</ h3 >
</ div >
< div class = " box-body " >
< form action = " '.ROOTDIR.'/controller.php?id_module='. $id_module .' " method = " post " enctype = " multipart/form-data " class = " form-inline " id = " update " >
< input type = " hidden " name = " op " value = " upload " >
2018-09-19 17:15:01 +02:00
< label >< input type = " file " name = " blob " id = " blob " ></ label >
2017-08-04 16:28:16 +02:00
2018-09-19 17:15:01 +02:00
< button type = " button " class = " btn btn-primary pull-right " onclick = " update() " >
2018-09-19 09:51:36 +02:00
< i class = " fa fa-upload " ></ i > '.tr(' Carica ').' ...
</ button >
</ form >
</ div >
</ div >
</ div > ' ;
echo '
2017-08-04 16:28:16 +02:00
2018-09-19 09:51:36 +02:00
< div class = " col-md-4 " >
< div class = " box box-info " >
< div class = " box-header with-border " >
< h3 class = " box-title " >
'.tr(' Ricerca aggiornamenti ').' < span class = " tip " title = " '.tr('Controllo automatica sulla presenza di aggiornamenti del gestionale').' " >< i class = " fa fa-question-circle-o " ></ i ></ span >
</ h3 >
</ div >
< div class = " box-body " id = " update-search " >
< button type = " button " class = " btn btn-info btn-block " onclick = " search(this) " >
< i class = " fa fa-search " ></ i > '.tr(' Ricerca ').'
</ button >
</ div >
</ div >
2018-07-04 17:15:14 +02:00
</ div >
</ div > ' ;
2017-08-04 16:28:16 +02:00
}
// Elenco moduli installati
echo '
< div class = " row " >
< div class = " col-md-12 col-lg-6 " >
2017-09-04 12:02:29 +02:00
< h3 > '.tr(' Moduli installati ').' </ h3 >
2017-08-04 16:28:16 +02:00
< table class = " table table-hover table-bordered table-condensed " >
< tr >
2017-09-04 12:02:29 +02:00
< th > '.tr(' Nome ').' </ th >
< th width = " 50 " > '.tr(' Versione ').' </ th >
< th width = " 30 " > '.tr(' Stato ').' </ th >
< th width = " 30 " > '.tr(' Compatibilità ').' </ th >
2017-09-13 15:38:47 +02:00
< th width = " 20 " > '.tr(' Opzioni ').' </ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
2018-06-29 17:58:42 +02:00
$modules = Modules :: getHierarchy ();
2017-08-04 16:28:16 +02:00
$osm_version = Update :: getVersion ();
foreach ( $modules as $module ) {
// STATO
if ( ! empty ( $module [ 'enabled' ])) {
2017-09-04 12:02:29 +02:00
$text = tr ( 'Abilitato' );
$text .= ( $module [ 'id' ] != $id_module ) ? '. ' . tr ( 'Clicca per disabilitarlo' ) . '...' : '' ;
2017-08-04 16:28:16 +02:00
$stato = '<i class="fa fa-cog fa-spin text-success" data-toggle="tooltip" title="' . $text . '"></i>' ;
} else {
2017-09-04 12:02:29 +02:00
$stato = '<i class="fa fa-cog text-warning" data-toggle="tooltip" title="' . tr ( 'Non abilitato' ) . '"></i>' ;
2017-08-04 16:28:16 +02:00
$class = 'warning' ;
}
// Possibilità di disabilitare o abilitare i moduli tranne quello degli aggiornamenti
if ( $module [ 'id' ] != $id_module ) {
if ( $module [ 'enabled' ]) {
2018-06-29 17:58:42 +02:00
$stato = " <a href='javascript:;' onclick= \" if( confirm(' " . tr ( 'Disabilitare questo modulo?' ) . " ') ) { $ .post( ' " . ROOTDIR . '/actions.php?id_module=' . $id_module . " ', { op: 'disable', id: ' " . $module [ 'id' ] . " ' }, function(response) { location.href=' " . ROOTDIR . '/controller.php?id_module=' . $id_module . " '; }); } \" > " . $stato . " </a> \n " ;
2017-08-04 16:28:16 +02:00
} else {
2018-06-29 17:58:42 +02:00
$stato = " <a href='javascript:;' onclick= \" if( confirm(' " . tr ( 'Abilitare questo modulo?' ) . " ') ) { $ .post( ' " . ROOTDIR . '/actions.php?id_module=' . $id_module . " ', { op: 'enable', id: ' " . $module [ 'id' ] . " ' }, function(response) { location.href=' " . ROOTDIR . '/controller.php?id_module=' . $id_module . " '; }); } \" \" > " . $stato . " </a> \n " ;
2017-08-04 16:28:16 +02:00
}
}
// COMPATIBILITA'
$compatibilities = explode ( ',' , $module [ 'compatibility' ]);
// Controllo per ogni versione se la regexp combacia per dire che è compatibile o meno
$comp = false ;
foreach ( $compatibilities as $compatibility ) {
$comp = ( preg_match ( '/' . $compatibility . '/' , $osm_version )) ? true : $comp ;
}
if ( $comp ) {
2017-09-04 12:02:29 +02:00
$compatible = '<i class="fa fa-check-circle text-success" data-toggle="tooltip" title="' . tr ( 'Compatibile' ) . '"></i>' ;
2018-06-26 14:30:26 +02:00
( $module [ 'enabled' ]) ? $class = 'success' : $class = 'warning' ;
2017-08-04 16:28:16 +02:00
} else {
2018-02-19 18:18:31 +01:00
$compatible = '<i class="fa fa-warning text-danger" data-toggle="tooltip" title="' . tr ( 'Non compatibile!' ) . tr ( 'Questo modulo è compatibile solo con le versioni' ) . ': ' . $module [ 'compatibility' ] . '"></i>' ;
2017-08-04 16:28:16 +02:00
$class = 'danger' ;
}
echo '
< tr class = " '. $class .' " >
2018-07-02 15:41:38 +02:00
< td > '.$module[' title '].' </ td >
2017-08-04 16:28:16 +02:00
< td align = " right " > '.$module[' version '].' </ td >
< td align = " center " > '.$stato.' </ td >
< td align = " center " > '.$compatible.' </ td > ' ;
echo '
< td > ' ;
2017-09-13 15:38:47 +02:00
2017-08-04 16:28:16 +02:00
// Possibilità di disinstallare solo se il modulo non è tra quelli predefiniti
if ( empty ( $module [ 'default' ])) {
echo "
2018-06-29 17:58:42 +02:00
< a href = \ " javascript:; \" data-toggle='tooltip' title= \" " . tr ( 'Disinstalla' ) . " ... \" onclick= \" if( confirm(' " . tr ( 'Vuoi disinstallare questo modulo?' ) . ' ' . tr ( 'Tutti i dati salvati andranno persi!' ) . " ') ) { if( confirm(' " . tr ( 'Sei veramente sicuro?' ) . " ') ) { $ .post( ' " . ROOTDIR . '/actions.php?id_module=' . $id_module . " ', { op: 'uninstall', id: ' " . $module [ 'id' ] . " ' }, function(response) { location.href=' " . ROOTDIR . '/controller.php?id_module=' . $id_module . " '; }); } } \" ><i class='fa fa-trash'></i></a> " ;
2017-09-13 15:38:47 +02:00
} else {
echo "
< a class = 'disabled text-muted' >
< i class = 'fa fa-trash' ></ i >
</ a > " ;
2017-08-04 16:28:16 +02:00
}
2017-09-13 15:38:47 +02:00
2017-08-04 16:28:16 +02:00
echo '
</ td >
</ tr > ' ;
// Prima di cambiare modulo verifico se ci sono sottomoduli
2018-08-10 17:14:09 +02:00
echo submodules ( $module [ 'all_children' ]);
2017-08-04 16:28:16 +02:00
}
echo '
</ table >
</ div > ' ;
// Widgets
echo '
< div class = " col-md-12 col-lg-6 " >
2017-09-04 12:02:29 +02:00
< h3 > '.tr(' Widgets ').' </ h3 >
2017-08-04 16:28:16 +02:00
< table class = " table table-hover table-bordered table-condensed " >
< tr >
2017-09-04 12:02:29 +02:00
< th > '.tr(' Nome ').' </ th >
< th width = " 200 " > '.tr(' Posizione ').' </ th >
< th width = " 30 " > '.tr(' Stato ').' </ th >
< th width = " 30 " > '.tr(' Posizione ').' </ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
$widgets = $dbo -> fetchArray ( 'SELECT zz_widgets.id, zz_widgets.name AS widget_name, zz_modules.name AS module_name, zz_widgets.enabled AS enabled, location FROM zz_widgets INNER JOIN zz_modules ON zz_widgets.id_module=zz_modules.id ORDER BY `id_module` ASC, `zz_widgets`.`order` ASC' );
$previous = '' ;
foreach ( $widgets as $widget ) {
// Nome modulo come titolo sezione
if ( $widget [ 'module_name' ] != $previous ) {
echo '
< tr >
< th colspan = " 4 " > '.$widget[' module_name '].' </ th >
</ tr > ' ;
}
// STATO
if ( $widget [ 'enabled' ]) {
2017-09-04 12:02:29 +02:00
$stato = '<i class="fa fa-cog fa-spin text-success" data-toggle="tooltip" title="' . tr ( 'Abilitato' ) . '. ' . tr ( 'Clicca per disabilitarlo' ) . '..."></i>' ;
2017-08-04 16:28:16 +02:00
$class = 'success' ;
} else {
2017-09-04 12:02:29 +02:00
$stato = '<i class="fa fa-cog text-warning" data-toggle="tooltip" title="' . tr ( 'Non abilitato' ) . '"></i>' ;
2017-08-04 16:28:16 +02:00
$class = 'warning' ;
}
// Possibilità di disabilitare o abilitare i moduli tranne quello degli aggiornamenti
if ( $widget [ 'enabled' ]) {
2018-06-29 17:58:42 +02:00
$stato = " <a href='javascript:;' onclick= \" if( confirm(' " . tr ( 'Disabilitare questo widget?' ) . " ') ) { $ .post( ' " . ROOTDIR . '/actions.php?id_module=' . $id_module . " ', { op: 'disable_widget', id: ' " . $widget [ 'id' ] . " ' }, function(response) { location.href=' " . ROOTDIR . '/controller.php?id_module=' . $id_module . " '; }); } \" > " . $stato . " </a> \n " ;
2017-08-04 16:28:16 +02:00
} else {
2018-06-29 17:58:42 +02:00
$stato = " <a href='javascript:;' onclick= \" if( confirm(' " . tr ( 'Abilitare questo widget?' ) . " ') ) { $ .post( ' " . ROOTDIR . '/actions.php?id_module=' . $id_module . " ', { op: 'enable_widget', id: ' " . $widget [ 'id' ] . " ' }, function(response) { location.href=' " . ROOTDIR . '/controller.php?id_module=' . $id_module . " '; }); } \" \" > " . $stato . " </a> \n " ;
2017-08-04 16:28:16 +02:00
}
// POSIZIONE
if ( $widget [ 'location' ] == 'controller_top' ) {
2017-09-04 12:02:29 +02:00
$location = tr ( 'Schermata modulo in alto' );
2017-08-04 16:28:16 +02:00
} elseif ( $widget [ 'location' ] == 'controller_right' ) {
2017-09-04 12:02:29 +02:00
$location = tr ( 'Schermata modulo a destra' );
2017-08-04 16:28:16 +02:00
}
if ( $widget [ 'location' ] == 'controller_right' ) {
2017-09-04 12:02:29 +02:00
$posizione = " <i class='fa fa-arrow-up text-warning' data-toggle='tooltip' title= \" " . tr ( 'Clicca per cambiare la posizione...' ) . " \" ></i> <i class='fa fa-arrow-right text-success' data-toggle='tooltip' title= \" \" ></i> " ;
2018-06-29 17:58:42 +02:00
$posizione = " <a href='javascript:;' onclick= \" if( confirm(' " . tr ( 'Cambiare la posizione di questo widget?' ) . " ') ) { $ .post( ' " . ROOTDIR . '/actions.php?id_module=' . $id_module . " ', { op: 'change_position_widget_top', id: ' " . $widget [ 'id' ] . " ' }, function(response) { location.href=' " . ROOTDIR . '/controller.php?id_module=' . $id_module . " '; }); } \" \" > " . $posizione . " </a> \n " ;
2017-08-04 16:28:16 +02:00
} elseif ( $widget [ 'location' ] == 'controller_top' ) {
2017-09-04 12:02:29 +02:00
$posizione = " <i class='fa fa-arrow-up text-success' data-toggle='tooltip' title= \" \" ></i> <i class='fa fa-arrow-right text-warning' data-toggle='tooltip' title= \" " . tr ( 'Clicca per cambiare la posizione...' ) . '"></i></i>' ;
2018-06-29 17:58:42 +02:00
$posizione = " <a href='javascript:;' onclick= \" if( confirm(' " . tr ( 'Cambiare la posizione di questo widget?' ) . " ') ) { $ .post( ' " . ROOTDIR . '/actions.php?id_module=' . $id_module . " ', { op: 'change_position_widget_right', id: ' " . $widget [ 'id' ] . " ' }, function(response) { location.href=' " . ROOTDIR . '/controller.php?id_module=' . $id_module . " '; }); } \" \" > " . $posizione . " </a> \n " ;
2017-08-04 16:28:16 +02:00
}
echo '
< tr class = " '. $class .' " >
< td > '.$widget[' widget_name '].' </ td >
< td align = " right " >< small > '.$location.' </ small ></ td >
< td align = " center " > '.$stato.' </ td >
< td align = " center " > '.$posizione.' </ td >
</ tr > ' ;
$previous = $widget [ 'module_name' ];
}
echo '
</ table >
</ div >
</ div > ' ;