<?php
	session_start();
	$_SESSION['sessionCamara'] = 'S';
    include "../php/conexaoDB.php";
    #header("Content-type: text/html; charset=utf-8");
?>
<!DOCTYPE html>
<html lang="pt-br">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<!--<meta name="viewport" content="width=device-width, initial-scale=1"> -->
		<!-- SEO -->
		<title>SPE - Riscos Fiscais</title>

		<!-- Fontes -->
		<link href='https://fonts.googleapis.com/css?family=Oswald:400,700' rel='stylesheet' type='text/css'>
		<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha256-3dkvEK0WLHRJ7/Csr0BZjAWxERc5WH7bdeUya2aXxdU= sha512-+L4yy6FRcDGbXJ9mPG8MT/3UCDzwR9gPeyFNMCtInsol++5m3bk2bXWKdZjvybmohrAsn3Ua5x8gfLnbE1YkOg==" crossorigin="anonymous">
		<link href='https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'>

		<script src="https://kit.fontawesome.com/b8524f33d3.js" crossorigin="anonymous"></script>
		
		<!-- Arquivos -->
		<link rel="shortcut icon" href='../images/spe_logo.png'>
		<link rel="stylesheet" href='../css/formatacoes.css' >

		<script src="https://code.jquery.com/jquery-3.5.1.js"></script>	
		<script src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>

		<script src="https://cdn.datatables.net/responsive/2.2.4/js/dataTables.responsive.min.js"></script>
		<script src="https://cdn.datatables.net/buttons/1.6.2/js/dataTables.buttons.min.js"></script>
		<script src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.colVis.min.js"></script>
		<script src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.print.min.js"></script>

		<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.4/css/responsive.dataTables.min.css"/>
		<!-- buttons -->
		<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css"/>
		<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.6.2/css/buttons.dataTables.min.css"/>

		<!-- buttons -->
		<script src="https://cdn.datatables.net/buttons/1.6.2/js/dataTables.buttons.min.js"></script>
		<script src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.flash.min.js"></script>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
		<script src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.html5.min.js"></script>
		<script src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.print.min.js"></script>

		<script type="text/javascript" language="javascript">
			var parametros = new Array();
			parametros["camara"] = 'S'; 
			parametros["senado"] = 'S';
			parametros["stf"] = 'S';

			$.fn.dataTable.ext.search.push( 
				function (settings, data, dataindex) {
					alert("Passou na função!");
				  		//if ($('#check_camara').checked && data[7] == 'C') {
				  		if ($('#check_camara').checked) {	
				  				parametros["camara"] = 'S'; 
				  				//return true;
				  				alert("passou por aqui!");
						  	} else {
						  		parametros["camara"] = 'N'; 
						  		alert("NÃO passou por aqui!");
					  			//return false;
					  		}
				});

			$(document).ready(function() {
				var table = $('#tabela').DataTable({
						dom: "Blfrtip",
        				buttons: [
            				"colvis",
            				{extend: "copy",
            				 text: "Copiar"},
            				"csv",
            				{extend: "excel",
            				messageTop: "SPE - Riscos fiscais"
            				},
            				"pdf",
            				{extend: "print",
            					text: "Imprimir",
       				 			title: "Secretaria de Política Econômica - SPE",
       				 			messageTop: "Riscos fiscais - Congresso e Justiça",
            				 	messageBottom: ";o)"
            				 	}
         				],
						deferRender: true,
						processing: true,
						serverSide: true,
						scrollX: true,
						scrollY: "555px",
						aaSorting: [[0,'desc']],
						language: {
							"thousands": ".",
							"decimal":  ",",
							"sProcessing": "Processando...",
							"sLengthMenu": "_MENU_ registros por página",
							"sZeroRecords": "Sem registros com esse critério",
							"sEmptyTable": "Sem registros armazenados",
							"sLoadingRecordes": "Carregando...",
							"sInfo": "_START_ a _END_ de _TOTAL_ registros",
							"sInfoEmpty": "0 registros",
							"sInfoFiltered": "(filtro em _MAX_ registros)",
							"sSearch": "Pesquisar: ",
							"oPaginate": {
								"sFirst": "Primeira",
								"sPrevious": "Anterior",
								"sNext": "Próxima",
								"sLast": "Última"
							},
							"buttons": {
                				colvis: 'Colunas'
            				}
						},
						pageLength: 25,
						ajax: {
							url: "pesq_tabela.php",
							data: parametros,
								//{
								//},
							"type": "POST",
						},
						columns: [
				            { "data": "dt_apres"},
				            { "data": "id"},
				            { "data": "proposicao"},
				            { "data": "ementa"},
				            { "data": "detalhe"},
				            { "data": "keyWords"},
				            { "data": "valor"},
				            { "data": "origem"}
		        			],
		        		columnDefs: [
								{ "targets": [ 7 ],
								"visible": false,
								"searchable": false 
								}
								//{ "width": "40px", "targets": 1 },
								//{ "width": "70px", "targets": 5 },
								//{ "width": "70px", "targets": 6 }
						    ]
					});

		/*			table.on( 'xhr', function () {
		    			var json = table.ajax.json();
					    alert( json.data.length +' row(s) were loaded' );
					    
					} );*/


				$checkBox = $('#tabela_parametros');
				$checkBox.on('click', 'input', onClicked);

				function onClicked() {
				  	//alert($(this).attr('id'));
				  	if ($(this).attr('id') == 'check_camara') {
				  		if ($(this).attr('id').checked) {
				  				parametros["camara"] = 'S';

						  	} else {
					  			parametros["camara"] = 'N';
					  			alert($(this).attr('id') + ' = ' + parametros['camara']);
					  		}
					}
					if ($(this).attr('id') == 'check_senado') {
				  		if ($(this).attr('id').checked) {
				  				parametros["senado"] = 'S';
						  	} else {
					  			parametros["senado"] = 'N';
					  		}
					}
				  	if ($(this).attr('id') == 'check_stf') {
				  		if ($(this).attr('id').checked) {
				  				parametros["stf"] = 'S';
						  	} else {
					  			parametros["stf"] = 'N';
					  		}
					}
			  		//$('#tabela').DataTable().ajax.reload();
			  		table.draw();
			  	};



			});


		</script>

		<script type="text/javascript">
			/*$(document).ready(function() {
				$checkBox = $('#tabela_parametros');

				$checkBox.on('click', 'input', onClicked);

				function onClicked() {
				  	alert($(this).attr('id'));
				  	if ($(this).attr('id') == 'check_camara') {
				  		if ($(this).attr('id').checked) {
				  				chk_camara = 'S';
						  	} else {
					  			chk_camara = 'N';
					  		}
					}
					if ($(this).attr('id') == 'check_senado') {
				  		if ($(this).attr('id').checked) {
				  				chk_senado = 'S';
						  	} else {
					  			chk_senado = 'N';
					  		}
					}
				  	if ($(this).attr('id') == 'check_stf') {
				  		if ($(this).attr('id').checked) {
				  				chk_stf = 'S';
						  	} else {
					  			chk_stf = 'N';
					  		}
					}
			  		$('#tabela').DataTable().ajax.reload();
			  		//$('#tabela').DataTable().draw();
				}
			});*/
		</script>

 		<style>
			div.dataTables_wrapper {
        	width: 1400px;
        	margin: 0 auto;
        	color: #263f1e;
        	font-size: 0.8em !important;
    		}
