<div class="row">
       	
	 <section class="content">
     
	 <?php echo '<div class="alert alert-warning fade in" >
			  <a href = "#" class = "close" data-dismiss= "alert"> &times;</a>
  				<strong>Atenção&nbsp;</strong> &nbsp;&nbsp;Preencha os dados necessarios para gerar os relatorios
				</div>'?>
	        <div class="box box-success">
            <div class="box-body">
              <div class="table-responsive">
             <div class="box-body">

			 <div class="col-md-14">
             <div class="nav-tabs-custom">
             <ul class="nav nav-tabs">
              <li class="active"><a href="#tab_1" data-toggle="tab">Extrato de Impactos do Mutuário</a></li>
              <li><a href="#tab_2" data-toggle="tab">Impactos por linha de financiamento</a></li>
              <li><a href="#tab_3" data-toggle="tab">Impactos por localização</a></li>
              <!--<li><a href="#tab_4" data-toggle="tab">Resumo</a></li>-->
              </ul>
             <div class="tab-content">
             <div class="tab-pane active" id="tab_1">
                <form class="form-horizontal" method="post" action="">
                    <?php echo '<div class="alert alert-info fade in" >
			  <a href = "#" class = "close" data-dismiss= "alert"> &times;</a>
  				Preencha os filtros para obtencao do relatorio.
				</div>'?>
                    <div class="box-body">
			            <div class="form-group">
                            <label for="" class="col-sm-2 control-label" style="color:#009900"><b style="color:red">*</b> Mutuário</label>
            				 <div class="col-sm-10">
                            <select name="borrower" class="customer select2" style="width: 100%;" required>
                      				<option>--Selecione Cliente--</option>
                      				<?php
                      				$get = mysqli_query($link, "SELECT * FROM borrowers order by id") or die (mysqli_error($link));
                      				while($rows = mysqli_fetch_array($get))
                      				{
                      				echo '<option value="'.$rows['id'].'">'.$rows['fname'].'&nbsp;'.$rows['lname'].'</option>';
                      				}
                      				?>
                            </select>
                          </div>
            			  </div>
		
            <div class="form-group">
                  <label for="" class="col-sm-2 control-label" style="color:#009900"><b style="color:red">*</b> Conta</label>
                  <div class="col-sm-10">
                  <select class="account select2" name="account" style="width: 100%;" required>
			
				</select>
                  </div>
            </div>

		
		<div class="form-group">
                  <label for="" class="col-sm-2 control-label" style="color:#009900"><b style="color:red">*</b> Linha de Financiamento</label>
                  <div class="col-sm-10">
                  <select class="credito select2" name="credito" style="width: 100%;" required>
				<option></option>
                  
				</select>
                  </div>
            </div>
    
    
			<div class="form-group">
                  <label for="" class="col-sm-2 control-label" style="color:#009900"><b style="color:red">*</b> Tipo de Credito</label>
                  <div class="col-sm-10">
                  <select class="cadeia select2" name="cadeia" style="width: 100%;" required>
				
				</select>
                  </div>
            </div>	
            <div class="form-group">
                  <label for="" class="col-sm-2 control-label" style="color:#009900"><b style="color:red">*</b>Cadeia de Valores</label>
                  <div class="col-sm-10">
                  <select class="cadeiaVal select2" name="cadeiaVal" style="width: 100%;" required>
				    <option value="Horticulas">Horticulas</option>
				    <option value="Piscicultura">Piscicultura</option>
				    <option value="Sivicultura">Sivicultura</option>
				    <option value="Pecuaria">Pecuaria</option>
				    <option value="Feijão">Feijão</option>
				    <option value="Milho">Milho</option>
				    <option value="Arroz">Arroz</option>
				    <option value="Soja">Soja</option>
				</select>
                  </div>
            </div>
			  <div align="right">
              <div class="box-footer">
                <button name="impactos" type="submit" class="btn btn-success btn-flat"><i class="fa fa-save">&nbsp;Gerar Relatorio</i></button>

              </div>
			  </div>
			        </div>
			     </form>
			 </div>
              <!-- /.tab-pane -->
              
              <!-- /.tab-pane -->
              	<div class="tab-pane" id="tab_2">
                    <form class="form-horizontal" method="post" action="">
                    <?php echo '<div class="alert alert-info fade in" >
			  <a href = "#" class = "close" data-dismiss= "alert"> &times;</a>
  				Preencha os filtros para obtencao do relatorio.
				</div>'?>
                    <div class="box-body">
			            
		
		    <div class="form-group">
                  <label for="" class="col-sm-2 control-label" style="color:#009900"> Linha de Financiamento</label>
                  <div class="col-sm-10">
                  <select class="credit select2" name="credit" style="width: 100%;">
				<option></option>
                  <?php
				$getin = mysqli_query($link, "SELECT * FROM tipo_credito order by id") or die (mysqli_error($link));
				while($row = mysqli_fetch_array($getin))
				{
				echo '<option value="'.$row['id'].'">'.$row['tipo_credito'].'</option>';
				}
				?>
				</select>
                  </div>
            </div>
            
			  <div align="right">
              <div class="box-footer">
                <button name="linhas" type="submit" class="btn btn-success btn-flat"><i class="fa fa-save">&nbsp;Gerar Relatorio</i></button>

              </div>
			  </div>
			        </div>
			     </form>
              </div>
              <!-- /.tab-pane -->
              <!-- /.tab-pane -->
              	<div class="tab-pane" id="tab_3">
                    <form class="form-horizontal" method="post" action="">
                    <?php echo '<div class="alert alert-info fade in" >
			  <a href = "#" class = "close" data-dismiss= "alert"> &times;</a>
  				Preencha os filtros para obtencao do relatorio.
				</div>'?>
                    <div class="box-body">
			           <div class="form-group">
                          <label for="" class="col-sm-2 control-label" style="color:#009900"> Provincia</label>
                          <div class="col-sm-10">
                          <input name="provincia" type="text" class="form-control" placeholder="Provincia" required>
                          </div>
                      </div>
                      
        			  <div align="right">
                      <div class="box-footer">
                        <button name="provinci" type="submit" class="btn btn-success btn-flat"><i class="fa fa-save">&nbsp;Gerar Relatorio</i></button>
        
                      </div>
        			  </div>
			        </div>
			     </form>
              </div>
              <!-- /.tab-pane -->
              <!-- /.tab-pane -->
              <!--	<div class="tab-pane" id="tab_4">-->
                <div class="tab-pane" id="tab_4">
                    <form class="form-horizontal" method="post" action="">
                    <?php echo '<div class="alert alert-info fade in" >
			  <a href = "#" class = "close" data-dismiss= "alert"> &times;</a>
  				Preencha os filtros para obtencao do relatorio.
				</div>'?>
                    <div class="box-body">
			           <div class="form-group">
                <label for="" class="col-sm-2 control-label" style="color:#009900"><b style="color:red">*</b> Data Inicial</label>
			 <div class="col-sm-10">
              <div class="input-group date">
                  <div class="input-group-addon">
                    <i class="fa fa-calendar"></i>
                  </div>
                  <input name="data_inicial2" type="date" class="form-control pull-right"  required>
                </div>
              </div>
			  </div>
			  <div class="form-group">
                <label for="" class="col-sm-2 control-label" style="color:#009900"><b style="color:red">*</b> Data Final</label>
			 <div class="col-sm-10">
              <div class="input-group date">
                  <div class="input-group-addon">
                    <i class="fa fa-calendar"></i>
                  </div>
                  <input name="data_final2" type="date" class="form-control pull-right"  required>
                </div>
              </div>
			  </div>
			          
        			  <div align="right">
                      <div class="box-footer">
                        <button name="resumo" type="submit" class="btn btn-success btn-flat"><i class="fa fa-save">&nbsp;Gerar Relatorio</i></button>
        
                      </div>
        			  </div>
			        </div>
			     </form>
              </div>
              <!--</div>-->
              <!-- /.tab-pane -->
              <!-- /.tab-pane -->
              <!--	<div class="tab-pane" id="tab_4">-->
                <div class="tab-pane" id="tab_4">
                    <form class="form-horizontal" method="post" action="">
                    <?php echo '<div class="alert alert-info fade in" >
			  <a href = "#" class = "close" data-dismiss= "alert"> &times;</a>
  				Preencha os filtros para obtencao do relatorio.
				</div>'?>
                    <div class="box-body">
			           <div class="form-group">
                <label for="" class="col-sm-2 control-label" style="color:#009900"><b style="color:red">*</b> Data Inicial</label>
			 <div class="col-sm-10">
              <div class="input-group date">
                  <div class="input-group-addon">
                    <i class="fa fa-calendar"></i>
                  </div>
                  <input name="data_inicial2" type="date" class="form-control pull-right"  required>
                </div>
              </div>
			  </div>
			  <div class="form-group">
                <label for="" class="col-sm-2 control-label" style="color:#009900"><b style="color:red">*</b> Data Final</label>
			 <div class="col-sm-10">
              <div class="input-group date">
                  <div class="input-group-addon">
                    <i class="fa fa-calendar"></i>
                  </div>
                  <input name="data_final2" type="date" class="form-control pull-right"  required>
                </div>
              </div>
			  </div>
			          
        			  <div align="right">
                      <div class="box-footer">
                        <button name="resumo" type="submit" class="btn btn-success btn-flat"><i class="fa fa-save">&nbsp;Gerar Relatorio</i></button>
        
                      </div>
        			  </div>
			        </div>
			     </form>
              </div>
              <!--</div>-->
              <!-- /.tab-pane -->
              
             
            </div>
            <!-- /.tab-content -->
          </div>
				 
					
					
				
				
				</div>
				

              </div>


