<?php

	require_once('config.php');
	require_once('sysclub_class/grid.php');
	require_once('sysclub_class/mensagem.php');
	require_once('sysclub_class/clientewebservice.php');
	require_once('sysclub_class/clientewebservice.php');
	require_once('sysclub_functions/functions.php');
	require_once('seguranca.php');

	switch ($action) 
	{
		default : index();
	}

	function formatDate($value)
	{
		$tmp = substr($value, 8, 2) ;
		$tmp .= "/" .substr($value, 5, 2) ;
		$tmp .= "/" .substr($value, 0, 4);
		return $tmp;
	}
		
	function index()
	{		
		global $CLUBE, $TITULO_SITE;

		try
		{
			$factory = new WebService();
			$result = $factory->GetDadosFinanceiro($_SESSION["CODIGO"]);
		}
		catch (Exception $e) 
		{
			$mensagem = new Mensagem();
			$conteudo = $mensagem->Make('Servi&ccedil;o de Boleto ON-LINE n&atilde;o esta dispon&iacute;vel...');
			include("view/template.php");
			exit;
		}

		$conteudo = "

		<br>
		<div class='row'>
			<div class='col-md-10'><h2>D&eacute;bitos</h2></div>
			<div class='col-md-2'></div>
		</div>

		<div class='row'>
			<div class='col-md-12'>
				
				<table class='table table-striped table-bordered' id='listing'>
					<thead>
					<tr>
						<th width='10%'></th>
						<th width='10%'>Vencimento</th>
						<th width='10%'>Valor</th>
						<th width='10%'>Valor Atual</th>
						<th width='60%'>Descrição</th>
					</tr>
					</thead>
					<tbody>";
					
					foreach($result as $row)
					{
						$conteudo .= "
						<tr>
							<td>
								<form name='form_gerar' id='form_gerar' method=post action=imprimir.php>
									<input type=hidden name='row_0' value='". $row['NR_LANCAMENTO'] ."'>
									<input type=hidden name='action' value='imprimir'>
									<button type=submit class='btn btn-primary btn-sm' id='btn_unico' name='btn_unico'>
										<span class='glyphicon glyphicon-print'></span> Gerar Boleto
									</button>
								</form>
							</td>
							<td>". formatDate($row['DT_VENCIMENTO']) ."</td>
							<td style='text-align: right;'>". $row['VALOR'] ."</td>
							<td style='text-align: right;'>". $row['VALORATUALIZADO'] ."</td>
							<td>". $row['DESCRICAO'] ."</td>
						</tr>";
						
					}
					
					$conteudo .= "
					</tbody>
				</table>
					
			</div>
		</div>

		";
		
		include("view/template.php");
	}

?>