2019-05-04 02:03:42 +02:00
< ? 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-05-04 02:03:42 +02:00
2020-11-27 17:11:18 +01:00
use API\Services ;
2020-11-27 16:49:10 +01:00
use Carbon\Carbon ;
2021-09-03 20:14:30 +02:00
include_once __DIR__ . '/../../core.php' ;
2019-05-04 02:03:42 +02:00
2021-09-03 20:14:30 +02:00
// Informazioni sui servizi attivi
2019-05-04 02:03:42 +02:00
echo '
2021-09-03 20:14:30 +02:00
< div class = " row " > ' ;
2021-10-18 15:55:20 +02:00
$days = 60 ;
$limite_scadenze = ( new Carbon ()) -> addDays ( $days );
2020-11-27 17:11:18 +01:00
if ( Services :: isEnabled ()) {
2021-09-03 20:14:30 +02:00
echo '
<!-- Informazioni sui Servizi attivi -->
< div class = " col-md-12 col-lg-6 " >
2021-10-18 15:55:20 +02:00
< div class = " box box-primary " >
2021-09-03 20:14:30 +02:00
< div class = " box-header " >
< h3 class = " box-title " >
2021-10-18 15:55:20 +02:00
'.tr(' Servizi ').'
2021-09-03 20:14:30 +02:00
</ h3 >
</ div >
< div class = " box-body " > ' ;
2021-09-24 12:26:34 +02:00
$servizi = Services :: getServiziAttivi () -> flatten ( 1 );
2021-09-03 20:14:30 +02:00
if ( ! $servizi -> isEmpty ()) {
echo '
2021-10-18 15:55:20 +02:00
< table class = " box-body table table-striped table-hover table-condensed " >
2021-09-03 20:14:30 +02:00
< thead >
< tr >
2021-10-18 15:55:20 +02:00
< th width = " 50% " > '.tr(' Nome ').' </ th >
2021-09-03 20:14:30 +02:00
< th > '.tr(' Tipo ').' </ th >
2021-10-18 15:55:20 +02:00
< th width = " 30% " > '.tr(' Scadenza ').' </ th >
2021-10-26 11:33:27 +02:00
< th width = " 10% " class = " text-center " > '.tr(' #').'</th>
2021-09-03 20:14:30 +02:00
</ tr >
</ thead >
2020-11-27 16:49:10 +01:00
2021-09-03 20:14:30 +02:00
< tbody > ' ;
2020-12-29 00:39:30 +01:00
foreach ( $servizi as $servizio ) {
2021-09-03 20:14:30 +02:00
$scadenza = Carbon :: parse ( $servizio [ 'data_conclusione' ]);
echo '
2021-10-18 15:55:20 +02:00
< tr class = " '.( $scadenza->lessThan (Carbon::now()) ? 'danger' : ( $scadenza->lessThan ( $limite_scadenze ) ? 'warning' : '')).' " >
2021-09-03 20:14:30 +02:00
< td > '.$servizio[' codice '].' - '.$servizio[' nome '].' </ td >
2021-10-18 15:55:20 +02:00
< td > '.$servizio[' sottocategoria '].' </ td >
2021-09-03 20:14:30 +02:00
< td > '.dateFormat($scadenza).' ( '.$scadenza->diffForHumans().' ) </ td >
2021-10-26 13:08:27 +02:00
< td class = " text-center " >
< input type = " checkbox " class = " check_rinnova '.( $scadenza->lessThan ( $limite_scadenze ) ? " " : " hide " ).' " name = " rinnova[] " value = " '. $servizio['codice'] .' " >
2021-10-26 11:33:27 +02:00
</ td >
2021-09-03 20:14:30 +02:00
</ tr > ' ;
2020-11-27 16:49:10 +01:00
}
2020-12-31 16:13:28 +01:00
// Gestione per crediti
elseif (
( isset ( $servizio [ 'credits' ]) && $servizio [ 'credits' ] < 100 )
) {
$servizi_in_scadenza [] = $servizio [ 'name' ] . ' (' . $servizio [ 'credits' ] . ' crediti)' ;
}
}
2020-11-27 16:49:10 +01:00
2021-10-26 13:08:27 +02:00
$servizi_in_scadenza = Services :: getServiziInScadenza ( $limite_scadenze );
$servizi_scaduti = Services :: getServiziScaduti ();
if ( ! $servizi_in_scadenza -> isEmpty () || ! $servizi_scaduti -> isEmpty ()){
//TODO: Il tasto deve preparare correttamente il carrello con servizi e le risorse in scadenza, considerando anche eventuali ampliamenti (es. spazio FE esaurito o in esaurimento)
echo ' </ tbody >
< tfoot >
< tr >
< td colspan = " 4 " >
< a type = " button " href = " https://marketplace.devcode.it/ " target = " _blank " id = " btn_rinnova " class = " btn btn-xs btn-primary pull-right disabled " >< i class = " fa fa-shopping-cart " ></ i > '.tr(' Rinnova ').' </ a >
</ td >
</ tr >
</ tfoot > ' ;
}
2020-12-29 00:39:30 +01:00
echo '
2021-09-03 20:14:30 +02:00
</ table > ' ;
} else {
echo '
2021-10-08 19:06:31 +02:00
< div class = " alert alert-info " role = " alert " >
< i class = " fa fa-info " ></ i > '.tr(' Nessun servizio abilitato al momento ').' .
2021-09-03 20:14:30 +02:00
</ div > ' ;
}
echo '
</ div >
</ div >
</ div >
<!-- Informazioni sulle Risorse API -->
< div class = " col-md-12 col-lg-6 " >
2021-10-11 19:16:56 +02:00
< div class = " box box-primary " >
2021-09-03 20:14:30 +02:00
< div class = " box-header " >
< h3 class = " box-title " >
2021-10-18 15:55:20 +02:00
'.tr(' Risorse ').'
2021-09-03 20:14:30 +02:00
</ h3 >
2020-11-27 16:49:10 +01:00
</ div >
2020-12-29 00:39:30 +01:00
< div class = " box-body " > ' ;
2020-11-27 16:49:10 +01:00
2021-09-03 20:14:30 +02:00
// Elaborazione delle risorse API in scadenza
2021-09-24 12:26:34 +02:00
$risorse_attive = Services :: getRisorseAttive ();
if ( ! $risorse_attive -> isEmpty ()) {
$risorse_in_scadenza = Services :: getRisorseInScadenza ( $limite_scadenze );
2021-10-18 15:55:20 +02:00
$risorse_scadute = Services :: getRisorseScadute ();
2021-10-18 10:23:39 +02:00
2021-10-18 15:55:20 +02:00
if ( ! $risorse_in_scadenza -> isEmpty () || ! $risorse_scadute -> isEmpty () ) {
2021-10-26 11:33:27 +02:00
if ( ! $risorse_scadute -> isEmpty ()){
2021-10-18 15:55:20 +02:00
echo '
2021-10-26 11:33:27 +02:00
< div class = " alert alert-danger " role = " alert " > < i class = " fa fa-exclamation-triangle " ></ i > '.tr(' Attenzione , alcune risorse sono scadute o hanno esaurito i crediti : ' , [
'_NUM_' => $risorse_scadute -> count (),
2021-10-18 15:55:20 +02:00
]) . '</div>' ;
}
2021-10-26 11:33:27 +02:00
if ( ! $risorse_in_scadenza -> isEmpty ()){
2021-10-18 15:55:20 +02:00
echo '
2021-10-26 11:33:27 +02:00
< div class = " alert alert-warning " role = " alert " > < i class = " fa fa-clock-o " ></ i > '.tr(' Attenzione , alcune risorse sono in scadenza o stanno per esaurire i crediti : ' , [
'_NUM_' => $risorse_in_scadenza -> count (),
2021-10-18 15:55:20 +02:00
]) . '</div>' ;
2021-10-26 11:33:27 +02:00
2021-10-18 15:55:20 +02:00
}
2021-10-18 10:23:39 +02:00
} else {
2021-10-26 11:33:27 +02:00
/* echo '
2021-10-18 15:55:20 +02:00
< div class = " alert alert-success " role = " alert " > < i class = " fa fa-check-circle " ></ i > '.tr(' Bene , tutte le risorse sono attive e non presentano avvisi : ' , [
2021-10-18 10:23:39 +02:00
'_NUM_' => $risorse_attive -> count (),
2021-10-26 11:33:27 +02:00
]) . '</div>' ; */
2021-10-11 19:16:56 +02:00
}
2020-11-27 17:11:18 +01:00
2021-10-11 19:16:56 +02:00
echo '
2021-10-18 15:55:20 +02:00
< table class = " box-body table table-striped table-hover table-condensed " >
2021-10-11 19:16:56 +02:00
< thead >
< tr >
< th width = " 50% " > '.tr(' Nome ').' </ th >
< th > '.tr(' Crediti ').' </ th >
2021-10-18 15:55:20 +02:00
< th width = " 30% " > '.tr(' Scadenza ').' </ th >
2021-10-11 19:16:56 +02:00
</ tr >
</ thead >
< tbody > ' ;
2021-10-18 10:23:39 +02:00
foreach ( $risorse_attive as $servizio ) {
$scadenza = Carbon :: parse ( $servizio [ 'expiration_at' ]);
echo '
2021-10-18 15:55:20 +02:00
< tr class = " '.( $scadenza->lessThan (Carbon::now()) ? 'danger' : ( $scadenza->lessThan ( $limite_scadenze ) ? 'warning' : '')).' " >
2021-10-11 19:16:56 +02:00
< td > '.$servizio[' name '].' </ td >
2021-10-26 11:33:27 +02:00
< td > '.(($servizio[' credits '] < 100 && $servizio[' credits '] !== null) ? ' < b >< i class = " fa fa-icon fa-warning text-warning " ></ i > ' : ' ').(($servizio[' credits '] !== null) ? $servizio[' credits '] : ' - ').(($servizio[' credits '] < 100 && $servizio[' credits '] !== null) ? ' </ b > ' : ' ').' </ td >
< td > '.((Carbon::now()->diffInDays($scadenza, false) < $days && $scadenza) ? ' < b >< i class = " fa fa-icon fa-warning text-warning " ></ i > ' : ' ').dateFormat($scadenza).' ( '.$scadenza->diffForHumans().' ) '.((Carbon::now()->diffInDays($scadenza, false) < $days && $scadenza) ? ' </ b > ' : ' ').' </ td >
2021-10-11 19:16:56 +02:00
</ tr > ' ;
2021-10-18 10:23:39 +02:00
}
2021-10-04 15:26:56 +02:00
2021-10-11 19:16:56 +02:00
echo '
</ tbody >
2021-10-18 15:55:20 +02:00
</ table ></ div ></ div > ' ;
2021-09-17 17:18:17 +02:00
2021-10-11 19:16:56 +02:00
//Il servizio Fatturazione Elettronica deve essere presente per visualizzare le Statistiche su Fatture Elettroniche
2021-10-18 10:23:39 +02:00
if ( Services :: getRisorseAttive () -> where ( 'name' , 'Fatturazione Elettronica' ) -> count ()) {
echo '
2021-10-04 15:26:56 +02:00
2021-10-26 13:08:27 +02:00
< div class = " panel panel-primary " >
2021-10-18 15:55:20 +02:00
< div class = " panel-heading " > < i class = " fa fa-bar-chart " ></ i > '.tr(' Statistiche su Fatture Elettroniche ').' </ div >
2021-10-11 19:16:56 +02:00
< div class = " panel-body " >
< div class = " alert hidden " role = " alert " id = " spazio-fe " >
2021-10-26 11:33:27 +02:00
< i id = " spazio-fe-icon " class = " " ></ i > < span > '.tr(' Attenzione , spazio per fatture elettroniche _TEXT_ : _NUM_ utilizzati su _TOT_ disponibili ' , [
2021-10-11 19:16:56 +02:00
'_TEXT_' => '<span id="spazio-fe-text"></span>' ,
'_NUM_' => '<span id="spazio-fe-occupato"></span>' ,
'_TOT_' => '<span id="spazio-fe-totale"></span>' ,
2021-10-26 11:33:27 +02:00
]) . '.<br>' . tr ( " Contattare l'assistenza per risolvere il problema " ) . ' </ span >.
2021-10-11 19:16:56 +02:00
</ div >
< div class = " alert hidden " role = " alert " id = " numero-fe " >
2021-10-26 11:33:27 +02:00
< i id = " numero-fe-icon " class = " " ></ i > < span > '.tr(' Attenzione , numero di fatture elettroniche per l\ 'annualità _TEXT_: _NUM_ documenti transitati su _TOT_ disponibili' , [
2021-10-11 19:16:56 +02:00
'_TEXT_' => '<span id="numero-fe-text"></span>' ,
'_NUM_' => '<span id="numero-fe-occupato"></span>' ,
'_TOT_' => '<span id="numero-fe-totale"></span>' ,
2021-10-26 11:33:27 +02:00
]) . '.<br>' . tr ( " Contattare l'assistenza per risolvere il problema " ) . ' </ span >.
2021-10-11 19:16:56 +02:00
</ div >
2021-10-18 15:55:20 +02:00
< table class = " box-body table table-striped table-hover table-condensed " >
2021-10-11 19:16:56 +02:00
< thead >
< tr >
< th > '.tr(' Anno ').' </ th >
< th >
2021-10-26 11:33:27 +02:00
'.tr(' N . documenti archiviati ').'
2021-10-11 19:16:56 +02:00
< span class = " tip " title = " '.tr('Fatture attive e relative ricevute, fatture passive').'. " >
< i class = " fa fa-question-circle-o " ></ i >
</ span >
</ th >
< th >
2021-10-26 11:33:27 +02:00
'.tr(' Spazio utilizzato ').'
2021-10-11 19:16:56 +02:00
< span class = " tip " title = " '.tr('Fatture attive con eventuali allegati e ricevute, fatture passive con eventuali allegati').'. " >
< i class = " fa fa-question-circle-o " ></ i >
</ span >
</ th >
</ tr >
</ thead >
2021-10-26 13:08:27 +02:00
< tfoot id = " elenco-fe " >
2021-10-18 15:55:20 +02:00
< tr style = " background-color:#CCCCCC; " >
2021-10-11 19:16:56 +02:00
< td > '.tr(' Totale ').' </ td >
< td id = " fe_numero " ></ td >
< td id = " fe_spazio " ></ td >
</ tr >
2021-10-26 13:08:27 +02:00
</ tfoot >
2021-10-11 19:16:56 +02:00
</ table >
</ div >
</ div >
2021-10-04 15:26:56 +02:00
< script >
$ ( document ) . ready ( function (){
aggiornaStatisticheFE ();
});
</ script > ' ;
2021-10-11 19:16:56 +02:00
}
2021-02-18 18:48:44 +01:00
} else {
2020-12-29 00:39:30 +01:00
echo '
2021-10-11 19:16:56 +02:00
< div class = " alert alert-info " role = " alert " >
< i class = " fa fa-info " ></ i > '.tr(' Nessuna risorsa Services abilitata ').' .
2021-10-04 15:26:56 +02:00
</ div > ' ;
2020-12-29 00:39:30 +01:00
}
2021-09-03 20:14:30 +02:00
echo '
</ div > ' ;
} else {
2021-10-04 09:10:38 +02:00
/*
2021-09-03 20:14:30 +02:00
echo '
< div class = " col-md-12 col-lg-6 " >
< div class = " alert alert-warning " role = " alert " >
< i class = " fa fa-warning " ></ i > '.tr("Configurazione per l' accesso Services non completata correttamente " ).'. '.tr('Per abilitare i servizi, compilare l \ 'impostazione " OSMCloud Services API Token " ').'.
</ div >
</ div > ' ;
2021-10-04 09:10:38 +02:00
*/
2020-11-27 16:49:10 +01:00
}
2021-09-03 20:14:30 +02:00
echo '
</ div >
< div class = " row " >
< div class = " col-md-12 col-lg-6 " >
< div class = " box box-info " >
< div class = " box-header " >
< h3 class = " box-title " >
'.tr(' Moduli disponibili ').'
</ h3 >
</ div >
< div class = " box-body " id = " moduli " >
</ div >
</ div >
</ div > ' ;
2019-05-04 02:03:42 +02:00
// Widgets
echo '
< div class = " col-md-12 col-lg-6 " >
2021-09-03 20:14:30 +02:00
< div class = " box box-info " >
< div class = " box-header " >
< h3 class = " box-title " >
'.tr(' Widget disponibili ').'
</ h3 >
</ div >
2019-05-04 02:03:42 +02:00
2021-09-03 20:14:30 +02:00
< div class = " box-body " id = " widget " >
</ div >
</ div >
</ div >
</ div >
2019-05-04 02:03:42 +02:00
2021-09-03 20:14:30 +02:00
< script >
2021-10-26 13:08:27 +02:00
$ ( " .check_rinnova " ) . each ( function () {
var len = 0 ;
input ( this ) . change ( function () {
len = $ ( " input[type=checkbox]:checked.check_rinnova " ) . length ;
if ( len > 0 ){
$ ( " #btn_rinnova " ) . removeClass ( " disabled " );
} else {
$ ( " #btn_rinnova " ) . addClass ( " disabled " );
}
});
});
2021-09-03 20:14:30 +02:00
function aggiornaStatisticheFE (){
$ . ajax ({
url : globals . rootdir + " /actions.php " ,
type : " GET " ,
dataType : " JSON " ,
data : {
id_module : globals . id_module ,
op : " informazioni-fe " ,
},
success : function ( response ) {
$ ( " #fe_numero " ) . html ( response . invoice_number );
2021-10-11 19:16:56 +02:00
2021-09-17 17:18:17 +02:00
$ ( " #fe_spazio " ) . html ( response . spazio_occupato );
// Informazioni sullo spazio occupato
$ ( " #spazio-fe-occupato " ) . html ( response . spazio_occupato );
$ ( " #spazio-fe-totale " ) . html ( response . spazio_totale );
2021-10-26 11:33:27 +02:00
2021-09-17 17:18:17 +02:00
if ( response . avviso_spazio ) {
2021-10-11 19:16:56 +02:00
2021-09-17 17:18:17 +02:00
$ ( " #spazio-fe " ) . removeClass ( " hidden " );
2021-10-26 13:08:27 +02:00
$ ( " input.check_rinnova " ) . addClass ( " disabled " );
2021-10-08 19:06:31 +02:00
2021-10-26 11:33:27 +02:00
response . spazio_occupato = parseFloat ( response . spazio_occupato );
response . spazio_totale = parseFloat ( response . spazio_totale );
if ( response . spazio_totale ){
$ ( " #fe_spazio " ) . html ( $ ( " #fe_spazio " ) . html () + " / " + response . spazio_totale );
if ( response . spazio_occupato > response . spazio_totale && response . avviso_spazio ){
$ ( " #fe_spazio " ) . html ( " <span style= \" font-weight:bold; \" ><i class= \" fa fa-warning text-warning \" ></i> " + $ ( " #fe_spazio " ) . html () + " </span> " );
}
}
2021-10-08 19:06:31 +02:00
if ( response . spazio_occupato < response . spazio_totale ){
2021-10-26 11:33:27 +02:00
$ ( " #spazio-fe-icon " ) . addClass ( " fa fa-clock-o " );
2021-10-08 19:06:31 +02:00
$ ( " #spazio-fe " ) . addClass ( " alert-warning " );
2021-10-11 19:16:56 +02:00
$ ( " #spazio-fe-text " ) . html ( " '.tr('in esaurimento').' " );
2021-10-08 19:06:31 +02:00
}
else if ( response . spazio_occupato >= response . spazio_totale ){
2021-10-26 11:33:27 +02:00
$ ( " #spazio-fe-icon " ) . addClass ( " fa fa-warning " );
2021-10-08 19:06:31 +02:00
$ ( " #spazio-fe " ) . addClass ( " alert-danger " );
2021-10-11 19:16:56 +02:00
$ ( " #spazio-fe-text " ) . html ( " '.tr('terminato').' " );
2021-10-08 19:06:31 +02:00
}
2021-09-17 17:18:17 +02:00
}
2021-10-08 19:06:31 +02:00
2021-09-03 20:14:30 +02:00
if ( response . history . length ) {
2021-10-08 19:06:31 +02:00
2021-09-03 20:14:30 +02:00
for ( let i = 0 ; i < response . history . length ; i ++ ) {
2021-10-08 19:06:31 +02:00
2021-09-03 20:14:30 +02:00
const data = response . history [ i ];
2021-10-11 19:16:56 +02:00
if ( data [ " year " ] == '.date(' Y ').' ){
2021-10-08 19:06:31 +02:00
2021-10-18 15:55:20 +02:00
var highlight = " <tr class= \" info \" > " ;
2021-10-11 19:16:56 +02:00
var number = data [ " number " ];
if ( response . maxNumber > 0 && response . maxNumber )
data [ " number " ] = number + " / " + response . maxNumber ;
if ( response . avviso_numero )
2021-10-26 11:33:27 +02:00
data [ " number " ] = " <span style= \" font-weight:bold; \" > <i class= \" fa fa-warning text-warning \" ></i> " + data [ " number " ] + " </span> " ;
2021-10-11 19:16:56 +02:00
$ ( " #numero-fe-occupato " ) . html ( number );
$ ( " #numero-fe-totale " ) . html ( response . maxNumber );
if ( response . avviso_numero ) {
2021-10-08 19:06:31 +02:00
2021-10-11 19:16:56 +02:00
$ ( " #numero-fe " ) . removeClass ( " hidden " );
2021-10-26 13:08:27 +02:00
$ ( " input.check_rinnova " ) . addClass ( " disabled " );
2021-10-08 19:06:31 +02:00
2021-10-11 19:16:56 +02:00
if ( number < response . maxNumber ){
2021-10-26 11:33:27 +02:00
$ ( " #numero-fe-icon " ) . addClass ( " fa fa-clock-o " );
2021-10-11 19:16:56 +02:00
$ ( " #numero-fe " ) . addClass ( " alert-warning " );
$ ( " #numero-fe-text " ) . html ( " '.tr('in esaurimento').' " );
}
else if ( number >= response . maxNumber ){
2021-10-26 11:33:27 +02:00
$ ( " #numero-fe-icon " ) . addClass ( " fa fa-warning " );
2021-10-11 19:16:56 +02:00
$ ( " #numero-fe " ) . addClass ( " alert-danger " );
$ ( " #numero-fe-text " ) . html ( " '.tr('esaurito').' " );
}
2021-10-08 19:06:31 +02:00
2021-10-11 19:16:56 +02:00
}
2021-10-08 19:06:31 +02:00
} else {
2021-10-11 19:16:56 +02:00
var highlight = " <tr> " ;
2021-10-08 19:06:31 +02:00
}
2019-05-04 02:03:42 +02:00
2021-10-11 19:16:56 +02:00
$ ( " #elenco-fe " ) . prepend ( highlight + `
2021-09-03 20:14:30 +02:00
< td > ` + data["year"] + ` </ td >
< td > ` + data["number"] + ` </ td >
< td > ` + data["size"] + ` </ td >
</ tr > ` );
2021-10-08 19:06:31 +02:00
2021-09-03 20:14:30 +02:00
}
}
}
});
}
2019-05-04 02:03:42 +02:00
2021-09-03 20:14:30 +02:00
function caricaElencoModuli () {
let container = $ ( " #moduli " );
localLoading ( container , true );
return $ . get ( " '. $structure->fileurl ('elenco-moduli.php').'?id_module='. $id_module .' " , function ( data ) {
container . html ( data );
localLoading ( container , false );
init ();
});
2019-05-04 02:03:42 +02:00
}
2021-09-03 20:14:30 +02:00
function caricaElencoWidget () {
let container = $ ( " #widget " );
localLoading ( container , true );
return $ . get ( " '. $structure->fileurl ('elenco-widget.php').'?id_module='. $id_module .' " , function ( data ) {
container . html ( data );
localLoading ( container , false );
init ();
});
}
$ ( document ) . ready ( function () {
caricaElencoModuli ();
caricaElencoWidget ();
init ();
});
</ script > ' ;