/*			table{
			  margin: 0 auto;
			  width: 100%;
			  clear: both;
			  border-collapse: collapse;
			  table-layout: fixed; 
			  word-wrap:break-word;
			} */
		</style>

	</head>

	<body>

		<div class="fab" id="fab"> X </div>

		<div class="tela_inicial_visivel">
			<div class="cabecalho_inicial">
				<header>
					<div class="cabecalho_inicial_esquerdo font150">
						<p>Ministério da Economia</p>
						<p>Secretaria de Política Econômica - SPE</p>
						<p>Acompanhamento de Riscos Fiscais das Proposições Parlamentares e Ações STF</p>
					</div>
				</header>
			</div>

			<div class="meio_pagina_inicial">
				<div class="logo">
					<img src="../images/spe_logo.png" height="300" width="300" style="opacity: 0.2">
				</div>
			</div>
		</div>

		<div class="premissas_tabela">
			<hr style="margin-top: 0px;">
			<p class="titulo_tabela_parametros font150">Proposições Parlamentares e Ações tramitando no STF que podem representar RISCOS FISCAIS</p>
			<hr style="margin-top: 0px;">
			
			<div class="conjunto_premissas">
				<div class="premissas_tabela_esquerda">
					<table class="tabela_geral continua">
						<p class="titulo_parametros font125">Parâmetros iniciais</p>
						<tbody class="tabela_parametros" id="tabela_parametros">

							<tr>
								<td class="tabela_parametros_primeira_coluna">Câmara</td>
								<td><label name="relatorio_opt_camara" class="switch"><input type="checkbox" id="check_camara" checked><span class="slider round"></span></label></td>
							</tr>

							<tr>
								<td>Senado</td>
								<td><label name="relatorio_opt_senado" class="switch"><input type="checkbox" id="check_senado" checked><span class="slider round"></span></label></td>
							</tr>

							<tr>
								<td>STF</td>
								<td><label name="relatorio_opt_stf" class="switch"><input type="checkbox" id="check_stf" checked><span class="slider round"></span></label></td>
							</tr>

							<tr>
								<td>Arquivados</td>
								<td><label name="relatorio_opt_arquivados" class="switch"><input type="checkbox" id="check_arquivados"><span class="slider_green round"></span></label></td>
							</tr>


							<tr>
								<td>Tramitando em conjunto</td>
								<td><label name="relatorio_opt_arquivados" class="switch"><input type="checkbox" id="check_tram_cjto" checked><span class="slider_orange round"></span></label></td>
							</tr>


							<tr>
								<td>Apenas trâmite CAE/CFT</td>
								<td><label name="relatorio_opt_cae_cft" class="switch"><input type="checkbox" id="check_cae_cft"><span class="slider_orange round"></span></label></td>
							</tr>

							<tr>
								<td>Apenas CONCLUSIVAS nas Comissões</td>
								<td><label name="relatorio_opt_arquivados" class="switch"><input type="checkbox" id="check_conclusiva"><span class="slider_orange round"></span></label></td>
							</tr>
						</tbody>
					</table>

				</div>

				<div class="premissas_tabela_direita">
					<table class="continua">
						<tr>
							<td class="premissa_coluna_um">Filtro de tempo</td>
							<td class="premissa_coluna_dois">
								<div class="slidecontainer">
						  			<input type="range" min="0" max="100" value="3" class="slider_tempo" id="contador">
								</div>
							</td>
							<td class="premissa_coluna_tres">
								<p>dias: <span id="valor_cursor" style="margin: 0px;"></span></p>
							</td>
						</tr>
						<tr>
							<td class="premissa_coluna_um">Priorizar tramitação</td>
							<td class="premissa_coluna_dois"></td>
							<td class="premissa_coluna_tres"></td>
						</tr>

						<tr>
							<td class="premissa_coluna_um">Priorizar assessoria</td>
							<td class="premissa_coluna_dois"></td>
							<td class="premissa_coluna_tres"></td>
						</tr>
						<tr>
							<td class="premissa_coluna_um">Priorizar SPE</td>
							<td class="premissa_coluna_dois"></td>
							<td class="premissa_coluna_tres"></td>
						</tr>
						<tr>
							<td class="premissa_coluna_um">Priorizar impacto fiscal</td>
							<td class="premissa_coluna_dois"></td>
							<td class="premissa_coluna_tres"></td>
						</tr>					
					</table>

				</div>

			</div>
			<div class="tabela">
				<hr style="height:2px;border-width:0;color:gray;background-color:gray">
				<table id="tabela" class="display responsive wrap" style="width:100%">
					<thead>
						<tr>
							<th>Apresentação</th>
							<th width="5%">ID</th>
							<th>Proposição</th>
							<th>Ementa</th>
							<th>Detalhe</th>
							<th>KeyWords</th>
							<th>Valor (R$ milhões)</th>
							<th>origem</th>
						</tr>
					</thead>

					<tfoot>
						<tr>
							<th>Apresentação</th>
							<th width="5%">ID</th>
							<th>Proposição</th>
							<th>Ementa</th>
							<th>Detalhe</th>
							<th>KeyWords</th>
							<th>Valor (R$ milhões)</th>
							<th>origem</th>
						</tr>
					</tfoot>

			</div>
		</div>

		<script type="text/javascript">
			$(document).ready(function() {
//AQUI			
				$("#fab").click(function (event) {
					event.preventDefault();
					let result = confirm("Sair?");
					if (result == true) {
						window.location.replace("../index.php");
					}

				});
			});
		</script>
	</body>
</html>