<?php
if(isset($_POST['linhas'])){
    $credito =  mysqli_real_escape_string($link, $_POST['credit']);

    if($credito == NULL){
        echo "<div class='alert alert-info'>Informe a linha de financimento </div>";
    }else{
        echo "<script>window.open('relatorio_impactos_financimento.php?credito=".$credito."', '_blank'); </script>)";
    }
}
?>


<?php
if(isset($_POST['balancete'])){
    $credito =  mysqli_real_escape_string($link, $_POST['credit']);
    $data_inicial =  mysqli_real_escape_string($link, $_POST['data_inicial1']);
    $data_final =  mysqli_real_escape_string($link, $_POST['data_final1']);
    
    if($id == NULL){
        echo "<div class='alert alert-info'>Informe o nome do mutuario </div>";
    }else{
        echo "<script>window.open('relatorio_balancete.php?credito=".$credito."&data_inicial=".$data_inicial."&data_final=".$data_final."', '_blank'); </script>";
    }
}
?>


<?php
if(isset($_POST['resumo'])){
    $data_inicial =  mysqli_real_escape_string($link, $_POST['data_inicial2']);
    $data_final =  mysqli_real_escape_string($link, $_POST['data_final2']);
    
    if($id == NULL){
        echo "<div class='alert alert-info'>Informe o nome do mutuario </div>";
    }else{
        echo "<script>window.open('relatorio_resumo.php?data_inicial=".$data_inicial."&data_final=".$data_final."', '_blank'); </script>";
    }
}
?>


