<?php

ini_set('display_errors', 1);
define("ADMIN", true);
require_once("../../../common/lib.php");
require_once("../../../common/define.php");
define("TITLE_ELEMENT", 'etat');
if(!isset($_SESSION['user'])){
    header("Location: /admin/login.php");
    exit();
}
require_once("../../includes/fn_module.php"); ?>
<!DOCTYPE html>
<head>
    <?php include("../../includes/inc_header_common.php"); ?>
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  <!-- jQuery -->
  <!-- JS Select2 -->
  <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>	
</head>
<body>
    <div id="wrapper">
        <?php include("../../includes/inc_top.php"); ?>
        <div id="page-wrapper">
            <div class="page-header">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-md-8">
                            <h1><i class="fa fa-random"></i> Etat Financier Détaillé</h1>
                        </div>
                    </div>
                </div>
            </div>
            <div class="container-fluid">
                <div class="alert-container">
                    <div class="alert alert-success alert-dismissable"></div>
                    <div class="alert alert-warning alert-dismissable"></div>
                    <div class="alert alert-danger alert-dismissable"></div>
                </div>
                <div class="row" style="width:50%;float:left;">				
				
	<form method="GET" action="rapport.php">	
	
	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Année exercice &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select id="annee" name="annee" class="form-control">	
						<option value="" >Tous</option>						 				
						
						<?php
						for ($x = 2018; $x <= date("Y"); $x++) {
						  echo "<option value='$x' >$x </option>";
						}
						?>					

					 </select>
				  </div>
			   </div>
		 </div>
	</div>
	
	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Type d’opération &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select id="type" name="type" class="form-control">					
						<option value="">Tous</option>						
						<option value="out">OUT</option>						
						<option value="in">IN</option>						
						
					 </select>
				  </div>
			   </div>
		 </div>
	</div> 	
	
	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Etat du règlement &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select id="payer" name="payer" class="form-control">					
						<option value="0">Non payé</option>						
						<option value="1">Payé</option>						
						
					 </select>
				  </div>
			   </div>
		 </div>
	</div> 

	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Mode de réglement &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select id="mode" name="mode" class="form-control">					
						<option value="">Tous</option>						
						<?php
						if($db !== false){
							$query = "SELECT * FROM `pm_mode_paiement` ";
							$result = @$db->query($query);
                            if($result !== false){
								foreach($result as $row){
									echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
								}	
							}	
							
						} ?>
					 </select>
				  </div>
			   </div>
		 </div>
	</div>
	
	<div class="panel panel-default">
		<div class="panel-body">
			<label class="col-lg-4 control-label  text-right">De&nbsp;<span class="red">*</span></label>
			<div class="col-lg-6">
				<div class=" form-inline">  
                                                                          
					<div class="input-group">
						<div class="input-group-addon"><i class="fa fa-calendar"></i></div>
						<input type="text" class="form-control datepicker" name="date_from" value="01-01-<? echo date("Y"); ?>" >
					</div>
				</div>
			</div>
		 </div>
	</div> 

	<div class="panel panel-default">
		<div class="panel-body">
			<label class="col-lg-4 control-label  text-right">A&nbsp;<span class="red">*</span></label>
			<div class="col-lg-6">
				<div class=" form-inline">  
                                                                          
					<div class="input-group">
						<div class="input-group-addon"><i class="fa fa-calendar"></i></div>
						<input type="text" class="form-control datepicker" name="date_to" value="31-12-<? echo date("Y"); ?>" >
					</div>
				</div>
			</div>
		 </div>
	</div> 

	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Journaux &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select id="journal" name="journal" class="form-control">					
						<option value="">Tous</option>						
						<?php
						if($db !== false){
							$query = "SELECT * FROM `pm_journal` ";
							$result = @$db->query($query);
                            if($result !== false){
								foreach($result as $row){
									echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
								}	
							}	
							
						} ?>
					 </select>
				  </div>
			   </div>
		 </div>
	</div> 
	


	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Compte financer &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select id="compte" name="compte" class="form-control">					
						<option value="">Tous</option>						
						<?php
						if($db !== false){
							$query = "SELECT * FROM `pm_compte_financier` ORDER BY name ASC";
							$result = @$db->query($query);
                            if($result !== false){
								foreach($result as $row){
									echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
								}	
							}	
							
						} ?>
					 </select>
				  </div>
			   </div>
		 </div>
	</div> 

		</div>
	<div class="row" style="width:50%;float:left;">	

	

	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Fournisseur &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select id="fournisseur" name="fournisseur" class="form-control">					
						<option value="">Tous</option>						
						<?php
						if($db !== false){
							$query = "SELECT * FROM `pm_fournisseurs` ORDER BY name ASC";
							$result = @$db->query($query);
                            if($result !== false){
								foreach($result as $row){
									echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
								}	
							}	
							
						} ?>
					 </select>
				  </div>
			   </div>
		 </div>
	</div> 	


	
	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Client &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select id="client" name="client" class="form-control">					
						<option value="">Tous</option>						
						<?php
						if($db !== false){
							$query = "SELECT * FROM `pm_client` ORDER BY name ASC";
							$result = @$db->query($query);
                            if($result !== false){
								foreach($result as $row){
									echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
								}	
							}	
							
						} ?>
					 </select>
				  </div>
			   </div>
		 </div>
	</div> 	

	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Référence facture Achat &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select id="ref_fac_achat" name="ref_fac_achat" class="form-control">					
						<option value="">Tous</option>						
						<?php
						if($db !== false){
							$query = "SELECT * FROM `pm_facture_achat` ORDER BY ref_bl ASC";
							$result = @$db->query($query);
                            if($result !== false){
								foreach($result as $row){
									echo '<option value="'.$row['id'].'">'.$row['ref_bl'].'</option>';
								}	
							}	
							
						} ?>
					 </select>
				  </div>
			   </div>
		 </div>
	</div> 
	
	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Référence facture Vente &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select id="ref_fac_vente" name="ref_fac_vente" class="form-control">					
						<option value="">Tous</option>						
						<?php
						if($db !== false){
							$query = "SELECT * FROM `pm_facture` ORDER BY idd ASC ";
							$result = @$db->query($query);
                            if($result !== false){
								foreach($result as $row){
									echo '<option value="'.$row['id'].'">'.$row['idd'].'</option>';
								}	
							}	
							
						} ?>
					 </select>
				  </div>
			   </div>
		 </div>
	</div> 	

	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label text-right">Retenue à la source &nbsp;<span class="red">*</span></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
					 <select id="retenue" name="retenue" class="form-control">					
						<option value="0">NON</option>		
						<option value="1">OUI</option>							
					 </select>
				  </div>
			   </div>
		 </div>
	</div> 	

	<div class="panel panel-default">
		<div class="panel-body">
			<label class="col-lg-4 control-label  text-right">Montant de<span class="red">*</span></label>
			<div class="col-lg-6">
				<div class=" form-inline">  
                                                                          
					<div class="input-group">
						<div class="input-group-addon"><i class="fa fa-money"></i></div>
						<input type="text" class="form-control" name="montant_from" value="0" >
					</div>
				</div>
			</div>
		 </div>
	</div>

	<div class="panel panel-default">
		<div class="panel-body">
			<label class="col-lg-4 control-label  text-right">Montant à<span class="red">*</span></label>
			<div class="col-lg-6">
				<div class=" form-inline">  
                                                                          
					<div class="input-group">
						<div class="input-group-addon"><i class="fa fa-money"></i></div>
						<input type="text" class="form-control" name="montant_to" value="0" >
					</div>
				</div>
			</div>
		 </div>
	</div>	

	<div class="panel panel-default">
		<div class="panel-body">
			<label class="col-lg-4 control-label  text-right">Référence<span class="red">*</span></label>
			<div class="col-lg-6">
				<div class=" form-inline">  
                                                                          
					<div class="input-group">
						<div class="input-group-addon"><i class="fa fa-registered"></i></div>
						<input type="text" class="form-control" name="ref" value="" placeholder="Référance">
					</div>
				</div>
			</div>
		 </div>
	</div>	
	
	<div class="panel panel-default">
		<div class="panel-body">
			   <label class="col-lg-4 control-label " ></label>
			   <div class="col-lg-6">
				  <div class=" form-inline">
						<button type="submit" class="btn btn-default mt15" data-toggle="tooltip" data-placement="bottom" title="Rchercher">
							<i class="fa fa-search"></i><span class="hidden-sm hidden-xs"> Rchercher</span>
						</button>
				  </div>
			   </div>
		 </div>
	</div> 


</form>	
									
                    <?php
                    if($db !== false){
                        
                    } ?>
					
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<?php
$_SESSION['msg_error'] = "";
$_SESSION['msg_success'] = "";
$_SESSION['msg_notice'] = ""; ?>


  <script>
    $(document).ready(function() {
      $('#fournisseur,#client,#compte,#ref_fac_achat,#ref_fac_vente').select2({
        placeholder: "Sélectionnez",
        allowClear: true
      });
    });
  </script>
  <style>
  /* Hauteur du champ */
  .select2-container--default .select2-selection--single {
    height: 40px !important;
    display: flex;
    align-items: center; /* Centre verticalement le contenu */
  }

  /* Centrage du texte à l'intérieur */
  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: normal !important;
    text-align: left;
    padding-left: 8px;
    padding-right: 8px;
    display: flex;
    align-items: center;
    height: 100%;
  }

  /* Icône flèche à droite bien alignée */
  .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100%;
    top: 0;
    right: 6px;
  }
</style>

