<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 Emprestimos Vs Pagamentos</a></li>
              <li><a href="#tab_3" data-toggle="tab">Extrato de Poupancas</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></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> 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_inicial" 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_final" type="date" class="form-control pull-right"  required>
                </div>
              </div>
			  </div>
			  <div align="right">
              <div class="box-footer">
                <button name="relatorio" 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 -->
              	
              <!-- /.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"><b style="color:red">*</b> Mutuário</label>
                             <div class="col-sm-10">
                            <select name="borrower" class="customer select2" style="width: 100%;" required>
                                    <option></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> 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_inicial3" 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_final3" type="date" class="form-control pull-right"  required>
                </div>
              </div>
			  </div>
        			  <div align="right">
                      <div class="box-footer">
                        <button name="financiamento" 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 -->
 
              
              
             
            </div>
            <!-- /.tab-content -->
          </div>
				 
					
					
				
				
				</div>
				

              </div>


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


<?php
if(isset($_POST['financiamento'])){
    $borrower =  mysqli_real_escape_string($link, $_POST['borrower']);
    $data_inicial =  mysqli_real_escape_string($link, $_POST['data_inicial3']);
    $data_final =  mysqli_real_escape_string($link, $_POST['data_final3']);
    
    if($borrower == NULL){
        echo "<div class='alert alert-info'>Informe pelo menos o mutuario </div>";
    }else{
        echo "<script>window.open('relatorio_poupanca.php?borrower=".$borrower."&data_inicial=".$data_inicial."&data_final=".$data_final."', '_blank'); </script>";
    }
}
?>
</div>	
</div>
</div>	
</div>