<?php
if(isset($_POST['provinci'])){
    $provincia =  mysqli_real_escape_string($link, $_POST['provincia']);
    
    if($provincia == NULL){
        echo "<div class='alert alert-info'>Informe pelo menos a provincia </div>";
    }else{
        echo "<script>window.open('relatorio_impacto_provincia.php?provincia=".$provincia."', '_blank'); </script>";
    }
}
?>

<?php
if(isset($_POST['impactos'])){
    $borrower =  mysqli_real_escape_string($link, $_POST['borrower']);
    $credito =  mysqli_real_escape_string($link, $_POST['credito']);
    $cadeia =  mysqli_real_escape_string($link, $_POST['cadeia']);
    $cadeiaVal =  mysqli_real_escape_string($link, $_POST['cadeiaVal']);
    
    if($borrower == NULL){
        echo "<div class='alert alert-info'>Informe o mutuario </div>";
    }else{
        echo "<script>window.open('relatorio_impactos_definitivo.php?mutuario=".$borrower."&credito=".$credito."&cadeia=".$cadeia."&cadeiaVal=".$cadeiaVal."', '_blank'); </script>";
    }
}
?>
</div>	
</div>
</div>	
</div>

<script type="text/javascript">
	$(function() {
	   $(".credito").on('change', function(){
	        preecher_select();
	    });
	    $(".customer").on('change', function(){
	        preecher_select2();
	        preecher_select3();
	    });
	    
		function preecher_select() {
		    var ida = $(".credito").val();
			$.ajax({
				url: 'cadeiaValores.php',
				type: 'GET',
				data:{
				    id: ida
				},
				success: function(data) {
					$(".cadeia").html(data);
				},
				error: function() {
					$(".cadeia").html("Ocorreu um erro na tentativa de preencher o select!");
				}
			});
		}
		
	
		function preecher_select2() {
		    var ida = $(".customer").val();
			$.ajax({
				url: 'numeroConta.php',
				type: 'GET',
				data:{
				    id: ida
				},
				success: function(data) {
					$(".account").html(data);
				},
				error: function() {
					$(".account").html("Ocorreu um erro na tentativa de preencher o select!");
				}
			});
		}
		function preecher_select3() {
		    var ida = $(".customer").val();
			$.ajax({
				url: 'linha_impacto.php',
				type: 'GET',
				data:{
				    id: ida
				},
				success: function(data) {
					$(".credito").html(data);
				},
				error: function() {
					$(".credito").html("Ocorreu um erro na tentativa de preencher o select!");
				}
			});
		}
	});
</script>