include( explode('public_html', __DIR__)[0]. "public_html/hospitalhacos" ."/api/conne.php" );
require_once( explode('public_html', __DIR__)[0]. "public_html/hospitalhacos" . "/api/raelgc/view/Template.php");
use raelgc\view\Template;
forceHTTPS();
/*======================Especifico HPT================*/
$url = getUrlBase(). "/api/v1/";
$url_options = getUrlBase() . "/api/v1/resumo_voluntario/";
$array_header = array(
'Content-Type: application/json'
);
// Se a sess?o n?o existir, inicia uma
if (!isset($_SESSION)){
//echo("inicia Sessao");
session_start();
}
if( isset($_GET["logout"]) ){
//echo("sair");
//$_SESSION = array();
session_destroy();
header("Location: login.php");
exit;
}
if( isset($_GET["sair"]) ){
//echo("sair");
//$_SESSION = array();
session_destroy();
header("Location: login.php");
exit;
}
if ( !isset($_SESSION["obj"])) {
session_destroy();
header("Location: login.php");
exit;
}
$json = $_SESSION["obj"];
$aJson = json_decode($json, true);
$obj = json_decode($json);
$foto = $obj->foto;
$meusEventos = sendRequest($url . "eventos_voluntario/".$obj->id, $array_header, null, "GET");
$meusEventos = json_decode($meusEventos, true);
$aMsg = lista("mensagens WHERE para =".$obj->id);
//Carrega as opions
$array_header = array('Content-Type: application/json');
$options = sendRequest($url_options . $obj->id , $array_header, null, "GET");
//echo($options);
$options = json_decode($options, true);
/*======================Especifico HPT================*/
$proximoEvento = "99/99/9999";
for( $i = 0; $i< count($meusEventos); $i++){
if( $meusEventos[$i]["data_sys"] >= dtos( date("d/m/Y") ) ) {
$proximoEvento = $meusEventos[$i]["data"] ;
$i = count($meusEventos);
}
}
// Seleciona Template
$tpl = new Template( explode('public_html', __DIR__)[0]. "public_html/hospitalhacos" . "/api/v1/templates/views/layout_base.html");
//Seleciona Conteúdo
$tpl->addFile('MENU_TEMPLATE', explode('public_html', __DIR__)[0]. "public_html/hospitalhacos" . "/api/v1/templates/views/menu.html");
setMenu($tpl, $obj->id);
$tpl->addFile('CONTEUDO', explode('public_html', __DIR__)[0]. "public_html/hospitalhacos" . "/api/v1/templates/views/painel/painel.html");
$tpl->FOTO = $foto;
$tpl->NOME = $obj->nome;
$tpl->EMAIL = $obj->email;
$tpl->PAGE_TITULO = "Painel";
$tpl->PROXIMO_EVENTO = $proximoEvento;
$tpl->TOTAL_NOTIFICACOES = count($aMsg) ;
$tpl->TOTAL_SALDO = number_format( $options["total"] ,2,",",".") ;
$tpl->RESUMO_ATUACOES = number_format( $options["atuacao"]["resumo"],2,",",".") ;
$tpl->RESUMO_EXTERNO = number_format( $options["externo"]["resumo"],2,",",".") ;
$tpl->RESUMO_TREINAMENTO = number_format( $options["treinamento"]["resumo"],2,",",".") ;
$tpl->addFile('FOOTER_TEMPLETE', explode('public_html', __DIR__)[0]. "public_html/hospitalhacos" . "/api/v1/templates/views/footer.html");
// Exibe
$tpl->show();
?>